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 +++++++-- Assets/ActionTool/Resources/hitbox.png | Bin 193 -> 193 bytes Assets/ActionTool/Resources/hurtbox.png | Bin 247 -> 247 bytes Assets/ActionTool/Resources/savefile.png | Bin 0 -> 357 bytes Assets/ActionTool/Resources/savefile.png.meta | 88 ++++++++++++++++++++++++ 7 files changed, 138 insertions(+), 18 deletions(-) create mode 100644 Assets/ActionTool/Resources/savefile.png create mode 100644 Assets/ActionTool/Resources/savefile.png.meta (limited to 'Assets/ActionTool') 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(); } diff --git a/Assets/ActionTool/Resources/hitbox.png b/Assets/ActionTool/Resources/hitbox.png index c462dbe5..a2d0ded9 100644 Binary files a/Assets/ActionTool/Resources/hitbox.png and b/Assets/ActionTool/Resources/hitbox.png differ diff --git a/Assets/ActionTool/Resources/hurtbox.png b/Assets/ActionTool/Resources/hurtbox.png index d990e3d2..eb9613fe 100644 Binary files a/Assets/ActionTool/Resources/hurtbox.png and b/Assets/ActionTool/Resources/hurtbox.png differ diff --git a/Assets/ActionTool/Resources/savefile.png b/Assets/ActionTool/Resources/savefile.png new file mode 100644 index 00000000..4ec11fe6 Binary files /dev/null and b/Assets/ActionTool/Resources/savefile.png differ diff --git a/Assets/ActionTool/Resources/savefile.png.meta b/Assets/ActionTool/Resources/savefile.png.meta new file mode 100644 index 00000000..50de496b --- /dev/null +++ b/Assets/ActionTool/Resources/savefile.png.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: eb4f19e4bb0ed1f40bd92086f3c3c8ed +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 9 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.1-26-g67d0