This commit is contained in:
CortexCore 2024-11-16 15:45:30 +08:00
parent f446abaaaa
commit 99cf181bbe
29 changed files with 1707 additions and 353 deletions

View File

@ -26,14 +26,14 @@ MonoBehaviour:
m_SupportsHDR: 1
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 0.5
m_UpscalingFilter: 0
m_RenderScale: 0.6
m_UpscalingFilter: 3
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_EnableLODCrossFade: 1
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightRenderingMode: 0
m_MainLightShadowsSupported: 0
m_MainLightShadowmapResolution: 2048
m_AdditionalLightsRenderingMode: 1
@ -87,7 +87,7 @@ MonoBehaviour:
m_PrefilteringModeAdditionalLightShadows: 0
m_PrefilterXRKeywords: 1
m_PrefilteringModeForwardPlus: 0
m_PrefilteringModeDeferredRendering: 0
m_PrefilteringModeDeferredRendering: 2
m_PrefilteringModeScreenSpaceOcclusion: 0
m_PrefilterDebugKeywords: 1
m_PrefilterWriteRenderingLayers: 1

View File

@ -70,7 +70,7 @@ MonoBehaviour:
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 1
m_RenderingMode: 0
m_RenderingMode: 1
m_DepthPrimingMode: 0
m_CopyDepthMode: 1
m_AccurateGbufferNormals: 0

View File

@ -155,8 +155,10 @@ namespace Net.Like.Xue.Tokyo
serviceProvider.GetRequiredService<WorldHighlightService>();
serviceProvider.GetRequiredService<UXConsole>();
YooAssets.LoadAssetSync("MyShaderVariants").AssetObject.As<ShaderVariantCollection>().WarmUp();
Application.targetFrameRate = 90;
Application.targetFrameRate = 165;
await destroyCancellationToken.WaitUntilCanceled();
}

View File

@ -74224,171 +74224,6 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 8593860148783514979, guid: 41563a34cef49c741a3270fae6bc69cb, type: 3}
m_PrefabInstance: {fileID: 1109160867}
m_PrefabAsset: {fileID: 0}
--- !u!43 &1114106005
Mesh:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh-95304
serializedVersion: 11
m_SubMeshes:
- serializedVersion: 2
firstByte: 0
indexCount: 6
topology: 0
baseVertex: 0
firstVertex: 0
vertexCount: 4
localAABB:
m_Center: {x: -3.8750002, y: 3.5, z: -4.0856207e-13}
m_Extent: {x: 3.8750002, y: 3.5, z: 4.0856207e-13}
m_Shapes:
vertices: []
shapes: []
channels: []
fullWeights: []
m_BindPose: []
m_BoneNameHashes:
m_RootBoneNameHash: 0
m_BonesAABB: []
m_VariableBoneCountWeights:
m_Data:
m_MeshCompression: 0
m_IsReadable: 1
m_KeepVertices: 1
m_KeepIndices: 1
m_IndexFormat: 0
m_IndexBuffer: 000001000200010003000200
m_VertexData:
serializedVersion: 3
m_VertexCount: 4
m_Channels:
- stream: 0
offset: 0
format: 0
dimension: 3
- stream: 0
offset: 12
format: 0
dimension: 3
- stream: 0
offset: 24
format: 0
dimension: 4
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 40
format: 0
dimension: 2
- stream: 0
offset: 48
format: 0
dimension: 2
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
m_DataSize: 224
_typelessdata: 0100f8c00000e040000066ab00000000dbb6012a0000803f000080bf0000000000000000000080bf0100f8400000e04052d8a33ccf73633f0000f8c03a1ba131000040a88b3146a64992022a0000803f000080bf499202058b3146a6000080bf0000f8403a1ba1310bd7a33c86d8a33ce64ea6b40000e040000066ab8b3146a64992022a0000803f000080bf499202058b3146a6000080bfe64ea6340000e0401b467b3fcf73633f0000000047e0ccb0000000008b31c6a6b76d032a0000803f000080bfb76d83058b31c6a6000080bf0000008047e0ccb010467b3f0bd7a33c
m_CompressedMesh:
m_Vertices:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_UV:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Normals:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Tangents:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Weights:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_NormalSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_TangentSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_FloatColors:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_BoneIndices:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_Triangles:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_UVInfo: 0
m_LocalAABB:
m_Center: {x: -3.8750002, y: 3.5, z: -4.0856207e-13}
m_Extent: {x: 3.8750002, y: 3.5, z: 4.0856207e-13}
m_MeshUsageFlags: 0
m_CookingOptions: 30
m_BakedConvexCollisionMesh:
m_BakedTriangleCollisionMesh:
m_MeshMetrics[0]: 1
m_MeshMetrics[1]: 64.96373
m_MeshOptimizationFlags: 1
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
--- !u!1001 &1114121753
PrefabInstance:
m_ObjectHideFlags: 0
@ -174606,7 +174441,7 @@ MonoBehaviour:
mr: {fileID: 1741184046}
mfr: {fileID: 0}
mf: {fileID: 1741184045}
mesh: {fileID: 1114106005}
mesh: {fileID: 32445914}
mt:
e00: 0.9999999
e01: 0.00000004371134
@ -174698,7 +174533,7 @@ MonoBehaviour:
mr: {fileID: 1701228418}
mfr: {fileID: 0}
mf: {fileID: 1701228417}
mesh: {fileID: 1735121239}
mesh: {fileID: 159773858}
mt:
e00: -0.9999999
e01: -0.000000043711353
@ -190088,171 +189923,6 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 7308271106939098549, guid: 2ff27fe76960f7f48a86d74b01695041, type: 3}
m_PrefabInstance: {fileID: 1733597572}
m_PrefabAsset: {fileID: 0}
--- !u!43 &1735121239
Mesh:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh-95304(Clone)
serializedVersion: 11
m_SubMeshes:
- serializedVersion: 2
firstByte: 0
indexCount: 6
topology: 0
baseVertex: 0
firstVertex: 0
vertexCount: 4
localAABB:
m_Center: {x: -3.8750002, y: 3.5, z: -4.0856207e-13}
m_Extent: {x: 3.8750002, y: 3.5, z: 4.0856207e-13}
m_Shapes:
vertices: []
shapes: []
channels: []
fullWeights: []
m_BindPose: []
m_BoneNameHashes:
m_RootBoneNameHash: 0
m_BonesAABB: []
m_VariableBoneCountWeights:
m_Data:
m_MeshCompression: 0
m_IsReadable: 1
m_KeepVertices: 1
m_KeepIndices: 1
m_IndexFormat: 0
m_IndexBuffer: 000001000200010003000200
m_VertexData:
serializedVersion: 3
m_VertexCount: 4
m_Channels:
- stream: 0
offset: 0
format: 0
dimension: 3
- stream: 0
offset: 12
format: 0
dimension: 3
- stream: 0
offset: 24
format: 0
dimension: 4
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 40
format: 0
dimension: 2
- stream: 0
offset: 48
format: 0
dimension: 2
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
- stream: 0
offset: 0
format: 0
dimension: 0
m_DataSize: 224
_typelessdata: 0100f8c00000e040000066ab00000000dbb6012a0000803f000080bf0000000000000000000080bf0100f8400000e04052d8a33ccf73633f0000f8c03a1ba131000040a88b3146a64992022a0000803f000080bf499202058b3146a6000080bf0000f8403a1ba1310bd7a33c86d8a33ce64ea6b40000e040000066ab8b3146a64992022a0000803f000080bf499202058b3146a6000080bfe64ea6340000e0401b467b3fcf73633f0000000047e0ccb0000000008b31c6a6b76d032a0000803f000080bfb76d83058b31c6a6000080bf0000008047e0ccb010467b3f0bd7a33c
m_CompressedMesh:
m_Vertices:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_UV:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Normals:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Tangents:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_Weights:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_NormalSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_TangentSigns:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_FloatColors:
m_NumItems: 0
m_Range: 0
m_Start: 0
m_Data:
m_BitSize: 0
m_BoneIndices:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_Triangles:
m_NumItems: 0
m_Data:
m_BitSize: 0
m_UVInfo: 0
m_LocalAABB:
m_Center: {x: -3.8750002, y: 3.5, z: -4.0856207e-13}
m_Extent: {x: 3.8750002, y: 3.5, z: 4.0856207e-13}
m_MeshUsageFlags: 0
m_CookingOptions: 30
m_BakedConvexCollisionMesh:
m_BakedTriangleCollisionMesh:
m_MeshMetrics[0]: 1
m_MeshMetrics[1]: 64.96373
m_MeshOptimizationFlags: 1
m_StreamData:
serializedVersion: 2
offset: 0
size: 0
path:
--- !u!1001 &1735271354
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -64,7 +64,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 5dfbdea9b35b1b842a25de267120dc75, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:

