From 3ad68338dff5229d3fd8ec9f3ee994d7e37fb0ed Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 2 Sep 2021 09:59:31 +0800 Subject: *override rootmotion --- Assets/ActionTool/Editor/ActionEventEditor.cs | 87 +++++++++++++++++++++------ 1 file changed, 68 insertions(+), 19 deletions(-) (limited to 'Assets/ActionTool/Editor/ActionEventEditor.cs') diff --git a/Assets/ActionTool/Editor/ActionEventEditor.cs b/Assets/ActionTool/Editor/ActionEventEditor.cs index 50b697e4..0fd9ea22 100644 --- a/Assets/ActionTool/Editor/ActionEventEditor.cs +++ b/Assets/ActionTool/Editor/ActionEventEditor.cs @@ -93,6 +93,7 @@ namespace ActionTool string name = field.Name + " (" + field.FieldType.Name + ")"; string tooltip = ""; bool skip = false; + bool isHDR = false; foreach (var attr in field.GetCustomAttributes()) { if(attr.GetType() == typeof(TooltipAttribute)) @@ -109,16 +110,27 @@ namespace ActionTool } else if (attr.GetType() == typeof(WhenAttribute)) { - WhenAttribute when = attr as WhenAttribute; - string conditionName = when.conditionName; - FieldInfo condition = type.GetField(conditionName); - if ((int)condition.GetValue(animEvent) != when.value) - { - skip = true; - break; - } - } - else if (attr.GetType() == typeof(WhenNotAttribute)) + WhenAttribute when = attr as WhenAttribute; + string conditionName = when.conditionName; + FieldInfo condition = type.GetField(conditionName); + if (!when.IsSatisfied((int)condition.GetValue(animEvent))) + { + skip = true; + break; + } + } + else if (attr.GetType() == typeof(AndWhenAttribute)) + { + AndWhenAttribute when = attr as AndWhenAttribute; + string conditionName = when.conditionName; + FieldInfo condition = type.GetField(conditionName); + if (!when.IsSatisfied((int)condition.GetValue(animEvent))) + { + skip = true; + break; + } + } + else if (attr.GetType() == typeof(WhenNotAttribute)) { WhenNotAttribute when = attr as WhenNotAttribute; string conditionName = when.conditionName; @@ -156,12 +168,16 @@ namespace ActionTool SpaceAttribute space = attr as SpaceAttribute; GUILayout.Space(space.height); } - else if (attr.GetType() == typeof(CommentAttribute)) - { - CommentAttribute comment = attr as CommentAttribute; - EditorGUILayout.LabelField(comment.comment); - } - else if (attr.GetType() == typeof(WhenAttribute)) + else if (attr.GetType() == typeof(CommentAttribute)) + { + CommentAttribute comment = attr as CommentAttribute; + GUIStyle style = GUI.skin.GetStyle("Label"); + TextAnchor preanchor = style.alignment; + style.alignment = comment.alignment; + GUI_Label(new GUIContent(comment.comment), style); + style.alignment = preanchor; + } + else if (attr.GetType() == typeof(WhenAttribute)) { WhenAttribute when = attr as WhenAttribute; string conditionName = when.conditionName; @@ -205,6 +221,10 @@ namespace ActionTool break; } } + else if(attr.GetType() == typeof(HDRAttribute)) + { + isHDR = true; + } } if (skip) { @@ -244,14 +264,31 @@ namespace ActionTool { field.SetValue(animEvent, GUI_Int((int)field.GetValue(animEvent))); } - GUILayout.Space(5); + else if(field.FieldType == typeof(Color)) + { + if(isHDR) + { + field.SetValue(animEvent, GUI_ColorHDR((Color)field.GetValue(animEvent))); + } + else + { + field.SetValue(animEvent, GUI_Color((Color)field.GetValue(animEvent))); + } + } + GUILayout.Space(5); } } EditorGUILayout.EndScrollView(); } - float GUI_Float(float value) + void GUI_Label(GUIContent label, GUIStyle style) + { + Rect rect = EditorGUILayout.GetControlRect(); + EditorGUI.LabelField(rect, label, style); + } + + float GUI_Float(float value) { Rect rect = EditorGUILayout.GetControlRect(); return EditorGUI.FloatField(rect, "", value); @@ -299,5 +336,17 @@ namespace ActionTool return GUI.Toggle(rect, value, "Check"); } - } + Color GUI_Color(Color col) + { + Rect rect = EditorGUILayout.GetControlRect(); + return EditorGUI.ColorField(rect, col); + } + + Color GUI_ColorHDR(Color col) + { + Rect rect = EditorGUILayout.GetControlRect(); + return EditorGUI.ColorField(rect, new GUIContent(""), col, true, true, true); + } + + } } \ No newline at end of file -- cgit v1.1-26-g67d0