using Sirenix.OdinInspector; using System.Collections; using System.Collections.Generic; using UnityCommon; using UnityEngine; namespace DTYJ { public class DianFuTiCtrl : SerializedMonoBehaviour { public static DianFuTiCtrl Instance; private void Awake() { Instance = this; } public Dictionary dic; public void SetState(string id, int state) { if (dic.ContainsKey(id)) { var anim = dic[id];//.GetComponent(); var animationName = anim.clip.name; //anim[animationName].time = state == 1 ? 0 : anim[animationName].length; switch (state) { case 0: anim[animationName].speed = 1; break; case 1: anim[animationName].speed = -1; break; case 2: case 3: anim[animationName].speed = 0; break; } anim[animationName].wrapMode = WrapMode.Loop; anim.CrossFade(animationName); } } [ContextMenu("´¦Àí")] public void HandleTemp() { Dictionary dicNew = new Dictionary(); foreach (var kvp in dic) { var animPath = Utility.GetPathInHierichy(kvp.Value.transform, null); dicNew["1_" + kvp.Key] = GameObject.Find("StationOthers/1/" + animPath).GetComponent(); dicNew["2_" + kvp.Key] = GameObject.Find("StationOthers/2/" + animPath).GetComponent(); } foreach (var kvp in dicNew) { dic[kvp.Key] = kvp.Value; } } } }