summaryrefslogtreecommitdiff
path: root/Assets/ActionTool
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/ActionTool')
-rw-r--r--Assets/ActionTool/ActionToolGizmos.cs48
-rw-r--r--Assets/ActionTool/Editor/ActionManager.cs1
-rw-r--r--Assets/ActionTool/Editor/ActionRootMotionEditor.cs13
3 files changed, 59 insertions, 3 deletions
diff --git a/Assets/ActionTool/ActionToolGizmos.cs b/Assets/ActionTool/ActionToolGizmos.cs
index f1d90911..58069527 100644
--- a/Assets/ActionTool/ActionToolGizmos.cs
+++ b/Assets/ActionTool/ActionToolGizmos.cs
@@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+using UnityEditor;
namespace ActionTool
{
@@ -9,13 +10,35 @@ namespace ActionTool
{
AnimationData m_AnimationData;
+ AnimationClip m_Clip;
+
+ AnimationClip clip
+ {
+ get
+ {
+ if (m_AnimationData == null)
+ return null;
+ if (m_Clip != null && m_Clip.name == m_AnimationData.animationName)
+ return m_Clip;
+ m_Clip = AssetDatabase.LoadAssetAtPath< AnimationClip>(m_AnimationData.animationPath);
+ return m_Clip;
+ }
+ }
+
float m_CurAnimFrame;
+ bool m_IsShowRootMotion;
+
public void SetAnimationData(AnimationData data)
{
m_AnimationData = data;
}
+ public void ShowRootMotionGizmos(bool show)
+ {
+ m_IsShowRootMotion = show;
+ }
+
public void SetCurAnimFrame(float frame)
{
m_CurAnimFrame = frame;
@@ -26,6 +49,8 @@ namespace ActionTool
DrawRoot();
DrawAxis();
DrawColliders();
+
+ DrawRootMotion();
}
void DrawRoot()
@@ -77,7 +102,30 @@ namespace ActionTool
}
}
}
+ }
+ void DrawRootMotion()
+ {
+ if (m_AnimationData == null)
+ return;
+ if (!m_AnimationData.overrideRootMotion)
+ return;
+ if (!m_IsShowRootMotion)
+ return;
+ if (clip == null)
+ return;
+ var rm = m_AnimationData.rootMotionOverrideData;
+ float frames = clip.length * AnimationData.FPS;
+ float step = 0.05f;
+ Vector3 prev = rm.GetPosition(0);
+ Vector3 cur = prev;
+ Gizmos.color = Color.white;
+ for (float f = step; f <= frames + step; f+= step)
+ {
+ cur = rm.GetPosition(f);
+ Gizmos.DrawLine(prev, cur);
+ prev = cur;
+ }
}
}
diff --git a/Assets/ActionTool/Editor/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs
index fd9c15d2..c6599cb7 100644
--- a/Assets/ActionTool/Editor/ActionManager.cs
+++ b/Assets/ActionTool/Editor/ActionManager.cs
@@ -198,6 +198,7 @@ namespace ActionTool
OnSelectBox(null);
if (EventEditWindow) EventEditWindow.Close();
if (ColliderFrameWindow) ColliderFrameWindow.Close();
+
}
public static bool HasSelectObj()
diff --git a/Assets/ActionTool/Editor/ActionRootMotionEditor.cs b/Assets/ActionTool/Editor/ActionRootMotionEditor.cs
index f6a97efe..020c86b6 100644
--- a/Assets/ActionTool/Editor/ActionRootMotionEditor.cs
+++ b/Assets/ActionTool/Editor/ActionRootMotionEditor.cs
@@ -38,11 +38,15 @@ namespace ActionTool
tex.Apply();
IsRecord = false;
+
+ ActionManager.gizmos.ShowRootMotionGizmos(true);
}
private void OnDisable()
{
IsRecord = false;
+
+ ActionManager.gizmos.ShowRootMotionGizmos(false);
}
private void Update()
@@ -74,7 +78,7 @@ namespace ActionTool
{
x += kToolbarControlMargin;
Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
- IsRecord = GUI.Toggle(rect, IsRecord, EditorGUIUtility.IconContent("d_Animation.Record"), GUI.skin.button);
+ IsRecord = GUI.Toggle(rect, IsRecord, EditorGUIUtility.IconContent("d_Animation.Record", "Record"), GUI.skin.button);
x += kToolbarControlSize;
}
@@ -84,17 +88,19 @@ namespace ActionTool
GUI.enabled = false;
x += kToolbarControlMargin;
Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize);
- if (GUI.Button(rect, m_UITextureTakeRecord))
+ if (GUI.Button(rect, EditorGUIUtility.IconContent("Animation.AddKeyframe", "Key Frame")))
{
Vector3 pos = ActionManager.unitInstance.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)
@@ -110,5 +116,6 @@ namespace ActionTool
GUI.enabled = true;
x += kToolbarControlSize;
}
+
}
} \ No newline at end of file