View File

@ -64,7 +64,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 204058911901c7f4796e1f3e14e7d0e4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
@ -131,7 +131,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.7830188, g: 0.7830188, b: 0.7830188, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.7830188, g: 0.7830188, b: 0.7830188, a: 1}
- _EmissionColor: {r: 1.1317791, g: 1.1317791, b: 1.1317791, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -116,7 +116,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -52,7 +52,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 63bc2cc92a31cda4cbf7583d770c4565, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:

View File

@ -63,8 +63,8 @@ Material:
m_Scale: {x: 1.5, y: 1.5}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Texture: {fileID: 2800000, guid: a47aed59ca9724041b2364d4598511ca, type: 3}
m_Scale: {x: 1.5, y: 1.5}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
@ -130,7 +130,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.735849, g: 0.48940897, b: 0.4954689, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.735849, g: 0.4894089, b: 0.49546885, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -63,7 +63,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: aaba07b8516f6f34e97166378131e3e9, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
@ -130,7 +130,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 0.94376385, b: 0.8443396, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 0.94376385, b: 0.8443396, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -85,7 +85,20 @@ MonoBehaviour:
AssetTags:
UserData:
- CollectPath: Assets/Artists/Scenes/map_new_menu.unity
CollectorGUID: 8c62e11b988f2e24b8d8b6de309cc851
CollectorGUID:
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
FilterRuleName: CollectAll
AssetTags:
UserData:
- GroupName: Shader
GroupDesc:
AssetTags:
ActiveRuleName: EnableGroup
Collectors:
- CollectPath: Assets/MyShaderVariants.shadervariants
CollectorGUID: 71b6126421472534591856552abe3bdd
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory

View File

@ -0,0 +1,407 @@
{
"ShaderTotalCount": 17,
"VariantTotalCount": 42,
"ShaderVariantInfos": [
{
"AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader",
"ShaderName": "Universal Render Pipeline/Lit",
"ShaderVariantCount": 25,
"ShaderVariantElements": [
{
"PassType": 8,
"Keywords": [
""
]
},
{
"PassType": 8,
"Keywords": [
"_ALPHATEST_ON"
]
},
{
"PassType": 13,
"Keywords": [
""
]
},
{
"PassType": 13,
"Keywords": [
"EVALUATE_SH_VERTEX",
"_ADDITIONAL_LIGHTS"
]
},
{
"PassType": 13,
"Keywords": [
"EVALUATE_SH_VERTEX",
"_ADDITIONAL_LIGHTS",
"_ALPHAPREMULTIPLY_ON",
"_NORMALMAP",
"_SURFACE_TYPE_TRANSPARENT"
]
},
{
"PassType": 13,
"Keywords": [
"EVALUATE_SH_VERTEX",
"_ADDITIONAL_LIGHTS",
"_ALPHAPREMULTIPLY_ON",
"_SURFACE_TYPE_TRANSPARENT"
]
},
{
"PassType": 13,
"Keywords": [
"EVALUATE_SH_VERTEX",
"_ADDITIONAL_LIGHTS",
"_NORMALMAP"
]
},
{
"PassType": 13,
"Keywords": [
"EVALUATE_SH_VERTEX",
"_ADDITIONAL_LIGHTS",
"_NORMALMAP",
"_SURFACE_TYPE_TRANSPARENT"
]
},
{
"PassType": 13,
"Keywords": [
"EVALUATE_SH_VERTEX",
"_ADDITIONAL_LIGHTS",
"_SURFACE_TYPE_TRANSPARENT"
]
},
{
"PassType": 13,
"Keywords": [
"_ALPHATEST_ON"
]
},
{
"PassType": 13,
"Keywords": [
"_ALPHATEST_ON",
"_DETAIL_MULX2"
]
},
{
"PassType": 13,
"Keywords": [
"_ALPHATEST_ON",
"_DETAIL_MULX2",
"_NORMALMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_DETAIL_MULX2"
]
},
{
"PassType": 13,
"Keywords": [
"_DETAIL_MULX2",
"_EMISSION"
]
},
{
"PassType": 13,
"Keywords": [
"_DETAIL_MULX2",
"_METALLICSPECGLOSSMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_DETAIL_MULX2",
"_METALLICSPECGLOSSMAP",
"_NORMALMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_DETAIL_MULX2",
"_NORMALMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_EMISSION"
]
},
{
"PassType": 13,
"Keywords": [
"_EMISSION",
"_METALLICSPECGLOSSMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_EMISSION",
"_METALLICSPECGLOSSMAP",
"_NORMALMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_EMISSION",
"_NORMALMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_EMISSION",
"_RECEIVE_SHADOWS_OFF",
"_SPECULARHIGHLIGHTS_OFF"
]
},
{
"PassType": 13,
"Keywords": [
"_METALLICSPECGLOSSMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_METALLICSPECGLOSSMAP",
"_NORMALMAP"
]
},
{
"PassType": 13,
"Keywords": [
"_NORMALMAP"
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/BlitCopy",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Skybox/Procedural",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
"_SUNDISK_SIMPLE"
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Skybox/Panoramic",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/Internal-GUITextureClip",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/Internal-GUITextureClipText",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/Internal-GUITexture",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/Internal-GUITextureBlit",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/Internal-GUIRoundedRect",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/Internal-GUIRoundedRectWithColorPerBorder",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/Internal-UIRAtlasBlitCopy",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Resources/unity_builtin_extra",
"ShaderName": "Hidden/UIElements/EditorUIE",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/CopyDepth.shader",
"ShaderName": "Hidden/Universal Render Pipeline/CopyDepth",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/StencilDeferred.shader",
"ShaderName": "Hidden/Universal Render Pipeline/StencilDeferred",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
"_DEFERRED_FIRST_LIGHT"
]
}
]
},
{
"AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/FallbackError.shader",
"ShaderName": "Hidden/Universal Render Pipeline/FallbackError",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Packages/com.unity.render-pipelines.universal/Shaders/Utils/CoreBlit.shader",
"ShaderName": "Hidden/Universal/CoreBlit",
"ShaderVariantCount": 1,
"ShaderVariantElements": [
{
"PassType": 0,
"Keywords": [
""
]
}
]
},
{
"AssetPath": "Assets/Arts/Fantasy Adventure Environment/Shaders/URP/FAE_Foliage.shadergraph",
"ShaderName": "Universal Render Pipeline/FAE/FAE_Foliage",
"ShaderVariantCount": 2,
"ShaderVariantElements": [
{
"PassType": 8,
"Keywords": [
"PROCEDURAL_INSTANCING_ON"
]
},
{
"PassType": 13,
"Keywords": [
""
]
}
]
}
]
}

View File

@ -0,0 +1,146 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!200 &20000000
ShaderVariantCollection:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Assets/MyShaderVariants.shadervariants
m_Shaders:
- first: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
second:
variants:
- keywords:
passType: 8
- keywords: _ALPHATEST_ON
passType: 8
- keywords:
passType: 13
- keywords: EVALUATE_SH_VERTEX _ADDITIONAL_LIGHTS
passType: 13
- keywords: EVALUATE_SH_VERTEX _ADDITIONAL_LIGHTS _ALPHAPREMULTIPLY_ON _NORMALMAP
_SURFACE_TYPE_TRANSPARENT
passType: 13
- keywords: EVALUATE_SH_VERTEX _ADDITIONAL_LIGHTS _ALPHAPREMULTIPLY_ON _SURFACE_TYPE_TRANSPARENT
passType: 13
- keywords: EVALUATE_SH_VERTEX _ADDITIONAL_LIGHTS _NORMALMAP
passType: 13
- keywords: EVALUATE_SH_VERTEX _ADDITIONAL_LIGHTS _NORMALMAP _SURFACE_TYPE_TRANSPARENT
passType: 13
- keywords: EVALUATE_SH_VERTEX _ADDITIONAL_LIGHTS _SURFACE_TYPE_TRANSPARENT
passType: 13
- keywords: _ALPHATEST_ON
passType: 13
- keywords: _ALPHATEST_ON _DETAIL_MULX2
passType: 13
- keywords: _ALPHATEST_ON _DETAIL_MULX2 _NORMALMAP
passType: 13
- keywords: _DETAIL_MULX2
passType: 13
- keywords: _DETAIL_MULX2 _EMISSION
passType: 13
- keywords: _DETAIL_MULX2 _METALLICSPECGLOSSMAP
passType: 13
- keywords: _DETAIL_MULX2 _METALLICSPECGLOSSMAP _NORMALMAP
passType: 13
- keywords: _DETAIL_MULX2 _NORMALMAP
passType: 13
- keywords: _EMISSION
passType: 13
- keywords: _EMISSION _METALLICSPECGLOSSMAP
passType: 13
- keywords: _EMISSION _METALLICSPECGLOSSMAP _NORMALMAP
passType: 13
- keywords: _EMISSION _NORMALMAP
passType: 13
- keywords: _EMISSION _RECEIVE_SHADOWS_OFF _SPECULARHIGHLIGHTS_OFF
passType: 13
- keywords: _METALLICSPECGLOSSMAP
passType: 13
- keywords: _METALLICSPECGLOSSMAP _NORMALMAP
passType: 13
- keywords: _NORMALMAP
passType: 13
- first: {fileID: 66, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 106, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords: _SUNDISK_SIMPLE
passType: 0
- first: {fileID: 108, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9000, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9001, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9002, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9003, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9004, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9007, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9101, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 9103, guid: 0000000000000000f000000000000000, type: 0}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
second:
variants:
- keywords: _DEFERRED_FIRST_LIGHT
passType: 0
- first: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
second:
variants:
- keywords:
passType: 0
- first: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
second:
variants:
- keywords:
passType: 0
- first: {fileID: -6465566751694194690, guid: dc1a634184354e343a9a36dd032cf2bf, type: 3}
second:
variants:
- keywords: PROCEDURAL_INSTANCING_ON
passType: 8
- keywords:
passType: 13

View File

@ -0,0 +1 @@
{"androidStore":"GooglePlay"}

View File

@ -0,0 +1,50 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using YooAsset.Editor;
[DisplayName("打包特效纹理(自定义)")]
public class PackEffectTexture : IPackRule
{
private const string PackDirectory = "Assets/Effect/Textures/";
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
{
string assetPath = data.AssetPath;
if (assetPath.StartsWith(PackDirectory) == false)
throw new Exception($"Only support folder : {PackDirectory}");
string assetName = Path.GetFileName(assetPath).ToLower();
string firstChar = assetName.Substring(0, 1);
string bundleName = $"{PackDirectory}effect_texture_{firstChar}";
var packRuleResult = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
return packRuleResult;
}
}
[DisplayName("打包视频(自定义)")]
public class PackVideo : IPackRule
{
public PackRuleResult GetPackRuleResult(PackRuleData data)
{
string bundleName = RemoveExtension(data.AssetPath);
string fileExtension = Path.GetExtension(data.AssetPath);
fileExtension = fileExtension.Remove(0, 1);
PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
return result;
}
private string RemoveExtension(string str)
{
if (string.IsNullOrEmpty(str))
return str;
int index = str.LastIndexOf(".");
if (index == -1)
return str;
else
return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test"
}
}

View File

@ -0,0 +1,138 @@
using System.IO;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
namespace YooAsset.Editor
{
public class PackageComparatorWindow : EditorWindow
{
static PackageComparatorWindow _thisInstance;
[MenuItem("Tools/补丁包比对工具", false, 102)]
static void ShowWindow()
{
if (_thisInstance == null)
{
_thisInstance = EditorWindow.GetWindow(typeof(PackageComparatorWindow), false, "补丁包比对工具", true) as PackageComparatorWindow;
_thisInstance.minSize = new Vector2(800, 600);
}
_thisInstance.Show();
}
private string _manifestPath1 = string.Empty;
private string _manifestPath2 = string.Empty;
private readonly List<PackageBundle> _changeList = new List<PackageBundle>();
private readonly List<PackageBundle> _newList = new List<PackageBundle>();
private Vector2 _scrollPos1;
private Vector2 _scrollPos2;
private void OnGUI()
{
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("选择补丁包1", GUILayout.MaxWidth(150)))
{
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
if (string.IsNullOrEmpty(resultPath))
return;
_manifestPath1 = resultPath;
}
EditorGUILayout.LabelField(_manifestPath1);
EditorGUILayout.EndHorizontal();
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("选择补丁包2", GUILayout.MaxWidth(150)))
{
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
if (string.IsNullOrEmpty(resultPath))
return;
_manifestPath2 = resultPath;
}
EditorGUILayout.LabelField(_manifestPath2);
EditorGUILayout.EndHorizontal();
if (string.IsNullOrEmpty(_manifestPath1) == false && string.IsNullOrEmpty(_manifestPath2) == false)
{
if (GUILayout.Button("比对差异", GUILayout.MaxWidth(150)))
{
ComparePackage(_changeList, _newList);
}
}
EditorGUILayout.Space();
using (new EditorGUI.DisabledScope(false))
{
int totalCount = _changeList.Count;
EditorGUILayout.Foldout(true, $"差异列表 ( {totalCount} )");
EditorGUI.indentLevel = 1;
_scrollPos1 = EditorGUILayout.BeginScrollView(_scrollPos1);
{
foreach (var bundle in _changeList)
{
EditorGUILayout.LabelField($"{bundle.BundleName} | {(bundle.FileSize / 1024)}K");
}
}
EditorGUILayout.EndScrollView();
EditorGUI.indentLevel = 0;
}
EditorGUILayout.Space();
using (new EditorGUI.DisabledScope(false))
{
int totalCount = _newList.Count;
EditorGUILayout.Foldout(true, $"新增列表 ( {totalCount} )");
EditorGUI.indentLevel = 1;
_scrollPos2 = EditorGUILayout.BeginScrollView(_scrollPos2);
{
foreach (var bundle in _newList)
{
EditorGUILayout.LabelField($"{bundle.BundleName}");
}
}
EditorGUILayout.EndScrollView();
EditorGUI.indentLevel = 0;
}
}
private void ComparePackage(List<PackageBundle> changeList, List<PackageBundle> newList)
{
changeList.Clear();
newList.Clear();
// 加载补丁清单1
byte[] bytesData1 = FileUtility.ReadAllBytes(_manifestPath1);
PackageManifest manifest1 = ManifestTools.DeserializeFromBinary(bytesData1);
// 加载补丁清单1
byte[] bytesData2 = FileUtility.ReadAllBytes(_manifestPath2);
PackageManifest manifest2 = ManifestTools.DeserializeFromBinary(bytesData2);
// 拷贝文件列表
foreach (var bundle2 in manifest2.BundleList)
{
if (manifest1.TryGetPackageBundleByBundleName(bundle2.BundleName, out PackageBundle bundle1))
{
if (bundle2.FileHash != bundle1.FileHash)
{
changeList.Add(bundle2);
}
}
else
{
newList.Add(bundle2);
}
}
// 按字母重新排序
changeList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
newList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
Debug.Log("资源包差异比对完成!");
}
}
}

