From 98f31f197a126850a5878cd6e583ae6dbf64ab3d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 15 Sep 2021 12:50:26 +0800 Subject: *rename --- Assets/ActionTool/Editor/ActionEditor.cs | 262 ------------------------------- 1 file changed, 262 deletions(-) delete mode 100644 Assets/ActionTool/Editor/ActionEditor.cs (limited to 'Assets/ActionTool/Editor/ActionEditor.cs') diff --git a/Assets/ActionTool/Editor/ActionEditor.cs b/Assets/ActionTool/Editor/ActionEditor.cs deleted file mode 100644 index b06ef89b..00000000 --- a/Assets/ActionTool/Editor/ActionEditor.cs +++ /dev/null @@ -1,262 +0,0 @@ -using System.IO; -using System.Collections; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using UnityEditor.SceneManagement; - -namespace ActionTool -{ - - public class ActionEditor : EditorWindow - { - [MenuItem("Erika/ActionTool/Open")] - static void OpenTools() - { - ActionManager.AnimationWindow = GetWindow(); - } - - string m_SearchText = ""; - ActionEditorStyles styles; - ActionEditorUI ui; - int currentPickerWindow; - - IEnumerator coLoadAnimationAssets; - Dictionary animationAssets = new Dictionary(); - - public void OnEnable() - { - titleContent = new GUIContent("Action Editor"); - - EditorApplication.update += OnUpdate; - ActionManager.onSelectObj += OnSelectObj; - } - - void OnUpdate() - { - if(coLoadAnimationAssets != null) - { - if (!coLoadAnimationAssets.MoveNext()) - { - coLoadAnimationAssets = null; - } - } - } - - public void OnDisable() - { - EditorApplication.update -= OnUpdate; - ActionManager.onSelectObj -= OnSelectObj; - } - - public void OnGUI() - { - if (styles == null) styles = ActionEditorStyles.Get(); - if (ui == null) ui = ActionEditorUI.Get(); - if (ActionManager.CurrentUnit == null) - ActionManager.Release(); - - GUILayout.Space(5); - GUI_SelectUnit(); - GUILayout.Space(5); - GUI_AnimationList(); - GUILayout.Space(5); - } - - private void GUI_SelectUnit() - { - GUILayout.BeginHorizontal(); - - GameObject selectObj = EditorGUILayout.ObjectField(ActionManager.CurrentUnit, typeof(GameObject), false, GUILayout.Width(position.width - 160)) as GameObject; - - if (selectObj != null && selectObj != ActionManager.CurrentUnit) - { - ActionManager.OnSelectObj(selectObj); - if (ActionManager.AnimationWindow != null) - { - ActionManager.AnimationWindow.Repaint(); - } - } - - if (GUILayout.Button("Select", GUILayout.Width(70))) - { - currentPickerWindow = EditorGUIUtility.GetControlID(FocusType.Passive) + 100; - EditorGUIUtility.ShowObjectPicker(ActionManager.CurrentUnit, false, "l:UnitPrefab", currentPickerWindow); - } - - string commandName = Event.current.commandName; - if(/*commandName.Equals("ObjectSelectorUpdated") || */commandName.Equals("ObjectSelectorClosed")) - { - GameObject go = EditorGUIUtility.GetObjectPickerObject() as GameObject; - if (/*go != null && */ActionManager.CurrentUnit != go) - { - ActionManager.OnSelectObj(go); - this.Repaint(); - } - } - - if (GUILayout.Button("Reimport", GUILayout.Width(70))) - { - ActionManager.OnSelectObj(ActionManager.CurrentUnit); - } - - GUILayout.EndHorizontal(); - - //var scene = EditorSceneManager.GetActiveScene(); - //if (scene == null || scene.path != ActionManager.scenePath) - //{ - // if(GUILayout.Button("打开ActionToolScene")) - // { - // EditorSceneManager.OpenScene(ActionManager.scenePath); - // } - //} - - if (ActionManager.CurrentUnit == null) - { - EditorGUILayout.HelpBox("选择角色prefab", MessageType.Warning); - } - - } - - private Vector2 m_AnimtionListScroll; - private void GUI_AnimationList() - { - if (!ActionManager.HasSelectObj()) - return; - - EditorGUILayout.LabelField("Animation List"); - - m_SearchText = GUILayout.TextField(m_SearchText, "SearchTextField", GUILayout.Width(position.width - 20)).ToLower(); - - string animFolder = ActionManager.unitAnimationClipFolder; - - string[] animfiles = Directory.GetFiles(animFolder); - - if (animfiles != null && animfiles.Length > 0) - { - GUIStyle style = GUI.skin.GetStyle("Button"); - TextAnchor prevAnchor = style.alignment; - TextClipping prevClipping = style.clipping; - bool prevRichText = style.richText; - style.alignment = TextAnchor.MiddleCenter; - style.clipping = TextClipping.Clip; - style.richText = false; - - m_AnimtionListScroll = EditorGUILayout.BeginScrollView(m_AnimtionListScroll); - - for (int i = 0; i < animfiles.Length; ++i) - { - string file = animfiles[i]; - if (file.Contains(".meta")) - continue; - string animName = Path.GetFileNameWithoutExtension(file); - bool show = m_SearchText == string.Empty || m_SearchText == "" || animName.ToLower().Contains(m_SearchText); - if (!show) - continue; - bool bChecked = ActionManager.CurrentAnimationName == animName; - EditorGUILayout.BeginHorizontal(); - - bool check = GUILayout.Toggle(bChecked, animName, style, GUILayout.Width(position.width - 60)); - if (check && ActionManager.CurrentAnimationName != animName) - ActionManager.OnSelectAnimation(animName); - - bool isFavorite = false; - if (animationAssets != null && animationAssets.ContainsKey(file)) - { - isFavorite = IsFavoritAnimation(animationAssets[file]); - } - if ((!animationAssets.ContainsKey(file) || animationAssets[file] == null) && coLoadAnimationAssets == null) - { - coLoadAnimationAssets = CoLoadAnimationAssets(); - } - Color bgColor = GUI.backgroundColor; - GUI.backgroundColor = isFavorite ? Color.yellow : Color.gray; - if (GUILayout.Button("", styles.starButton, GUILayout.Width(12), GUILayout.Height(13))) - { - isFavorite = !isFavorite; - if(animationAssets.ContainsKey(file)) - { - if(!isFavorite) - { - AssetDatabase.SetLabels(animationAssets[file], new string[0]); - } - else - { - AssetDatabase.SetLabels(animationAssets[file], new string[1] { "GoodAnimation" }); - } - } - } - GUI.backgroundColor = bgColor; - - if (GUILayout.Button("", styles.selectObj, GUILayout.Width(15), GUILayout.Height(15))) - { - ui.SelectObject(file); - } - - EditorGUILayout.EndHorizontal(); - } - - EditorGUILayout.EndScrollView(); - - style.alignment = prevAnchor; - style.clipping = prevClipping; - style.richText = prevRichText; - } - } - - bool IsFavoritAnimation(Object animationFile) - { - var labels = AssetDatabase.GetLabels(animationFile); - for (int j = 0; j < labels.Length; ++j) - { - if (labels[j] == "GoodAnimation") - return true; - } - return false; - } - - IEnumerator CoLoadAnimationAssets() - { - if (!ActionManager.HasSelectObj()) - yield break; - - if (animationAssets != null) - animationAssets.Clear(); - else - animationAssets = new Dictionary(); - - string animFolder = ActionManager.unitAnimationClipFolder; - - string[] animfiles = Directory.GetFiles(animFolder); - - for (int i = 0; i < animfiles.Length; ++i) - { - string file = animfiles[i]; - if (file.Contains(".meta")) - continue; - var animFile = AssetDatabase.LoadMainAssetAtPath(file); - if (animationAssets.ContainsKey(file)) - { - animationAssets[file] = animFile; - } - else - { - animationAssets.Add(file, animFile); - } - if (IsFavoritAnimation(animFile)) - { - this.Repaint(); - } - yield return null; - } - } - - void OnSelectObj(params object[] objs) - { - animationAssets.Clear(); - coLoadAnimationAssets = CoLoadAnimationAssets(); - } - - } - -} \ No newline at end of file -- cgit v1.1-26-g67d0