From 0081fa2bd7b2bf2c40bbae087a2b5753125de30d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 4 Aug 2021 13:17:54 +0800 Subject: =?UTF-8?q?*=E5=8A=A8=E7=94=BB=E8=9E=8D=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ActionTool/Editor/ActionEditorStyles.cs | 4 ++ Assets/ActionTool/Editor/ActionManager.cs | 8 ++++ Assets/ActionTool/Editor/ActionPreviewEditor.cs | 59 +++++++++++++++---------- 3 files changed, 48 insertions(+), 23 deletions(-) (limited to 'Assets/ActionTool') diff --git a/Assets/ActionTool/Editor/ActionEditorStyles.cs b/Assets/ActionTool/Editor/ActionEditorStyles.cs index d4bd37cd..32c03dec 100644 --- a/Assets/ActionTool/Editor/ActionEditorStyles.cs +++ b/Assets/ActionTool/Editor/ActionEditorStyles.cs @@ -11,6 +11,7 @@ namespace ActionTool public GUIStyle textBold; public GUIStyle selectObj; public GUIStyle textSmall; + public GUIStyle textMiddle; public GUIStyle boxToggle; public GUIStyle keyFrameButton; @@ -61,6 +62,9 @@ namespace ActionTool InitStyle(out textSmall, GUI.skin.label, s => { s.fontSize = 8; }); + InitStyle(out textMiddle, GUI.skin.label, s => { + s.fontSize = 10; + }); InitStyle(out boxToggle, EditorStyles.miniButtonLeft, s => { s.fontSize = 8; s.normal.textColor = Color.white; diff --git a/Assets/ActionTool/Editor/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs index b39dec61..c2e6d291 100644 --- a/Assets/ActionTool/Editor/ActionManager.cs +++ b/Assets/ActionTool/Editor/ActionManager.cs @@ -85,6 +85,14 @@ namespace ActionTool } } + public static string AnimationDataPath + { + get + { + return AssetDatabase.GetAssetPath(sharedAnimationData); + } + } + private static AnimationEventBase m_CurAnimationEvent; public static AnimationEventBase animationEvent { get { return m_CurAnimationEvent; } } diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index a45a503e..15bf8d14 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -42,7 +42,7 @@ namespace ActionTool const float kToolbarControlSize = kToolbarHeight - kToolbarControlMargin * 2; const float kCurveYOffset = 80; const float kTimeLineViewXOffset = 20; - const float kTimeLineViewYOffset = 110; + float kTimeLineViewYOffset = 110; const float kFrameWidth = 10; const float kFrameHeight = 20; @@ -99,9 +99,11 @@ namespace ActionTool if (ui == null) ui = ActionEditorUI.Get(); GUI_Toolbar(); - GUI_Detail(); - GUI_Curve(); - GUI_TimeLineView(); + + float y = kToolbarHeight + 5; + GUI_Detail(ref y); + GUI_Curve(ref y); + GUI_TimeLineView(ref y); } void GUI_Toolbar() @@ -212,48 +214,59 @@ namespace ActionTool x += kToolbarControlSize; } - void GUI_Detail() + void GUI_Detail(ref float y) { - float y = kToolbarHeight + 5; - float x = 5; + 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); + 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); + 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(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); + y += 15; - GUI.Label(new Rect(x, y, 105, 20), "Animation Name:"); - x += 105; - GUI.Label(new Rect(x, y, 210, 20), ActionManager.CurrentAnimationName, styles.textBold); - x += 200; } - void GUI_Curve() + void GUI_Curve(ref float y) { AnimationData animData = ActionManager.animationData; if (animData == null) return; - float y = kCurveYOffset; float x = 5; - GUI.Label(new Rect(x, y, 105, 20), "Speed Curve:"); + GUI.Label(new Rect(x, y, 105, 15), "Speed Curve:", styles.textMiddle); x += 105; - animData.curve = EditorGUI.CurveField(new Rect(x, y, 210, 20), animData.curve); - ui.DrawVerticalLineFast(x + 210 * ActionManager.actionData.curAnimTimeNormal, y , y + 20, Color.red); - } + animData.curve = EditorGUI.CurveField(new Rect(x, y, 210, 15), animData.curve); + ui.DrawVerticalLineFast(x + 210 * ActionManager.actionData.curAnimTimeNormal, y , y + 15, Color.red); + y += 20; + } - Vector2 scrollPos = Vector2.zero; - void GUI_TimeLineView() + Vector2 scrollPos = Vector2.zero; + void GUI_TimeLineView(ref float iy) { if (ActionManager.actionData == null) return; ActionData action = ActionManager.actionData; - float y = kTimeLineViewYOffset; + kTimeLineViewYOffset = iy; + + float y = iy; float contentHeight = ActionManager.eventAndBoxCount * kFrameHeight + 40; Rect content = new Rect(0, 0, action.totalFrame * kFrameWidth + 30, contentHeight); float height = 300; - if (position.height - 80 > contentHeight) - height = contentHeight + 15; + if (position.height - kTimeLineViewYOffset > contentHeight) + height = contentHeight; else - height = position.height - 80; + height = position.height - kTimeLineViewYOffset; Rect viewport = new Rect(0, y, position.width, height); scrollPos = GUI.BeginScrollView(viewport, scrollPos, content); -- cgit v1.1-26-g67d0