diff --git a/Packages/webxr/CHANGELOG.md b/Packages/webxr/CHANGELOG.md
index deacb6c6..d35071a7 100644
--- a/Packages/webxr/CHANGELOG.md
+++ b/Packages/webxr/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- An option to auto-load WebXRManager on start in WebXRSettings.
- An option to auto-load WebXRInputSystem on start in WebXRSettings.
+- Error message when there's no Universal Render Pipeline package in project.
## [0.20.0] - 2023-12-18
### Added
diff --git a/Packages/webxr/Editor/WebXR.Editor.asmdef b/Packages/webxr/Editor/WebXR.Editor.asmdef
index bab0fd0a..da362da2 100644
--- a/Packages/webxr/Editor/WebXR.Editor.asmdef
+++ b/Packages/webxr/Editor/WebXR.Editor.asmdef
@@ -1,5 +1,6 @@
{
"name": "WebXR.Editor",
+ "rootNamespace": "",
"references": [
"GUID:fd4abe4ffe74ef1448afe15c6cb36bb7",
"GUID:f9fe0089ec81f4079af78eb2287a6163"
@@ -13,6 +14,12 @@
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
- "versionDefines": [],
+ "versionDefines": [
+ {
+ "name": "com.unity.render-pipelines.universal",
+ "expression": "",
+ "define": "HAS_URP"
+ }
+ ],
"noEngineReferences": false
}
\ No newline at end of file
diff --git a/Packages/webxr/Editor/WebXRBuildProcessor.cs b/Packages/webxr/Editor/WebXRBuildProcessor.cs
index 54c51305..c351e965 100644
--- a/Packages/webxr/Editor/WebXRBuildProcessor.cs
+++ b/Packages/webxr/Editor/WebXRBuildProcessor.cs
@@ -8,46 +8,46 @@ namespace WebXR
{
public class WebXRBuildProcessor : IPreprocessBuildWithReport, IPostprocessBuildWithReport
{
- /// Override of and
- public int callbackOrder
- {
- get { return 0; }
- }
+ /// Override of and
+ public int callbackOrder
+ {
+ get { return 0; }
+ }
- void CleanOldSettings()
- {
- UnityEngine.Object[] preloadedAssets = PlayerSettings.GetPreloadedAssets();
- if (preloadedAssets == null)
- return;
+ void CleanOldSettings()
+ {
+ UnityEngine.Object[] preloadedAssets = PlayerSettings.GetPreloadedAssets();
+ if (preloadedAssets == null)
+ return;
- var oldSettings = from s in preloadedAssets
- where s != null && s.GetType() == typeof(WebXRSettings)
- select s;
-
- if (oldSettings != null && oldSettings.Any())
- {
- var assets = preloadedAssets.ToList();
- foreach (var s in oldSettings)
- {
- assets.Remove(s);
- }
+ var oldSettings = from s in preloadedAssets
+ where s != null && s.GetType() == typeof(WebXRSettings)
+ select s;
- PlayerSettings.SetPreloadedAssets(assets.ToArray());
- }
+ if (oldSettings != null && oldSettings.Any())
+ {
+ var assets = preloadedAssets.ToList();
+ foreach (var s in oldSettings)
+ {
+ assets.Remove(s);
}
- /// Override of
- /// Build report.
- public void OnPreprocessBuild(BuildReport report)
- {
- // Always remember to cleanup preloaded assets after build to make sure we don't
- // dirty later builds with assets that may not be needed or are out of date.
- CleanOldSettings();
+ PlayerSettings.SetPreloadedAssets(assets.ToArray());
+ }
+ }
- if (report.summary.platform != BuildTarget.WebGL)
- {
- return;
- }
+ /// Override of
+ /// Build report.
+ public void OnPreprocessBuild(BuildReport report)
+ {
+ // Always remember to cleanup preloaded assets after build to make sure we don't
+ // dirty later builds with assets that may not be needed or are out of date.
+ CleanOldSettings();
+
+ if (report.summary.platform != BuildTarget.WebGL)
+ {
+ return;
+ }
#if UNITY_2020_3 || UNITY_2021_1
if (!PlayerSettings.WebGL.emscriptenArgs.Contains("-std="))
@@ -56,28 +56,36 @@ public void OnPreprocessBuild(BuildReport report)
}
#endif
- WebXRSettings settings = null;
- EditorBuildSettings.TryGetConfigObject("WebXR.Settings", out settings);
- if (settings == null)
- return;
+ WebXRSettings settings = WebXRSettings.GetSettings();
+ if (settings == null)
+ return;
- UnityEngine.Object[] preloadedAssets = PlayerSettings.GetPreloadedAssets();
+ UnityEngine.Object[] preloadedAssets = PlayerSettings.GetPreloadedAssets();
- if (!preloadedAssets.Contains(settings))
- {
- var assets = preloadedAssets.ToList();
- assets.Add(settings);
- PlayerSettings.SetPreloadedAssets(assets.ToArray());
- }
- }
+ if (!preloadedAssets.Contains(settings))
+ {
+ var assets = preloadedAssets.ToList();
+ assets.Add(settings);
+ PlayerSettings.SetPreloadedAssets(assets.ToArray());
+ }
+ }
- /// Override of
- /// Build report.
- public void OnPostprocessBuild(BuildReport report)
- {
- // Always remember to cleanup preloaded assets after build to make sure we don't
- // dirty later builds with assets that may not be needed or are out of date.
- CleanOldSettings();
- }
+ /// Override of
+ /// Build report.
+ public void OnPostprocessBuild(BuildReport report)
+ {
+ // Always remember to cleanup preloaded assets after build to make sure we don't
+ // dirty later builds with assets that may not be needed or are out of date.
+ CleanOldSettings();
+ }
+
+#if !HAS_URP
+ [InitializeOnLoadMethod]
+ private static void OnPostprocessAssets()
+ {
+ UnityEngine.Debug.LogError(@"WebXR Export requires Universal Render Pipeline,
+using Built-in Render Pipeline might cause issues.");
+ }
+#endif
}
}