From f7f2ebc0ce06aaf7d34325258c9bfe689043de94 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 12 Jul 2021 20:07:05 +0800 Subject: *action tool --- Assets/ActionTool/Editor/ActionEditorStyles.cs | 28 +++++++++++++--------- Assets/ActionTool/Editor/ActionEditorUI.cs | 8 +++++++ Assets/ActionTool/Editor/ActionPreviewEditor.cs | 32 +++++++++++++++++++------ 3 files changed, 50 insertions(+), 18 deletions(-) (limited to 'Assets/ActionTool/Editor') diff --git a/Assets/ActionTool/Editor/ActionEditorStyles.cs b/Assets/ActionTool/Editor/ActionEditorStyles.cs index dc68da8d..2a3695b2 100644 --- a/Assets/ActionTool/Editor/ActionEditorStyles.cs +++ b/Assets/ActionTool/Editor/ActionEditorStyles.cs @@ -13,8 +13,11 @@ namespace ActionTool public GUIStyle boxToggle; public GUIStyle keyFrameButton; - Texture2D m_SelectIcon; - Texture2D m_KeyFrameIcon; + public Texture2D selectIcon; + public Texture2D keyFrameIcon; + public Texture2D addFileIcon; + public Texture2D saveFileIcon; + public Texture2D deleteIcon; private static ActionEditorStyles s_instance; public static ActionEditorStyles Get() @@ -29,20 +32,23 @@ namespace ActionTool private ActionEditorStyles() { - m_SelectIcon = (Texture2D)Resources.Load("select_white"); - m_SelectIcon.filterMode = FilterMode.Point; + selectIcon = (Texture2D)Resources.Load("select_white"); + selectIcon.filterMode = FilterMode.Point; - m_KeyFrameIcon = EditorGUIUtility.FindTexture("animationkeyframe"); + keyFrameIcon = EditorGUIUtility.FindTexture("animationkeyframe"); + addFileIcon = EditorGUIUtility.FindTexture("d_Collab.FileAdded"); + saveFileIcon = EditorGUIUtility.FindTexture("d_Collab.FileUpdated"); + deleteIcon = EditorGUIUtility.FindTexture("d_P4_DeletedLocal"); - InitStyle(out textBold, GUI.skin.label, s => { + InitStyle(out textBold, GUI.skin.label, s => { s.fontStyle = FontStyle.Bold; }); InitStyle(out selectObj, GUI.skin.button, s => { - s.normal.background = m_SelectIcon; - s.active.background = m_SelectIcon; - s.focused.background = m_SelectIcon; - s.hover.background = m_SelectIcon; - s.normal.background = m_SelectIcon; + s.normal.background = selectIcon; + s.active.background = selectIcon; + s.focused.background = selectIcon; + s.hover.background = selectIcon; + s.normal.background = selectIcon; }); InitStyle(out textSmall, GUI.skin.label, s => { s.fontSize = 8; diff --git a/Assets/ActionTool/Editor/ActionEditorUI.cs b/Assets/ActionTool/Editor/ActionEditorUI.cs index 91ff9cad..a1e2ba36 100644 --- a/Assets/ActionTool/Editor/ActionEditorUI.cs +++ b/Assets/ActionTool/Editor/ActionEditorUI.cs @@ -72,6 +72,14 @@ namespace ActionTool EditorGUI.DrawRect(rect, color); } + public void DrawRectFrame(Rect rect, Color col) + { + DrawHorizontalLineFast(rect.y, rect.x, rect.x + rect.width, col); + DrawHorizontalLineFast(rect.y + rect.height, rect.x, rect.x + rect.width, col); + DrawVerticalLineFast(rect.x, rect.y, rect.y + rect.height, col); + DrawVerticalLineFast(rect.x + rect.width, rect.y, rect.y + rect.height, col); + } + public void SelectObject(Object obj) { Selection.activeObject = obj; diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index 8c9d8f05..45048f0e 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -29,7 +29,8 @@ namespace ActionTool const float kToolbarControlMargin = 5; const float kToolbarHeight = 50; const float kToolbarControlSize = kToolbarHeight - kToolbarControlMargin * 2; - const float kTimeLineViewXOffset = 30; + const float kTimeLineViewXOffset = 20; + const float kTimeLineViewYOffset = 80; const float kFrameWidth = 10; const float kFrameHeight = 20; @@ -197,12 +198,27 @@ namespace ActionTool x += 200; } + Vector2 scrollPos = Vector2.zero; void GUI_TimeLineView() { if (ActionManager.actionData == null) return; - float y = 80; + ActionData action = ActionManager.actionData; + + float y = kTimeLineViewYOffset; + + 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; + else + height = position.height - 80; + Rect viewport = new Rect(0, y, position.width, height); + scrollPos = GUI.BeginScrollView(viewport, scrollPos, content); + + y = 0; GUI_FrameText(ref y); GUI_Slider(ref y); @@ -210,6 +226,8 @@ namespace ActionTool GUI_Events(); GUI_Boxes(); GUI_FrameLine(); + + GUI.EndScrollView(); } void GUI_FrameText(ref float y) @@ -434,7 +452,7 @@ namespace ActionTool { x += kToolbarControlMargin; Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); - if (GUI.Button(rect, new GUIContent("New", m_UITextureNewHurtBox))) + if (GUI.Button(rect, new GUIContent(" + ", m_UITextureNewHurtBox, "New hurt box"))) { ActionManager.NewHurtBox(); } @@ -445,7 +463,7 @@ namespace ActionTool { x += kToolbarControlMargin; Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); - if (GUI.Button(rect, new GUIContent("New", m_UITextureNewHitBox))) + if (GUI.Button(rect, new GUIContent(" + ", m_UITextureNewHitBox, "New hit box"))) { ActionManager.NewHitBox(); } @@ -457,7 +475,7 @@ namespace ActionTool x += kToolbarControlMargin; Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); GUI.enabled = ActionManager.colliderData != null; - if (GUI.Button(rect, "Delete")) + if (GUI.Button(rect, new GUIContent(styles.deleteIcon, "Delete this collider"))) { ActionManager.DeleteCurBox(); } @@ -469,7 +487,7 @@ namespace ActionTool { x += kToolbarControlMargin; Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); - if (GUI.Button(rect, new GUIContent("New"))) + if (GUI.Button(rect, new GUIContent(styles.addFileIcon, "Add new animation data file"))) { ActionManager.CreateAnimationData(); } @@ -480,7 +498,7 @@ namespace ActionTool { x += kToolbarControlMargin; Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); - if (GUI.Button(rect, new GUIContent("Save"))) + if (GUI.Button(rect, new GUIContent(styles.saveFileIcon, "Save"))) { ActionManager.SaveAnimationData(); } -- cgit v1.1-26-g67d0