summaryrefslogtreecommitdiff
path: root/Assets/ActionTool/Editor/ActionEditor.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-09-11 15:27:24 +0800
committerchai <chaifix@163.com>2021-09-11 15:27:24 +0800
commitc57d5bbbdd20eef57fa31c5ef921b2739b5b164e (patch)
tree313afeb0d0cd88ae45b02cac89031d12ad4d375c /Assets/ActionTool/Editor/ActionEditor.cs
parent9d4cdc732f8ba8358686ba0441b62e3443c47d9c (diff)
parent5575843d450870db566b9c275584536299ef40bf (diff)
Merge branch 'master' of warmcat.org:/home/git-repo/Erika
Diffstat (limited to 'Assets/ActionTool/Editor/ActionEditor.cs')
-rw-r--r--Assets/ActionTool/Editor/ActionEditor.cs113
1 files changed, 100 insertions, 13 deletions
diff --git a/Assets/ActionTool/Editor/ActionEditor.cs b/Assets/ActionTool/Editor/ActionEditor.cs
index b84b9e0e..2abe9a2b 100644
--- a/Assets/ActionTool/Editor/ActionEditor.cs
+++ b/Assets/ActionTool/Editor/ActionEditor.cs
@@ -21,16 +21,35 @@ namespace ActionTool
ActionEditorUI ui;
int currentPickerWindow;
+ IEnumerator coLoadAnimationAssets;
+ Dictionary<string, Object> animationAssets = new Dictionary<string, Object>();
+
public void OnEnable()
{
titleContent = new GUIContent("Action Editor");
+
+ EditorApplication.update += OnUpdate;
+ ActionManager.onSelectObj += OnSelectObj;
}
- public void OnDisable()
+ void OnUpdate()
+ {
+ if(coLoadAnimationAssets != null)
+ {
+ if (!coLoadAnimationAssets.MoveNext())
+ {
+ coLoadAnimationAssets = null;
+ }
+ }
+ }
+
+ public void OnDisable()
{
+ EditorApplication.update -= OnUpdate;
+ ActionManager.onSelectObj -= OnSelectObj;
}
- public void OnGUI()
+ public void OnGUI()
{
if (styles == null) styles = ActionEditorStyles.Get();
if (ui == null) ui = ActionEditorUI.Get();
@@ -44,15 +63,8 @@ namespace ActionTool
GUILayout.Space(5);
}
- public enum Foo
- {
- A =0,
- B= 0,
- }
-
private void GUI_SelectUnit()
{
-
GUILayout.BeginHorizontal();
GameObject selectObj = EditorGUILayout.ObjectField(ActionManager.CurrentUnit, typeof(GameObject), false, GUILayout.Width(position.width - 160)) as GameObject;
@@ -143,13 +155,49 @@ namespace ActionTool
continue;
bool bChecked = ActionManager.CurrentAnimationName == animName;
EditorGUILayout.BeginHorizontal();
- bool check = GUILayout.Toggle(bChecked, animName, style, GUILayout.Width(position.width - 42), GUILayout.Height(15));
+
+ bool check = GUILayout.Toggle(bChecked, animName, style, GUILayout.Width(position.width - 60), GUILayout.Height(15));
if (check && ActionManager.CurrentAnimationName != animName)
ActionManager.OnSelectAnimation(animName);
- if(GUILayout.Button("", styles.selectObj, GUILayout.Width(15), GUILayout.Height(15)))
+
+ bool isFavorite = false;
+ if (animationAssets != null && animationAssets.ContainsKey(file))
+ {
+ var labels = AssetDatabase.GetLabels(animationAssets[file]);
+ for (int j = 0; j < labels.Length; ++j)
+ {
+ if (labels[j] == "GoodAnimation")
+ isFavorite = true;
+ }
+ }
+ 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();
}
@@ -159,8 +207,47 @@ namespace ActionTool
style.clipping = prevClipping;
style.richText = prevRichText;
}
-
}
- }
+ IEnumerator CoLoadAnimationAssets()
+ {
+ if (!ActionManager.HasSelectObj())
+ yield break;
+
+ if (animationAssets != null)
+ animationAssets.Clear();
+ else
+ animationAssets = new Dictionary<string, Object>();
+
+ 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);
+ }
+ this.Repaint();
+ yield return null;
+ }
+ }
+
+ void OnSelectObj(params object[] objs)
+ {
+ animationAssets.Clear();
+ coLoadAnimationAssets = CoLoadAnimationAssets();
+ }
+
+ }
+
} \ No newline at end of file