2023-09-26 06:24:34 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Events;
|
|
|
|
|
public class SPUM_Prefabs : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public float _version;
|
|
|
|
|
public SPUM_SpriteList _spriteOBj;
|
|
|
|
|
public bool EditChk;
|
|
|
|
|
public string _code;
|
|
|
|
|
public Animator _anim;
|
|
|
|
|
public bool _horse;
|
|
|
|
|
public bool isRideHorse{
|
|
|
|
|
get => _horse;
|
|
|
|
|
set {
|
|
|
|
|
_horse = value;
|
|
|
|
|
UnitTypeChanged?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string _horseString;
|
|
|
|
|
|
|
|
|
|
public UnityEvent UnitTypeChanged = new UnityEvent();
|
|
|
|
|
private AnimationClip[] _animationClips;
|
|
|
|
|
public AnimationClip[] AnimationClips => _animationClips;
|
|
|
|
|
private Dictionary<string, int> _nameToHashPair = new Dictionary<string, int>();
|
|
|
|
|
private void InitAnimPair(){
|
|
|
|
|
_nameToHashPair.Clear();
|
|
|
|
|
_animationClips = _anim.runtimeAnimatorController.animationClips;
|
|
|
|
|
foreach (var clip in _animationClips)
|
|
|
|
|
{
|
|
|
|
|
int hash = Animator.StringToHash(clip.name);
|
|
|
|
|
_nameToHashPair.Add(clip.name, hash);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void Awake() {
|
|
|
|
|
InitAnimPair();
|
|
|
|
|
}
|
|
|
|
|
private void Start() {
|
|
|
|
|
UnitTypeChanged.AddListener(InitAnimPair);
|
|
|
|
|
}
|
|
|
|
|
// 이름으로 애니메이션 실행
|
|
|
|
|
public void PlayAnimation(string name){
|
2024-01-04 04:53:13 +00:00
|
|
|
|
|
|
|
|
|
Debug.Log(name);
|
|
|
|
|
|
2023-09-26 06:24:34 +00:00
|
|
|
|
foreach (var animationName in _nameToHashPair)
|
|
|
|
|
{
|
|
|
|
|
if(animationName.Key.ToLower().Contains(name.ToLower()) ){
|
|
|
|
|
_anim.Play(animationName.Value, 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|