View File

@ -0,0 +1,91 @@
using System.IO;
using UnityEngine;
using UnityEditor;
namespace YooAsset.Editor
{
public class PackageImporterWindow : EditorWindow
{
static PackageImporterWindow _thisInstance;
[MenuItem("Tools/补丁包导入工具", false, 101)]
static void ShowWindow()
{
if (_thisInstance == null)
{
_thisInstance = EditorWindow.GetWindow(typeof(PackageImporterWindow), false, "补丁包导入工具", true) as PackageImporterWindow;
_thisInstance.minSize = new Vector2(800, 600);
}
_thisInstance.Show();
}
private string _manifestPath = string.Empty;
private string _packageName = "DefaultPackage";
private void OnGUI()
{
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("选择补丁包", GUILayout.MaxWidth(150)))
{
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
if (string.IsNullOrEmpty(resultPath))
return;
_manifestPath = resultPath;
}
EditorGUILayout.LabelField(_manifestPath);
EditorGUILayout.EndHorizontal();
if (string.IsNullOrEmpty(_manifestPath) == false)
{
if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150)))
{
string streamingAssetsRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
EditorTools.ClearFolder(streamingAssetsRoot);
CopyPackageFiles(_manifestPath);
}
}
}
private void CopyPackageFiles(string manifestFilePath)
{
string manifestFileName = Path.GetFileNameWithoutExtension(manifestFilePath);
string outputDirectory = Path.GetDirectoryName(manifestFilePath);
// 加载补丁清单
byte[] bytesData = FileUtility.ReadAllBytes(manifestFilePath);
PackageManifest manifest = ManifestTools.DeserializeFromBinary(bytesData);
// 拷贝核心文件
{
string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes";
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.bytes";
EditorTools.CopyFile(sourcePath, destPath, true);
}
{
string sourcePath = $"{outputDirectory}/{manifestFileName}.hash";
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.hash";
EditorTools.CopyFile(sourcePath, destPath, true);
}
{
string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName);
string sourcePath = $"{outputDirectory}/{fileName}";
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{fileName}";
EditorTools.CopyFile(sourcePath, destPath, true);
}
// 拷贝文件列表
int fileCount = 0;
foreach (var packageBundle in manifest.BundleList)
{
fileCount++;
string sourcePath = $"{outputDirectory}/{packageBundle.FileName}";
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{packageBundle.FileName}";
EditorTools.CopyFile(sourcePath, destPath, true);
}
Debug.Log($"补丁包拷贝完成,一共拷贝了{fileCount}个资源文件");
AssetDatabase.Refresh();
}
}
}

