diff options
author | chai <chaifix@163.com> | 2021-07-07 18:47:37 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-07-07 18:47:37 +0800 |
commit | a13f10139d33264fc9ebc5a15c75faf16fc7757e (patch) | |
tree | 9d6c40a21fc873c6e25ff4bbdeba663a73927427 /Assets/ActionTool/Editor/ActionPreviewEditor.cs | |
parent | 1bb4971cffac3851a119f16e815bfe42abfc2df6 (diff) |
+Action Tool
Diffstat (limited to 'Assets/ActionTool/Editor/ActionPreviewEditor.cs')
-rw-r--r-- | Assets/ActionTool/Editor/ActionPreviewEditor.cs | 166 |
1 files changed, 166 insertions, 0 deletions
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 |