summaryrefslogtreecommitdiff
path: root/Assets/Tools/ActionTool/Editor/ActionRootMotionEditor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Tools/ActionTool/Editor/ActionRootMotionEditor.cs')
-rw-r--r--Assets/Tools/ActionTool/Editor/ActionRootMotionEditor.cs121
1 files changed, 0 insertions, 121 deletions
diff --git a/Assets/Tools/ActionTool/Editor/ActionRootMotionEditor.cs b/Assets/Tools/ActionTool/Editor/ActionRootMotionEditor.cs
deleted file mode 100644
index eb076fc3..00000000
--- a/Assets/Tools/ActionTool/Editor/ActionRootMotionEditor.cs
+++ /dev/null
@@ -1,121 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-using UnityEditor;
-
-namespace ActionTool
-{
- public class ActionRootMotionEditor : EditorWindow
- {
- ActionEditorStyles styles;
-
- // isrecord的时候playbackFrame是整数
- 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;
- Texture m_UITextureTrashCan;
-
- Texture2D tex;
-
- private void OnEnable()
- {
- maxSize = new Vector2(300, 90);
- minSize = maxSize;
- this.titleContent = new GUIContent("RootMotion Editor");
-
- m_UITextureRecord = (Texture)Resources.Load("button_control_record");
- m_UITextureTakeRecord = (Texture)Resources.Load("button_control_takerecord");
- m_UITextureTrashCan = EditorGUIUtility.FindTexture("d_TreeEditor.Trash");
-
- tex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
- tex.SetPixel(0, 0, new Color(1f, 0, 0) * 0.5f);
- tex.Apply();
-
- IsRecord = false;
-
- ActionManager.gizmos.ShowRootMotionGizmos(true);
- }
-
- private void OnDisable()
- {
- IsRecord = false;
-
- ActionManager.gizmos.ShowRootMotionGizmos(false);
- }
-
- private void Update()
- {
-
- }
-
- private void OnGUI()
- {
- if(ActionManager.animationData == null || ActionManager.animationData.overrideRootMotion == false)
- {
- 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);
- GUI_Delete(ref x, ref y);
- GUI.enabled = false;
- EditorGUI.Vector3Field(new Rect(0, kToolbarHeight, position.width, 20), "Position: ", ActionManager.unitRoot.transform.position);
- GUI.enabled = true;
- }
-
- void GUI_Record(ref float x, ref float y)
- {
- x += kToolbarControlMargin;
- Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
- IsRecord = GUI.Toggle(rect, IsRecord, EditorGUIUtility.IconContent("d_Animation.Record", "Record"), GUI.skin.button);
- x += kToolbarControlSize;
- }
-
- void GUI_TakeRecord(ref float x, ref float y)
- {
- if (!IsRecord)
- GUI.enabled = false;
- x += kToolbarControlMargin;
- Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
- if (GUI.Button(rect, EditorGUIUtility.IconContent("Animation.AddKeyframe", "Key Frame")))
- {
- Vector3 pos = ActionManager.unitRoot.transform.position;
- int frame = (int)ActionManager.actionData.curAnimFrame;
- ActionManager.animationData.rootMotionOverrideData.SetPosition(frame, pos);
- ActionManager.PreviewWindow.Repaint();
- EditorWindow.GetWindow<SceneView>()?.Repaint();
- SceneView.RepaintAll();
- }
- GUI.enabled = true;
- x += kToolbarControlSize;
- }
-
- void GUI_Delete(ref float x, ref float y)
- {
- if (!IsRecord)
- GUI.enabled = false;
- x += kToolbarControlMargin;
- Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
- if (GUI.Button(rect, m_UITextureTrashCan))
- {
- int frame = (int)ActionManager.actionData.curAnimFrame;
- ActionManager.animationData.rootMotionOverrideData.RemovePositionAtFrame(frame);
- ActionManager.PreviewWindow.Repaint();
- }
- GUI.enabled = true;
- x += kToolbarControlSize;
- }
-
- }
-} \ No newline at end of file