View File

@ -0,0 +1,38 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
using YooAsset.Editor;
public static class ShaderVariantCollectionHelper
{
public static void ClearCurrentShaderVariantCollection()
{
EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "ClearCurrentShaderVariantCollection");
}
public static void SaveCurrentShaderVariantCollection(string savePath)
{
EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "SaveCurrentShaderVariantCollection", savePath);
}
public static int GetCurrentShaderVariantCollectionShaderCount()
{
return (int)EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetCurrentShaderVariantCollectionShaderCount");
}
public static int GetCurrentShaderVariantCollectionVariantCount()
{
return (int)EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetCurrentShaderVariantCollectionVariantCount");
}
/// <summary>
/// 获取着色器的变种总数量
/// </summary>
public static string GetShaderVariantCount(string assetPath)
{
Shader shader = AssetDatabase.LoadAssetAtPath<Shader>(assetPath);
var variantCount = EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetVariantCount", shader, true);
return variantCount.ToString();
}
}

View File

@ -0,0 +1,146 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEditor;
[Serializable]
public class ShaderVariantCollectionManifest
{
[Serializable]
public class ShaderVariantElement
{
/// <summary>
/// Pass type to use in this variant.
/// </summary>
public PassType PassType;
/// <summary>
/// Array of shader keywords to use in this variant.
/// </summary>
public string[] Keywords;
}
[Serializable]
public class ShaderVariantInfo
{
/// <summary>
/// 着色器资源路径.
/// </summary>
public string AssetPath;
/// <summary>
/// 着色器名称
/// </summary>
public string ShaderName;
/// <summary>
/// 着色器变种总数
/// </summary>
public int ShaderVariantCount = 0;
/// <summary>
/// 着色器变种列表
/// </summary>
public List<ShaderVariantElement> ShaderVariantElements = new List<ShaderVariantElement>(1000);
}
/// <summary>
/// Number of shaders in this collection
/// </summary>
public int ShaderTotalCount;
/// <summary>
/// Number of total varians in this collection
/// </summary>
public int VariantTotalCount;
/// <summary>
/// Shader variants info list.
/// </summary>
public List<ShaderVariantInfo> ShaderVariantInfos = new List<ShaderVariantInfo>(1000);
/// <summary>
/// 添加着色器变种信息
/// </summary>
public void AddShaderVariant(string assetPath, string shaderName, PassType passType, string[] keywords)
{
var info = GetOrCreateShaderVariantInfo(assetPath, shaderName);
ShaderVariantElement element = new ShaderVariantElement();
element.PassType = passType;
element.Keywords = keywords;
info.ShaderVariantElements.Add(element);
info.ShaderVariantCount++;
}
private ShaderVariantInfo GetOrCreateShaderVariantInfo(string assetPath, string shaderName)
{
var selectList = ShaderVariantInfos.Where(t => t.ShaderName == shaderName && t.AssetPath == assetPath).ToList();
if (selectList.Count == 0)
{
ShaderVariantInfo newInfo = new ShaderVariantInfo();
newInfo.AssetPath = assetPath;
newInfo.ShaderName = shaderName;
ShaderVariantInfos.Add(newInfo);
return newInfo;
}
if (selectList.Count != 1)
throw new Exception("Should never get here !");
return selectList[0];
}
/// <summary>
/// 解析SVC文件并将数据写入到清单
/// </summary>
public static ShaderVariantCollectionManifest Extract(ShaderVariantCollection svc)
{
var manifest = new ShaderVariantCollectionManifest();
manifest.ShaderTotalCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount();
manifest.VariantTotalCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionVariantCount();
using (var so = new SerializedObject(svc))
{
var shaderArray = so.FindProperty("m_Shaders.Array");
if (shaderArray != null && shaderArray.isArray)
{
for (int i = 0; i < shaderArray.arraySize; ++i)
{
var shaderRef = shaderArray.FindPropertyRelative($"data[{i}].first");
var shaderVariantsArray = shaderArray.FindPropertyRelative($"data[{i}].second.variants");
if (shaderRef != null && shaderRef.propertyType == SerializedPropertyType.ObjectReference && shaderVariantsArray != null && shaderVariantsArray.isArray)
{
var shader = shaderRef.objectReferenceValue as Shader;
if (shader == null)
{
throw new Exception("Invalid shader in ShaderVariantCollection file.");
}
string shaderAssetPath = AssetDatabase.GetAssetPath(shader);
string shaderName = shader.name;
// 添加变种信息
for (int j = 0; j < shaderVariantsArray.arraySize; ++j)
{
var propKeywords = shaderVariantsArray.FindPropertyRelative($"Array.data[{j}].keywords");
var propPassType = shaderVariantsArray.FindPropertyRelative($"Array.data[{j}].passType");
if (propKeywords != null && propPassType != null && propKeywords.propertyType == SerializedPropertyType.String)
{
string[] keywords = propKeywords.stringValue.Split(' ');
PassType pathType = (PassType)propPassType.intValue;
manifest.AddShaderVariant(shaderAssetPath, shaderName, pathType, keywords);
}
}
}
}
}
}
return manifest;
}
}

