From 7a73788fec18aa8648a4ff7d1d86760b22908513 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 2 Sep 2021 16:50:41 +0800 Subject: *misc --- Assets/ActionTool/Editor/ActionRootMotionEditor.cs | 41 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'Assets/ActionTool/Editor/ActionRootMotionEditor.cs') diff --git a/Assets/ActionTool/Editor/ActionRootMotionEditor.cs b/Assets/ActionTool/Editor/ActionRootMotionEditor.cs index ff0dae62..5d539b52 100644 --- a/Assets/ActionTool/Editor/ActionRootMotionEditor.cs +++ b/Assets/ActionTool/Editor/ActionRootMotionEditor.cs @@ -9,6 +9,7 @@ namespace ActionTool { ActionEditorStyles styles; + // isrecord的时候playbackFrame是整数 public static bool IsRecord { get; private set; } const float kToolbarControlMargin = 5; @@ -18,25 +19,30 @@ namespace ActionTool Texture m_UITextureRecord; Texture m_UITextureTakeRecord; + Texture m_UITextureTrashCan; Texture2D tex; private void OnEnable() { - maxSize = new Vector2(300, 80); + maxSize = new Vector2(300, 100); 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.8f); + tex.SetPixel(0, 0, new Color(1f, 0, 0) * 0.5f); tex.Apply(); + + IsRecord = false; } private void OnDisable() { - + IsRecord = false; } private void Update() @@ -46,7 +52,7 @@ namespace ActionTool private void OnGUI() { - if(ActionManager.animationData == null || ActionManager.animationData.overrideRootMotion == null) + if(ActionManager.animationData == null || ActionManager.animationData.overrideRootMotion == false) { this.Close(); return; @@ -58,6 +64,10 @@ namespace ActionTool 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.unitInstance.transform.position); + GUI.enabled = true; } void GUI_Record(ref float x, ref float y) @@ -70,14 +80,35 @@ namespace ActionTool 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, m_UITextureTakeRecord)) { - + Vector3 pos = ActionManager.unitInstance.transform.position; + int frame = (int)ActionManager.actionData.curAnimFrame; + ActionManager.animationData.rootMotionOverrideData.SetPosition(frame, pos); + ActionManager.PreviewWindow.Repaint(); } + 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 -- cgit v1.1-26-g67d0