From 22891bf59032ba88262824255a706d652031384b Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 10 Mar 2022 14:07:40 +0800 Subject: * move folder --- .../ActionTool/Editor/ActionColliderEditor.cs | 346 --------------------- 1 file changed, 346 deletions(-) delete mode 100644 Assets/Tools/ActionTool/Editor/ActionColliderEditor.cs (limited to 'Assets/Tools/ActionTool/Editor/ActionColliderEditor.cs') diff --git a/Assets/Tools/ActionTool/Editor/ActionColliderEditor.cs b/Assets/Tools/ActionTool/Editor/ActionColliderEditor.cs deleted file mode 100644 index adb8819f..00000000 --- a/Assets/Tools/ActionTool/Editor/ActionColliderEditor.cs +++ /dev/null @@ -1,346 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using UnityEngine; -using UnityEditor; - -namespace ActionTool -{ - - // 编辑事件 - public class ActionColliderEditor : EditorWindow - { - EditorWindow sceneView; - ActionEditorStyles styles; - - ColliderBox collider; - - Dictionary m_Foldout = new Dictionary (); - - int indent = 0; - - private void OnEnable() - { - titleContent = new GUIContent("Collider Editor"); - m_Foldout.Clear(); - } - - private void OnDisable() - { - m_Foldout.Clear(); - ActionManager.colliderData = null; - ActionManager.ColliderWindow = null; - if(ActionManager.PreviewWindow != null) - ActionManager.PreviewWindow.Repaint(); - } - - private void Update() - { - } - - Vector2 scroll; - private void OnGUI() - { - if (ActionManager.colliderData == null) - { - this.Close(); - return; - } - - collider = ActionManager.colliderData.collider; - if (collider == null) - return; - - if (styles == null) styles = ActionEditorStyles.Get(); - - GUILayout.Space(2); - - EditorGUILayout.LabelField(collider.type.ToString() + " " + ActionManager.colliderIndex, styles.textBoldBig, GUILayout.Height(25)); - - GUILayout.Space(2); - - EditorGUILayout.BeginHorizontal(); - if (GUILayout.Button("Save")) - { - - } - if (GUILayout.Button("Revert")) - { - - } - Color prevColor = GUI.backgroundColor; - GUI.backgroundColor = Color.red; - if (GUILayout.Button("Delete")) - { - ActionManager.DeleteCurBox(); - } - GUI.backgroundColor = prevColor; - EditorGUILayout.EndHorizontal(); - - GUILayout.Space(5); - - scroll = EditorGUILayout.BeginScrollView(scroll); - - Type type = collider.GetType(); - FieldInfo[] fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); - if (fields != null && fields.Length > 0) - { - int collliderType = -1; - FoldoutAttribute foldout = null; - int foldoutElementCount = 0; - for (int i = 0; i < fields.Length; ++i) - { - FieldInfo field = fields[i]; - string name = field.Name + " (" + field.FieldType.Name + ")"; - string tooltip = ""; - bool skip = false; - foreach (var attr in field.GetCustomAttributes()) - { - if (attr.GetType() == typeof(ColliderTypeAttribute)) - { - ColliderTypeAttribute t = attr as ColliderTypeAttribute; - collliderType = (int)t.type; - } - } - if (collliderType != -1 && collliderType != (int)collider.type) - { - skip = true; - } - if (skip) - { - continue; - } - foreach (var attr in field.GetCustomAttributes()) - { - if (attr.GetType() == typeof(WhenAttribute)) - { - WhenAttribute when = attr as WhenAttribute; - string conditionName = when.conditionName; - FieldInfo condition = type.GetField(conditionName); - if ((float)condition.GetValue(collider) != when.value) - { - skip = true; - break; - } - } - else if (attr.GetType() == typeof(WhenNotAttribute)) - { - WhenNotAttribute when = attr as WhenNotAttribute; - string conditionName = when.conditionName; - FieldInfo condition = type.GetField(conditionName); - if ((float)condition.GetValue(collider) == when.value) - { - skip = true; - break; - } - } - else if(attr.GetType() == typeof(IfAttribute)) - { - IfAttribute when = attr as IfAttribute; - string conditionName = when.conditionName; - FieldInfo condition = type.GetField(conditionName); - if (!(bool)condition.GetValue(collider)) - { - skip = true; - break; - } - } - else if (attr.GetType() == typeof(IfNotAttribute)) - { - IfNotAttribute when = attr as IfNotAttribute; - string conditionName = when.conditionName; - FieldInfo condition = type.GetField(conditionName); - if ((bool)condition.GetValue(collider)) - { - skip = true; - break; - } - } - else if (attr.GetType() == typeof(FoldoutAttribute)) - { - if(collliderType == -1 || collliderType == (int)collider.type) - { - foldout = attr as FoldoutAttribute; - if (!m_Foldout.ContainsKey(foldout.title)) - m_Foldout.Add(foldout.title, false); - m_Foldout[foldout.title] = EditorGUILayout.Foldout(m_Foldout[foldout.title], foldout.title); - foldoutElementCount = 0; - indent = 13; - } - } - 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; - } - } - if(foldout != null && (++foldoutElementCount) <= foldout.count) - { - skip |= !m_Foldout[foldout.title]; - } - if (skip) - { - if (foldout != null && foldoutElementCount == foldout.count) - { - foldout = null; - foldoutElementCount = 0; - indent = 0; - } - GUI.enabled = true; - continue; - } - - foreach (var attr in field.GetCustomAttributes()) - { - if (attr.GetType() == typeof(TooltipAttribute)) - { - TooltipAttribute tooltipattr = attr as TooltipAttribute; - if (tooltip != null) - { - tooltip = tooltipattr.tooltip; - } - } - else if (attr.GetType() == typeof(DisallowModifiyInGUI)) - { - GUI.enabled = false; - } - else if (attr.GetType() == typeof(SpaceAttribute)) - { - SpaceAttribute space = attr as SpaceAttribute; - GUILayout.Space(space.height); - } - } - - GUI_Label(new GUIContent(name, tooltip), styles.textBold); - - if (field.FieldType == typeof(Vector3)) - { - field.SetValue(collider, GUI_Vector3((Vector3)field.GetValue(collider))); - } - else if (field.FieldType == typeof(Vector2)) - { - field.SetValue(collider, GUI_Vector2((Vector2)field.GetValue(collider))); - } - else if(field.FieldType == typeof(Color)) - { - field.SetValue(collider, GUI_Color((Color)field.GetValue(collider))); - } - else if (field.FieldType == typeof(string)) - { - field.SetValue(collider, GUI_String((string)field.GetValue(collider))); - } - else if (field.FieldType == typeof(bool)) - { - field.SetValue(collider, GUI_Bool((bool)field.GetValue(collider))); - } - else if (field.FieldType == typeof(AnimationCurve)) - { - field.SetValue(collider, GUI_Curve(field.GetValue(collider) as AnimationCurve)); - } - else if (field.FieldType.IsEnum) - { - field.SetValue(collider, GUI_Enum((Enum)field.GetValue(collider))); - } - else if (field.FieldType == typeof(float)) - { - field.SetValue(collider, GUI_Float((float)field.GetValue(collider))); - } - else if (field.FieldType == typeof(int)) - { - field.SetValue(collider, GUI_Int((int)field.GetValue(collider))); - } - GUI.enabled = true; - GUILayout.Space(5); - - if (foldout != null && foldoutElementCount == foldout.count) - { - foldout = null; - foldoutElementCount = 0; - indent = 0; - } - } - } - EditorGUILayout.EndScrollView(); - } - - Rect GetControlRect() - { - Rect rect = EditorGUILayout.GetControlRect(); - rect.x += indent; - rect.width -= indent; - return rect; - } - - void GUI_Label(GUIContent label, GUIStyle style) - { - Rect rect = GetControlRect(); - EditorGUI.LabelField(rect, label, style); - } - - Vector3 GUI_Vector3(Vector3 value) - { - Rect rect = GetControlRect(); - return EditorGUI.Vector3Field(rect, "", value); - } - - Vector2 GUI_Vector2(Vector2 value) - { - Rect rect = GetControlRect(); - return EditorGUI.Vector2Field(rect, "", value); - } - - string GUI_String(string value) - { - Rect rect = GetControlRect(); - return EditorGUI.TextField(rect, "", value); - } - - bool GUI_Bool(bool value) - { - Rect rect = GetControlRect(); - return GUI.Toggle(rect, value, "Check"); - } - - void GUI_Enum(string value) - { - Rect rect = GetControlRect(); - GUI.Label(rect, value); - } - - float GUI_Float(float value) - { - Rect rect = GetControlRect(); - return EditorGUI.FloatField(rect, "", value); - } - - int GUI_Int(int value) - { - Rect rect = GetControlRect(); - return EditorGUI.IntField(rect, "", value); - } - - AnimationCurve GUI_Curve(AnimationCurve curve) - { - Rect rect = GetControlRect(); - return EditorGUI.CurveField(rect, "", curve); - } - - Enum GUI_Enum(Enum enumValue) - { - Rect rect = GetControlRect(); - return EditorGUI.EnumPopup(rect, "", enumValue); - } - - Color GUI_Color(Color col) - { - Rect rect = GetControlRect(); - return EditorGUI.ColorField(rect, col); - } - - } -} \ No newline at end of file -- cgit v1.1-26-g67d0