From 404297b51c1c71e6bb428aa199743b7fbf8db493 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 12 Jul 2021 10:12:53 +0800 Subject: *misc --- Assets/ActionTool/Editor/ActionColliderEditor.cs | 6 +- Assets/ActionTool/Editor/ActionEditorStyles.cs | 9 ++- Assets/ActionTool/Editor/ActionEditorUI.cs | 71 +++++++++++++----------- Assets/ActionTool/Editor/ActionManager.cs | 3 +- Assets/ActionTool/Editor/ActionPreviewEditor.cs | 65 ++++++---------------- 5 files changed, 65 insertions(+), 89 deletions(-) (limited to 'Assets/ActionTool') diff --git a/Assets/ActionTool/Editor/ActionColliderEditor.cs b/Assets/ActionTool/Editor/ActionColliderEditor.cs index 0c312806..d75fd8fc 100644 --- a/Assets/ActionTool/Editor/ActionColliderEditor.cs +++ b/Assets/ActionTool/Editor/ActionColliderEditor.cs @@ -62,13 +62,13 @@ namespace ActionTool GUILayout.Space(10); - Color prevColor = GUI.color; - GUI.color = Color.red; + Color prevColor = GUI.backgroundColor; + GUI.backgroundColor = Color.red; if (GUILayout.Button("Delete")) { ActionManager.DeleteCurFrame(); } - GUI.color = prevColor; + GUI.backgroundColor = prevColor; if (GUI.changed) { diff --git a/Assets/ActionTool/Editor/ActionEditorStyles.cs b/Assets/ActionTool/Editor/ActionEditorStyles.cs index fd940b33..dc68da8d 100644 --- a/Assets/ActionTool/Editor/ActionEditorStyles.cs +++ b/Assets/ActionTool/Editor/ActionEditorStyles.cs @@ -14,6 +14,7 @@ namespace ActionTool public GUIStyle keyFrameButton; Texture2D m_SelectIcon; + Texture2D m_KeyFrameIcon; private static ActionEditorStyles s_instance; public static ActionEditorStyles Get() @@ -31,7 +32,9 @@ namespace ActionTool m_SelectIcon = (Texture2D)Resources.Load("select_white"); m_SelectIcon.filterMode = FilterMode.Point; - InitStyle(out textBold, GUI.skin.label, s => { + m_KeyFrameIcon = EditorGUIUtility.FindTexture("animationkeyframe"); + + InitStyle(out textBold, GUI.skin.label, s => { s.fontStyle = FontStyle.Bold; }); InitStyle(out selectObj, GUI.skin.button, s => { @@ -46,11 +49,11 @@ namespace ActionTool }); InitStyle(out boxToggle, EditorStyles.miniButtonLeft, s => { s.fontSize = 8; - s.normal.textColor = Color.white; + s.normal.textColor = Color.white; s.onNormal.textColor = Color.white; s.active.textColor = Color.white; s.onActive.textColor = Color.white; - }); + }); InitStyle(out keyFrameButton, GUI.skin.button, s => { s.fontSize = 8; }); diff --git a/Assets/ActionTool/Editor/ActionEditorUI.cs b/Assets/ActionTool/Editor/ActionEditorUI.cs index f04c10ea..91ff9cad 100644 --- a/Assets/ActionTool/Editor/ActionEditorUI.cs +++ b/Assets/ActionTool/Editor/ActionEditorUI.cs @@ -31,41 +31,46 @@ namespace ActionTool public void DrawVerticalLineFast(float x, float minY, float maxY, Color color) { - bool bWin = Application.platform == RuntimePlatform.WindowsEditor; - if (bWin) - { - GL.Color(color); - GL.Vertex(new Vector3(x - 0.5f, minY, 0f)); - GL.Vertex(new Vector3(x + 0.5f, minY, 0f)); - GL.Vertex(new Vector3(x + 0.5f, maxY, 0f)); - GL.Vertex(new Vector3(x - 0.5f, maxY, 0f)); - } - else - { - GL.Color(color); - GL.Vertex(new Vector3(x, minY, 0f)); - GL.Vertex(new Vector3(x, maxY, 0f)); - } - } + // GL画线在GenericMenu弹出来时会有问题 + //bool bWin = Application.platform == RuntimePlatform.WindowsEditor; + //if (bWin) + //{ + // GL.Color(color); + // GL.Vertex(new Vector3(x - 0.5f, minY, 0f)); + // GL.Vertex(new Vector3(x + 0.5f, minY, 0f)); + // GL.Vertex(new Vector3(x + 0.5f, maxY, 0f)); + // GL.Vertex(new Vector3(x - 0.5f, maxY, 0f)); + //} + //else + //{ + // GL.Color(color); + // GL.Vertex(new Vector3(x, minY, 0f)); + // GL.Vertex(new Vector3(x, maxY, 0f)); + //} + Rect rect = new Rect(x-0.5f, minY, 1, maxY - minY); + EditorGUI.DrawRect(rect, color); + } - public void DrawHorizontalLineFast(float y, float minX, float maxX, Color color) + public void DrawHorizontalLineFast(float y, float minX, float maxX, Color color) { - bool bWin = Application.platform == RuntimePlatform.WindowsEditor; - if (bWin) - { - GL.Color(color); - GL.Vertex(new Vector3(minX, y - 0.5f, 0f)); - GL.Vertex(new Vector3(minX, y + 0.5f, 0f)); - GL.Vertex(new Vector3(maxX, y + 0.5f, 0f)); - GL.Vertex(new Vector3(maxX, y - 0.5f, 0f)); - } - else - { - GL.Color(color); - GL.Vertex(new Vector3(minX, y, 0f)); - GL.Vertex(new Vector3(maxX, y, 0f)); - } - } + //bool bWin = Application.platform == RuntimePlatform.WindowsEditor; + //if (bWin) + //{ + // GL.Color(color); + // GL.Vertex(new Vector3(minX, y - 0.5f, 0f)); + // GL.Vertex(new Vector3(minX, y + 0.5f, 0f)); + // GL.Vertex(new Vector3(maxX, y + 0.5f, 0f)); + // GL.Vertex(new Vector3(maxX, y - 0.5f, 0f)); + //} + //else + //{ + // GL.Color(color); + // GL.Vertex(new Vector3(minX, y, 0f)); + // GL.Vertex(new Vector3(maxX, y, 0f)); + //} + Rect rect = new Rect(minX, y - 0.5f, maxX - minX, 1); + EditorGUI.DrawRect(rect, color); + } public void SelectObject(Object obj) { diff --git a/Assets/ActionTool/Editor/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs index 89e04c80..396e0342 100644 --- a/Assets/ActionTool/Editor/ActionManager.cs +++ b/Assets/ActionTool/Editor/ActionManager.cs @@ -328,7 +328,8 @@ namespace ActionTool var data = frame.collider; if(data != null) { - data.AddFrame(frameIndex); + var frameData = data.AddFrame(frameIndex); + OnSelectColliderFrame(frameData); } } diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index 8e620d54..8c9d8f05 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -234,7 +234,7 @@ namespace ActionTool void GUI_Slider( ref float y) { ActionData action = ActionManager.actionData; - Rect rect = new Rect(kTimeLineViewXOffset - 4, y, action.totalFrame * kFrameWidth + 8, 15); + Rect rect = new Rect(kTimeLineViewXOffset - 4, y, action.totalFrame * kFrameWidth + 7, 15); float t = GUI.HorizontalSlider(rect,action.curAnimTimeNormal, 0, 1); if(t != action.curAnimTimeNormal) { @@ -261,14 +261,6 @@ namespace ActionTool Rect bgRect = new Rect(kTimeLineViewXOffset, y, action.totalFrame * kFrameWidth, ActionManager.eventAndBoxCount * kFrameHeight); GUI.Box(bgRect, ""); - ui.defaultUIMaterail.SetPass(0); - GL.PushMatrix(); - GL.LoadPixelMatrix(); - bool bWin = Application.platform == RuntimePlatform.WindowsEditor; - if (bWin) - GL.Begin(GL.QUADS); - else - GL.Begin(GL.LINES); Color lineColor = new Color(0.3f, 0.3f, 0.3f); Color lineColor2 = new Color(0.5f, 0.5f, 0.5f); for (int i = 0; i < ActionManager.eventAndBoxCount + 1; i++) @@ -282,8 +274,6 @@ namespace ActionTool x = Mathf.Clamp(x, kTimeLineViewXOffset, kTimeLineViewXOffset + action.totalFrame * kFrameWidth); ui.DrawVerticalLineFast(x, y, y + ActionManager.eventAndBoxCount * kFrameHeight, c); } - GL.PopMatrix(); - GL.End(); y += ActionManager.eventAndBoxCount * kFrameHeight; } @@ -294,18 +284,8 @@ namespace ActionTool ActionData action = ActionManager.actionData; Rect bgRect = new Rect(kTimeLineViewXOffset, y, action.totalFrame * kFrameWidth, ActionManager.eventAndBoxCount * kFrameHeight); ui.defaultUIMaterail.SetPass(0); - GL.PushMatrix(); - GL.LoadPixelMatrix(); - bool bWin = Application.platform == RuntimePlatform.WindowsEditor; - if (bWin) - GL.Begin(GL.QUADS); - else - GL.Begin(GL.LINES); ui.DrawVerticalLineFast(kTimeLineViewXOffset + bgRect.width * action.curAnimTimeNormal, y, y + ActionManager.eventAndBoxCount * kFrameHeight, Color.red); - - GL.PopMatrix(); - GL.End(); } void GUI_Events() @@ -353,20 +333,10 @@ namespace ActionTool { ActionManager.OnSelectBox(box); - ui.defaultUIMaterail.SetPass(0); - GL.PushMatrix(); - GL.LoadPixelMatrix(); - bool bWin = Application.platform == RuntimePlatform.WindowsEditor; - if (bWin) - GL.Begin(GL.QUADS); - else - GL.Begin(GL.LINES); - float length = action.totalFrame * kFrameWidth; - ui.DrawHorizontalLineFast(y, kTimeLineViewXOffset, kTimeLineViewXOffset + length, c * 0.7f); - ui.DrawHorizontalLineFast(y + kFrameHeight, kTimeLineViewXOffset, kTimeLineViewXOffset + length, c * 0.7f); - ui.DrawVerticalLineFast(kTimeLineViewXOffset + length + 1, y, y + kFrameHeight, c * 0.7f); - GL.PopMatrix(); - GL.End(); + //float length = action.totalFrame * kFrameWidth; + //ui.DrawHorizontalLineFast(y, kTimeLineViewXOffset, kTimeLineViewXOffset + length, c * 0.7f); + //ui.DrawHorizontalLineFast(y + kFrameHeight, kTimeLineViewXOffset, kTimeLineViewXOffset + length, c * 0.7f); + //ui.DrawVerticalLineFast(kTimeLineViewXOffset + length + 1, y, y + kFrameHeight, c * 0.7f); } else if(selected && !select) { @@ -397,9 +367,16 @@ namespace ActionTool { float length = (frameIndex - prevIndex - 1) * kFrameWidth; Rect region = new Rect(kTimeLineViewXOffset + (prevIndex + 1) * kFrameWidth, y, length, kFrameHeight); - EditorGUI.DrawRect(region, c * 0.4f); - } - if (frame.active) + float animFrame = action.curAnimFrame; + Color col = c * 0.4f; + //if (ActionManager.IsPlay) + //{ + bool highlight = action.curAnimFrame >= prevIndex && action.curAnimFrame < frameIndex; + col = highlight ? c * 0.6f : c * 0.4f; + //} + EditorGUI.DrawRect(region, col); + } + if (frame.active) prevIndex = frameIndex; else prevIndex = -1; @@ -409,7 +386,6 @@ namespace ActionTool GUI.color = prevColor; } - GenericMenu _newFrameMenu; void DrawBoxFrameMenuItem() { Event e = Event.current; @@ -434,7 +410,7 @@ namespace ActionTool param.frame = frame; if(ActionManager.colliderData != box) ActionManager.OnSelectBox(box); - _newFrameMenu = new GenericMenu(); + GenericMenu _newFrameMenu = new GenericMenu(); _newFrameMenu.AddItem(new GUIContent("New Frame"), false, ActionManager.AddNewBoxFrame, param); _newFrameMenu.AddItem(new GUIContent("Delete"), false, ActionManager.DeleteBoxFrame, param); _newFrameMenu.ShowAsContext(); @@ -448,19 +424,10 @@ namespace ActionTool void GUI_DrawSeperateLine(float x, float y, float height) { ui.defaultUIMaterail.SetPass(0); - GL.PushMatrix(); - GL.LoadPixelMatrix(); - bool bWin = Application.platform == RuntimePlatform.WindowsEditor; - if (bWin) - GL.Begin(GL.QUADS); - else - GL.Begin(GL.LINES); Color lineColor = new Color(0.3f, 0.3f, 0.3f); Color lineColor2 = new Color(0.1f, 0.1f, 0.1f); ui.DrawVerticalLineFast(x, y, y +height, lineColor2); ui.DrawVerticalLineFast(x+1, y, y +height, lineColor); - GL.PopMatrix(); - GL.End(); } void GUI_Toolbar_NewHurtBox(ref float x, ref float y) -- cgit v1.1-26-g67d0