@@ -10,25 +10,32 @@ namespace UnityEditor.Rendering
1010{
1111 static class SurfaceCacheStripperUtility
1212 {
13- static bool IsSurfaceCacheEnabled ( List < UniversalRenderPipelineAsset > urpAssets )
13+ static bool IsSurfaceCacheEnabled ( UniversalRenderPipelineAsset urpAsset )
1414 {
15- foreach ( var urpAssetForBuild in urpAssets )
15+ foreach ( var rendererData in urpAsset . m_RendererDataList )
1616 {
17- foreach ( var rendererData in urpAssetForBuild . m_RendererDataList )
17+ if ( rendererData is not UniversalRendererData )
18+ continue ;
19+
20+ foreach ( var rendererFeature in rendererData . rendererFeatures )
1821 {
19- if ( rendererData is not UniversalRendererData )
20- continue ;
21-
22- foreach ( var rendererFeature in rendererData . rendererFeatures )
23- {
24- if ( rendererFeature is SurfaceCacheGIRendererFeature { isActive : true } )
25- return true ;
26- }
22+ if ( rendererFeature is SurfaceCacheGIRendererFeature { isActive : true } )
23+ return true ;
2724 }
2825 }
2926 return false ;
3027 }
3128
29+ static bool IsSurfaceCacheEnabled ( List < UniversalRenderPipelineAsset > urpAssets )
30+ {
31+ foreach ( var urpAssetForBuild in urpAssets )
32+ {
33+ if ( IsSurfaceCacheEnabled ( urpAssetForBuild ) )
34+ return true ;
35+ }
36+ return false ;
37+ }
38+
3239 internal static bool CanRemoveSurfaceCacheSettings ( List < UniversalRenderPipelineAsset > urpAssets )
3340 {
3441 if ( GraphicsSettings . TryGetRenderPipelineSettings < URPShaderStrippingSetting > ( out var urpShaderStrippingSettings ) && ! urpShaderStrippingSettings . stripUnusedVariants )
@@ -39,6 +46,26 @@ internal static bool CanRemoveSurfaceCacheSettings(List<UniversalRenderPipelineA
3946
4047 return true ;
4148 }
49+
50+ // Required by native side for meta pass stripping.
51+ [ UnityEngine . Scripting . Preserve ]
52+ internal static bool IsSurfaceCacheEnabledForBuild ( )
53+ {
54+ // Check if we're building with URP and if Surface Cache is enabled in the build assets
55+ if ( URPBuildData . instance . buildingPlayerForUniversalRenderPipeline )
56+ {
57+ return IsSurfaceCacheEnabled ( URPBuildData . instance . renderPipelineAssets ) ;
58+ }
59+
60+ // Fallback to current render pipeline asset if not in a build context
61+ var currentRP = UnityEngine . Rendering . GraphicsSettings . currentRenderPipeline ;
62+ if ( currentRP is UniversalRenderPipelineAsset urpAsset )
63+ {
64+ return IsSurfaceCacheEnabled ( urpAsset ) ;
65+ }
66+
67+ return false ;
68+ }
4269 }
4370
4471 class UniversalSurfaceCacheIntegrationStripper : IRenderPipelineGraphicsSettingsStripper < UnityEngine . Rendering . Universal . SurfaceCacheRenderPipelineResourceSet >
0 commit comments