From adb364a79f5dd69de08f72072cc2261131314e53 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 2 Sep 2021 13:01:49 +0800 Subject: +override rootmotion --- Assets/ActionTool/Editor/ActionRootMotionEditor.cs | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Assets/ActionTool/Editor/ActionRootMotionEditor.cs (limited to 'Assets/ActionTool/Editor/ActionRootMotionEditor.cs') diff --git a/Assets/ActionTool/Editor/ActionRootMotionEditor.cs b/Assets/ActionTool/Editor/ActionRootMotionEditor.cs new file mode 100644 index 00000000..ff0dae62 --- /dev/null +++ b/Assets/ActionTool/Editor/ActionRootMotionEditor.cs @@ -0,0 +1,83 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace ActionTool +{ + public class ActionRootMotionEditor : EditorWindow + { + ActionEditorStyles styles; + + public static bool IsRecord { get; private set; } + + const float kToolbarControlMargin = 5; + const float kToolbarHeight = 50; + const float kToolbarControlSize = kToolbarHeight - kToolbarControlMargin * 2; + float m_ToolbarOffset = 0; // <= 0 + + Texture m_UITextureRecord; + Texture m_UITextureTakeRecord; + + Texture2D tex; + + private void OnEnable() + { + maxSize = new Vector2(300, 80); + minSize = maxSize; + this.titleContent = new GUIContent("RootMotion Editor"); + + m_UITextureRecord = (Texture)Resources.Load("button_control_record"); + m_UITextureTakeRecord = (Texture)Resources.Load("button_control_takerecord"); + tex = new Texture2D(1, 1, TextureFormat.RGBA32, false); + tex.SetPixel(0, 0, new Color(1f, 0, 0) * 0.8f); + tex.Apply(); + } + + private void OnDisable() + { + + } + + private void Update() + { + + } + + private void OnGUI() + { + if(ActionManager.animationData == null || ActionManager.animationData.overrideRootMotion == null) + { + this.Close(); + return; + } + if (IsRecord) + { + GUI.DrawTexture(new Rect(0, 0, maxSize.x, maxSize.y), tex, ScaleMode.StretchToFill); + } + float x = m_ToolbarOffset, y = kToolbarControlMargin; + GUI_Record(ref x, ref y); + GUI_TakeRecord(ref x, ref y); + } + + void GUI_Record(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + IsRecord = GUI.Toggle(rect, IsRecord, m_UITextureRecord, GUI.skin.button); + x += kToolbarControlSize; + } + + void GUI_TakeRecord(ref float x, ref float y) + { + x += kToolbarControlMargin; + Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); + if (GUI.Button(rect, m_UITextureTakeRecord)) + { + + } + x += kToolbarControlSize; + } + + } +} \ No newline at end of file -- cgit v1.1-26-g67d0