From 52b9a609181763a26ef3f7f8017845a0f82444fe Mon Sep 17 00:00:00 2001 From: max Date: Thu, 27 Jul 2023 23:52:53 +0200 Subject: [PATCH] Start working on Toolbar --- Editor/Icons.meta | 8 ++ Editor/Icons/GenerateGrid.png | 3 + Editor/Icons/GenerateGrid.png.meta | 123 +++++++++++++++++++++++++++ Editor/Icons/Load.png | 3 + Editor/Icons/Load.png.meta | 123 +++++++++++++++++++++++++++ Editor/Icons/Save.png | 3 + Editor/Icons/Save.png.meta | 123 +++++++++++++++++++++++++++ Editor/ScenePartitionToolbar.cs | 84 ++++++++++++++++++ Editor/ScenePartitionToolbar.cs.meta | 11 +++ 9 files changed, 481 insertions(+) create mode 100644 Editor/Icons.meta create mode 100644 Editor/Icons/GenerateGrid.png create mode 100644 Editor/Icons/GenerateGrid.png.meta create mode 100644 Editor/Icons/Load.png create mode 100644 Editor/Icons/Load.png.meta create mode 100644 Editor/Icons/Save.png create mode 100644 Editor/Icons/Save.png.meta create mode 100644 Editor/ScenePartitionToolbar.cs create mode 100644 Editor/ScenePartitionToolbar.cs.meta diff --git a/Editor/Icons.meta b/Editor/Icons.meta new file mode 100644 index 0000000..6c994ab --- /dev/null +++ b/Editor/Icons.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 60276e4d3d7c1074a8718c58a545fe31 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Icons/GenerateGrid.png b/Editor/Icons/GenerateGrid.png new file mode 100644 index 0000000..2f8ce5e --- /dev/null +++ b/Editor/Icons/GenerateGrid.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5614a68faed99d948bbda8063c5fe592aba87cc6a458f7c0b422048d4e2f428 +size 1860 diff --git a/Editor/Icons/GenerateGrid.png.meta b/Editor/Icons/GenerateGrid.png.meta new file mode 100644 index 0000000..51cd1f0 --- /dev/null +++ b/Editor/Icons/GenerateGrid.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 62eb74ebb0f60354abe70675fd2beedb +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + 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 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + 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: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Icons/Load.png b/Editor/Icons/Load.png new file mode 100644 index 0000000..49409db --- /dev/null +++ b/Editor/Icons/Load.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81fd3ab6682e018bdcf43ff9938dbd12a4805cdc1aa8451f9a624fc57bda9ed6 +size 2034 diff --git a/Editor/Icons/Load.png.meta b/Editor/Icons/Load.png.meta new file mode 100644 index 0000000..228a8b1 --- /dev/null +++ b/Editor/Icons/Load.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 1364209397e55e04ea9c1aca613fb86a +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + 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 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + 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: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Icons/Save.png b/Editor/Icons/Save.png new file mode 100644 index 0000000..3943fa0 --- /dev/null +++ b/Editor/Icons/Save.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b32b27f738f4f9cc8fad620217523ce59b74522df102e6fee0fda57c3f3637a8 +size 1933 diff --git a/Editor/Icons/Save.png.meta b/Editor/Icons/Save.png.meta new file mode 100644 index 0000000..0a1fa71 --- /dev/null +++ b/Editor/Icons/Save.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: f8afdb607709a2d4ba6f59767274ef6b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + 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 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 32 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 2 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/ScenePartitionToolbar.cs b/Editor/ScenePartitionToolbar.cs new file mode 100644 index 0000000..961536e --- /dev/null +++ b/Editor/ScenePartitionToolbar.cs @@ -0,0 +1,84 @@ +using UnityEditor; +using UnityEditor.Overlays; +using UnityEditor.Toolbars; +using UnityEngine; + +namespace VertexColor.ScenePartition.Editor +{ + [Overlay(typeof(SceneView), "ScenePartition")] + public class ScenePartitionToolbar : ToolbarOverlay + { + private const string iconPath = "Packages/com.vertexcolor.scenepartition/Editor/Icons"; + + public ScenePartitionToolbar() : base(Load.Id, Save.Id, GenerateGrid.Id) { } + + [EditorToolbarElement(Id, typeof(SceneView))] + public class Load : EditorToolbarButton, IAccessContainerWindow + { + public const string Id = "ScenePartition/Load"; + + public EditorWindow containerWindow { get; set; } + + public Load() + { + text = "Load"; + icon = AssetDatabase.LoadAssetAtPath($"{iconPath}/Load.png"); + tooltip = "Load the entire scene"; + clicked += OnClick; + } + + void OnClick() + { + if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)) return; + + scenePartitionSO.LoadAll(); + } + } + + [EditorToolbarElement(Id, typeof(SceneView))] + public class Save : EditorToolbarButton, IAccessContainerWindow + { + public const string Id = "ScenePartition/Save"; + + public EditorWindow containerWindow { get; set; } + + public Save() + { + text = "Save"; + icon = AssetDatabase.LoadAssetAtPath($"{iconPath}/Save.png"); + tooltip = "Save scene"; + clicked += OnClick; + } + + void OnClick() + { + if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)) return; + + scenePartitionSO.Save(); + } + } + + [EditorToolbarElement(Id, typeof(SceneView))] + public class GenerateGrid : EditorToolbarButton, IAccessContainerWindow + { + public const string Id = "ScenePartition/GenerateGrid"; + + public EditorWindow containerWindow { get; set; } + + public GenerateGrid() + { + text = "GenerateGrid"; + icon = AssetDatabase.LoadAssetAtPath($"{iconPath}/GenerateGrid.png"); + tooltip = "Generate scene grid"; + clicked += OnClick; + } + + void OnClick() + { + if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)) return; + + scenePartitionSO.GenerateSceneGridData(); + } + } + } +} \ No newline at end of file diff --git a/Editor/ScenePartitionToolbar.cs.meta b/Editor/ScenePartitionToolbar.cs.meta new file mode 100644 index 0000000..bdfb601 --- /dev/null +++ b/Editor/ScenePartitionToolbar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fb370b37d068c4244acc38008f1960f1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: