@@ -8,6 +8,9 @@ namespace UnityEditor.Rendering.PostProcessing
8
8
{
9
9
public sealed class PostProcessResourceStripper : ScriptableObject
10
10
{
11
+ public const string DefaultStrippingConfigAssetPath = "Assets/PostProcessStrippingConfig.asset" ;
12
+
13
+
11
14
private PostProcessStrippingConfig stripping ;
12
15
private PostProcessStrippingConfig defaultConfig ;
13
16
@@ -32,7 +35,6 @@ public static PostProcessResourceStripper instance
32
35
void Awake ( )
33
36
{
34
37
SceneManager . sceneLoaded += OnSceneLoaded ;
35
-
36
38
}
37
39
38
40
void OnDestroy ( )
@@ -68,22 +70,35 @@ static private void StripDebugShaders(PostProcessResources resources)
68
70
resources . computeShaders . vectorscope = null ;
69
71
}
70
72
71
- private void LazyInitStrippingConfig ( )
73
+ static private string FindPostProcessStrippingConfigGUID ( )
72
74
{
73
- if ( stripping != null )
74
- return ;
75
-
76
75
var guids = AssetDatabase . FindAssets ( "t:PostProcessStrippingConfig" , null ) ;
77
76
if ( guids . Length > 0 )
78
- {
79
- stripping = ( PostProcessStrippingConfig ) AssetDatabase . LoadAssetAtPath ( AssetDatabase . GUIDToAssetPath ( guids [ 0 ] ) , typeof ( PostProcessStrippingConfig ) ) ;
80
- }
77
+ return guids [ 0 ] ;
81
78
else
79
+ return null ;
80
+ }
81
+
82
+ static public void EnsurePostProcessStrippingConfigAssetExists ( )
83
+ {
84
+ var guid = FindPostProcessStrippingConfigGUID ( ) ;
85
+ if ( guid != null )
86
+ return ;
87
+
88
+ AssetDatabase . CreateAsset ( CreateInstance < PostProcessStrippingConfig > ( ) , DefaultStrippingConfigAssetPath ) ;
89
+ AssetDatabase . SaveAssets ( ) ;
90
+ AssetDatabase . Refresh ( ) ;
91
+ }
92
+
93
+ private void LazyLoadStrippingConfig ( )
94
+ {
95
+ if ( stripping != null )
96
+ return ;
97
+
98
+ var guid = FindPostProcessStrippingConfigGUID ( ) ;
99
+ if ( guid != null )
82
100
{
83
- // Create a new config asset
84
- AssetDatabase . CreateAsset ( defaultConfig , "Assets/PostProcessStrippingConfig.asset" ) ;
85
- AssetDatabase . SaveAssets ( ) ;
86
- AssetDatabase . Refresh ( ) ;
101
+ stripping = ( PostProcessStrippingConfig ) AssetDatabase . LoadAssetAtPath ( AssetDatabase . GUIDToAssetPath ( guid ) , typeof ( PostProcessStrippingConfig ) ) ;
87
102
}
88
103
89
104
if ( stripping == null )
@@ -115,7 +130,7 @@ private void Apply(BuildTarget target, PostProcessResources resources)
115
130
if ( defaultConfig == null )
116
131
return ;
117
132
118
- LazyInitStrippingConfig ( ) ;
133
+ LazyLoadStrippingConfig ( ) ;
119
134
if ( stripping == null )
120
135
return ;
121
136
@@ -230,6 +245,7 @@ public void OnPreprocessBuild(BuildTarget target, string path)
230
245
public class SetupStripping {
231
246
static SetupStripping ( )
232
247
{
248
+ PostProcessResourceStripper . EnsurePostProcessStrippingConfigAssetExists ( ) ;
233
249
PostProcessResourcesFactory . Init ( PostProcessResourceStripper . Strip ) ;
234
250
}
235
251
}
0 commit comments