generated from max/template-unity-project
Compare commits
19 Commits
41df190afb
...
main
Author | SHA1 | Date | |
---|---|---|---|
8453143918 | |||
1b9c367221 | |||
4fe602e932 | |||
40c49b076e | |||
fbd5a342fb | |||
8d567c8cda | |||
73ac3485aa | |||
12fd64f015 | |||
6fc95943fb | |||
df82f44c4a | |||
52b9a60918 | |||
ebb8ba559e | |||
6edb307e9c | |||
236c7377c7 | |||
daf622f327 | |||
6667f013bf | |||
d859ad1af5 | |||
8b44c33813 | |||
ddf71ef7d7 |
@ -16,5 +16,18 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void HorizontalLine() => HorizontalLine(horizontalLineColor);
|
public static void HorizontalLine() => HorizontalLine(horizontalLineColor);
|
||||||
|
|
||||||
|
public struct FoldoutHeaderScope : System.IDisposable
|
||||||
|
{
|
||||||
|
public FoldoutHeaderScope(string label, ref bool foldout)
|
||||||
|
{
|
||||||
|
foldout = EditorGUILayout.BeginFoldoutHeaderGroup(foldout, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly void Dispose()
|
||||||
|
{
|
||||||
|
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
8
Editor/Icons.meta
Normal file
8
Editor/Icons.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 60276e4d3d7c1074a8718c58a545fe31
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Editor/Icons/GenerateGrid.png
(Stored with Git LFS)
Normal file
BIN
Editor/Icons/GenerateGrid.png
(Stored with Git LFS)
Normal file
Binary file not shown.
123
Editor/Icons/GenerateGrid.png.meta
Normal file
123
Editor/Icons/GenerateGrid.png.meta
Normal file
@ -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:
|
BIN
Editor/Icons/Load.png
(Stored with Git LFS)
Normal file
BIN
Editor/Icons/Load.png
(Stored with Git LFS)
Normal file
Binary file not shown.
123
Editor/Icons/Load.png.meta
Normal file
123
Editor/Icons/Load.png.meta
Normal file
@ -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:
|
BIN
Editor/Icons/Reload.png
(Stored with Git LFS)
Normal file
BIN
Editor/Icons/Reload.png
(Stored with Git LFS)
Normal file
Binary file not shown.
123
Editor/Icons/Reload.png.meta
Normal file
123
Editor/Icons/Reload.png.meta
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ab6018b4eb072fa4b8db2154f19559c1
|
||||||
|
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:
|
BIN
Editor/Icons/Save.png
(Stored with Git LFS)
Normal file
BIN
Editor/Icons/Save.png
(Stored with Git LFS)
Normal file
Binary file not shown.
123
Editor/Icons/Save.png.meta
Normal file
123
Editor/Icons/Save.png.meta
Normal file
@ -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:
|
BIN
Editor/Icons/Unload.png
(Stored with Git LFS)
Normal file
BIN
Editor/Icons/Unload.png
(Stored with Git LFS)
Normal file
Binary file not shown.
123
Editor/Icons/Unload.png.meta
Normal file
123
Editor/Icons/Unload.png.meta
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 08a68b1330e59aa409bd68cd3e541161
|
||||||
|
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:
|
@ -9,8 +9,12 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
private const int cellSize = 10;
|
private const int cellSize = 10;
|
||||||
|
|
||||||
private Vector2 scrollPos = Vector2.zero;
|
private Vector2 scrollPos = Vector2.zero;
|
||||||
|
private bool foldoutGroupEnabled = false;
|
||||||
|
|
||||||
[MenuItem("Max/ScenePartitionWindow")]
|
private ulong id = 0;
|
||||||
|
private int gridId = 0;
|
||||||
|
|
||||||
|
[MenuItem("Window/ScenePartition")]
|
||||||
public static void ShowExample()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
ScenePartitionEditorWindow window = GetWindow<ScenePartitionEditorWindow>();
|
ScenePartitionEditorWindow window = GetWindow<ScenePartitionEditorWindow>();
|
||||||
@ -18,6 +22,99 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
using (new EditorGUILayout.VerticalScope())
|
||||||
|
{
|
||||||
|
DrawScenePartition();
|
||||||
|
|
||||||
|
GUILayout.FlexibleSpace();
|
||||||
|
|
||||||
|
DrawSceneDataCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawScenePartition()
|
||||||
|
{
|
||||||
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out var scenePartitionSO)) return;
|
||||||
|
|
||||||
|
EditorGUILayout.LabelField($"ScenePartition | {scenePartitionSO.SceneName}", EditorStyles.boldLabel);
|
||||||
|
|
||||||
|
if (scenePartitionSO.SceneAsset == null)
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("Create Scene"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.CreateScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (GUILayout.Button("Load All"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.LoadAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
using (new EditorGUILayout.HorizontalScope())
|
||||||
|
{
|
||||||
|
if (GUILayout.Button(new GUIContent("Unload", "Empty the scene and save it (so it has no changes in source control)."), EditorStyles.miniButtonLeft))
|
||||||
|
{
|
||||||
|
scenePartitionSO.Unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button(new GUIContent("Reload", "Discard changes and reload loaded partitions."), EditorStyles.miniButtonRight))
|
||||||
|
{
|
||||||
|
scenePartitionSO.Reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("Save"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
|
using (new EditorGUILayout.HorizontalScope())
|
||||||
|
{
|
||||||
|
id = (ulong)EditorGUILayout.LongField("id", (long)id);
|
||||||
|
|
||||||
|
if (GUILayout.Button("Load Id"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.LoadPartitions(new ulong[1] { id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
|
ScenePartitionSceneViewEditor.cellSize = EditorGUILayout.IntSlider("cellSize", ScenePartitionSceneViewEditor.cellSize, 10, 1000);
|
||||||
|
|
||||||
|
if (GUILayout.Button("GenerateSceneGrid"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.GenerateSceneGridData();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scenePartitionSO.Data.SceneGrid != null)
|
||||||
|
{
|
||||||
|
using (new EditorGUILayout.HorizontalScope())
|
||||||
|
{
|
||||||
|
gridId = EditorGUILayout.IntField("gridId", gridId);
|
||||||
|
|
||||||
|
if (GUILayout.Button("LoadSceneGrid"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.LoadCell(gridId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
|
if (GUILayout.Button("Open Scene Data Folder"))
|
||||||
|
{
|
||||||
|
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawSceneDataCache()
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField("Cache", EditorStyles.boldLabel);
|
EditorGUILayout.LabelField("Cache", EditorStyles.boldLabel);
|
||||||
|
|
||||||
@ -36,63 +133,63 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
|
|
||||||
EditorGUIUtils.HorizontalLine();
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
DrawSceneDataCache();
|
using (EditorGUIUtils.FoldoutHeaderScope foldoutGroup = new EditorGUIUtils.FoldoutHeaderScope("SceneDataCache", ref foldoutGroupEnabled))
|
||||||
}
|
|
||||||
|
|
||||||
private void DrawSceneDataCache()
|
|
||||||
{
|
|
||||||
using (EditorGUILayout.ScrollViewScope scope = new EditorGUILayout.ScrollViewScope(scrollPos))
|
|
||||||
{
|
{
|
||||||
scrollPos = scope.scrollPosition;
|
if (!foldoutGroupEnabled) return;
|
||||||
|
|
||||||
using (new EditorGUI.DisabledGroupScope(true))
|
using (EditorGUILayout.ScrollViewScope scope = new EditorGUILayout.ScrollViewScope(scrollPos))
|
||||||
{
|
{
|
||||||
ScenePartitionSS scenePartitionSS = ScenePartitionSS.instance;
|
scrollPos = scope.scrollPosition;
|
||||||
|
|
||||||
foreach (KeyValuePair<ScenePartitionSO, ScenePartitionData> sceneData in scenePartitionSS.SceneDataCache)
|
using (new EditorGUI.DisabledGroupScope(true))
|
||||||
{
|
{
|
||||||
if (sceneData.Key == null || sceneData.Value == null) continue;
|
ScenePartitionSS scenePartitionSS = ScenePartitionSS.instance;
|
||||||
|
|
||||||
EditorGUILayout.LabelField($"{sceneData.Key.name}");
|
foreach (KeyValuePair<ScenePartitionSO, ScenePartitionData> sceneData in scenePartitionSS.SceneDataCache)
|
||||||
|
|
||||||
if (sceneData.Value.HasCreatedPartitions)
|
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField($"scenePartitions");
|
if (sceneData.Key == null || sceneData.Value == null) continue;
|
||||||
|
|
||||||
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.ScenePartitions)
|
EditorGUILayout.LabelField($"{sceneData.Key.name}");
|
||||||
|
|
||||||
|
if (sceneData.Value.HasCreatedPartitions)
|
||||||
{
|
{
|
||||||
EditorGUILayout.LongField((long)scenePartition.Key);
|
EditorGUILayout.LabelField($"scenePartitions");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.ScenePartitions)
|
||||||
|
|
||||||
if (sceneData.Value.HasLoadedPartitions)
|
|
||||||
{
|
|
||||||
EditorGUILayout.LabelField($"loadedScenePartitions");
|
|
||||||
|
|
||||||
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.LoadedScenePartitions)
|
|
||||||
{
|
|
||||||
EditorGUILayout.LongField((long)scenePartition.Value.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sceneData.Value.SceneGrid != null)
|
|
||||||
{
|
|
||||||
EditorGUILayout.LabelField($"generatedSceneGrid");
|
|
||||||
|
|
||||||
foreach (KeyValuePair<int, GridList> item in sceneData.Value.SceneGrid.Grid)
|
|
||||||
{
|
|
||||||
EditorGUILayout.IntField("gridId", item.Key);
|
|
||||||
|
|
||||||
EditorGUI.indentLevel++;
|
|
||||||
|
|
||||||
foreach (ulong id in item.Value.list)
|
|
||||||
{
|
{
|
||||||
EditorGUILayout.LongField((long)id);
|
EditorGUILayout.LongField((long)scenePartition.Key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EditorGUI.indentLevel--;
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
if (sceneData.Value.HasLoadedPartitions)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField($"loadedScenePartitions");
|
||||||
|
|
||||||
|
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in sceneData.Value.LoadedScenePartitions)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LongField((long)scenePartition.Value.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sceneData.Value.SceneGrid != null)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField($"generatedSceneGrid");
|
||||||
|
|
||||||
|
foreach (KeyValuePair<int, GridList> item in sceneData.Value.SceneGrid.Grid)
|
||||||
|
{
|
||||||
|
EditorGUILayout.IntField("gridId", item.Key);
|
||||||
|
|
||||||
|
EditorGUI.indentLevel++;
|
||||||
|
|
||||||
|
foreach (ulong id in item.Value.list)
|
||||||
|
{
|
||||||
|
EditorGUILayout.LongField((long)id);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUI.indentLevel--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
54
Editor/ScenePartitionMenuEditor.cs
Normal file
54
Editor/ScenePartitionMenuEditor.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace VertexColor.ScenePartition.Editor
|
||||||
|
{
|
||||||
|
public static class ScenePartitionMenuEditor
|
||||||
|
{
|
||||||
|
[MenuItem("GameObject/ScenePartition/CopyObjectId", false, 10000)]
|
||||||
|
public static void CopyObjectId(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// Get context from menu command instead of selection because the menu command is executed for each selected object when executed from the hierarchy.
|
||||||
|
if (menuCommand.context is not GameObject go) return;
|
||||||
|
if (go == null) return;
|
||||||
|
if (go.scene == null) return;
|
||||||
|
|
||||||
|
ulong id = ScenePartitionUtils.GetTargetObjectId(go);
|
||||||
|
|
||||||
|
EditorGUIUtility.systemCopyBuffer = id.ToString();
|
||||||
|
Debug.Log($"Copied object id '{id}' from '{go}' to clipboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/ScenePartition/AddToAlwaysLoad", false, 10000)]
|
||||||
|
public static void AddToAlwaysLoad(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// Get context from menu command instead of selection because the menu command is executed for each selected object when executed from the hierarchy.
|
||||||
|
if (menuCommand.context is not GameObject go) return;
|
||||||
|
if (go == null) return;
|
||||||
|
if (go.scene == null) return;
|
||||||
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out var scenePartitionSO)) return;
|
||||||
|
|
||||||
|
ulong id = ScenePartitionUtils.GetTargetObjectId(go);
|
||||||
|
|
||||||
|
if (scenePartitionSO.alwaysLoadIds.Contains(id)) return;
|
||||||
|
|
||||||
|
scenePartitionSO.alwaysLoadIds.Add(id);
|
||||||
|
Debug.Log($"Added '{go}' ({id}) to '{scenePartitionSO.name}' ({scenePartitionSO.SceneName})");
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/ScenePartition/RemoveFromAlwaysLoad", false, 10000)]
|
||||||
|
public static void RemoveFromAlwaysLoad(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// Get context from menu command instead of selection because the menu command is executed for each selected object when executed from the hierarchy.
|
||||||
|
if (menuCommand.context is not GameObject go) return;
|
||||||
|
if (go == null) return;
|
||||||
|
if (go.scene == null) return;
|
||||||
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out var scenePartitionSO)) return;
|
||||||
|
|
||||||
|
ulong id = ScenePartitionUtils.GetTargetObjectId(go);
|
||||||
|
|
||||||
|
scenePartitionSO.alwaysLoadIds.Remove(id);
|
||||||
|
Debug.Log($"Removed '{go}' ({id}) from '{scenePartitionSO.name}' ({scenePartitionSO.SceneName})");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Editor/ScenePartitionMenuEditor.cs.meta
Normal file
11
Editor/ScenePartitionMenuEditor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ab63a69b46a3ff4438723520d0656c93
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -82,33 +82,56 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
|
|
||||||
private void LoadScenePartitions(SortedSet<ulong> partitionIds)
|
private void LoadScenePartitions(SortedSet<ulong> partitionIds)
|
||||||
{
|
{
|
||||||
if (!Data.HasCreatedPartitions) return;
|
using (new ProfilerUtility.ProfilerScope($"{nameof(LoadScenePartitions)}"))
|
||||||
|
|
||||||
string scenePath = ScenePartitionUtils.GetScenePath(this);
|
|
||||||
|
|
||||||
List<string> sceneData = new List<string>();
|
|
||||||
|
|
||||||
Data.LoadedScenePartitions.Clear();
|
|
||||||
|
|
||||||
// Add always load ids.
|
|
||||||
SortedSet<ulong> baseIds = GetAlwaysLoadIds();
|
|
||||||
foreach (var id in baseIds)
|
|
||||||
{
|
{
|
||||||
partitionIds.Add(id);
|
if (!Data.HasCreatedPartitions) return;
|
||||||
|
|
||||||
|
string scenePath = ScenePartitionUtils.GetScenePath(this);
|
||||||
|
|
||||||
|
Data.LoadedScenePartitions.Clear();
|
||||||
|
|
||||||
|
// Add always load ids.
|
||||||
|
SortedSet<ulong> baseIds = GetAlwaysLoadIds();
|
||||||
|
foreach (ulong id in baseIds)
|
||||||
|
{
|
||||||
|
partitionIds.Add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear file.
|
||||||
|
File.WriteAllText(scenePath, string.Empty);
|
||||||
|
|
||||||
|
// Create scene data.
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (FileStream outputStream = new FileStream(scenePath, FileMode.Append, FileAccess.Write))
|
||||||
|
{
|
||||||
|
foreach (ulong id in partitionIds)
|
||||||
|
{
|
||||||
|
ScenePartition p = Data.ScenePartitions[id];
|
||||||
|
|
||||||
|
using (FileStream inputStream = new FileStream(p.filePath, FileMode.Open, FileAccess.Read))
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = inputStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
outputStream.Write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Data.LoadedScenePartitions.Add(p.id, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
// 'Reload' the scene to prevent the user getting the popup 'Scene has been changed on disk'.
|
||||||
|
EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create scene data.
|
|
||||||
foreach (ulong id in partitionIds)
|
|
||||||
{
|
|
||||||
ScenePartition p = Data.ScenePartitions[id];
|
|
||||||
sceneData.AddRange(File.ReadAllLines(p.filePath));
|
|
||||||
Data.LoadedScenePartitions.Add(p.id, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create scene.
|
|
||||||
File.WriteAllLines(scenePath, sceneData);
|
|
||||||
|
|
||||||
AssetDatabase.Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -116,38 +139,44 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
DeleteLoadedPartitions(); // Delete the loaded partitions from disk so we can write the new ones.
|
using (new ProfilerUtility.ProfilerScope($"{nameof(Save)}"))
|
||||||
|
|
||||||
string pattern = @"&(\d+)";
|
|
||||||
string dataPath = ScenePartitionUtils.GetDataPath(this);
|
|
||||||
string scenePath = ScenePartitionUtils.GetScenePath(this);
|
|
||||||
|
|
||||||
// Read the data from the scene file.
|
|
||||||
string[] sceneData = File.ReadAllLines(scenePath);
|
|
||||||
|
|
||||||
// Split it into blocks.
|
|
||||||
int lastIndex = sceneData.Length;
|
|
||||||
for (int i = sceneData.Length - 1; i >= 0; i--)
|
|
||||||
{
|
{
|
||||||
if (sceneData[i].StartsWith("---")) // --- is the start of a new yaml document.
|
// Check if the user wants to save the scene if dirty.
|
||||||
|
if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) return;
|
||||||
|
|
||||||
|
DeleteLoadedPartitions(); // Delete the loaded partitions from disk so we can write the new ones.
|
||||||
|
|
||||||
|
string pattern = @"&(\d+)";
|
||||||
|
string dataPath = ScenePartitionUtils.GetDataPath(this);
|
||||||
|
string scenePath = ScenePartitionUtils.GetScenePath(this);
|
||||||
|
|
||||||
|
// Read the data from the scene file.
|
||||||
|
string[] sceneData = File.ReadAllLines(scenePath);
|
||||||
|
|
||||||
|
// Split it into blocks.
|
||||||
|
int lastIndex = sceneData.Length;
|
||||||
|
for (int i = sceneData.Length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
Match match = Regex.Match(sceneData[i], pattern);
|
if (sceneData[i].StartsWith("---")) // --- is the start of a new yaml document.
|
||||||
|
|
||||||
if (match.Success)
|
|
||||||
{
|
{
|
||||||
// Extract the file number
|
Match match = Regex.Match(sceneData[i], pattern);
|
||||||
string id = match.Groups[1].Value;
|
|
||||||
|
|
||||||
// Write data to disk.
|
if (match.Success)
|
||||||
File.WriteAllLines($"{dataPath}/{SceneName}-{id}.yaml", sceneData[i..lastIndex]);
|
{
|
||||||
|
// Extract the file number
|
||||||
|
string id = match.Groups[1].Value;
|
||||||
|
|
||||||
|
// Write data to disk.
|
||||||
|
File.WriteAllLines($"{dataPath}/{SceneName}-{id}.yaml", sceneData[i..lastIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastIndex = i;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Write header to disk.
|
// Write header to disk.
|
||||||
File.WriteAllLines($"{dataPath}/{SceneName}.yaml", sceneData[0..lastIndex]);
|
File.WriteAllLines($"{dataPath}/{SceneName}.yaml", sceneData[0..lastIndex]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -155,51 +184,89 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Unload()
|
public void Unload()
|
||||||
{
|
{
|
||||||
string dataPath = ScenePartitionUtils.GetDataPath(this);
|
using (new ProfilerUtility.ProfilerScope($"{nameof(Unload)}"))
|
||||||
string scenePath = ScenePartitionUtils.GetScenePath(this);
|
|
||||||
|
|
||||||
Scene scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
|
|
||||||
|
|
||||||
GameObject[] gameObjects = scene.GetRootGameObjects();
|
|
||||||
|
|
||||||
for (int i = gameObjects.Length - 1; i >= 0; i--)
|
|
||||||
{
|
{
|
||||||
DestroyImmediate(gameObjects[i]);
|
string dataPath = ScenePartitionUtils.GetDataPath(this);
|
||||||
|
string scenePath = ScenePartitionUtils.GetScenePath(this);
|
||||||
|
|
||||||
|
Scene scene = EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
|
||||||
|
|
||||||
|
GameObject[] gameObjects = scene.GetRootGameObjects();
|
||||||
|
|
||||||
|
for (int i = gameObjects.Length - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
DestroyImmediate(gameObjects[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorSceneManager.SaveScene(scene);
|
||||||
|
|
||||||
|
Data.LoadedScenePartitions.Clear();
|
||||||
|
|
||||||
|
AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorSceneManager.SaveScene(scene);
|
|
||||||
|
|
||||||
Data.LoadedScenePartitions.Clear();
|
|
||||||
|
|
||||||
AssetDatabase.Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteLoadedPartitions()
|
private void DeleteLoadedPartitions()
|
||||||
{
|
{
|
||||||
if (!Data.HasLoadedPartitions) return;
|
using (new ProfilerUtility.ProfilerScope($"{nameof(DeleteLoadedPartitions)}"))
|
||||||
|
|
||||||
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in Data.LoadedScenePartitions)
|
|
||||||
{
|
{
|
||||||
if (!File.Exists(scenePartition.Value.filePath)) continue;
|
if (!Data.HasLoadedPartitions) return;
|
||||||
|
|
||||||
File.Delete(scenePartition.Value.filePath);
|
foreach (KeyValuePair<ulong, ScenePartition> scenePartition in Data.LoadedScenePartitions)
|
||||||
|
{
|
||||||
|
if (!File.Exists(scenePartition.Value.filePath)) continue;
|
||||||
|
|
||||||
|
File.Delete(scenePartition.Value.filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadPartitions(ulong[] ids)
|
public void LoadPartitions(ulong[] ids)
|
||||||
{
|
{
|
||||||
SortedSet<ulong> partitionIds = new SortedSet<ulong>();
|
using (new ProfilerUtility.ProfilerScope($"{nameof(LoadPartitions)}"))
|
||||||
|
|
||||||
for (int i = 0; i < ids.Length; i++)
|
|
||||||
{
|
{
|
||||||
SortedSet<ulong> connections = ScenePartitionUtils.FindDeeplyLinkedObjects(Data.ScenePartitions, ids[i]);
|
SortedSet<ulong> partitionIds = new SortedSet<ulong>();
|
||||||
foreach (ulong c in connections)
|
|
||||||
{
|
|
||||||
partitionIds.Add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadScenePartitions(partitionIds);
|
for (int i = 0; i < ids.Length; i++)
|
||||||
|
{
|
||||||
|
SortedSet<ulong> connections = ScenePartitionUtils.FindDeeplyLinkedObjects(Data.ScenePartitions, ids[i]);
|
||||||
|
foreach (ulong c in connections)
|
||||||
|
{
|
||||||
|
partitionIds.Add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadScenePartitions(partitionIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadPartitionsAdditive(ulong[] ids)
|
||||||
|
{
|
||||||
|
using (new ProfilerUtility.ProfilerScope($"{nameof(LoadPartitions)}"))
|
||||||
|
{
|
||||||
|
SortedSet<ulong> partitionIds = new SortedSet<ulong>();
|
||||||
|
|
||||||
|
// Additive partitions to load.
|
||||||
|
for (int i = 0; i < ids.Length; i++)
|
||||||
|
{
|
||||||
|
SortedSet<ulong> connections = ScenePartitionUtils.FindDeeplyLinkedObjects(Data.ScenePartitions, ids[i]);
|
||||||
|
foreach (ulong c in connections)
|
||||||
|
{
|
||||||
|
partitionIds.Add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Partitions already loaded.
|
||||||
|
if (Data.HasLoadedPartitions)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<ulong, ScenePartition> item in Data.LoadedScenePartitions)
|
||||||
|
{
|
||||||
|
partitionIds.Add(item.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadScenePartitions(partitionIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortedSet<ulong> GetAlwaysLoadIds()
|
private SortedSet<ulong> GetAlwaysLoadIds()
|
||||||
@ -220,76 +287,79 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
|
|
||||||
public void GenerateSceneGridData()
|
public void GenerateSceneGridData()
|
||||||
{
|
{
|
||||||
LoadAll();
|
using (new ProfilerUtility.ProfilerScope($"{nameof(GenerateSceneGridData)}"))
|
||||||
|
|
||||||
if (!Data.HasCreatedPartitions) return;
|
|
||||||
|
|
||||||
Scene scene = EditorSceneManager.OpenScene(ScenePartitionUtils.GetScenePath(this), OpenSceneMode.Single);
|
|
||||||
|
|
||||||
GameObject[] rootGameObjects = scene.GetRootGameObjects();
|
|
||||||
|
|
||||||
Data.SceneGrid.Grid.Clear();
|
|
||||||
|
|
||||||
//// Maybe later switch to getting the data from disk instead of loading the scene and then unloading it again.
|
|
||||||
//foreach (GameObject gameObject in rootGameObjects)
|
|
||||||
//{
|
|
||||||
// // https://forum.unity.com/threads/how-to-get-the-local-identifier-in-file-for-scene-objects.265686/
|
|
||||||
// PropertyInfo inspectorModeInfo = typeof(SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
// SerializedObject serializedObject = new SerializedObject(gameObject.transform);
|
|
||||||
// inspectorModeInfo.SetValue(serializedObject, InspectorMode.Debug, null);
|
|
||||||
// SerializedProperty localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile");
|
|
||||||
|
|
||||||
// long localId = localIdProp.longValue;
|
|
||||||
|
|
||||||
// if (localId == 0)
|
|
||||||
// {
|
|
||||||
// if (PrefabUtility.IsPartOfPrefabInstance(gameObject))
|
|
||||||
// {
|
|
||||||
// GlobalObjectId id = GlobalObjectId.GetGlobalObjectIdSlow(gameObject); // We could use this funtion for all objects. Might be a bit slower but is also simple.
|
|
||||||
// localId = long.Parse(id.targetPrefabId.ToString());
|
|
||||||
|
|
||||||
// Debug.Log($"{id.assetGUID} | {id.identifierType} | {id.targetObjectId} | {id.targetPrefabId}");
|
|
||||||
|
|
||||||
// if (id.targetObjectId == 0 && id.targetPrefabId == 0)
|
|
||||||
// {
|
|
||||||
// Debug.LogWarning($"Could not find LocalIdentfierInFile for {gameObject.transform} {gameObject.name} {gameObject.transform.GetInstanceID()}");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// Debug.LogWarning($"Could not find LocalIdentfierInFile for {gameObject.transform} {gameObject.name} {gameObject.transform.GetInstanceID()}");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!Data.ScenePartitions.ContainsKey(localId))
|
|
||||||
// {
|
|
||||||
// Debug.LogWarning($"Could not find LocalIdentfierInFile for {gameObject.transform} {gameObject.name} {gameObject.transform.GetInstanceID()}");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Data.SceneGrid.Insert(localId, gameObject.transform.position);
|
|
||||||
//}
|
|
||||||
|
|
||||||
GlobalObjectId[] ids = new GlobalObjectId[rootGameObjects.Length];
|
|
||||||
GlobalObjectId.GetGlobalObjectIdsSlow(rootGameObjects, ids);
|
|
||||||
|
|
||||||
for (int i = 0; i < ids.Length; i++)
|
|
||||||
{
|
{
|
||||||
Debug.Log($"{ids[i].assetGUID} | {ids[i].identifierType} | {ids[i].targetObjectId} | {ids[i].targetPrefabId}");
|
LoadAll();
|
||||||
|
|
||||||
if (ids[i].targetPrefabId == 0) // 0 = no prefab.
|
if (!Data.HasCreatedPartitions) return;
|
||||||
|
|
||||||
|
Scene scene = EditorSceneManager.OpenScene(ScenePartitionUtils.GetScenePath(this), OpenSceneMode.Single);
|
||||||
|
|
||||||
|
GameObject[] rootGameObjects = scene.GetRootGameObjects();
|
||||||
|
|
||||||
|
Data.SceneGrid.Grid.Clear();
|
||||||
|
|
||||||
|
//// Maybe later switch to getting the data from disk instead of loading the scene and then unloading it again.
|
||||||
|
//foreach (GameObject gameObject in rootGameObjects)
|
||||||
|
//{
|
||||||
|
// // https://forum.unity.com/threads/how-to-get-the-local-identifier-in-file-for-scene-objects.265686/
|
||||||
|
// PropertyInfo inspectorModeInfo = typeof(SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
// SerializedObject serializedObject = new SerializedObject(gameObject.transform);
|
||||||
|
// inspectorModeInfo.SetValue(serializedObject, InspectorMode.Debug, null);
|
||||||
|
// SerializedProperty localIdProp = serializedObject.FindProperty("m_LocalIdentfierInFile");
|
||||||
|
|
||||||
|
// long localId = localIdProp.longValue;
|
||||||
|
|
||||||
|
// if (localId == 0)
|
||||||
|
// {
|
||||||
|
// if (PrefabUtility.IsPartOfPrefabInstance(gameObject))
|
||||||
|
// {
|
||||||
|
// GlobalObjectId id = GlobalObjectId.GetGlobalObjectIdSlow(gameObject); // We could use this funtion for all objects. Might be a bit slower but is also simple.
|
||||||
|
// localId = long.Parse(id.targetPrefabId.ToString());
|
||||||
|
|
||||||
|
// Debug.Log($"{id.assetGUID} | {id.identifierType} | {id.targetObjectId} | {id.targetPrefabId}");
|
||||||
|
|
||||||
|
// if (id.targetObjectId == 0 && id.targetPrefabId == 0)
|
||||||
|
// {
|
||||||
|
// Debug.LogWarning($"Could not find LocalIdentfierInFile for {gameObject.transform} {gameObject.name} {gameObject.transform.GetInstanceID()}");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Debug.LogWarning($"Could not find LocalIdentfierInFile for {gameObject.transform} {gameObject.name} {gameObject.transform.GetInstanceID()}");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!Data.ScenePartitions.ContainsKey(localId))
|
||||||
|
// {
|
||||||
|
// Debug.LogWarning($"Could not find LocalIdentfierInFile for {gameObject.transform} {gameObject.name} {gameObject.transform.GetInstanceID()}");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Data.SceneGrid.Insert(localId, gameObject.transform.position);
|
||||||
|
//}
|
||||||
|
|
||||||
|
GlobalObjectId[] ids = new GlobalObjectId[rootGameObjects.Length];
|
||||||
|
GlobalObjectId.GetGlobalObjectIdsSlow(rootGameObjects, ids);
|
||||||
|
|
||||||
|
for (int i = 0; i < ids.Length; i++)
|
||||||
{
|
{
|
||||||
Data.SceneGrid.Insert(ids[i].targetObjectId, rootGameObjects[i].transform.position);
|
//Debug.Log($"{ids[i].assetGUID} | {ids[i].identifierType} | {ids[i].targetObjectId} | {ids[i].targetPrefabId}");
|
||||||
}
|
|
||||||
else
|
if (ids[i].targetPrefabId == 0) // 0 = no prefab.
|
||||||
{
|
{
|
||||||
Data.SceneGrid.Insert(ids[i].targetPrefabId, rootGameObjects[i].transform.position);
|
Data.SceneGrid.Insert(ids[i].targetObjectId, rootGameObjects[i].transform.position, ScenePartitionSceneViewEditor.cellSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Data.SceneGrid.Insert(ids[i].targetPrefabId, rootGameObjects[i].transform.position, ScenePartitionSceneViewEditor.cellSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
Unload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadCell(int gridId)
|
public void LoadCell(int gridId)
|
||||||
@ -300,6 +370,14 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadCellAdditive(int gridId)
|
||||||
|
{
|
||||||
|
if (Data.SceneGrid.Grid.TryGetValue(gridId, out GridList ids))
|
||||||
|
{
|
||||||
|
LoadPartitionsAdditive(ids.list.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ClearCache()
|
public void ClearCache()
|
||||||
{
|
{
|
||||||
data = null;
|
data = null;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
//EditorGUILayout.PropertyField(sceneAssetProperty);
|
//EditorGUILayout.PropertyField(sceneAssetProperty);
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
if (scenePartitionSO.SceneAsset == null)
|
if (scenePartitionSO.SceneAsset == null)
|
||||||
{
|
{
|
||||||
@ -31,14 +30,29 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (GUILayout.Button("Open Scene Data Folder"))
|
||||||
|
{
|
||||||
|
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
if (GUILayout.Button("Load All"))
|
if (GUILayout.Button("Load All"))
|
||||||
{
|
{
|
||||||
scenePartitionSO.LoadAll();
|
scenePartitionSO.LoadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("Reload"))
|
using (new EditorGUILayout.HorizontalScope())
|
||||||
{
|
{
|
||||||
scenePartitionSO.Reload();
|
if (GUILayout.Button(new GUIContent("Unload", "Empty the scene and save it (so it has no changes in source control)."), EditorStyles.miniButtonLeft))
|
||||||
|
{
|
||||||
|
scenePartitionSO.Unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button(new GUIContent("Reload", "Discard changes and reload loaded partitions."), EditorStyles.miniButtonRight))
|
||||||
|
{
|
||||||
|
scenePartitionSO.Reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("Save"))
|
if (GUILayout.Button("Save"))
|
||||||
@ -46,57 +60,37 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
scenePartitionSO.Save();
|
scenePartitionSO.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("Unload"))
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
|
using (new EditorGUILayout.HorizontalScope())
|
||||||
{
|
{
|
||||||
scenePartitionSO.Unload();
|
id = (ulong)EditorGUILayout.LongField("id", (long)id);
|
||||||
|
|
||||||
|
if (GUILayout.Button("Load Id"))
|
||||||
|
{
|
||||||
|
scenePartitionSO.LoadPartitions(new ulong[1] { id });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUIUtils.HorizontalLine();
|
||||||
|
|
||||||
if (GUILayout.Button("Open Scene Data Folder"))
|
ScenePartitionSceneViewEditor.cellSize = EditorGUILayout.IntSlider("cellSize", ScenePartitionSceneViewEditor.cellSize, 10, 1000);
|
||||||
{
|
|
||||||
EditorUtility.RevealInFinder(ScenePartitionUtils.GetDataPath(scenePartitionSO));
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
|
|
||||||
id = (ulong)EditorGUILayout.LongField("id", (long)id);
|
|
||||||
|
|
||||||
if (GUILayout.Button("Load Section"))
|
|
||||||
{
|
|
||||||
scenePartitionSO.LoadPartitions(new ulong[1] { id });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GUILayout.Button("GenerateSceneGrid"))
|
if (GUILayout.Button("GenerateSceneGrid"))
|
||||||
{
|
{
|
||||||
scenePartitionSO.GenerateSceneGridData();
|
scenePartitionSO.GenerateSceneGridData();
|
||||||
}
|
}
|
||||||
|
|
||||||
gridId = EditorGUILayout.IntField("gridId", gridId);
|
|
||||||
|
|
||||||
if (GUILayout.Button("LoadSceneGrid"))
|
|
||||||
{
|
|
||||||
scenePartitionSO.LoadCell(gridId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scenePartitionSO.Data.SceneGrid != null)
|
if (scenePartitionSO.Data.SceneGrid != null)
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField($"generatedSceneGrid");
|
using (new EditorGUILayout.HorizontalScope())
|
||||||
|
|
||||||
scenePartitionSO.Data.SceneGrid.cellSize = EditorGUILayout.IntSlider("cellSize", scenePartitionSO.Data.SceneGrid.cellSize, 10, 1000);
|
|
||||||
|
|
||||||
foreach (KeyValuePair<int, GridList> item in scenePartitionSO.Data.SceneGrid.Grid)
|
|
||||||
{
|
{
|
||||||
EditorGUILayout.LongField("gridId", item.Key);
|
gridId = EditorGUILayout.IntField("gridId", gridId);
|
||||||
|
|
||||||
EditorGUI.indentLevel++;
|
if (GUILayout.Button("LoadSceneGrid"))
|
||||||
|
|
||||||
foreach (ulong id in item.Value.list)
|
|
||||||
{
|
{
|
||||||
EditorGUILayout.LongField((long)id);
|
scenePartitionSO.LoadCell(gridId);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUI.indentLevel--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
[InitializeOnLoad]
|
[InitializeOnLoad]
|
||||||
public class ScenePartitionSceneViewEditor : UnityEditor.Editor
|
public class ScenePartitionSceneViewEditor : UnityEditor.Editor
|
||||||
{
|
{
|
||||||
|
public static int cellSize = 100;
|
||||||
|
|
||||||
private static ScenePartitionSO scenePartitionSO = null;
|
private static ScenePartitionSO scenePartitionSO = null;
|
||||||
|
|
||||||
static ScenePartitionSceneViewEditor()
|
static ScenePartitionSceneViewEditor()
|
||||||
@ -18,7 +20,6 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
if (Event.current.modifiers != EventModifiers.Control) return;
|
if (Event.current.modifiers != EventModifiers.Control) return;
|
||||||
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out scenePartitionSO)) return;
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out scenePartitionSO)) return;
|
||||||
|
|
||||||
int cellSize = scenePartitionSO.Data.SceneGrid.cellSize;
|
|
||||||
Vector3 gridPosition = CalculateGridPosition(Event.current.mousePosition);
|
Vector3 gridPosition = CalculateGridPosition(Event.current.mousePosition);
|
||||||
int gridId = SceneGrid.CalculateGridPosition(gridPosition, cellSize);
|
int gridId = SceneGrid.CalculateGridPosition(gridPosition, cellSize);
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
GenericMenu menu = new GenericMenu();
|
GenericMenu menu = new GenericMenu();
|
||||||
|
|
||||||
menu.AddItem(new GUIContent($"Load {gridId}"), false, Load, gridId);
|
menu.AddItem(new GUIContent($"Load {gridId}"), false, Load, gridId);
|
||||||
|
menu.AddItem(new GUIContent($"LoadAdditive {gridId}"), false, LoadAdditive, gridId);
|
||||||
menu.ShowAsContext();
|
menu.ShowAsContext();
|
||||||
|
|
||||||
Event.current.Use();
|
Event.current.Use();
|
||||||
@ -94,5 +96,14 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
|
|
||||||
scenePartitionSO.LoadCell(cellId);
|
scenePartitionSO.LoadCell(cellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void LoadAdditive(object gridId)
|
||||||
|
{
|
||||||
|
if (scenePartitionSO == null) return;
|
||||||
|
if (gridId == null) return;
|
||||||
|
if (gridId is not int cellId) return;
|
||||||
|
|
||||||
|
scenePartitionSO.LoadCellAdditive(cellId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
130
Editor/ScenePartitionToolbar.cs
Normal file
130
Editor/ScenePartitionToolbar.cs
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
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, Reload.Id, Unload.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<Texture2D>($"{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<Texture2D>($"{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 Reload : EditorToolbarButton, IAccessContainerWindow
|
||||||
|
{
|
||||||
|
public const string Id = "ScenePartition/Reload";
|
||||||
|
|
||||||
|
public EditorWindow containerWindow { get; set; }
|
||||||
|
|
||||||
|
public Reload()
|
||||||
|
{
|
||||||
|
text = "Reload";
|
||||||
|
icon = AssetDatabase.LoadAssetAtPath<Texture2D>($"{iconPath}/Reload.png");
|
||||||
|
tooltip = "Discard changes and reload scene";
|
||||||
|
clicked += OnClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnClick()
|
||||||
|
{
|
||||||
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)) return;
|
||||||
|
|
||||||
|
scenePartitionSO.Reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[EditorToolbarElement(Id, typeof(SceneView))]
|
||||||
|
public class Unload : EditorToolbarButton, IAccessContainerWindow
|
||||||
|
{
|
||||||
|
public const string Id = "ScenePartition/Unload";
|
||||||
|
|
||||||
|
public EditorWindow containerWindow { get; set; }
|
||||||
|
|
||||||
|
public Unload()
|
||||||
|
{
|
||||||
|
text = "Unload";
|
||||||
|
icon = AssetDatabase.LoadAssetAtPath<Texture2D>($"{iconPath}/Unload.png");
|
||||||
|
tooltip = "Unload the scene";
|
||||||
|
clicked += OnClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnClick()
|
||||||
|
{
|
||||||
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)) return;
|
||||||
|
|
||||||
|
scenePartitionSO.Unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[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<Texture2D>($"{iconPath}/GenerateGrid.png");
|
||||||
|
tooltip = "Generate scene grid";
|
||||||
|
clicked += OnClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnClick()
|
||||||
|
{
|
||||||
|
if (!ScenePartitionUtils.TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)) return;
|
||||||
|
|
||||||
|
scenePartitionSO.GenerateSceneGridData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Editor/ScenePartitionToolbar.cs.meta
Normal file
11
Editor/ScenePartitionToolbar.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fb370b37d068c4244acc38008f1960f1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -33,9 +33,12 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
|
|
||||||
public static SortedSet<ulong> FindDeeplyLinkedObjects(SortedList<ulong, ScenePartition> scenePartitions, ulong partitionId)
|
public static SortedSet<ulong> FindDeeplyLinkedObjects(SortedList<ulong, ScenePartition> scenePartitions, ulong partitionId)
|
||||||
{
|
{
|
||||||
SortedSet<ulong> linkedObjects = new SortedSet<ulong>();
|
using (new ProfilerUtility.ProfilerScope($"{nameof(FindDeeplyLinkedObjects)}"))
|
||||||
FindDeeplyLinkedObjectsRecursive(scenePartitions, partitionId, linkedObjects);
|
{
|
||||||
return linkedObjects;
|
SortedSet<ulong> linkedObjects = new SortedSet<ulong>();
|
||||||
|
FindDeeplyLinkedObjectsRecursive(scenePartitions, partitionId, linkedObjects);
|
||||||
|
return linkedObjects;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FindDeeplyLinkedObjectsRecursive(SortedList<ulong, ScenePartition> scenePartitions, ulong partitionId, SortedSet<ulong> linkedObjects)
|
private static void FindDeeplyLinkedObjectsRecursive(SortedList<ulong, ScenePartition> scenePartitions, ulong partitionId, SortedSet<ulong> linkedObjects)
|
||||||
@ -60,32 +63,49 @@ namespace VertexColor.ScenePartition.Editor
|
|||||||
|
|
||||||
public static bool TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)
|
public static bool TryGetScenePartitionSOForActiveScene(out ScenePartitionSO scenePartitionSO)
|
||||||
{
|
{
|
||||||
scenePartitionSO = null;
|
using (new ProfilerUtility.ProfilerScope($"{nameof(TryGetScenePartitionSOForActiveScene)}"))
|
||||||
|
|
||||||
UnityEngine.SceneManagement.Scene activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
|
||||||
|
|
||||||
if (activeScene == null) return false;
|
|
||||||
|
|
||||||
string filter = $"t:{nameof(ScenePartitionSO)}";
|
|
||||||
string[] assets = AssetDatabase.FindAssets(filter);
|
|
||||||
|
|
||||||
if (assets == null || assets.Length <= 0) return false;
|
|
||||||
|
|
||||||
for (int i = 0; i < assets.Length; i++)
|
|
||||||
{
|
{
|
||||||
string path = AssetDatabase.GUIDToAssetPath(assets[i]);
|
scenePartitionSO = null;
|
||||||
ScenePartitionSO scenePartition = AssetDatabase.LoadAssetAtPath<ScenePartitionSO>(path);
|
|
||||||
|
|
||||||
if (scenePartition == null) continue;
|
UnityEngine.SceneManagement.Scene activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
|
||||||
|
|
||||||
if (scenePartition.SceneName == activeScene.name)
|
if (activeScene == null) return false;
|
||||||
|
|
||||||
|
string filter = $"t:{nameof(ScenePartitionSO)}";
|
||||||
|
string[] assets = AssetDatabase.FindAssets(filter);
|
||||||
|
|
||||||
|
if (assets == null || assets.Length <= 0) return false;
|
||||||
|
|
||||||
|
for (int i = 0; i < assets.Length; i++)
|
||||||
{
|
{
|
||||||
scenePartitionSO = scenePartition;
|
string path = AssetDatabase.GUIDToAssetPath(assets[i]);
|
||||||
return true;
|
ScenePartitionSO scenePartition = AssetDatabase.LoadAssetAtPath<ScenePartitionSO>(path);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
if (scenePartition == null) continue;
|
||||||
|
|
||||||
|
if (scenePartition.SceneName == activeScene.name)
|
||||||
|
{
|
||||||
|
scenePartitionSO = scenePartition;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ulong GetTargetObjectId(Object targetObject)
|
||||||
|
{
|
||||||
|
GlobalObjectId globalId = GlobalObjectId.GetGlobalObjectIdSlow(targetObject);
|
||||||
|
|
||||||
|
if (globalId.targetPrefabId == 0) // 0 = no prefab.
|
||||||
|
{
|
||||||
|
return globalId.targetObjectId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return globalId.targetPrefabId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
Copyright (c) 2023 Max Kruf
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
@ -1,2 +1,9 @@
|
|||||||
# template-unity-project
|
# Scene Partition
|
||||||
|
|
||||||
|
**One file per scene object** (in editor time).
|
||||||
|
|
||||||
|
Trying to reduce the overlap between users by splitting the scene data into multiple small files. This removes the need to save the entire scene into one file. Usually when working with multiple people on a level you have to lock the entire scene to prevent having to merge the conflicting changes. This approach tries to avoid that and if you have conflicting changes they are on small readable files which should be easier to merge.
|
||||||
|
|
||||||
|
Next to that an other tool is to put the scene objects into a grid to allow for **partial scene loading** (in editor time), this could be helpful when working on large scenes where you only want to test/work on a small portion. Keeping the editor fast and your work focused.
|
||||||
|
|
||||||
|
The scene data is stored outside of the asset folder to prevent Unity from importing many small files into the asset database, instead it is saved into a data folder located at `ProjectRoot/Data/ScenePartition`.
|
||||||
|
26
Runtime/ProfilerUtility.cs
Normal file
26
Runtime/ProfilerUtility.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Profiling;
|
||||||
|
|
||||||
|
namespace VertexColor.ScenePartition
|
||||||
|
{
|
||||||
|
public static class ProfilerUtility
|
||||||
|
{
|
||||||
|
public struct ProfilerScope : System.IDisposable
|
||||||
|
{
|
||||||
|
public ProfilerScope(string name)
|
||||||
|
{
|
||||||
|
Profiler.BeginSample(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProfilerScope(string name, Object target)
|
||||||
|
{
|
||||||
|
Profiler.BeginSample(name, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly void Dispose()
|
||||||
|
{
|
||||||
|
Profiler.EndSample();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Runtime/ProfilerUtility.cs.meta
Normal file
11
Runtime/ProfilerUtility.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7338cbb3bcd0a224fbfca184c7efcd7e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -5,15 +5,12 @@ namespace VertexColor.ScenePartition
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class SceneGrid
|
public class SceneGrid
|
||||||
{
|
{
|
||||||
[SerializeField]
|
|
||||||
public int cellSize = 10;
|
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private SceneGridDictionary grid = new SceneGridDictionary();
|
private SceneGridDictionary grid = new SceneGridDictionary();
|
||||||
|
|
||||||
public SceneGridDictionary Grid => grid;
|
public SceneGridDictionary Grid => grid;
|
||||||
|
|
||||||
public void Insert(ulong scenePartitionId, Vector3 point)
|
public void Insert(ulong scenePartitionId, Vector3 point, int cellSize)
|
||||||
{
|
{
|
||||||
int gridId = CalculateGridPosition(point, cellSize);
|
int gridId = CalculateGridPosition(point, cellSize);
|
||||||
if (grid.TryGetValue(gridId, out GridList ids))
|
if (grid.TryGetValue(gridId, out GridList ids))
|
||||||
|
Reference in New Issue
Block a user