summaryrefslogtreecommitdiff
path: root/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-15 19:05:22 +0800
committerchai <chaifix@163.com>2020-10-15 19:05:22 +0800
commitf049177e20a276049c61edbad631c1b2bbdd5706 (patch)
tree7d1a1cd9b690a5d9a8b9a65554a191d6ec769601 /Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs
parent6990a0d1fbdcbbf404f40713363ac1a148c8840a (diff)
-advanced inspector
+odin
Diffstat (limited to 'Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs')
-rw-r--r--Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs196
1 files changed, 0 insertions, 196 deletions
diff --git a/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs b/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs
deleted file mode 100644
index 4219fa75..00000000
--- a/Assets/Plugins/Editor/AdvancedInspector/ExtraGUI/ExtraGUI.cs
+++ /dev/null
@@ -1,196 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using UnityEngine;
-using UnityEditor;
-
-using UniToolsEditor;
-
-namespace AdvancedInspector
-{
- public static class ExtraGUI
- {
- private static Texture knob;
-
- private static Texture Knob
- {
- get
- {
- if (knob == null)
- {
- knob = Helper.Load(EditorResources.Knob);
- knob.filterMode = FilterMode.Trilinear;
- }
-
- return knob;
- }
- }
-
- private static Texture knobBack;
-
- private static Texture KnobBack
- {
- get
- {
- if (knobBack == null)
- knobBack = Helper.Load(EditorResources.KnobBack);
-
- return knobBack;
- }
- }
-
- private static Vector2 mousePosition;
-
- public static float FloatAngle(Rect rect, float value)
- {
- return FloatAngle(rect, value, -1, -1, -1);
- }
-
- public static float FloatAngle(Rect rect, float value, float snap)
- {
- return FloatAngle(rect, value, snap, -1, -1);
- }
-
- public static float FloatAngle(Rect rect, float value, float snap, float min, float max)
- {
- int id = GUIUtility.GetControlID(FocusType.Passive, rect);
-
- Rect knobRect = new Rect(rect.x, rect.y, rect.height, rect.height);
-
- float delta;
- if (min != max)
- delta = ((max - min) / 360);
- else
- delta = 1;
-
- if (Event.current != null)
- {
- if (Event.current.type == EventType.MouseDown && knobRect.Contains(Event.current.mousePosition))
- {
- GUIUtility.hotControl = id;
- mousePosition = Event.current.mousePosition;
- }
- else if (Event.current.type == EventType.MouseUp && GUIUtility.hotControl == id)
- GUIUtility.hotControl = 0;
- else if (Event.current.type == EventType.MouseDrag && GUIUtility.hotControl == id)
- {
- Vector2 move = mousePosition - Event.current.mousePosition;
- value += delta * (-move.x - move.y);
-
- if (snap > 0)
- {
- float mod = value % snap;
-
- if (mod < (delta * 3) || Mathf.Abs(mod - snap) < (delta * 3))
- value = Mathf.Round(value / snap) * snap;
- }
-
- mousePosition = Event.current.mousePosition;
- GUI.changed = true;
- }
- }
-
- GUI.DrawTexture(knobRect, KnobBack);
- Matrix4x4 matrix = GUI.matrix;
-
- if (min != max)
- GUIUtility.RotateAroundPivot(value * (360 / (max - min)), knobRect.center);
- else
- GUIUtility.RotateAroundPivot(value, knobRect.center);
-
- GUI.DrawTexture(knobRect, Knob);
- GUI.matrix = matrix;
-
- Rect label = new Rect(rect.x + rect.height + 9, rect.y + (rect.height / 2) - 9, rect.height, 18);
- value = EditorGUI.FloatField(label, value);
-
- if (min != max)
- value = Mathf.Clamp(value, min, max);
-
- return value;
- }
-
- public static int IntAngle(Rect rect, int value)
- {
- return IntAngle(rect, value, -1, -1, -1);
- }
-
- public static int IntAngle(Rect rect, int value, int snap)
- {
- return IntAngle(rect, value, snap, -1, -1);
- }
-
- public static int IntAngle(Rect rect, int value, int snap, int min, int max)
- {
- int id = GUIUtility.GetControlID(FocusType.Passive, rect);
-
- Rect knobRect = new Rect(rect.x, rect.y, rect.height, rect.height);
-
- int delta;
- if (min != max)
- delta = ((max - min) / 360);
- else
- delta = 1;
-
- if (Event.current != null)
- {
- if (Event.current.type == EventType.MouseDown && knobRect.Contains(Event.current.mousePosition))
- {
- GUIUtility.hotControl = id;
- mousePosition = Event.current.mousePosition;
- }
- else if (Event.current.type == EventType.MouseUp && GUIUtility.hotControl == id)
- GUIUtility.hotControl = 0;
- else if (Event.current.type == EventType.MouseDrag && GUIUtility.hotControl == id)
- {
- Vector2 move = mousePosition - Event.current.mousePosition;
- value += delta * (-(int)move.x - (int)move.y);
-
- if (snap > 0)
- {
- float mod = value % snap;
-
- if (mod < (delta * 3) || Mathf.Abs(mod - snap) < (delta * 3))
- value = (int)Mathf.Round(value / snap) * snap;
- }
-
- mousePosition = Event.current.mousePosition;
- GUI.changed = true;
- }
- }
-
- GUI.DrawTexture(knobRect, KnobBack);
- Matrix4x4 matrix = GUI.matrix;
-
- if (min != max)
- GUIUtility.RotateAroundPivot(value * (360 / (max - min)), knobRect.center);
- else
- GUIUtility.RotateAroundPivot(value, knobRect.center);
-
- GUI.DrawTexture(knobRect, Knob);
- GUI.matrix = matrix;
-
- Rect label = new Rect(rect.x + rect.height + 9, rect.y + (rect.height / 2) - 9, rect.height, 18);
- value = EditorGUI.IntField(label, value);
-
- if (min != max)
- value = Mathf.Clamp(value, min, max);
-
- return value;
- }
-
- public static int CycleButton(Rect rect, int selected, GUIContent[] contents, GUIStyle style)
- {
- if (GUI.Button(rect, contents[selected], style))
- {
- selected++;
- if (selected >= contents.Length)
- selected = 0;
- }
-
- return selected;
- }
- }
-}