using Thousandto.Launcher.ExternalLibs; using System; using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.Animations; using UnityEngine.Playables; namespace Thousandto.DIY.UniScene { public class SelectAnimPlayEditor : EditorWindow { [MenuItem("Window/SelectAnimPlayEditor &7")] static void Open() { var win = (SelectAnimPlayEditor)EditorWindow.GetWindow(typeof(SelectAnimPlayEditor)); win.Show(); } #region//属性 private int _selectAnim = 0; #endregion private void OnGUI() { var selectGo = UnityEditor.Selection.activeGameObject; if (selectGo != null) { var animScript = selectGo.GetComponent(); if (animScript == null) { return; } var script = selectGo.GetComponent(); if(script == null) { script = selectGo.AddComponent(); } for (int i = animScript.NewAnimList.Count - 1; i >= 0; --i) { if (animScript.NewAnimList[i] == null) { animScript.NewAnimList.RemoveAt(i); } } for (int i = animScript.SelfAnimList.Count - 1; i >= 0; --i) { if (animScript.SelfAnimList[i] == null) { animScript.SelfAnimList.RemoveAt(i); } } string[] animArray = new string[animScript.NewAnimList.Count + animScript.SelfAnimList.Count]; for (int i = 0; i < animScript.SelfAnimList.Count; ++i) { animArray[i] = animScript.SelfAnimList[i].name; } for (int i = 0; i < animScript.NewAnimList.Count; ++i) { animArray[i + animScript.SelfAnimList.Count] = animScript.NewAnimList[i].name; } _selectAnim = EditorGUILayout.Popup(_selectAnim, animArray); script.AnimName = animArray[_selectAnim]; } } } }