From d373067ce7982c14040274f9eab8ad9a1c50c5f1 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 10 Jul 2021 11:58:54 +0800 Subject: *misc --- Assets/ActionTool/ActionToolScene.unity | 93 +----------------------- Assets/ActionTool/Editor/ActionColliderEditor.cs | 40 +++++++--- Assets/ActionTool/Editor/ActionEditorStyles.cs | 6 +- Assets/ActionTool/Editor/ActionManager.cs | 11 +-- Assets/ActionTool/Editor/ActionPreviewEditor.cs | 33 +++++---- 5 files changed, 59 insertions(+), 124 deletions(-) (limited to 'Assets/ActionTool') diff --git a/Assets/ActionTool/ActionToolScene.unity b/Assets/ActionTool/ActionToolScene.unity index 59524151..e5572892 100644 --- a/Assets/ActionTool/ActionToolScene.unity +++ b/Assets/ActionTool/ActionToolScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -377,97 +377,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1944034771 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1944034775} - - component: {fileID: 1944034774} - - component: {fileID: 1944034773} - - component: {fileID: 1944034772} - m_Layer: 0 - m_Name: Plane - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!65 &1944034772 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1944034771} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &1944034773 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1944034771} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &1944034774 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1944034771} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &1944034775 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1944034771} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -0.04, z: 0} - m_LocalScale: {x: 1, y: 0.1, z: 500} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1974325401 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/ActionTool/Editor/ActionColliderEditor.cs b/Assets/ActionTool/Editor/ActionColliderEditor.cs index 57c060fa..0c312806 100644 --- a/Assets/ActionTool/Editor/ActionColliderEditor.cs +++ b/Assets/ActionTool/Editor/ActionColliderEditor.cs @@ -9,18 +9,29 @@ namespace ActionTool // 编辑collider帧 public class ActionColliderEditor : EditorWindow { + EditorWindow sceneView; private void OnEnable() { - titleContent = new GUIContent("Collider Editor"); - } + titleContent = new GUIContent("Collider Editor"); + maxSize = new Vector2(300, 150); + minSize = maxSize; - private void OnDisable() + if(!sceneView) + sceneView = EditorWindow.GetWindow(); + } + + private void OnDisable() { - ActionManager.OnSelectColliderFrame(null); + // sceneView = null; + ActionManager.OnSelectColliderFrame(null); } - private void OnGUI() + private void Update() + { + } + + private void OnGUI() { var frame = ActionManager.editColliderFrame; if (frame == null) @@ -29,12 +40,11 @@ namespace ActionTool return; } - Rect pos = position; - pos.width = 300; - pos.height = 150; - position = pos; + GUI.changed = false; - EditorGUILayout.BeginHorizontal(); + GUILayout.Space(5); + + EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("frame: "); EditorGUILayout.LabelField(frame.frame.ToString()); EditorGUILayout.EndHorizontal(); @@ -59,6 +69,14 @@ namespace ActionTool ActionManager.DeleteCurFrame(); } GUI.color = prevColor; + + if (GUI.changed) + { + if (sceneView != null) + sceneView.Repaint(); + if (ActionManager.PreviewWindow != null) + ActionManager.PreviewWindow.Repaint(); + } } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/Assets/ActionTool/Editor/ActionEditorStyles.cs b/Assets/ActionTool/Editor/ActionEditorStyles.cs index 1943a74f..fd940b33 100644 --- a/Assets/ActionTool/Editor/ActionEditorStyles.cs +++ b/Assets/ActionTool/Editor/ActionEditorStyles.cs @@ -47,9 +47,9 @@ namespace ActionTool InitStyle(out boxToggle, EditorStyles.miniButtonLeft, s => { s.fontSize = 8; s.normal.textColor = Color.white; - //s.normal.background = null; - s.active.textColor = Color.white; - //s.active.background = null; + 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/ActionManager.cs b/Assets/ActionTool/Editor/ActionManager.cs index 29384821..89e04c80 100644 --- a/Assets/ActionTool/Editor/ActionManager.cs +++ b/Assets/ActionTool/Editor/ActionManager.cs @@ -293,7 +293,7 @@ namespace ActionTool return; } ColliderData box = new ColliderData(ColliderBox.EColliderType.HurtBox, ColliderBox.Pivot.MiddleBottom); - animationData.AddBox(animationData.hurtBoxes, box); + animationData.AddBox(ref animationData.hurtBoxes, box); } public static void NewHitBox() @@ -304,7 +304,7 @@ namespace ActionTool return; } ColliderData box = new ColliderData(ColliderBox.EColliderType.HitBox, ColliderBox.Pivot.MiddleCenter); - animationData.AddBox(animationData.hitBoxes, box); + animationData.AddBox(ref animationData.hitBoxes, box); } public static void DeleteCurBox() @@ -356,11 +356,12 @@ namespace ActionTool public static void OnSelectColliderFrame(ColliderData.ColliderFrame frame) { s_CurEditColliderFrame = frame; - ColliderWindow = EditorWindow.GetWindow(true); - if(frame != null) + if (frame != null) { - ActionData action = ActionManager.actionData; + ColliderWindow = EditorWindow.GetWindow(true); + + ActionData action = ActionManager.actionData; float normaltime = frame.frame / action.totalFrame; action.curAnimTimeNormal = normaltime; } diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index d236770e..8e620d54 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -52,7 +52,6 @@ namespace ActionTool m_UITextureNewHurtBox = (Texture)Resources.Load("hurtbox"); m_UITextureNewHitBox = (Texture)Resources.Load("hitbox"); - styles = ActionEditorStyles.Get(); } void Update() @@ -67,7 +66,9 @@ namespace ActionTool private void OnGUI() { - if (ActionManager.CurrentAnimationName == null || ActionManager.CurrentAnimationName == "") + styles = ActionEditorStyles.Get(); + + if (ActionManager.CurrentAnimationName == null || ActionManager.CurrentAnimationName == "") { EditorGUILayout.HelpBox("选择动画", MessageType.Warning); return; @@ -338,12 +339,17 @@ namespace ActionTool void DrawBox(int index, ColliderData box, float y, Color c) { ActionData action = ActionManager.actionData; - Color prevColor = GUI.color; - GUI.color = c; - Rect rect = new Rect(kTimeLineViewXOffset - 18, y - 1, 17, kFrameHeight); + + Color prevColor = GUI.backgroundColor; + GUI.backgroundColor = c; + Rect rect = new Rect(kTimeLineViewXOffset - 17, y - 1, 17, kFrameHeight); bool selected = ActionManager.colliderData == box; - bool select = GUI.Toggle(rect, selected, index.ToString(), styles.boxToggle); - if (select) + bool select = GUI.Toggle(rect, selected, index.ToString(), styles.boxToggle); + GUI.backgroundColor = prevColor; + + prevColor = GUI.color; + GUI.color = c; + if (select) { ActionManager.OnSelectBox(box); @@ -403,7 +409,8 @@ namespace ActionTool GUI.color = prevColor; } - void DrawBoxFrameMenuItem() + GenericMenu _newFrameMenu; + void DrawBoxFrameMenuItem() { Event e = Event.current; if (e.button != 1 || !e.isMouse || e.type != EventType.MouseDown) @@ -427,16 +434,16 @@ namespace ActionTool param.frame = frame; if(ActionManager.colliderData != box) ActionManager.OnSelectBox(box); - GenericMenu menu = new GenericMenu(); - menu.AddItem(new GUIContent("New Frame"), false, ActionManager.AddNewBoxFrame, param); - menu.AddItem(new GUIContent("Delete"), false, ActionManager.DeleteBoxFrame, param); - menu.ShowAsContext(); + _newFrameMenu = new GenericMenu(); + _newFrameMenu.AddItem(new GUIContent("New Frame"), false, ActionManager.AddNewBoxFrame, param); + _newFrameMenu.AddItem(new GUIContent("Delete"), false, ActionManager.DeleteBoxFrame, param); + _newFrameMenu.ShowAsContext(); } else { Debug.LogError("[ActionTool] 错误的点击"); } - } + } void GUI_DrawSeperateLine(float x, float y, float height) { -- cgit v1.1-26-g67d0