From ab19e54405f23499b794b67aed389a7a4b644c22 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 9 Aug 2021 15:05:07 +0800 Subject: *mics --- Assets/ActionTool/Editor/ActionPreviewEditor.cs | 71 +++++++++++++++++++++---- 1 file changed, 62 insertions(+), 9 deletions(-) (limited to 'Assets/ActionTool/Editor/ActionPreviewEditor.cs') diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index 9c5fac92..938ffd39 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -47,6 +47,12 @@ namespace ActionTool const float kFrameHeight = 20; float m_GridY = 0; + float m_ToolbarOffset = 0; // <= 0 + bool m_ShowLeftButton; + bool m_ShowRightButton; + Rect m_LeftRegion; + Rect m_RightRegion; + bool m_IsLeftOrRightButtonClicked; ActionEditorStyles styles; ActionEditorUI ui; @@ -67,6 +73,8 @@ namespace ActionTool m_UITextureNewThrowBox = (Texture)Resources.Load("throwbox"); m_UITextureNewBlockBox = (Texture)Resources.Load("blockbox"); m_UITextureNewDefendBox = (Texture)Resources.Load("defendbox"); + + m_IsLeftOrRightButtonClicked = false; } void Update() @@ -114,7 +122,14 @@ namespace ActionTool void GUI_Toolbar() { - float x = 0, y = kToolbarControlMargin; + Event e = Event.current; + + float x = m_ToolbarOffset, y = kToolbarControlMargin; + m_IsLeftOrRightButtonClicked = (e.isMouse && ((m_ShowLeftButton && m_LeftRegion.Contains(e.mousePosition)) || + (m_ShowRightButton && m_RightRegion.Contains(e.mousePosition)))); + + GUI.enabled = !m_IsLeftOrRightButtonClicked; + GUI_Toolbar_BG(); GUI_Toolbar_Start(ref x, ref y); GUI_Toolbar_Previous(ref x, ref y); @@ -126,7 +141,7 @@ namespace ActionTool GUI_DrawSeperateLine(x + 10 + kToolbarControlMargin, 0, kToolbarHeight); x += 20; - GUI.enabled = ActionManager.animationData != null; + GUI.enabled = !m_IsLeftOrRightButtonClicked && ActionManager.animationData != null; GUI_Toolbar_NewHurtBox(ref x, ref y); GUI_Toolbar_NewHitBox(ref x, ref y); GUI_Toolbar_NewThrowBox(ref x, ref y); @@ -134,18 +149,21 @@ namespace ActionTool GUI_Toolbar_NewDefendBox(ref x, ref y); //GUI_Toolbar_Detail(ref x, ref y); //GUI_Toolbar_Delete(ref x, ref y); - GUI.enabled = true; + GUI.enabled = !m_IsLeftOrRightButtonClicked; GUI_DrawSeperateLine(x + 10 + kToolbarControlMargin, 0, kToolbarHeight); x += 20; - GUI.enabled = ActionManager.animationData == null; + GUI.enabled = !m_IsLeftOrRightButtonClicked && ActionManager.animationData == null; GUI_Toolbar_NewAnimationData(ref x, ref y); - GUI.enabled = true; + GUI.enabled = !m_IsLeftOrRightButtonClicked; - GUI.enabled = ActionManager.animationData != null; + GUI.enabled = !m_IsLeftOrRightButtonClicked && ActionManager.animationData != null; GUI_Toolbar_Save(ref x, ref y); + GUI.enabled = !m_IsLeftOrRightButtonClicked; + GUI.enabled = true; + GUI_Toolbar_Expand(x); } void GUI_Toolbar_BG() @@ -684,7 +702,7 @@ namespace ActionTool { x += kToolbarControlMargin + 20; Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); - GUI.enabled = ActionManager.colliderData != null; + GUI.enabled = !m_IsLeftOrRightButtonClicked && ActionManager.colliderData != null; if (GUI.Button(rect, new GUIContent(styles.infoIcon, "Detail"))) { ActionManager.EditCollider(); @@ -697,7 +715,7 @@ namespace ActionTool { x += kToolbarControlMargin; Rect rect = new Rect(x, y, kToolbarControlSize, kToolbarControlSize); - GUI.enabled = ActionManager.colliderData != null; + GUI.enabled = !m_IsLeftOrRightButtonClicked && ActionManager.colliderData != null; if (GUI.Button(rect, new GUIContent(styles.deleteIcon, "Delete this collider"))) { ActionManager.DeleteCurBox(); @@ -730,7 +748,42 @@ namespace ActionTool x += kToolbarControlSize; } - void GUI_Events() + void GUI_Toolbar_Expand(float x) + { + x += 5; + float width = position.width; + if (width >= x - m_ToolbarOffset) + { + m_ShowLeftButton = m_ShowRightButton = false; + return; + } + float btnWidth = 20; + Rect leftRect = new Rect(-2, kToolbarControlMargin - 6, btnWidth, kToolbarControlSize + 11); + Rect rightRect = new Rect(position.width - 18, kToolbarControlMargin - 6, btnWidth, kToolbarControlSize + 11); + m_LeftRegion = leftRect; + m_RightRegion = rightRect; + Color col = GUI.backgroundColor; + GUI.backgroundColor = Color.gray; + if (x > width) + { + m_ShowRightButton = true; + if (GUI.Button(rightRect, "►", EditorStyles.miniButtonLeft)) + { + m_ToolbarOffset -= Mathf.Min(kToolbarControlSize, x - width); + } + } + if(m_ToolbarOffset < 0) + { + m_ShowLeftButton = true; + if (GUI.Button(leftRect, "◄", EditorStyles.miniButtonRight)) + { + m_ToolbarOffset += Mathf.Min(kToolbarControlSize, -m_ToolbarOffset); + } + } + GUI.backgroundColor = col; + } + + void GUI_Events() { DrawAllEvents(); GenericMenu_Event(); -- cgit v1.1-26-g67d0