diff options
author | chai <chaifix@163.com> | 2021-08-04 17:37:56 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-08-04 17:37:56 +0800 |
commit | aafae64318a5a08a68b7033441449c36f0f85a17 (patch) | |
tree | 9908e6fd3b6cd3156e3c105da193950031a21f6e /Assets/ActionTool/Editor | |
parent | 0081fa2bd7b2bf2c40bbae087a2b5753125de30d (diff) |
*actiontool
Diffstat (limited to 'Assets/ActionTool/Editor')
-rw-r--r-- | Assets/ActionTool/Editor/ActionData.cs | 32 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionEditorStyles.cs | 11 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionInfoEditor.cs | 47 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionInfoEditor.cs.meta | 11 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionManager.cs | 2 | ||||
-rw-r--r-- | Assets/ActionTool/Editor/ActionPreviewEditor.cs | 46 |
6 files changed, 132 insertions, 17 deletions
diff --git a/Assets/ActionTool/Editor/ActionData.cs b/Assets/ActionTool/Editor/ActionData.cs index ade27488..936bc422 100644 --- a/Assets/ActionTool/Editor/ActionData.cs +++ b/Assets/ActionTool/Editor/ActionData.cs @@ -49,6 +49,12 @@ namespace ActionTool private double m_PrevLocalTime;
private float m_PrevNormalTime;
+
+ private bool m_NotApplyCurve;
+ public bool applyCurve { get { return !m_NotApplyCurve; } set { m_NotApplyCurve = !value; } } // 是否开启curve控制速度
+ private bool m_NotApplyRM;
+ public bool applyRootMotion { get { return !m_NotApplyRM; } set { m_NotApplyRM = !value; } }
+
private const string kStateName = "Action";
private RootMotionData m_RootMotion;
@@ -138,18 +144,20 @@ namespace ActionTool {
if (ActionManager.IsPlay)
{
- float dt = (float)(EditorApplication.timeSinceStartup - m_PrevLocalTime) * (ActionManager.FPS * ActionManager.Speed);
-#if true
- float normalizeTime = m_CurAnimFrame / m_TotalFrame;
- AnimationData animData = ActionManager.animationData;
- if (animData)
- {
- AnimationCurve curve = animData.curve;
- dt *= curve.Evaluate(normalizeTime);
- }
-#endif
+ float deltaFrame = (float)(EditorApplication.timeSinceStartup - m_PrevLocalTime) * (ActionManager.FPS * ActionManager.Speed);
+
+ if (applyCurve)
+ {
+ float normalizeTime = m_CurAnimFrame / m_TotalFrame;
+ AnimationData animData = ActionManager.animationData;
+ if (animData)
+ {
+ AnimationCurve curve = animData.curve;
+ deltaFrame *= curve.Evaluate(normalizeTime);
+ }
+ }
- m_CurAnimFrame += dt;
+ m_CurAnimFrame += deltaFrame;
if (m_CurAnimFrame > m_TotalFrame)
{
@@ -182,7 +190,7 @@ namespace ActionTool m_Animator.Update(0);
m_Animator.speed = 0;
- if(m_RootMotion)
+ if(applyRootMotion && m_RootMotion)
{
#if true
m_Animator.transform.position = m_RootMotion.GetRootMotion(normalizeTime);
diff --git a/Assets/ActionTool/Editor/ActionEditorStyles.cs b/Assets/ActionTool/Editor/ActionEditorStyles.cs index 32c03dec..cc806bf7 100644 --- a/Assets/ActionTool/Editor/ActionEditorStyles.cs +++ b/Assets/ActionTool/Editor/ActionEditorStyles.cs @@ -12,9 +12,12 @@ namespace ActionTool public GUIStyle selectObj;
public GUIStyle textSmall;
public GUIStyle textMiddle;
+ public GUIStyle textMiddleBold;
public GUIStyle boxToggle;
public GUIStyle keyFrameButton;
+ public GUIStyle toggleSmallBold;
+
public Texture2D selectIcon;
public Texture2D keyFrameIcon;
public Texture2D addFileIcon;
@@ -65,6 +68,10 @@ namespace ActionTool InitStyle(out textMiddle, GUI.skin.label, s => {
s.fontSize = 10;
});
+ InitStyle(out textMiddleBold, GUI.skin.label, s => {
+ s.fontSize = 10;
+ s.fontStyle = FontStyle.Bold;
+ });
InitStyle(out boxToggle, EditorStyles.miniButtonLeft, s => {
s.fontSize = 8;
s.normal.textColor = Color.white;
@@ -82,6 +89,10 @@ namespace ActionTool s.focused.textColor = Color.yellow;
s.hover.textColor = Color.yellow;
});
+ InitStyle(out toggleSmallBold, GUI.skin.toggle, s => {
+ s.fontSize = 10;
+ //s.fontStyle = FontStyle.Bold;
+ });
}
private delegate void Initter(GUIStyle style);
diff --git a/Assets/ActionTool/Editor/ActionInfoEditor.cs b/Assets/ActionTool/Editor/ActionInfoEditor.cs new file mode 100644 index 00000000..0d4a0f4f --- /dev/null +++ b/Assets/ActionTool/Editor/ActionInfoEditor.cs @@ -0,0 +1,47 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEditor;
+
+namespace ActionTool
+{
+
+ // 编辑collider帧
+ public class ActionInfoEditor : EditorWindow
+ {
+ private static string title;
+ private static string content;
+ private static Vector2 size;
+
+ public static void ShowContent(string tlt, string cnt)
+ {
+ title = tlt;
+ content = cnt;
+ size = GUI.skin.label.CalcSize(new GUIContent(content));
+ var editor = EditorWindow.GetWindow<ActionInfoEditor>(true);
+ editor.titleContent = new GUIContent(title);
+ editor.OnEnable();
+ }
+
+ private void OnEnable()
+ {
+ titleContent = new GUIContent(title);
+ maxSize = new Vector2(50 + size.x, 10 + size.y);
+ minSize = maxSize;
+ }
+
+ private void OnDisable()
+ {
+ }
+
+ private void Update()
+ {
+ }
+
+ private void OnGUI()
+ {
+ Vector2 size= GUI.skin.label.CalcSize(new GUIContent(content));
+ GUI.Label(new Rect(5,5, size.x, size.y), content);
+ }
+ }
+}
\ No newline at end of file diff --git a/Assets/ActionTool/Editor/ActionInfoEditor.cs.meta b/Assets/ActionTool/Editor/ActionInfoEditor.cs.meta new file mode 100644 index 00000000..49da3876 --- /dev/null +++ b/Assets/ActionTool/Editor/ActionInfoEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8121c73011a3e1c4ea6beaf52d54e673 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ActionTool/Editor/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs index c2e6d291..deb7e3a1 100644 --- a/Assets/ActionTool/Editor/ActionManager.cs +++ b/Assets/ActionTool/Editor/ActionManager.cs @@ -84,6 +84,7 @@ namespace ActionTool }
}
}
+ public static AnimationClip curClip;
public static string AnimationDataPath
{
@@ -154,6 +155,7 @@ namespace ActionTool string animpath = unitAnimationClipFolder + animation + ".anim";
AnimationClip clip = AssetDatabase.LoadAssetAtPath(animpath, typeof(AnimationClip)) as AnimationClip;
+ curClip = clip;
if (clip)
{
s_OverrideContorller["EmptyAction"] = clip;
diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index 15bf8d14..a14064f2 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -103,6 +103,7 @@ namespace ActionTool float y = kToolbarHeight + 5;
GUI_Detail(ref y);
GUI_Curve(ref y);
+ GUI_Setting(ref y);
GUI_TimeLineView(ref y);
}
@@ -219,17 +220,40 @@ namespace ActionTool float xl = 5, xr = xl + 105;
GUI.Label(new Rect(xl, y, 105, 15), "Animation Name:", styles.textMiddle);
- GUI.Label(new Rect(xr, y, 210, 15), ActionManager.CurrentAnimationName, styles.textMiddle);
+ float width = styles.textMiddleBold.CalcSize(new GUIContent(ActionManager.CurrentAnimationName)).x;
+ GUI.Label(new Rect(xr, y, width, 15), ActionManager.CurrentAnimationName, styles.textMiddleBold);
+ if(GUI.Button(new Rect(xr + width + 10, y, 50, 15), "Info"))
+ {
+ ActionInfoEditor.ShowContent("Animation Info",
+ "Length: " + ActionManager.curClip.length + "s \n" +
+ "WrapMode: " + ActionManager.curClip.wrapMode + "\n" +
+ "IsLooping: " + ActionManager.curClip.isLooping + "\n" +
+ "FrameRate: " + ActionManager.curClip.frameRate
+ );
+ }
y += 15;
- GUI.Label(new Rect(xl, y, 105, 15), "ActionData File:", styles.textMiddle);
- GUI.Label(new Rect(xr, y, 510, 15), ActionManager.AnimationDataPath, styles.textMiddle);
+ GUI.Label(new Rect(xl, y, 105, 15), "AnimationData:", styles.textMiddle);
+ width = styles.textMiddleBold.CalcSize(new GUIContent(ActionManager.AnimationDataPath)).x;
+ GUI.Label(new Rect(xr, y, width, 15), ActionManager.AnimationDataPath, styles.textMiddleBold);
+ if (GUI.Button(new Rect(xr + width + 10, y, 50, 15), "Info"))
+ {
+ AnimationData animData = ActionManager.animationData;
+ ActionInfoEditor.ShowContent("AnimationData Info",
+ "Events: " + (animData.animationEvents == null ? 0 : animData.animationEvents.Count )+ "\n" +
+ "HurtBoxes: " + (animData.hurtBoxes == null ? 0 : animData.hurtBoxes.Count) + "\n" +
+ "HitBoxes: " + (animData.hitBoxes == null ? 0 : animData.hitBoxes.Count) + "\n" +
+ "ThrowBoxes: " + (animData.throwBoxes == null ? 0 : animData.throwBoxes.Count) + "\n" +
+ "BlockBoxes: " + (animData.blockBoxes == null ? 0 : animData.blockBoxes.Count) + "\n" +
+ "DefendBoxes: " + (animData.defendBoxes == null ? 0 : animData.defendBoxes.Count) + "\n"
+ );
+ }
y += 15;
GUI.Label(new Rect(xl, y, 105, 15), "Playback Frame:", styles.textMiddle);
- GUI.Label(new Rect(xr, y, 510, 15), ActionManager.actionData.curAnimFrame.ToString("f2"), styles.textMiddle);
+ GUI.Label(new Rect(xr, y, 510, 15), ActionManager.actionData.curAnimFrame.ToString("f2"), styles.textMiddleBold);
GUI.Label(new Rect(xl + 150, y, 105, 15), "Normalized Time:", styles.textMiddle);
- GUI.Label(new Rect(xr + 150, y, 510, 15), ActionManager.actionData.curAnimTimeNormal.ToString("f2"), styles.textMiddle);
+ GUI.Label(new Rect(xr + 150, y, 510, 15), ActionManager.actionData.curAnimTimeNormal.ToString("f2"), styles.textMiddleBold);
y += 15;
}
@@ -248,6 +272,18 @@ namespace ActionTool y += 20;
}
+ void GUI_Setting(ref float y)
+ {
+ ActionData action = ActionManager.actionData;
+
+ float x = 5;
+ action.applyRootMotion = GUI.Toggle(new Rect(x, y, 120, 15), action.applyRootMotion, "Apply RootMotion", styles.toggleSmallBold);
+ x += 130;
+ action.applyCurve = GUI.Toggle(new Rect(x, y, 120, 15), action.applyCurve, "Apply Curve", styles.toggleSmallBold);
+
+ y += 20;
+ }
+
Vector2 scrollPos = Vector2.zero;
void GUI_TimeLineView(ref float iy)
{
|