View File

@ -0,0 +1,256 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using YooAsset.Editor;
using Debug = UnityEngine.Debug;
public static class ShaderVariantCollector
{
private enum ESteps
{
None,
Prepare,
CollectAllMaterial,
CollectVariants,
CollectSleeping,
WaitingDone,
}
private const float WaitMilliseconds = 1000f;
private const float SleepMilliseconds = 100f;
private static string _savePath;
private static string _packageName;
private static int _processMaxNum;
private static Action _completedCallback;
private static ESteps _steps = ESteps.None;
private static Stopwatch _elapsedTime;
private static List<string> _allMaterials;
private static List<GameObject> _allSpheres = new List<GameObject>(1000);
/// <summary>
/// 开始收集
/// </summary>
public static void Run(string savePath, string packageName, int processMaxNum, Action completedCallback)
{
if (_steps != ESteps.None)
return;
if (Path.HasExtension(savePath) == false)
savePath = $"{savePath}.shadervariants";
if (Path.GetExtension(savePath) != ".shadervariants")
throw new System.Exception("Shader variant file extension is invalid.");
if (string.IsNullOrEmpty(packageName))
throw new System.Exception("Package name is null or empty !");
// 注意先删除再保存否则ShaderVariantCollection内容将无法及时刷新
AssetDatabase.DeleteAsset(savePath);
EditorTools.CreateFileDirectory(savePath);
_savePath = savePath;
_packageName = packageName;
_processMaxNum = processMaxNum;
_completedCallback = completedCallback;
// 聚焦到游戏窗口
EditorTools.FocusUnityGameWindow();
// 创建临时测试场景
CreateTempScene();
_steps = ESteps.Prepare;
EditorApplication.update += EditorUpdate;
}
private static void EditorUpdate()
{
if (_steps == ESteps.None)
return;
if (_steps == ESteps.Prepare)
{
ShaderVariantCollectionHelper.ClearCurrentShaderVariantCollection();
_steps = ESteps.CollectAllMaterial;
return; //等待一帧
}
if (_steps == ESteps.CollectAllMaterial)
{
_allMaterials = GetAllMaterials();
_steps = ESteps.CollectVariants;
return; //等待一帧
}
if (_steps == ESteps.CollectVariants)
{
int count = Mathf.Min(_processMaxNum, _allMaterials.Count);
List<string> range = _allMaterials.GetRange(0, count);
_allMaterials.RemoveRange(0, count);
CollectVariants(range);
if (_allMaterials.Count > 0)
{
_elapsedTime = Stopwatch.StartNew();
_steps = ESteps.CollectSleeping;
}
else
{
_elapsedTime = Stopwatch.StartNew();
_steps = ESteps.WaitingDone;
}
}
if (_steps == ESteps.CollectSleeping)
{
if (_elapsedTime.ElapsedMilliseconds > SleepMilliseconds)
{
DestroyAllSpheres();
_elapsedTime.Stop();
_steps = ESteps.CollectVariants;
}
}
if (_steps == ESteps.WaitingDone)
{
// 注意:一定要延迟保存才会起效
if (_elapsedTime.ElapsedMilliseconds > WaitMilliseconds)
{
_elapsedTime.Stop();
_steps = ESteps.None;
// 保存结果并创建清单
ShaderVariantCollectionHelper.SaveCurrentShaderVariantCollection(_savePath);
CreateManifest();
Debug.Log($"搜集SVC完毕");
EditorApplication.update -= EditorUpdate;
_completedCallback?.Invoke();
}
}
}
private static void CreateTempScene()
{
EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
}
private static List<string> GetAllMaterials()
{
int progressValue = 0;
List<string> allAssets = new List<string>(1000);
// 获取所有打包的资源
CollectResult collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(EBuildMode.DryRunBuild, _packageName);
foreach (var assetInfo in collectResult.CollectAssets)
{
string[] depends = AssetDatabase.GetDependencies(assetInfo.AssetInfo.AssetPath, true);
foreach (var dependAsset in depends)
{
if (allAssets.Contains(dependAsset) == false)
allAssets.Add(dependAsset);
}
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, collectResult.CollectAssets.Count);
}
EditorTools.ClearProgressBar();
// 搜集所有材质球
progressValue = 0;
List<string> allMaterial = new List<string>(1000);
foreach (var assetPath in allAssets)
{
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
if (assetType == typeof(UnityEngine.Material))
{
allMaterial.Add(assetPath);
}
EditorTools.DisplayProgressBar("搜集所有材质球", ++progressValue, allAssets.Count);
}
EditorTools.ClearProgressBar();
// 返回结果
return allMaterial;
}
private static void CollectVariants(List<string> materials)
{
Camera camera = Camera.main;
if (camera == null)
throw new System.Exception("Not found main camera.");
// 设置主相机
float aspect = camera.aspect;
int totalMaterials = materials.Count;
float height = Mathf.Sqrt(totalMaterials / aspect) + 1;
float width = Mathf.Sqrt(totalMaterials / aspect) * aspect + 1;
float halfHeight = Mathf.CeilToInt(height / 2f);
float halfWidth = Mathf.CeilToInt(width / 2f);
camera.orthographic = true;
camera.orthographicSize = halfHeight;
camera.transform.position = new Vector3(0f, 0f, -10f);
// 创建测试球体
int xMax = (int)(width - 1);
int x = 0, y = 0;
int progressValue = 0;
for (int i = 0; i < materials.Count; i++)
{
var material = materials[i];
var position = new Vector3(x - halfWidth + 1f, y - halfHeight + 1f, 0f);
var go = CreateSphere(material, position, i);
if (go != null)
_allSpheres.Add(go);
if (x == xMax)
{
x = 0;
y++;
}
else
{
x++;
}
EditorTools.DisplayProgressBar("照射所有材质球", ++progressValue, materials.Count);
}
EditorTools.ClearProgressBar();
}
private static GameObject CreateSphere(string assetPath, Vector3 position, int index)
{
var material = AssetDatabase.LoadAssetAtPath<Material>(assetPath);
var shader = material.shader;
if (shader == null)
return null;
var go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
go.GetComponent<Renderer>().sharedMaterial = material;
go.transform.position = position;
go.name = $"Sphere_{index} | {material.name}";
return go;
}
private static void DestroyAllSpheres()
{
foreach (var go in _allSpheres)
{
GameObject.DestroyImmediate(go);
}
_allSpheres.Clear();
// 尝试释放编辑器加载的资源
EditorUtility.UnloadUnusedAssetsImmediate(true);
}
private static void CreateManifest()
{
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
ShaderVariantCollection svc = AssetDatabase.LoadAssetAtPath<ShaderVariantCollection>(_savePath);
if (svc != null)
{
var wrapper = ShaderVariantCollectionManifest.Extract(svc);
string jsonData = JsonUtility.ToJson(wrapper, true);
string savePath = _savePath.Replace(".shadervariants", ".json");
File.WriteAllText(savePath, jsonData);
}
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
}
}

