@@ -8,46 +8,46 @@ namespace WebXR
8
8
{
9
9
public class WebXRBuildProcessor : IPreprocessBuildWithReport , IPostprocessBuildWithReport
10
10
{
11
- /// <summary>Override of <see cref="IPreprocessBuildWithReport"/> and <see cref="IPostprocessBuildWithReport"/></summary>
12
- public int callbackOrder
13
- {
14
- get { return 0 ; }
15
- }
11
+ /// <summary>Override of <see cref="IPreprocessBuildWithReport"/> and <see cref="IPostprocessBuildWithReport"/></summary>
12
+ public int callbackOrder
13
+ {
14
+ get { return 0 ; }
15
+ }
16
16
17
- void CleanOldSettings ( )
18
- {
19
- UnityEngine . Object [ ] preloadedAssets = PlayerSettings . GetPreloadedAssets ( ) ;
20
- if ( preloadedAssets == null )
21
- return ;
17
+ void CleanOldSettings ( )
18
+ {
19
+ UnityEngine . Object [ ] preloadedAssets = PlayerSettings . GetPreloadedAssets ( ) ;
20
+ if ( preloadedAssets == null )
21
+ return ;
22
22
23
- var oldSettings = from s in preloadedAssets
24
- where s != null && s . GetType ( ) == typeof ( WebXRSettings )
25
- select s ;
26
-
27
- if ( oldSettings != null && oldSettings . Any ( ) )
28
- {
29
- var assets = preloadedAssets . ToList ( ) ;
30
- foreach ( var s in oldSettings )
31
- {
32
- assets . Remove ( s ) ;
33
- }
23
+ var oldSettings = from s in preloadedAssets
24
+ where s != null && s . GetType ( ) == typeof ( WebXRSettings )
25
+ select s ;
34
26
35
- PlayerSettings . SetPreloadedAssets ( assets . ToArray ( ) ) ;
36
- }
27
+ if ( oldSettings != null && oldSettings . Any ( ) )
28
+ {
29
+ var assets = preloadedAssets . ToList ( ) ;
30
+ foreach ( var s in oldSettings )
31
+ {
32
+ assets . Remove ( s ) ;
37
33
}
38
34
39
- /// <summary>Override of <see cref="IPreprocessBuildWithReport"/></summary>
40
- /// <param name="report">Build report.</param>
41
- public void OnPreprocessBuild ( BuildReport report )
42
- {
43
- // Always remember to cleanup preloaded assets after build to make sure we don't
44
- // dirty later builds with assets that may not be needed or are out of date.
45
- CleanOldSettings ( ) ;
35
+ PlayerSettings . SetPreloadedAssets ( assets . ToArray ( ) ) ;
36
+ }
37
+ }
46
38
47
- if ( report . summary . platform != BuildTarget . WebGL )
48
- {
49
- return ;
50
- }
39
+ /// <summary>Override of <see cref="IPreprocessBuildWithReport"/></summary>
40
+ /// <param name="report">Build report.</param>
41
+ public void OnPreprocessBuild ( BuildReport report )
42
+ {
43
+ // Always remember to cleanup preloaded assets after build to make sure we don't
44
+ // dirty later builds with assets that may not be needed or are out of date.
45
+ CleanOldSettings ( ) ;
46
+
47
+ if ( report . summary . platform != BuildTarget . WebGL )
48
+ {
49
+ return ;
50
+ }
51
51
52
52
#if UNITY_2020_3 || UNITY_2021_1
53
53
if ( ! PlayerSettings . WebGL . emscriptenArgs . Contains ( "-std=" ) )
@@ -56,28 +56,36 @@ public void OnPreprocessBuild(BuildReport report)
56
56
}
57
57
#endif
58
58
59
- WebXRSettings settings = null ;
60
- EditorBuildSettings . TryGetConfigObject < WebXRSettings > ( "WebXR.Settings" , out settings ) ;
61
- if ( settings == null )
62
- return ;
59
+ WebXRSettings settings = WebXRSettings . GetSettings ( ) ;
60
+ if ( settings == null )
61
+ return ;
63
62
64
- UnityEngine . Object [ ] preloadedAssets = PlayerSettings . GetPreloadedAssets ( ) ;
63
+ UnityEngine . Object [ ] preloadedAssets = PlayerSettings . GetPreloadedAssets ( ) ;
65
64
66
- if ( ! preloadedAssets . Contains ( settings ) )
67
- {
68
- var assets = preloadedAssets . ToList ( ) ;
69
- assets . Add ( settings ) ;
70
- PlayerSettings . SetPreloadedAssets ( assets . ToArray ( ) ) ;
71
- }
72
- }
65
+ if ( ! preloadedAssets . Contains ( settings ) )
66
+ {
67
+ var assets = preloadedAssets . ToList ( ) ;
68
+ assets . Add ( settings ) ;
69
+ PlayerSettings . SetPreloadedAssets ( assets . ToArray ( ) ) ;
70
+ }
71
+ }
73
72
74
- /// <summary>Override of <see cref="IPostprocessBuildWithReport"/></summary>
75
- /// <param name="report">Build report.</param>
76
- public void OnPostprocessBuild ( BuildReport report )
77
- {
78
- // Always remember to cleanup preloaded assets after build to make sure we don't
79
- // dirty later builds with assets that may not be needed or are out of date.
80
- CleanOldSettings ( ) ;
81
- }
73
+ /// <summary>Override of <see cref="IPostprocessBuildWithReport"/></summary>
74
+ /// <param name="report">Build report.</param>
75
+ public void OnPostprocessBuild ( BuildReport report )
76
+ {
77
+ // Always remember to cleanup preloaded assets after build to make sure we don't
78
+ // dirty later builds with assets that may not be needed or are out of date.
79
+ CleanOldSettings ( ) ;
80
+ }
81
+
82
+ #if ! HAS_URP
83
+ [ InitializeOnLoadMethod ]
84
+ private static void OnPostprocessAssets ( )
85
+ {
86
+ UnityEngine . Debug . LogError ( @"WebXR Export requires Universal Render Pipeline,
87
+ using Built-in Render Pipeline might cause issues." ) ;
88
+ }
89
+ #endif
82
90
}
83
91
}
0 commit comments