diff options
Diffstat (limited to 'Assets/UI_Extension/Scripts/Animation/Tween/Editor')
13 files changed, 723 insertions, 30 deletions
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/New Animation.anim b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/New Animation.anim new file mode 100644 index 0000000..bb5fc5b --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/New Animation.anim @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: New Animation + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: [] + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: [] + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: [] + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_Events: [] diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/New Animation.anim.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/New Animation.anim.meta new file mode 100644 index 0000000..1c541cb --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/New Animation.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2c8f8c78a811b1046a3cb6c304892d09 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs index c4267b9..cc57055 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs @@ -36,10 +36,35 @@ namespace TweenAnimation static string[] s_TweenModuleClassNames;
static Dictionary<string, MethodInfo> s_TweenModuleGUI;
+ static int s_ModuleTabHash = "TweenModuleTab".GetHashCode();
+ static int s_ModuleEnabledHash = "TweenModuleEnabled".GetHashCode();
+
+ // 是否在时间轴上显示
+ bool m_ShowEvents;
+ bool m_ShowModules;
+
+ bool m_Play;
+ bool m_Pause;
+ bool m_Stop;
+
+ HashSet<float> m_EventTimeSet;
+ float m_SelectedEventTime;
+
public void OnEnable()
{
+ if(s_TweenModuleGUI == null)
+ s_TweenModuleGUI = new Dictionary<string, MethodInfo>();
+
m_ShowAnimationTab = true;
- s_TweenModuleGUI = new Dictionary<string, MethodInfo>();
+
+ m_ShowEvents = true;
+ m_ShowModules = true;
+
+ if (m_EventTimeSet == null)
+ m_EventTimeSet = new HashSet<float>();
+ m_EventTimeSet.Clear();
+
+ m_SelectedEventTime = -1;
}
public override void OnInspectorGUI()
@@ -48,6 +73,8 @@ namespace TweenAnimation if (animation == null)
return;
+ this.serializedObject.Update();
+
EditorGUILayout.Space();
AnimationTab();
@@ -55,6 +82,8 @@ namespace TweenAnimation AnimationModules();
EditorGUILayout.Space();
+
+ serializedObject.ApplyModifiedProperties();
}
void AnimationTab()
@@ -72,7 +101,7 @@ namespace TweenAnimation GUI.Label(new Rect(rect.x + 10, rect.y + 3, 100, 20), "Tween Animation", styles.headerTitle);
Vector2 size = styles.text.CalcSize(new GUIContent(animation.description));
GUI.Label(new Rect(rect.x + rect.width - size.x - 10, rect.y + 3, 100, 20), animation.description, styles.text);
-
+
if (m_ShowAnimationTab)
{
animation.description = ui.GUIText("Description", animation.description);
@@ -94,7 +123,21 @@ namespace TweenAnimation // 事件触发方向
animation.eventTriggeredDirection = (TweenAnimation.EventTriggeredDirection)ui.GUIEnumMask("Event Direction", animation.eventTriggeredDirection);
+
+ // 是否只触发一次
+ animation.triggerOnce = ui.GUIToggle("Trigger Once", animation.triggerOnce);
+
+ // ITweenEventHandler
+ animation.scriptHandler = ui.GUIToggle("Event Handler", animation.scriptHandler);
+
+ GUILayout.Space(5);
+
+ // 时间轴
+ DrawRuler(1f, true);
+
+ EventList();
}
+
DrawBgWire(rect, (m_ShowAnimationTab ? 4 : -2));
if(!m_ShowAnimationTab)
GUILayout.Space(-4);
@@ -107,8 +150,8 @@ namespace TweenAnimation Rect rect = ui.GetControlRect(20);
Rect labelRect = rect;
- labelRect.y += 2;
- GUI.Label(labelRect, "Modules ", styles.text);
+ labelRect.y += 1;
+ GUI.Label(labelRect, "Modules ", styles.textBold);
rect.x = rect.x + rect.width - 15;
rect.width = 20;
@@ -173,33 +216,31 @@ namespace TweenAnimation bool enabled = module.enabled;
// header
Rect rect = ui.GetControlRect(20);
-
- if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseUp)
+ Rect checkRect = rect;
+ checkRect.x += 1;
+ checkRect.y += 1;
+ checkRect.width = 20;
+ checkRect.height = 20;
+ Rect headerRect = rect;
+ headerRect.x -= 2;
+ headerRect.width += 8;
+ Rect deleteRect = rect;
+ deleteRect.x = rect.x + rect.width - 18;
+ deleteRect.width = 20;
+ deleteRect.height = 20;
+ if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseUp || Event.current.type == EventType.Layout)
{
- Rect checkRect = rect;
- checkRect.x += 1;
- checkRect.y += 1;
- checkRect.width = 20;
- checkRect.height = 20;
- module.enabled = GUI.Toggle(checkRect, enabled, "", styles.checkmark);
- Rect headerRect = rect;
- headerRect.x -= 2;
- headerRect.width += 8;
+ module.enabled = GUI.Toggle(checkRect, module.enabled, "", styles.checkmark);
+ if (GUI.Button(deleteRect, "-", styles.textBoldBig))
+ animation.RemoveModule(module);
if (GUI.Button(headerRect, "", styles.headerBg))
module.unfold = !module.unfold;
}
- else if(Event.current.type == EventType.Repaint || Event.current.type == EventType.Layout)
+ else if (Event.current.type == EventType.Repaint /*|| Event.current.type == EventType.Layout*/)
{
- Rect headerRect = rect;
- headerRect.x -= 2;
- headerRect.width += 8;
GUI.Button(headerRect, "", styles.headerBg);
- Rect checkRect = rect;
- checkRect.x += 1;
- checkRect.y += 1;
- checkRect.width = 20;
- checkRect.height = 20;
GUI.Toggle(checkRect, enabled, "", styles.checkmark);
+ GUI.Button(deleteRect, "-", styles.textBoldBig);
}
Vector2 size = styles.text.CalcSize(new GUIContent(name));
@@ -208,6 +249,7 @@ namespace TweenAnimation // content
if (module.unfold)
{
+ GUILayout.Space(-3);
MethodInfo method;
string classname = module.GetType().Name;
if (!s_TweenModuleGUI.TryGetValue(classname, out method))
@@ -250,9 +292,338 @@ namespace TweenAnimation }
// 绘制时间轴
- void DrawRuler()
+ void DrawRuler(float alpha, bool bLabels)
+ {
+ if (animation.duration <= 0)
+ return;
+
+ float duration = animation.duration;
+ Rect timelineRect = ui.GetControlRect(110);
+
+ bool bRepaint = Event.current.type == EventType.Repaint;
+
+ GUI.BeginGroup(timelineRect);
+
+ // draw ruler
+ Rect rulerRect = new Rect(5, 5, timelineRect.width - 10, 60);
+
+ Rect bgRect = rulerRect;
+ EditorGUI.DrawRect(bgRect, new Color(1, 1, 1, 1f) * 0.7f);
+
+ int rulerWidth = (int)rulerRect.width;
+ styles.defaultUIMaterail.SetPass(0);
+ GL.PushMatrix();
+ GL.LoadPixelMatrix();
+ bool bWin = Application.platform == RuntimePlatform.WindowsEditor;
+ if (bWin)
+ GL.Begin(GL.QUADS);
+ else
+ GL.Begin(GL.LINES);
+
+ //ui.DrawVerticalLineFast(rulerRect.x, 0, rulerRect.height, Color.red);
+ //ui.DrawVerticalLineFast(rulerRect.x + rulerRect.width, 0, rulerRect.height, Color.red);
+ //ui.DrawHorizontalLineFast(rulerRect.y, rulerRect.x, rulerRect.x + rulerRect.width, Color.blue);
+ //ui.DrawHorizontalLineFast(rulerRect.y + rulerRect.height, rulerRect.x, rulerRect.x + rulerRect.width, Color.blue);
+
+ int yOffBase = (int)rulerRect.height + (int)rulerRect.y;
+ if (bRepaint)
+ ui.DrawHorizontalLineFast(yOffBase, rulerRect.x, rulerRect.x + rulerRect.width, Color.gray);
+
+ int log = (int)Mathf.Floor(Mathf.Log10(duration)) ;
+ float stepCount;
+ int stepSlice = 5; // 每个stepBig分为几个小step
+ do
+ {
+ float stepBig = Mathf.Pow(10, log);
+ float stepSmall = stepBig / stepSlice;
+ stepCount = duration / stepSmall;
+ log--;
+ stepSlice *= 2;
+ } while (stepCount < 20);
+ log++;
+ stepSlice /= 2;
+
+ int j = 1;
+ while (stepCount > 30)
+ {
+ float stepBig = Mathf.Pow(10, log) * j * 2;
+ float stepSmall = stepBig / stepSlice;
+ stepCount = duration / stepSmall;
+ ++j;
+ //Debug.Log("stepBig=" + stepBig + ",stepSmall=" + stepSmall);
+ }
+
+ float stepPixelWidth = rulerWidth / stepCount;
+ float timePerStep = duration / stepCount;
+
+ if(bRepaint)
+ {
+ for (int i = 0; i <= stepCount; ++i)
+ {
+ int len = 15;
+ if (i % stepSlice == 0)
+ len = 30;
+ ui.DrawVerticalLineFast(rulerRect.x + i * stepPixelWidth, yOffBase, yOffBase - len, Color.gray);
+ }
+ }
+
+ // 绘制事件的竖线
+ //if (bRepaint && m_ShowEvents && animation.eventList != null)
+ //{
+ // m_EventTimeSet.Clear();
+ // for (int i = 0; i < animation.eventList.Count; ++i)
+ // {
+ // TweenEvent e = animation.eventList[i];
+ // if (e != null)
+ // {
+ // if (!m_EventTimeSet.Contains(e.time))
+ // m_EventTimeSet.Add(e.time);
+ // }
+ // }
+ // float y = rulerRect.y + 3;
+ // Rect eventRect = new Rect(0, y, 15, 15);
+ // foreach (float time in m_EventTimeSet)
+ // {
+ // float x = time / duration * rulerWidth;
+ // eventRect.x = x + 5;
+ // ui.DrawVerticalLineFast(eventRect.x, yOffBase, yOffBase - 50, Color.gray);
+ // }
+ //}
+
+ // 绘制module时间
+ if(m_ShowModules && bRepaint)
+ {
+ int xStart = 5;
+ int yStart = 25;
+ for(int i = 0; i < animation.modules.Count; ++i)
+ {
+ TweenModule module = animation.modules[i];
+ if(module.unfold)
+ {
+ float left = module.timeOffset / duration * rulerRect.width;
+ float right = (module.timeOffset + module.duration) / duration * rulerRect.width;
+ left = Mathf.Clamp(left, 0, rulerRect.width) + xStart;
+ right = Mathf.Clamp(right, 0, rulerRect.width) + xStart;
+ ui.DrawHorizontalLineFast(yStart + (rulerRect.height - 20) / animation.modules.Count * i, left, right, Color.white);
+ }
+ }
+ }
+
+ GL.PopMatrix();
+ GL.End();
+
+ // draw labels
+ if(bLabels)
+ {
+ for (int i = 0; i <= stepCount; ++i)
+ {
+ if (i % stepSlice == 0 || stepSlice == 10 && i % (stepSlice / 2) == 0)
+ {
+ float time = i * timePerStep; // sec
+ Vector2 size = styles.text.CalcSize(new GUIContent(time.ToString("f2")));
+ GUI.Label(new Rect(rulerRect.x + i * stepPixelWidth - size.x / 2, yOffBase + 2, 50, 15), time.ToString("f2"), styles.text );
+ }
+ }
+ }
+
+ // draw events
+ if(m_ShowEvents && animation.eventList != null)
+ {
+ m_EventTimeSet.Clear();
+ for (int i = 0; i < animation.eventList.Count; ++i)
+ {
+ TweenEvent e = animation.eventList[i];
+ if(e != null)
+ {
+ if(!m_EventTimeSet.Contains(e.time))
+ m_EventTimeSet.Add(e.time);
+ }
+ }
+ float y = rulerRect.y - 1;
+ Rect eventRect = new Rect(0, y, 15, 15);
+ foreach (float time in m_EventTimeSet)
+ {
+ float x = time / duration * rulerWidth - 15 / 4;
+ eventRect.x = x;
+ if (GUI.Button(eventRect, TweenModuleGUIStyles.eventIcon, styles.text))
+ {
+ m_SelectedEventTime = time;
+ }
+ ui.DrawVerticalLineFast(eventRect.x, yOffBase, yOffBase - eventRect.y, Color.gray);
+ }
+ }
+
+ // buttons
+
+ // 控制时间轴显示
+ {
+ Rect buttonRect = new Rect(5 + rulerRect.width - 20 * 2, yOffBase + 20, 20, 20);
+ Color pressedColor = Color.gray;
+
+ Rect eventRect = buttonRect;
+ Color col = GUI.color;
+ if (m_ShowEvents)
+ GUI.color = pressedColor;
+ if (GUI.Button(eventRect, TweenModuleGUIStyles.eventIcon, EditorStyles.miniButtonLeft))
+ {
+ m_ShowEvents = !m_ShowEvents;
+ if (!m_ShowEvents)
+ m_SelectedEventTime = -1;
+ }
+ GUI.color = col;
+
+ Rect moduleRect = buttonRect;
+ moduleRect.x += 20;
+ col = GUI.color;
+ if (m_ShowModules)
+ GUI.color = pressedColor;
+ if (GUI.Button(moduleRect, TweenModuleGUIStyles.moduleIcon, EditorStyles.miniButtonRight))
+ m_ShowModules = !m_ShowModules;
+ GUI.color = col;
+ }
+
+ // 播放、暂停等
+ {
+ Rect buttonRect = new Rect(5 , yOffBase + 20, 30, 20);
+ Rect eventRect = buttonRect;
+ Color pressedColor = Color.gray;
+
+ Rect playRect = buttonRect;
+ Color col = GUI.color;
+ if (m_Play)
+ GUI.color = pressedColor;
+ if (GUI.Button(eventRect, "Play", styles.miniLeft))
+ {
+ m_Play = !m_Play;
+ if(m_Play)
+ {
+ m_Pause = m_Stop = false;
+ EditorPlay();
+ }
+ }
+ GUI.color = col;
+
+ Rect pauseRect = buttonRect;
+ pauseRect.x += buttonRect.width;
+ col = GUI.color;
+ if (m_Pause)
+ GUI.color = pressedColor;
+ if (GUI.Button(pauseRect, "Pause", styles.miniMid))
+ {
+ m_Pause = !m_Pause;
+ if (m_Pause)
+ m_Play = m_Stop = false;
+ }
+ GUI.color = col;
+
+ Rect stopRect = buttonRect;
+ stopRect.x += 2 * buttonRect.width;
+ if (GUI.Button(stopRect, "Stop", styles.miniRight))
+ {
+ EditorStop();
+ m_Pause = m_Play = false;
+ }
+ }
+
+ GUI.EndGroup();
+ }
+
+ void EventList()
+ {
+ Rect evetRect = ui.GetControlRect(15);
+
+ Rect labelRect = evetRect;
+ labelRect.x += 2;
+ GUI.Label(labelRect, "Events", styles.textBold);
+
+ Rect addButton = evetRect;
+ addButton.x = evetRect.x + evetRect.width - 20;
+ if(GUI.Button(addButton, "+", styles.textBoldBig))
+ {
+ animation.AddEvent(new TweenEvent());
+ }
+
+ if (animation.eventList == null || animation.eventList.Count == 0)
+ return;
+
+ for(int i = 0; i < animation.eventList.Count; ++i)
+ {
+ DrawEvent(animation.eventList[i], i);
+ }
+ }
+
+ void DrawEvent (TweenEvent e, int index)
{
+ Rect rect = ui.GetControlRect(15);
+
+ // delete button
+ Rect deleteButton = rect;
+ deleteButton.x += 5;
+ deleteButton.width = 10;
+ deleteButton.y -= 2;
+ if (GUI.Button(deleteButton, "-", styles.textBoldBig))
+ {
+ animation.RemoveEvent(e);
+ return;
+ }
+
+ // event time
+ Rect timeLabelRect = rect;
+ timeLabelRect.x += 25;
+ timeLabelRect.width = 30;
+ timeLabelRect.height = 13;
+ GUI.Label(timeLabelRect, "time:", e.time == m_SelectedEventTime ? styles.textBold : styles.text);
+ Rect timeRect = timeLabelRect;
+ timeRect.x += 25;
+ float time = EditorGUI.FloatField(timeRect, e.time, styles.floatfiled);
+ time = Mathf.Clamp(time, 0, float.MaxValue);
+ e.time = time;
+ // event name
+ Rect nameLabelRect = rect;
+ nameLabelRect.x += 150;
+ nameLabelRect.width = 100;
+ nameLabelRect.height = 13;
+ GUI.Label(nameLabelRect, "name:", styles.text);
+ Rect nameRect = nameLabelRect;
+ nameRect.x += 32;
+ e.name = EditorGUI.TextField(nameRect, e.name, styles.textField);
+
+ // 折叠
+ Rect unfoldRect = rect;
+ unfoldRect.x = rect.x + rect.width - 19;
+ unfoldRect.width = 13;
+ unfoldRect.height = 13;
+ e.unfold = GUI.Button(unfoldRect, (e.unfold ? "▲" : "▼"), styles.textSmall) ? !e.unfold : e.unfold;
+ if(e.unfold)
+ {
+ SerializedProperty eventHandler = null;
+ SerializedProperty list = serializedObject.FindProperty("eventList");
+ for (int i = 0; i < list.arraySize; ++i)
+ {
+ if (i != index)
+ continue;
+ SerializedProperty ent = list.GetArrayElementAtIndex(i);
+ if (ent != null)
+ {
+ foreach(var property in ent)
+ {
+ SerializedProperty prop = property as SerializedProperty;
+ if(prop != null && prop.name == "eventHandler")
+ {
+ eventHandler = prop;
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ if(eventHandler != null)
+ {
+ EditorGUILayout.PropertyField(eventHandler);
+ }
+ }
}
}
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Alpha.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Alpha.cs index 6585ded..1f7c0cd 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Alpha.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Alpha.cs @@ -1,6 +1,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+using UnityEngine.UI;
using UnityEditor;
namespace TweenAnimation
{
@@ -9,8 +10,18 @@ namespace TweenAnimation {
public void OnInspector_TweenAlpha(TweenModule module)
{
+ OnInspector_Base(module);
TweenAlpha tween = module as TweenAlpha;
- value = ui.GUIFloat("Float value", value, "f2");
+
+ float alpha = ui.GUIFloat("From", tween.from, "f1");
+ alpha = Mathf.Clamp(alpha, 0, 1);
+ tween.from = alpha;
+
+ alpha = ui.GUIFloat("To", tween.to, "f1");
+ alpha = Mathf.Clamp(alpha, 0, 1);
+ tween.to = alpha;
+
+ tween.target = ui.GUIObject("Target", tween.target, typeof(Graphic)) as Graphic;
}
}
}
\ No newline at end of file diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Base.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Base.cs new file mode 100644 index 0000000..27a398c --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Base.cs @@ -0,0 +1,22 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+namespace TweenAnimation
+{
+
+ public partial class TweenAnimationInspector : Editor
+ {
+ public void OnInspector_Base(TweenModule module)
+ {
+ float offset = ui.GUIFloat("Time Offset", module.timeOffset, "f2");
+ offset = Mathf.Clamp(offset, 0, float.MaxValue);
+ module.timeOffset = offset;
+
+ float duration = ui.GUIFloat("Duration", module.duration, "f2");
+ duration = Mathf.Clamp(duration, 0, float.MaxValue);
+ module.duration = duration;
+
+ }
+ }
+}
\ No newline at end of file diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Base.cs.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Base.cs.meta new file mode 100644 index 0000000..03ad61d --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Base.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3042e5763233e73449a6ec02f43ee13c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Color.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Color.cs index c129b4a..2aee642 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Color.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Color.cs @@ -9,6 +9,8 @@ namespace TweenAnimation {
public void OnInspector_TweenColor(TweenModule module)
{
+ OnInspector_Base(module);
+
value = ui.GUIFloat("Float value", value, "f2");
}
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Play.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Play.cs new file mode 100644 index 0000000..a4f4c3b --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Play.cs @@ -0,0 +1,35 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using UnityEngine;
+using UnityEditor;
+
+namespace TweenAnimation
+{
+ public partial class TweenAnimationInspector : Editor
+ {
+ float m_Time;
+
+ // 编辑器下播放动画
+ void EditorPlay()
+ {
+ m_Time = 0;
+ EditorApplication.update -= Update;
+ EditorApplication.update += Update;
+ }
+
+ void EditorStop()
+ {
+ EditorApplication.update -= Update;
+ }
+
+ void Update()
+ {
+ m_Time += Time.deltaTime;
+ animation.UpdateEditor(m_Time);
+ }
+
+ }
+}
\ No newline at end of file diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Play.cs.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Play.cs.meta new file mode 100644 index 0000000..e5705e7 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Play.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0102651372a3cee42b26b997c168fc8a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_RectSize.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_RectSize.cs new file mode 100644 index 0000000..be6bf44 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_RectSize.cs @@ -0,0 +1,19 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+namespace TweenAnimation
+{
+
+ public partial class TweenAnimationInspector : Editor
+ {
+ public void OnInspector_TweenRectSize(TweenModule module)
+ {
+ OnInspector_Base(module);
+
+ value = ui.GUIFloat("Float value", value, "f2");
+
+ }
+
+ }
+}
\ No newline at end of file diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_RectSize.cs.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_RectSize.cs.meta new file mode 100644 index 0000000..56c06ba --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_RectSize.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3f9b80b143c598349a4f9ba12e576197 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs index 2e90cb8..43dca65 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs @@ -16,6 +16,13 @@ namespace TweenAnimation static Texture2D m_BgTextureActive;
static Texture2D m_BgTextureWire;
static Texture2D m_BgTextureWireSmall;
+ static Material m_material;
+
+ public static Texture2D eventIcon;
+ public static Texture2D moduleIcon;
+ public static Texture2D eventBuoy;
+
+ public Material defaultUIMaterail => m_material;
static Texture2D LoadTexture(string path)
{
@@ -31,6 +38,13 @@ namespace TweenAnimation m_BgTextureActive = LoadTexture(TweenAnimationSetup.root + "Icons/BackgroundActive.png");
m_BgTextureWire = LoadTexture(TweenAnimationSetup.root + "Icons/BackgroundWire.png");
m_BgTextureWireSmall = LoadTexture(TweenAnimationSetup.root + "Icons/BackgroundWireSmall.png");
+ eventIcon = LoadTexture(TweenAnimationSetup.root + "Icons/EventIcon.png");
+ moduleIcon = LoadTexture(TweenAnimationSetup.root + "Icons/ModuleIcon.png");
+ eventBuoy = LoadTexture(TweenAnimationSetup.root + "Icons/EventBuoy.png");
+
+ m_material = new Material(Shader.Find("Hidden/Internal-Colored"));
+ m_material.hideFlags = HideFlags.HideAndDontSave;
+
}
private static Delegate GetMethod(Type del, Type type, string name, BindingFlags flag)
@@ -299,6 +313,31 @@ namespace TweenAnimation private GUIStyle m_Text;
public GUIStyle text { get { return m_Text; } }
+ private GUIStyle m_TextSmall;
+ public GUIStyle textSmall { get { return m_TextSmall; } }
+
+ private GUIStyle m_TextBold;
+ public GUIStyle textBold { get { return m_TextBold; } }
+
+ private GUIStyle m_TextBoldBig;
+ public GUIStyle textBoldBig { get { return m_TextBoldBig; } }
+
+ private GUIStyle m_TextField;
+ public GUIStyle textField { get { return m_TextField; } }
+
+
+ private GUIStyle m_MiniLeft;
+ public GUIStyle miniLeft { get { return m_MiniLeft; } }
+
+ private GUIStyle m_MiniMid;
+ public GUIStyle miniMid { get { return m_MiniMid; } }
+
+ private GUIStyle m_MiniRight;
+ public GUIStyle miniRight { get { return m_MiniRight; } }
+
+ public GUIStyle m_Obj;
+ public GUIStyle obj { get { return m_Obj; } }
+
public static TweenModuleGUIStyles Get()
{
bool flag = s_TweenModuleGUIStyles == null;
@@ -348,7 +387,7 @@ namespace TweenAnimation });
InitStyle(out m_HeaderTitle, s => {
s.fontStyle = FontStyle.Bold;
- s.fontSize = 9;
+ s.fontSize = 10;
});
InitStyle(out m_Bg, s => {
s.border = new RectOffset(5, 5, 5, 5);
@@ -362,11 +401,44 @@ namespace TweenAnimation s.fontSize = 9;
});
- InitStyle(out m_Text, EditorStyles.label, s => {
+ InitStyle(out m_Text, /*EditorStyles.label, */s => {
+ s.fontSize = 10;
+ });
+
+ InitStyle(out m_TextSmall, /*EditorStyles.label, */s => {
+ s.fontSize = 7;
+ });
+
+ InitStyle(out m_TextBold, /*EditorStyles.label, */s => {
+ s.fontStyle = FontStyle.Bold;
+ s.fontSize = 10;
+ });
+
+ InitStyle(out m_TextBoldBig, /*EditorStyles.label, */s => {
+ s.fontStyle = FontStyle.Bold;
+ s.fontSize = 12;
+ });
+
+ InitStyle(out m_TextField, EditorStyles.textField, s => {
+ s.fontSize = 9;
+ });
+
+ InitStyle(out m_MiniLeft, EditorStyles.miniButtonLeft, s => {
s.fontSize = 9;
});
+ InitStyle(out m_MiniMid, EditorStyles.miniButtonMid, s => {
+ s.fontSize = 9;
+ });
+ InitStyle(out m_MiniRight, EditorStyles.miniButtonRight, s => {
+ s.fontSize = 9;
+ });
+
+ InitStyle(out m_Obj, EditorStyles.objectField, s => {
+ s.fontSize = 9;
+ });
+
}
-
+
private static void InitStyle(out GUIStyle normal, string name)
{
normal = FindStyle(name);
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs index aeb4e8b..22071ea 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs @@ -104,7 +104,7 @@ namespace TweenAnimation PrefixLabel(controlRect, guiContent);
Rect position = controlRect;
position.xMin += EditorGUIUtility.labelWidth;
- content = GUI.TextField(position, content);
+ content = GUI.TextField(position, content, styles.textField);
return content;
}
@@ -132,6 +132,35 @@ namespace TweenAnimation return EditorGUI.EnumPopup(rect, enumValue, styles.popup);
}
+ public bool GUIToggle(string label, bool toggled, params GUILayoutOption[] layoutOptions)
+ {
+ return GUIToggle(new GUIContent(label), toggled, layoutOptions);
+ }
+
+ public bool GUIToggle(GUIContent label, bool toggled, params GUILayoutOption[] layoutOptions)
+ {
+ Rect rect = GetControlRect(13, layoutOptions);
+ rect = PrefixLabel(rect, label);
+ toggled = EditorGUI.Toggle(rect, toggled, styles.toggle);
+ return toggled;
+ }
+
+ public UnityEngine.Object GUIObject(string label, UnityEngine.Object obj, Type type, params GUILayoutOption[] layoutOptions)
+ {
+ return GUIObject(new GUIContent(label), obj, type, layoutOptions);
+ }
+
+ public UnityEngine.Object GUIObject(GUIContent label, UnityEngine.Object obj, Type type, params GUILayoutOption[] layoutOptions)
+ {
+ Rect rect = GetControlRect(13, layoutOptions);
+ rect = PrefixLabel(rect, label);
+ int fontsize = EditorStyles.objectField.fontSize;
+ EditorStyles.objectField.fontSize = 9;
+ obj = EditorGUI.ObjectField(rect, obj, type, true);
+ EditorStyles.objectField.fontSize = fontsize;
+ return obj;
+ }
+
private Rect PrefixLabel(Rect totalPosition, GUIContent label)
{
bool flag = !EditorGUI_LabelHasContent(label);
@@ -181,6 +210,44 @@ namespace TweenAnimation return GUILayoutUtility.GetLastRect();
}
+ public void DrawVerticalLineFast(float x, float minY, float maxY, Color color)
+ {
+ bool bWin = Application.platform == RuntimePlatform.WindowsEditor;
+ if (bWin)
+ {
+ GL.Color(color);
+ GL.Vertex(new Vector3(x - 0.5f, minY, 0f));
+ GL.Vertex(new Vector3(x + 0.5f, minY, 0f));
+ GL.Vertex(new Vector3(x + 0.5f, maxY, 0f));
+ GL.Vertex(new Vector3(x - 0.5f, maxY, 0f));
+ }
+ else
+ {
+ GL.Color(color);
+ GL.Vertex(new Vector3(x, minY, 0f));
+ GL.Vertex(new Vector3(x, maxY, 0f));
+ }
+ }
+
+ public void DrawHorizontalLineFast(float y, float minX, float maxX, Color color)
+ {
+ bool bWin = Application.platform == RuntimePlatform.WindowsEditor;
+ if (bWin)
+ {
+ GL.Color(color);
+ GL.Vertex(new Vector3(minX, y - 0.5f, 0f));
+ GL.Vertex(new Vector3(minX, y + 0.5f, 0f));
+ GL.Vertex(new Vector3(maxX, y + 0.5f, 0f));
+ GL.Vertex(new Vector3(maxX, y - 0.5f, 0f));
+ }
+ else
+ {
+ GL.Color(color);
+ GL.Vertex(new Vector3(minX, y, 0f));
+ GL.Vertex(new Vector3(maxX, y, 0f));
+ }
+ }
+
}
}
|