View File

@ -0,0 +1,29 @@
using UnityEngine;
using UnityEditor;
public class ShaderVariantCollectorSetting : ScriptableObject
{
private const string DefaultSavePath = "Assets/MyShaderVariants.shadervariants";
public static string GeFileSavePath(string packageName)
{
string key = $"{Application.productName}_{packageName}_GeFileSavePath";
return EditorPrefs.GetString(key, DefaultSavePath);
}
public static void SetFileSavePath(string packageName, string savePath)
{
string key = $"{Application.productName}_{packageName}_GeFileSavePath";
EditorPrefs.SetString(key, savePath);
}
public static int GeProcessCapacity(string packageName)
{
string key = $"{Application.productName}_{packageName}_GeProcessCapacity";
return EditorPrefs.GetInt(key, 1000);
}
public static void SetProcessCapacity(string packageName, int capacity)
{
string key = $"{Application.productName}_{packageName}_GeProcessCapacity";
EditorPrefs.SetInt(key, capacity);
}
}

View File

@ -0,0 +1,150 @@
#if UNITY_2019_4_OR_NEWER
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
using YooAsset.Editor;
public class ShaderVariantCollectorWindow : EditorWindow
{
[MenuItem("Tools/着色器变种收集器", false, 100)]
public static void OpenWindow()
{
ShaderVariantCollectorWindow window = GetWindow<ShaderVariantCollectorWindow>("着色器变种收集工具", true);
window.minSize = new Vector2(800, 600);
}
private Button _collectButton;
private TextField _collectOutputField;
private Label _currentShaderCountField;
private Label _currentVariantCountField;
private SliderInt _processCapacitySlider;
private PopupField<string> _packageField;
private List<string> _packageNames;
private string _currentPackageName;
public void CreateGUI()
{
try
{
VisualElement root = this.rootVisualElement;
// 加载布局文件
var visualAsset = UxmlLoader.LoadWindowUXML<ShaderVariantCollectorWindow>();
if (visualAsset == null)
return;
visualAsset.CloneTree(root);
// 包裹名称列表
_packageNames = GetBuildPackageNames();
_currentPackageName = _packageNames[0];
// 文件输出目录
_collectOutputField = root.Q<TextField>("CollectOutput");
_collectOutputField.SetValueWithoutNotify(ShaderVariantCollectorSetting.GeFileSavePath(_currentPackageName));
_collectOutputField.RegisterValueChangedCallback(evt =>
{
ShaderVariantCollectorSetting.SetFileSavePath(_currentPackageName, _collectOutputField.value);
});
// 收集的包裹
var packageContainer = root.Q("PackageContainer");
if (_packageNames.Count > 0)
{
int defaultIndex = GetDefaultPackageIndex(_currentPackageName);
_packageField = new PopupField<string>(_packageNames, defaultIndex);
_packageField.label = "Package";
_packageField.style.width = 350;
_packageField.RegisterValueChangedCallback(evt =>
{
_currentPackageName = _packageField.value;
});
packageContainer.Add(_packageField);
}
else
{
_packageField = new PopupField<string>();
_packageField.label = "Package";
_packageField.style.width = 350;
packageContainer.Add(_packageField);
}
// 容器值
_processCapacitySlider = root.Q<SliderInt>("ProcessCapacity");
_processCapacitySlider.SetValueWithoutNotify(ShaderVariantCollectorSetting.GeProcessCapacity(_currentPackageName));
#if !UNITY_2020_3_OR_NEWER
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
_processCapacitySlider.RegisterValueChangedCallback(evt =>
{
ShaderVariantCollectorSetting.SetProcessCapacity(_currentPackageName, _processCapacitySlider.value);
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
});
#else
_processCapacitySlider.RegisterValueChangedCallback(evt =>
{
ShaderVariantCollectorSetting.SetProcessCapacity(_currentPackageName, _processCapacitySlider.value);
});
#endif
_currentShaderCountField = root.Q<Label>("CurrentShaderCount");
_currentVariantCountField = root.Q<Label>("CurrentVariantCount");
// 变种收集按钮
_collectButton = root.Q<Button>("CollectButton");
_collectButton.clicked += CollectButton_clicked;
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}
}
private void Update()
{
if (_currentShaderCountField != null)
{
int currentShaderCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount();
_currentShaderCountField.text = $"Current Shader Count : {currentShaderCount}";
}
if (_currentVariantCountField != null)
{
int currentVariantCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionVariantCount();
_currentVariantCountField.text = $"Current Variant Count : {currentVariantCount}";
}
}
private void CollectButton_clicked()
{
string savePath = ShaderVariantCollectorSetting.GeFileSavePath(_currentPackageName);
int processCapacity = _processCapacitySlider.value;
ShaderVariantCollector.Run(savePath, _currentPackageName, processCapacity, null);
}
// 构建包裹相关
private int GetDefaultPackageIndex(string packageName)
{
for (int index = 0; index < _packageNames.Count; index++)
{
if (_packageNames[index] == packageName)
{
return index;
}
}
return 0;
}
private List<string> GetBuildPackageNames()
{
List<string> result = new List<string>();
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
{
result.Add(package.PackageName);
}
return result;
}
}
#endif

