diff options
author | chai <chaifix@163.com> | 2021-05-27 18:11:57 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-05-27 18:11:57 +0800 |
commit | 654d95efad67a00cb4cffc300419092e9a5093e5 (patch) | |
tree | 8d8d66ae9550baaf55dd07e8a126603256b61949 | |
parent | 9ff19bb9f048e74670b6292889edc54ae47c61fe (diff) |
*tween animation
21 files changed, 970 insertions, 45 deletions
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Demo/TweenDemo.unity b/Assets/UI_Extension/Scripts/Animation/Tween/Demo/TweenDemo.unity index 045e79e..482073e 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Demo/TweenDemo.unity +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Demo/TweenDemo.unity @@ -257,6 +257,8 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 98030082} + - component: {fileID: 98030084} + - component: {fileID: 98030085} - component: {fileID: 98030083} m_Layer: 5 m_Name: Panel @@ -295,6 +297,59 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6f0c0bc999ebb1a4ea14378d250ac5b5, type: 3} m_Name: m_EditorClassIdentifier: + description: normal + duration: 1 + playbackStyle: 1 + eventTriggeredDirection: -1 + playbackLimit: 0 +--- !u!114 &98030084 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 98030081} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1a60e4bfc89118145bda9abd42b07e9e, type: 3} + m_Name: + m_EditorClassIdentifier: + curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 2 + time: 0 + value: 100 + inSlope: -99 + outSlope: -99 + tangentMode: 34 + - serializedVersion: 2 + time: 1 + value: 1 + inSlope: -99 + outSlope: -99 + tangentMode: 34 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 0 + animations: + - name: + animation: {fileID: 98030083} +--- !u!114 &98030085 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 98030081} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6f0c0bc999ebb1a4ea14378d250ac5b5, type: 3} + m_Name: + m_EditorClassIdentifier: + description: normal + duration: 1 + playbackStyle: 1 + eventTriggeredDirection: -1 + playbackLimit: 0 --- !u!1 &212790671 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs index e0f2b9a..e79c90d 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector.cs @@ -1,6 +1,8 @@ using System;
using System.Collections;
using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
using UnityEngine;
using UnityEditor;
@@ -9,7 +11,7 @@ namespace TweenAnimation [CustomEditor(typeof(TweenAnimation), false)]
public partial class TweenAnimationInspector : Editor
{
- private TweenModuleGUIStyles styles
+ TweenModuleGUIStyles styles
{
get
{
@@ -17,17 +19,229 @@ namespace TweenAnimation }
}
- public void Awake()
+ TweenModuleUI ui
{
+ get
+ {
+ return TweenModuleUI.Get();
+ }
}
+ float value = 20;
+
+ TweenAnimation animation;
+ bool m_ShowAnimationTab = true;
+
+ static Dictionary<string, Type> s_TweenModuleClasses;
+ static string[] s_TweenModuleClassNames;
+ static Dictionary<string, MethodInfo> s_TweenModuleGUI;
+
+ public void OnEnable()
+ {
+ m_ShowAnimationTab = true;
+ s_TweenModuleGUI = new Dictionary<string, MethodInfo>();
+ }
+
public override void OnInspectorGUI()
{
- TweenAnimation tween = target as TweenAnimation;
+ animation = target as TweenAnimation;
+ if (animation == null)
+ return;
+
+ EditorGUILayout.Space();
+
+ AnimationTab();
+ AddNewModule();
+ AnimationModules();
+
+ EditorGUILayout.Space();
+ }
+
+ void AnimationTab()
+ {
+ Rect rect = ui.GetControlRect(40);
+
+ Rect headerRect = rect;
+ headerRect.x -= 2;
+ headerRect.width += 8;
+ if (GUI.Button(headerRect, "", styles.headerBg))
+ {
+ m_ShowAnimationTab = !m_ShowAnimationTab;
+ }
+
+ 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);
+ // 播放风格
+ animation.playbackStyle = (TweenAnimation.PlaybackStyle) ui.GUIEnum("Playback Style", animation.playbackStyle);
+
+ if(animation.playbackStyle != TweenAnimation.PlaybackStyle.Once)
+ {
+ // 播放次数限制
+ string fmt = animation.playbackLimit <= 0 ? "Unlimited" : "";
+ float limit = ui.GUIFloat("Playback Limit", animation.playbackLimit, fmt);
+ limit = Mathf.Clamp(limit, 0, Int32.MaxValue);
+ animation.playbackLimit = animation.playbackLimit > limit ? (int)Mathf.Floor(limit) : (int)Mathf.Ceil(limit);
+ }
+
+ // 事件触发方向
+ animation.eventTriggeredDirection = (TweenAnimation.EventTriggeredDirection)ui.GUIEnumMask("Event Direction", animation.eventTriggeredDirection);
+ }
+ DrawBgWire(rect, (m_ShowAnimationTab ? 4 : -2));
+ if(!m_ShowAnimationTab)
+ GUILayout.Space(-4);
+ else
+ GUILayout.Space(2);
+ }
+
+ void AddNewModule()
+ {
+ Rect rect = ui.GetControlRect(20);
- GUILayout.Label("content", styles.editableLabel);
- GUILayout.Label("content", styles.editableLabel);
+ Rect labelRect = rect;
+ labelRect.y += 2;
+ GUI.Label(labelRect, "Modules ", styles.text);
+
+ rect.x = rect.x + rect.width - 15;
+ rect.width = 20;
+ rect.height = 20;
+ //if (GUI.Button(rect, "", styles.plus))
+ {
+ if(s_TweenModuleClasses == null)
+ {
+ s_TweenModuleClasses = new Dictionary<string, Type>();
+ // 获得TweenModule的派生类
+ var classes = Assembly
+ .GetAssembly(typeof(TweenModule))
+ .GetTypes()
+ .Where(t => t.IsSubclassOf(typeof(TweenModule)));
+ foreach(var itor in classes)
+ {
+ string name = itor.Name;
+ Type type = itor;
+ s_TweenModuleClasses.Add(name, type);
+ }
+ s_TweenModuleClassNames = null;
+ }
+ if(s_TweenModuleClassNames == null)
+ {
+ s_TweenModuleClassNames = new string[s_TweenModuleClasses.Count];
+ int i = 0;
+ var itor = s_TweenModuleClasses.GetEnumerator();
+ while(itor.MoveNext())
+ {
+ s_TweenModuleClassNames[i++] = itor.Current.Key;
+ }
+ }
+ int selected = EditorGUI.Popup(rect, -1, s_TweenModuleClassNames, styles.plus);
+ if(selected >= 0 && selected < s_TweenModuleClassNames.Length)
+ {
+ string name = s_TweenModuleClassNames[selected];
+ Type type = s_TweenModuleClasses[name];
+ var module = Activator.CreateInstance(type);
+ animation.AddModule(module as TweenModule);
+ }
+ }
+ GUILayout.Space(-4);
+ }
+
+ void AnimationModules()
+ {
+ if (animation.modules == null)
+ return;
+ for(int i = 0; i < animation.modules.Count; ++i)
+ {
+ TweenModule module = animation.modules[i];
+ AnimaitonModule(module, i == animation.modules.Count - 1);
+ }
+ }
+
+ void AnimaitonModule(TweenModule module, bool isLast)
+ {
+ string name = module.name;
+ string description = module.description;
+ 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;
+ module.enabled = GUI.Toggle(checkRect, enabled, "", styles.checkmark);
+ Rect headerRect = rect;
+ headerRect.x -= 2;
+ headerRect.width += 8;
+ if (GUI.Button(headerRect, "", styles.headerBg))
+ module.unfold = !module.unfold;
+ }
+ 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);
+ }
+
+ Vector2 size = styles.text.CalcSize(new GUIContent(name));
+ GUI.Label(new Rect(rect.x + 15, rect.y + 2, size.x, 20), name, styles.text);
+
+ // content
+ if (module.unfold)
+ {
+ MethodInfo method;
+ string classname = module.GetType().Name;
+ if (!s_TweenModuleGUI.TryGetValue(classname, out method))
+ {
+ Type type = this.GetType();
+ method = type.GetMethod("OnInspector_" + classname);
+ s_TweenModuleGUI.Add(classname, method);
+ }
+ if (method != null)
+ {
+ object[] parameter = new object[]{ module};
+ method.Invoke(this, parameter);
+ }
+ else
+ {
+ Debug.LogError("没有对应的绘制函数" + "OnInspector_" + classname);
+ }
+ }
+
+ // wire
+ DrawBgWire(rect, module.unfold ? 4 : -2);
+
+ if (!module.unfold)
+ GUILayout.Space(-4);
+ else
+ GUILayout.Space(2);
+
+ if (!isLast)
+ GUILayout.Space(-1);
+ }
+
+ void DrawBgWire(Rect firstRect, int hOff)
+ {
+ Rect bgRect = ui.GetLastControlRect();
+ bgRect.height = bgRect.y + bgRect.height - firstRect.y + hOff/*(m_ShowAnimationTab ? 4 : -2)*/;
+ bgRect.x = firstRect.x - 3;
+ bgRect.y = firstRect.y - 1;
+ bgRect.width = firstRect.width + 5;
+ GUI.Label(bgRect, "", styles.bgSmall);
}
}
-}
\ No newline at end of file +}
\ No newline at end of file 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 0ccbe70..6585ded 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Alpha.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Alpha.cs @@ -7,10 +7,10 @@ namespace TweenAnimation public partial class TweenAnimationInspector : Editor
{
- public void foo(TweenModule module)
+ public void OnInspector_TweenAlpha(TweenModule module)
{
-
-
+ TweenAlpha tween = module as TweenAlpha;
+ value = ui.GUIFloat("Float value", value, "f2");
}
}
}
\ No newline at end of file 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 f051b61..c129b4a 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Color.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenAnimationInspector_Color.cs @@ -7,7 +7,11 @@ namespace TweenAnimation public partial class TweenAnimationInspector : Editor
{
+ public void OnInspector_TweenColor(TweenModule module)
+ {
+ value = ui.GUIFloat("Float value", value, "f2");
+ }
}
}
\ No newline at end of file diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs index ad9d09a..2e90cb8 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleGUIStyles.cs @@ -12,11 +12,25 @@ namespace TweenAnimation private delegate bool GetBoldDefaultFontFunc();
private static GetBoldDefaultFontFunc GetBoldDefaultFont;
+ static Texture2D m_BgTexture;
+ static Texture2D m_BgTextureActive;
+ static Texture2D m_BgTextureWire;
+ static Texture2D m_BgTextureWireSmall;
+
+ static Texture2D LoadTexture(string path)
+ {
+ return AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D;
+ }
+
static TweenModuleGUIStyles()
{
Type editorGUIUtility = typeof(EditorGUIUtility);
+ GetBoldDefaultFont = (GetBoldDefaultFontFunc)GetMethod(typeof(GetBoldDefaultFontFunc), typeof(EditorGUIUtility), "GetBoldDefaultFont", BindingFlags.Static | BindingFlags.NonPublic);
- GetBoldDefaultFont = (GetBoldDefaultFontFunc) GetMethod(typeof(GetBoldDefaultFontFunc), typeof(EditorGUIUtility), "GetBoldDefaultFont", BindingFlags.Static | BindingFlags.NonPublic);
+ m_BgTexture = LoadTexture(TweenAnimationSetup.root + "Icons/Background.png");
+ m_BgTextureActive = LoadTexture(TweenAnimationSetup.root + "Icons/BackgroundActive.png");
+ m_BgTextureWire = LoadTexture(TweenAnimationSetup.root + "Icons/BackgroundWire.png");
+ m_BgTextureWireSmall = LoadTexture(TweenAnimationSetup.root + "Icons/BackgroundWireSmall.png");
}
private static Delegate GetMethod(Type del, Type type, string name, BindingFlags flag)
@@ -194,6 +208,22 @@ namespace TweenAnimation }
}
+ public GUIStyle floatfiled
+ {
+ get
+ {
+ return m_FloatField;
+ }
+ }
+
+ public GUIStyle headerBg
+ {
+ get
+ {
+ return m_HeaderBg;
+ }
+ }
+
private GUIStyle m_Label;
private GUIStyle m_LabelBold;
@@ -246,10 +276,29 @@ namespace TweenAnimation private GUIStyle m_CustomDataWindow;
+ private GUIStyle m_FloatField;
+
private Texture2D m_WarningIcon;
private static TweenModuleGUIStyles s_TweenModuleGUIStyles;
+ private GUIStyle m_HeaderBg;
+
+ private GUIStyle m_HeaderTitle;
+ public GUIStyle headerTitle { get { return m_HeaderTitle; } }
+
+ private GUIStyle m_Bg;
+ public GUIStyle bg { get { return m_Bg; } }
+
+ private GUIStyle m_BgSmall;
+ public GUIStyle bgSmall { get { return m_BgSmall; } }
+
+ private GUIStyle m_AddNewModule;
+ public GUIStyle addNewModule { get { return m_AddNewModule; } }
+
+ private GUIStyle m_Text;
+ public GUIStyle text { get { return m_Text; } }
+
public static TweenModuleGUIStyles Get()
{
bool flag = s_TweenModuleGUIStyles == null;
@@ -285,18 +334,58 @@ namespace TweenAnimation this.m_CustomDataWindow.font = EditorStyles.miniFont;
this.m_EmitterHeaderStyle.clipping = TextClipping.Clip;
this.m_EmitterHeaderStyle.padding.right = 45;
- //this.m_WarningIcon = EditorGUIUtility.LoadIcon("console.infoicon.sml");
this.m_ToolbarButtonLeftAlignText = new GUIStyle(this.m_ToolbarButtonLeftAlignText);
this.m_ToolbarButtonLeftAlignText.alignment = TextAnchor.MiddleLeft;
this.m_ModulePadding = new GUIStyle();
this.m_ModulePadding.padding = new RectOffset(3, 3, 4, 2);
- }
+ InitStyle(out m_FloatField, EditorStyles.numberField, s => s.fontSize = 9);
+ InitStyle(out m_HeaderBg, s => {
+ s.border = new RectOffset(11, 15, 10, 15);
+ s.normal.background = m_BgTexture;
+ s.active.background = m_BgTextureActive;
+ s.hover.background = m_BgTexture;
+ });
+ InitStyle(out m_HeaderTitle, s => {
+ s.fontStyle = FontStyle.Bold;
+ s.fontSize = 9;
+ });
+ InitStyle(out m_Bg, s => {
+ s.border = new RectOffset(5, 5, 5, 5);
+ s.normal.background = m_BgTextureWire;
+ });
+ InitStyle(out m_BgSmall, s => {
+ s.border = new RectOffset(3, 3, 3, 3);
+ s.normal.background = m_BgTextureWireSmall;
+ });
+ InitStyle(out m_AddNewModule,EditorStyles.miniButtonMid , s => {
+ s.fontSize = 9;
+ });
+
+ InitStyle(out m_Text, EditorStyles.label, s => {
+ s.fontSize = 9;
+ });
+ }
+
private static void InitStyle(out GUIStyle normal, string name)
{
normal = FindStyle(name);
}
+ private delegate void Initter(GUIStyle style);
+
+ private static void InitStyle(out GUIStyle normal, GUIStyle other, Initter initter)
+ {
+ normal = new GUIStyle(other);
+ initter(normal);
+ }
+
+ private static void InitStyle(out GUIStyle normal, Initter initter)
+ {
+ normal = new GUIStyle();
+ initter(normal);
+ }
+
private static void InitStyle(out GUIStyle normal, out GUIStyle bold, string name)
{
InitStyle(out normal, name);
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs index 9819014..aeb4e8b 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/TweenModuleUI.cs @@ -1,13 +1,186 @@ -using System.Collections;
+using System;
+using System.Reflection;
+using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+using UnityEditor;
-public static class TweenModuleUI
+namespace TweenAnimation
{
- public static float GUIFloat(GUIContent guiContent, float floatValue, string formatString, params GUILayoutOption[] layoutOptions)
+
+ public class TweenModuleUI
{
+ static TweenModuleUI m_instance;
+ public static TweenModuleUI Get()
+ {
+ if (m_instance == null)
+ m_instance = new TweenModuleUI();
+ return m_instance;
+ }
+
+ private TweenModuleGUIStyles styles
+ {
+ get
+ {
+ return TweenModuleGUIStyles.Get();
+ }
+ }
+
+ private readonly GUIStyle s_ControlRectStyle = new GUIStyle
+ {
+ margin = new RectOffset(0, 0, 2, 2)
+ };
+
+ private float labelWidth
+ {
+ get
+ {
+ return EditorGUIUtility.labelWidth;
+ }
+ }
+
+ #region Editor internals
+ MethodInfo EditorGUI_DoFloatField; // EditorGUI.DoFloatField internal float DoFloatField(EditorGUI.RecycledTextEditor editor, Rect position, Rect dragHotZone, int id, float value, string formatString, GUIStyle style, bool draggable)
+ FieldInfo EditorGUI_RecycledEditor; // EditorGUI.s_RecycleEditor
+
+ int EditorGUI_FloatFieldHash = "EditorTextField".GetHashCode();
+
+ #endregion
+
+ TweenModuleUI()
+ {
+ Type editorGUIType = typeof(EditorGUI);
+ Type recycledTextEditorType = Assembly.GetAssembly(editorGUIType).GetType("UnityEditor.EditorGUI+RecycledTextEditor");
+
+ // DoFloatField
+ {
+ Type[] argumentTypes = new Type[] { recycledTextEditorType, typeof(Rect), typeof(Rect), typeof(int), typeof(float), typeof(string), typeof(GUIStyle), typeof(bool) };
+ EditorGUI_DoFloatField = editorGUIType.GetMethod("DoFloatField", BindingFlags.NonPublic | BindingFlags.Static, null, argumentTypes, null);
+ EditorGUI_RecycledEditor = editorGUIType.GetField("s_RecycledEditor", BindingFlags.NonPublic | BindingFlags.Static);
+ }
+ }
+
+ private object Invoke(MethodInfo method, object caller, params object[] param)
+ {
+ return method.Invoke(caller, param);
+ }
+
+ public Rect GetControlRect(int height)
+ {
+ return GetControlRect(height, null);
+ }
+
+ public float GUIFloat(string guiContent, float floatValue, string formatString = null, params GUILayoutOption[] layoutOptions)
+ {
+ return GUIFloat(new GUIContent(guiContent), floatValue, formatString, layoutOptions);
+ }
+
+ public float GUIFloat(GUIContent guiContent, float floatValue, string formatString, params GUILayoutOption[] layoutOptions)
+ {
+ Rect controlRect = GetControlRect(13, layoutOptions);
+ PrefixLabel(controlRect, guiContent);
+ return FloatDraggable(controlRect, floatValue, 1f, EditorGUIUtility.labelWidth, formatString);
+ }
+
+ public float FloatDraggable(Rect rect, float floatValue, float remap, float dragWidth, string formatString)
+ {
+ int controlID = GUIUtility.GetControlID(EditorGUI_FloatFieldHash, FocusType.Keyboard, rect);
+ Rect dragHotZone = rect;
+ dragHotZone.width = dragWidth;
+ Rect position = rect;
+ position.xMin += dragWidth;
+ float v = (float)Invoke(EditorGUI_DoFloatField, null, EditorGUI_RecycledEditor.GetValue(null), position, dragHotZone, controlID, floatValue * remap, formatString, styles.floatfiled, true);
+ return v / remap;
+ }
+
+ public string GUIText(string label, string content, params GUILayoutOption[] layoutOptions)
+ {
+ return GUIText(new GUIContent(label), content, layoutOptions);
+ }
+
+ public string GUIText(GUIContent guiContent, string content, params GUILayoutOption[] layoutOptions)
+ {
+ Rect controlRect = GetControlRect(13, layoutOptions);
+ PrefixLabel(controlRect, guiContent);
+ Rect position = controlRect;
+ position.xMin += EditorGUIUtility.labelWidth;
+ content = GUI.TextField(position, content);
+ return content;
+ }
+
+ public Enum GUIEnumMask(string label, Enum enumValue, params GUILayoutOption[] layoutOptions)
+ {
+ return GUIEnumMask(new GUIContent(label), enumValue, layoutOptions);
+ }
+
+ public Enum GUIEnumMask(GUIContent label, Enum enumValue, params GUILayoutOption[] layoutOptions)
+ {
+ Rect rect = GetControlRect(13, layoutOptions);
+ rect = PrefixLabel(rect, label);
+ return EditorGUI.EnumFlagsField(rect, enumValue, styles.popup);
+ }
+
+ public Enum GUIEnum(string label, Enum enumValue, params GUILayoutOption[] layoutOptions)
+ {
+ return GUIEnum(new GUIContent(label), enumValue, layoutOptions);
+ }
+
+ public Enum GUIEnum(GUIContent label, Enum enumValue, params GUILayoutOption[] layoutOptions)
+ {
+ Rect rect = GetControlRect(13, layoutOptions);
+ rect = PrefixLabel(rect, label);
+ return EditorGUI.EnumPopup(rect, enumValue, styles.popup);
+ }
+
+ private Rect PrefixLabel(Rect totalPosition, GUIContent label)
+ {
+ bool flag = !EditorGUI_LabelHasContent(label);
+ Rect result;
+ if (flag)
+ {
+ result = EditorGUI.IndentedRect(totalPosition);
+ }
+ else
+ {
+ Rect labelPosition;
+ Rect rect = FieldPosition(totalPosition, out labelPosition);
+ EditorGUI.HandlePrefixLabel(totalPosition, labelPosition, label, 0, styles.label);
+ result = rect;
+ }
+ return result;
+ }
+
+ private Rect FieldPosition(Rect totalPosition, out Rect labelPosition)
+ {
+ labelPosition = new Rect(totalPosition.x + EditorGUI_indent, totalPosition.y, EditorGUIUtility.labelWidth - EditorGUI_indent, 13f);
+ return new Rect(totalPosition.x + EditorGUIUtility.labelWidth, totalPosition.y, totalPosition.width - EditorGUIUtility.labelWidth, totalPosition.height);
+ }
+
+ private Rect GetControlRect(int height, params GUILayoutOption[] layoutOptions)
+ {
+ return GUILayoutUtility.GetRect(0f, (float)height, s_ControlRectStyle, layoutOptions);
+ }
+
+ private bool EditorGUI_LabelHasContent(GUIContent label)
+ {
+ bool flag = label == null;
+ return flag || label.text != string.Empty || label.image != null;
+ }
+
+ // EditorGUI.indent
+ private float EditorGUI_indent
+ {
+ get
+ {
+ return (float)EditorGUI.indentLevel * 15f;
+ }
+ }
+
+ public Rect GetLastControlRect()
+ {
+ return GUILayoutUtility.GetLastRect();
+ }
- return floatValue;
}
}
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/ITweenEventHandler.cs b/Assets/UI_Extension/Scripts/Animation/Tween/ITweenEventHandler.cs new file mode 100644 index 0000000..4b53b97 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/ITweenEventHandler.cs @@ -0,0 +1,11 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace TweenAnimation
+{
+ public interface ITweenEventHandler
+ {
+ void OnTweenEvent(string eventName);
+ }
+}
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/ITweenEventHandler.cs.meta b/Assets/UI_Extension/Scripts/Animation/Tween/ITweenEventHandler.cs.meta new file mode 100644 index 0000000..a057370 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/ITweenEventHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 583c6eb4390032f418a9437d8657d4fb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/Background.png b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/Background.png Binary files differnew file mode 100644 index 0000000..b8439e2 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/Background.png diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/Background.png.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/Background.png.meta new file mode 100644 index 0000000..6a6f56d --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/Background.png.meta @@ -0,0 +1,106 @@ +fileFormatVersion: 2 +guid: 1e452e857f86e054982c0c6c4e7d0fda +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 11, y: 15, z: 15, w: 10} + spriteGenerateFallbackPhysicsShape: 0 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: iPhone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundActive.png b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundActive.png Binary files differnew file mode 100644 index 0000000..e507c4f --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundActive.png diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundActive.png.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundActive.png.meta new file mode 100644 index 0000000..3dd5113 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundActive.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: 4afd355451ab4364983b2a2fc72fe816 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWire.png b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWire.png Binary files differnew file mode 100644 index 0000000..7690bbb --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWire.png diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWire.png.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWire.png.meta new file mode 100644 index 0000000..98171e6 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWire.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: eb02d995e32849f4997eed34d4054c21 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWireSmall.png b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWireSmall.png Binary files differnew file mode 100644 index 0000000..df62ea4 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWireSmall.png diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWireSmall.png.meta b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWireSmall.png.meta new file mode 100644 index 0000000..cd505e9 --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Icons/BackgroundWireSmall.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: 67d9e5e7c03d8bb4c914afa5a3103265 +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenAlpha.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenAlpha.cs index 4576673..231ee76 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/TweenAlpha.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenAlpha.cs @@ -6,15 +6,9 @@ namespace TweenAnimation {
public class TweenAlpha : TweenModule
{
-
-
#if UNITY_EDITOR
public override string name { get { return "Alpha"; } }
- public override void OnGUI()
- {
-
- }
#endif
}
}
\ No newline at end of file diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenAnimation.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenAnimation.cs index 93b5b17..8494bef 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/TweenAnimation.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenAnimation.cs @@ -6,14 +6,57 @@ using UnityEngine.Events; namespace TweenAnimation
{
- [DisallowMultipleComponent]
public class TweenAnimation : MonoBehaviour
{
+ public enum EventTriggeredDirection
+ {
+ None = 0,
+ Forward = 1,
+ Backward = 2,
+ }
+ public enum PlaybackStyle
+ {
+ Once,
+ Loop,
+ PingPong,
+ }
+
+ public string description = "No Description";
public List<TweenModule> modules;
- public UnityEvent onPlayEnd;
+ public float duration;
+
+ public PlaybackStyle playbackStyle;
+
+ public EventTriggeredDirection eventTriggeredDirection;
+
+ // 回放次数,0是不限制,默认是0
+ public int playbackLimit;
+
+ public TweenAnimation()
+ {
+ this.playbackStyle = PlaybackStyle.Loop;
+ this.playbackLimit = 0;
+ this.duration = 1;
+ this.modules = new List<TweenModule>();
+ }
+
+ public void AddModule(TweenModule module)
+ {
+ if (modules == null)
+ modules = new List<TweenModule>();
+ modules.Add(module);
+ }
+
+ public void RemoveModule(TweenModule module)
+ {
+ if (modules == null)
+ return;
+ if (modules.Contains(module))
+ modules.Remove(module);
+ }
}
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenColor.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenColor.cs index 7f0c541..e85d077 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/TweenColor.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenColor.cs @@ -6,19 +6,16 @@ namespace TweenAnimation public class TweenColor : TweenModule
{
+#if UNITY_EDITOR
public override string name
{
get
{
- throw new System.NotImplementedException();
+ return "Tint Color";
}
}
-#if UNITY_EDITOR
- public override void OnGUI()
- {
- throw new System.NotImplementedException();
- }
#endif
+
}
}
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs index 3d4968a..ca8a425 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenModule.cs @@ -8,19 +8,23 @@ namespace TweenAnimation [Serializable]
public abstract class TweenModule
{
- public string description;
-
- public bool enabled;
+ public bool enabled = true;
#if UNITY_EDITOR
public abstract string name { get; }
+ public string description;
+
public virtual string tooltip { get { return "Tween Module " + name; } }
- public virtual void OnGUI()
+ [NonSerialized]
+ public bool unfold;
+#endif
+
+ // 根据当前时间更新值
+ public virtual void Update(float time)
{
}
-#endif
}
}
\ No newline at end of file diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/TweenRectSize.cs b/Assets/UI_Extension/Scripts/Animation/Tween/TweenRectSize.cs index 96f39b4..ae8f603 100644 --- a/Assets/UI_Extension/Scripts/Animation/Tween/TweenRectSize.cs +++ b/Assets/UI_Extension/Scripts/Animation/Tween/TweenRectSize.cs @@ -4,19 +4,15 @@ using UnityEngine; namespace TweenAnimation
{
- public class TweenRectSize : MonoBehaviour
+ public class TweenRectSize : TweenModule
{
-
- // Use this for initialization
- void Start()
+ public override string name
{
-
+ get
+ {
+ return "RectTransform Size";
+ }
}
- // Update is called once per frame
- void Update()
- {
-
- }
}
}
\ No newline at end of file |