From a13f10139d33264fc9ebc5a15c75faf16fc7757e Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Jul 2021 18:47:37 +0800 Subject: +Action Tool --- Assets/ActionTool/Editor/ActionPreviewEditor.cs | 166 ++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 Assets/ActionTool/Editor/ActionPreviewEditor.cs (limited to 'Assets/ActionTool/Editor/ActionPreviewEditor.cs') diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs new file mode 100644 index 00000000..9b557128 --- /dev/null +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -0,0 +1,166 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace ActionTool +{ + + public class ActionPreviewEditor : EditorWindow + { + private Texture m_UITextureStop; + private Texture m_UITexturePause; + private Texture m_UITexturePlay; + private Texture m_UITextureNext; + private Texture m_UITextureEnd; + private Texture m_UITexturePrevious; + private Texture m_UITextureStart; + + private GUIStyle m_StyleBold; + + private const float kToolbarControlMargin = 5; + private const float kToolbarHeight = 50; + private const float kToolbarControlSize = kToolbarHeight - kToolbarControlMargin * 2; + + private ActionEditorStyles styles; + private ActionEditorUI ui; + + private void OnEnable() + { + titleContent = new GUIContent("Action Preview"); + + m_UITextureStop = (Texture)Resources.Load("button_control_stop"); + m_UITexturePause = (Texture)Resources.Load("button_control_pause"); + m_UITexturePlay = (Texture)Resources.Load("button_control_play"); + m_UITextureNext = (Texture)Resources.Load("button_control_next"); + m_UITextureEnd = (Texture)Resources.Load("button_control_end"); + m_UITexturePrevious = (Texture)Resources.Load("button_control_previous"); + m_UITextureStart = (Texture)Resources.Load("button_control_start"); + + styles = ActionEditorStyles.Get(); + } + + private void OnDisable() + { + ActionManager.PreviewWindow = null; + } + + private void OnGUI() + { + if (ActionManager.CurrentAnimationName == null || ActionManager.CurrentAnimationName == "") + { + EditorGUILayout.HelpBox("选择动画", MessageType.Warning); + return; + } + + if (styles == null) styles = ActionEditorStyles.Get(); + if (ui == null) ui = ActionEditorUI.Get(); + + GUI_Toolbar(); + GUI_Detail(); + } + + void GUI_Toolbar() + { + float x = 0, y = kToolbarControlMargin; + GUI_Toolbar_BG(); + GUI_Toolbar_Start(ref x, ref y); + GUI_Toolbar_Previous(ref x, ref y); + GUI_Toolbar_Stop(ref x, ref y); + GUI_Toolbar_Pause(ref x, ref y); + GUI_Toolbar_Next(ref x, ref y); + GUI_Toolbar_End(ref x, ref y); + } + + void GUI_Toolbar_BG() + { + GUI.DrawTexture(new Rect(0, 0, position.width, 50), EditorStyles.toolbar.normal.background); + } + + void GUI_Toolbar_Start(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + if(GUI.Button(rect, m_UITextureStart)) + { + + } + x += kToolbarControlSize; + } + + void GUI_Toolbar_Previous(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + if (GUI.Button(rect, m_UITexturePrevious)) + { + + } + x += kToolbarControlSize; + } + + void GUI_Toolbar_Stop(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + if (GUI.Button(rect, m_UITextureStop)) + { + + } + x += kToolbarControlSize; + } + + void GUI_Toolbar_Pause(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + Texture tex = ActionManager.IsPlay ? m_UITexturePlay : m_UITexturePause; + if (GUI.Button(rect, tex)) + { + ActionManager.Pause(); + } + x += kToolbarControlSize; + } + + void GUI_Toolbar_Next(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + if (GUI.Button(rect, m_UITextureNext)) + { + + } + x += kToolbarControlSize; + } + + void GUI_Toolbar_End(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + if (GUI.Button(rect, m_UITextureEnd)) + { + + } + x += kToolbarControlSize; + } + + void GUI_Detail() + { + float y = kToolbarHeight + 5; + float x = 5; + + GUI.Label(new Rect(x, y, 105, 20), "Animation Name:"); + x += 105; + GUI.Label(new Rect(x, y, 210, 20), ActionManager.CurrentAnimationName, styles.textBold); + x += 200; + + } + + void Update() + { + ActionManager.UpdateFrame(); + } + + } + +} \ No newline at end of file -- cgit v1.1-26-g67d0