View File

@ -0,0 +1,11 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;" />
<ui:VisualElement name="CollectContainer">
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" style="height: 22px;" />
<ui:VisualElement name="PackageContainer" style="height: 24px;" />
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" style="height: 20px; padding-left: 4px;" />
<ui:Label text="Current Variant Count" display-tooltip-when-elided="true" name="CurrentVariantCount" style="height: 20px; padding-left: 4px;" />
<ui:SliderInt picking-mode="Ignore" label="Capacity" value="9999" high-value="1000" name="ProcessCapacity" low-value="10" show-input-field="true" />
<ui:Button text="开始搜集" display-tooltip-when-elided="true" name="CollectButton" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
</ui:VisualElement>
</ui:UXML>

View File

@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
public static class AssetOperationHandleExtension
{
/// <summary>
/// 等待异步执行完毕
/// </summary>
public static AssetHandle WaitForAsyncOperationComplete(this AssetHandle thisHandle)
{
thisHandle.WaitForAsyncComplete();
return thisHandle;
}
}

View File

@ -0,0 +1,73 @@
using UnityEngine;
using YooAsset;
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(GameObjectAssetReference), true)]
public class GameObjectAssetReferenceInspector : UnityEditor.Editor
{
private bool _init = false;
private GameObject _cacheObject;
public override void OnInspectorGUI()
{
GameObjectAssetReference mono = (GameObjectAssetReference)target;
if (_init == false)
{
_init = true;
if (string.IsNullOrEmpty(mono.AssetGUID) == false)
{
string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(mono.AssetGUID);
if (string.IsNullOrEmpty(assetPath) == false)
{
_cacheObject = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
}
}
}
GameObject go = (GameObject)UnityEditor.EditorGUILayout.ObjectField(_cacheObject, typeof(GameObject), false);
if (go != _cacheObject)
{
_cacheObject = go;
string assetPath = UnityEditor.AssetDatabase.GetAssetPath(go);
mono.AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
UnityEditor.EditorUtility.SetDirty(target);
}
UnityEditor.EditorGUILayout.LabelField("Asset GUID", mono.AssetGUID);
}
}
#endif
public class GameObjectAssetReference : MonoBehaviour
{
[HideInInspector]
public string AssetGUID = "";
private AssetHandle _handle;
public void Start()
{
var package = YooAssets.GetPackage("DefaultPackage");
var assetInfo = package.GetAssetInfoByGUID(AssetGUID);
_handle = package.LoadAssetAsync(assetInfo);
_handle.Completed += Handle_Completed;
}
public void OnDestroy()
{
if (_handle != null)
{
_handle.Release();
_handle = null;
}
}
private void Handle_Completed(AssetHandle handle)
{
if (handle.Status == EOperationStatus.Succeed)
{
handle.InstantiateSync(this.transform);
}
}
}

View File

@ -0,0 +1,117 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
public class LoadAssetsByTagOperation<TObject> : GameAsyncOperation where TObject : UnityEngine.Object
{
private enum ESteps
{
None,
LoadAssets,
CheckResult,
Done,
}
private readonly string _tag;
private ESteps _steps = ESteps.None;
private List<AssetHandle> _handles;
/// <summary>
/// 资源对象集合
/// </summary>
public List<TObject> AssetObjects { private set; get; }
public LoadAssetsByTagOperation(string tag)
{
_tag = tag;
}
protected override void OnStart()
{
_steps = ESteps.LoadAssets;
}
protected override void OnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadAssets)
{
AssetInfo[] assetInfos = YooAssets.GetAssetInfos(_tag);
_handles = new List<AssetHandle>(assetInfos.Length);
foreach (var assetInfo in assetInfos)
{
var handle = YooAssets.LoadAssetAsync(assetInfo);
_handles.Add(handle);
}
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
int index = 0;
foreach (var handle in _handles)
{
if (handle.IsDone == false)
{
Progress = (float)index / _handles.Count;
return;
}
index++;
}
AssetObjects = new List<TObject>(_handles.Count);
foreach (var handle in _handles)
{
if (handle.Status == EOperationStatus.Succeed)
{
var assetObject = handle.AssetObject as TObject;
if (assetObject != null)
{
AssetObjects.Add(assetObject);
}
else
{
string error = $"资源类型转换失败:{handle.AssetObject.name}";
Debug.LogError($"{error}");
AssetObjects.Clear();
SetFinish(false, error);
return;
}
}
else
{
Debug.LogError($"{handle.LastError}");
AssetObjects.Clear();
SetFinish(false, handle.LastError);
return;
}
}
SetFinish(true);
}
}
protected override void OnAbort()
{
}
private void SetFinish(bool succeed, string error = "")
{
Error = error;
Status = succeed ? EOperationStatus.Succeed : EOperationStatus.Failed;
_steps = ESteps.Done;
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void ReleaseHandle()
{
foreach (var handle in _handles)
{
handle.Release();
}
_handles.Clear();
}
}

View File

@ -139,7 +139,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 0.58
bundleVersion: 0.61
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0

View File

@ -33,7 +33,7 @@ QualitySettings:
lodBias: 0.3
maximumLODLevel: 0
enableLODCrossFade: 1
streamingMipmapsActive: 0
streamingMipmapsActive: 1
streamingMipmapsAddAllCameras: 1
streamingMipmapsMemoryBudget: 512
streamingMipmapsRenderersPerFrame: 512

View File

@ -4,7 +4,7 @@
UnityConnectSettings:
m_ObjectHideFlags: 0
serializedVersion: 1
m_Enabled: 0
m_Enabled: 1
m_TestMode: 0
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
@ -23,7 +23,7 @@ UnityConnectSettings:
m_Enabled: 0
m_TestMode: 0
m_InitializeOnStartup: 1
m_PackageRequiringCoreStatsPresent: 0
m_PackageRequiringCoreStatsPresent: 1
UnityAdsSettings:
m_Enabled: 0
m_InitializeOnStartup: 1