diff --git a/Unity/Assets/Ubiq/Editor/Avatars/AvatarEditor.cs b/Unity/Assets/Ubiq/Editor/Avatars/AvatarEditor.cs index 41f21f97e..7b6f86834 100644 --- a/Unity/Assets/Ubiq/Editor/Avatars/AvatarEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Avatars/AvatarEditor.cs @@ -6,7 +6,7 @@ namespace Ubiq.Avatars { [CustomEditor(typeof(Avatar))] - public class AvatarEditor : Editor + public class AvatarEditor : UnityEditor.Editor { public override void OnInspectorGUI() { diff --git a/Unity/Assets/Ubiq/Editor/ExampleAvatar/TexturedAvatarEditor.cs b/Unity/Assets/Ubiq/Editor/ExampleAvatar/TexturedAvatarEditor.cs index ebda6f508..94803c4a6 100644 --- a/Unity/Assets/Ubiq/Editor/ExampleAvatar/TexturedAvatarEditor.cs +++ b/Unity/Assets/Ubiq/Editor/ExampleAvatar/TexturedAvatarEditor.cs @@ -6,7 +6,7 @@ namespace Ubiq.Samples { [CustomEditor(typeof(TexturedAvatar))] - public class TexturedAvatarEditor : Editor + public class TexturedAvatarEditor : UnityEditor.Editor { public override void OnInspectorGUI() { diff --git a/Unity/Assets/Ubiq/Editor/Logging/LogCollectorEditor.cs b/Unity/Assets/Ubiq/Editor/Logging/LogCollectorEditor.cs index 4d26ac997..8c7077cc1 100644 --- a/Unity/Assets/Ubiq/Editor/Logging/LogCollectorEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Logging/LogCollectorEditor.cs @@ -6,7 +6,7 @@ namespace Ubiq.Logging { [CustomEditor(typeof(LogCollector))] - public class LogCollectorEditor : Editor + public class LogCollectorEditor : UnityEditor.Editor { public override void OnInspectorGUI() { diff --git a/Unity/Assets/Ubiq/Editor/Messaging/LatencyMeterEditor.cs b/Unity/Assets/Ubiq/Editor/Messaging/LatencyMeterEditor.cs index 25592b19a..330c4fc40 100644 --- a/Unity/Assets/Ubiq/Editor/Messaging/LatencyMeterEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Messaging/LatencyMeterEditor.cs @@ -6,14 +6,14 @@ namespace Ubiq.Messaging { [CustomEditor(typeof(LatencyMeter))] - public class LatencyMeterEditor : Editor + public class LatencyMeterEditor : UnityEditor.Editor { public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUI.BeginDisabledGroup(!Application.isPlaying); - + var component = target as LatencyMeter; if (GUILayout.Button("Measure Latencies")) { diff --git a/Unity/Assets/Ubiq/Editor/Messaging/NetworkSceneEditor.cs b/Unity/Assets/Ubiq/Editor/Messaging/NetworkSceneEditor.cs index ce65fb162..e965f2f97 100644 --- a/Unity/Assets/Ubiq/Editor/Messaging/NetworkSceneEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Messaging/NetworkSceneEditor.cs @@ -7,7 +7,7 @@ namespace Ubiq.Messaging { [CustomEditor(typeof(NetworkScene))] - public class NetworkSceneEditor : Editor + public class NetworkSceneEditor : UnityEditor.Editor { public override void OnInspectorGUI() { diff --git a/Unity/Assets/Ubiq/Editor/Networking/ConnectionDefinitionEditor.cs b/Unity/Assets/Ubiq/Editor/Networking/ConnectionDefinitionEditor.cs index 4d012c03e..4bc07556d 100644 --- a/Unity/Assets/Ubiq/Editor/Networking/ConnectionDefinitionEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Networking/ConnectionDefinitionEditor.cs @@ -7,7 +7,7 @@ namespace Ubiq.Networking { [CustomEditor(typeof(ConnectionDefinition))] - public class ConnectionDefinitionEditor : Editor + public class ConnectionDefinitionEditor : UnityEditor.Editor { private ReorderableList platformsReorderableList; private SerializedProperty platformsProperty; diff --git a/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs b/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs index 372af6b2f..c7b0b6754 100644 --- a/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs +++ b/Unity/Assets/Ubiq/Editor/Packages/AddPackageWebRTC.cs @@ -1,9 +1,9 @@ #if !UNITY_WEBRTC_NO_VULKAN_HOOK && !(UNITY_WEBRTC && UBIQ_DISABLE_WEBRTCCOMPATIBILITYCHECK) using UnityEngine; using UnityEditor; -using UbiqEditor; +using Ubiq.Editor; -namespace UbiqEditor +namespace Ubiq.Editor { [InitializeOnLoad] public class AddPackageWebRTC diff --git a/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs b/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs index 790a3e86d..034d72b30 100644 --- a/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs +++ b/Unity/Assets/Ubiq/Editor/Packages/PackageManagerHelper.cs @@ -8,7 +8,7 @@ using System.Text; using Unity.EditorCoroutines.Editor; -namespace UbiqEditor +namespace Ubiq.Editor { public static class PackageManagerHelper { diff --git a/Unity/Assets/Ubiq/Editor/Rooms/RoomClientEditor.cs b/Unity/Assets/Ubiq/Editor/Rooms/RoomClientEditor.cs index 6866f15fa..428cc0579 100644 --- a/Unity/Assets/Ubiq/Editor/Rooms/RoomClientEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Rooms/RoomClientEditor.cs @@ -10,7 +10,7 @@ namespace Ubiq.Rooms { [CustomEditor(typeof(RoomClient))] - public class RoomClientEditor : Editor + public class RoomClientEditor : UnityEditor.Editor { private ReorderableList managerReorderableList; private SerializedProperty serversProperty; diff --git a/Unity/Assets/Ubiq/Editor/Scenes/SceneInfoEditor.cs b/Unity/Assets/Ubiq/Editor/Scenes/SceneInfoEditor.cs index 4b66ab216..84a5ac486 100644 --- a/Unity/Assets/Ubiq/Editor/Scenes/SceneInfoEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Scenes/SceneInfoEditor.cs @@ -6,7 +6,7 @@ namespace Ubiq.Samples { [CustomEditor(typeof(SceneInfo))] - public class SceneInfoEditor : Editor + public class SceneInfoEditor : UnityEditor.Editor { public override void OnInspectorGUI() { diff --git a/Unity/Assets/Ubiq/Editor/Spawning/PrefabCatalogueEditor.cs b/Unity/Assets/Ubiq/Editor/Spawning/PrefabCatalogueEditor.cs index 5153f7f44..b71cafe6f 100644 --- a/Unity/Assets/Ubiq/Editor/Spawning/PrefabCatalogueEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Spawning/PrefabCatalogueEditor.cs @@ -7,7 +7,7 @@ namespace Ubiq.Spawning { [CustomEditor(typeof(PrefabCatalogue))] - public class PrefabCatalogueEditor : Editor + public class PrefabCatalogueEditor : UnityEditor.Editor { private ReorderableList prefabsReorderableList; // private SerializedProperty uuids; diff --git a/Unity/Assets/Ubiq/Editor/Voip/VoipPeerConnectionEditor.cs b/Unity/Assets/Ubiq/Editor/Voip/VoipPeerConnectionEditor.cs index dac890670..d9d7ef2d3 100644 --- a/Unity/Assets/Ubiq/Editor/Voip/VoipPeerConnectionEditor.cs +++ b/Unity/Assets/Ubiq/Editor/Voip/VoipPeerConnectionEditor.cs @@ -3,7 +3,7 @@ namespace Ubiq.Voip { [CustomEditor(typeof(VoipPeerConnection))] - public class VoipPeerConnectionEditor : Editor + public class VoipPeerConnectionEditor : UnityEditor.Editor { public override void OnInspectorGUI() { diff --git a/Unity/Assets/Ubiq/Editor/XRI.meta b/Unity/Assets/Ubiq/Editor/XRI.meta new file mode 100644 index 000000000..ca349ca82 --- /dev/null +++ b/Unity/Assets/Ubiq/Editor/XRI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d446281858ed4b04d96a2fe33d24c339 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Ubiq/Editor/XRI/Ubiq.Editor.XRI.asmdef b/Unity/Assets/Ubiq/Editor/XRI/Ubiq.Editor.XRI.asmdef new file mode 100644 index 000000000..a9a91111f --- /dev/null +++ b/Unity/Assets/Ubiq/Editor/XRI/Ubiq.Editor.XRI.asmdef @@ -0,0 +1,34 @@ +{ + "name": "Ubiq.Editor.XRI", + "rootNamespace": "", + "references": [ + "GUID:ab979a98ba0be4546bceb48f770b11c8", + "GUID:a8b0ee606e2d3ea47a04b62a948d4604", + "GUID:fe685ec1767f73d42b749ea8045bfe43" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.xr.interaction.toolkit", + "expression": "0.0.0", + "define": "XRI_0_0_0_OR_NEWER" + }, + { + "name": "com.unity.xr.interaction.toolkit", + "expression": "2.5.2", + "define": "XRI_2_5_2_OR_NEWER" + }, + { + "name": "com.unity.xr.interaction.toolkit", + "expression": "2.5.3", + "define": "XRI_2_5_3_OR_NEWER" + } + ], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Unity/Assets/Ubiq/Editor/XRI/Ubiq.Editor.XRI.asmdef.meta b/Unity/Assets/Ubiq/Editor/XRI/Ubiq.Editor.XRI.asmdef.meta new file mode 100644 index 000000000..46b88838f --- /dev/null +++ b/Unity/Assets/Ubiq/Editor/XRI/Ubiq.Editor.XRI.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bad2b0f10eaa41942a2cb9c40b7000d9 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackageXRI_WebXR.cs b/Unity/Assets/Ubiq/Editor/XRI/XRIImportHelper.cs similarity index 53% rename from Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackageXRI_WebXR.cs rename to Unity/Assets/Ubiq/Editor/XRI/XRIImportHelper.cs index 5306950a6..4a38c1510 100644 --- a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackageXRI_WebXR.cs +++ b/Unity/Assets/Ubiq/Editor/XRI/XRIImportHelper.cs @@ -1,22 +1,9 @@ -using UnityEngine; -using UnityEditor; -using UbiqEditor; - -namespace Ubiq.Samples.WebXR.Editor +namespace Ubiq.Editor.XRI { - [InitializeOnLoad] - public class AddPackageXRI_WebXR + public static class XRIImportHelper { - static AddPackageXRI_WebXR() + public static void Import() { - // Custom for WebXR sample begins - if (RequireSamplesXRIUtil.AssetExistsFromGUID(RequireSamplesXRIUtil.DEMO_SCENE_GUID)) - { - // XRI sample is already in the project, let that handle it - return; - } - // Custom for WebXR sample ends - #if XRI_2_5_3_OR_NEWER && XRI_0_0_0_OR_NEWER #if !UBIQ_SILENCEWARNING_XRIVERSION Debug.LogWarning( @@ -27,19 +14,13 @@ static AddPackageXRI_WebXR() " symbols"); #endif #endif - // Safer to interact with Unity on main thread - EditorApplication.update += Update; - } - static void Update() - { #if !XRI_0_0_0_OR_NEWER PackageManagerHelper.AddPackage("com.unity.xr.interaction.toolkit@2.5.2"); #else PackageManagerHelper.RequireSample("com.unity.xr.interaction.toolkit","Starter Assets"); PackageManagerHelper.RequireSample("com.unity.xr.interaction.toolkit","XR Device Simulator"); #endif - EditorApplication.update -= Update; } } -} \ No newline at end of file +} diff --git a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/RequireSamplesXRI_WebXR.cs.meta b/Unity/Assets/Ubiq/Editor/XRI/XRIImportHelper.cs.meta similarity index 83% rename from Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/RequireSamplesXRI_WebXR.cs.meta rename to Unity/Assets/Ubiq/Editor/XRI/XRIImportHelper.cs.meta index b8463e3cd..d6be5a440 100644 --- a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/RequireSamplesXRI_WebXR.cs.meta +++ b/Unity/Assets/Ubiq/Editor/XRI/XRIImportHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 87247a696344dca4981cb488ee9bf308 +guid: 367419eaae9000a4c8898dc7e8bcd02c MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Unity/Assets/Ubiq/Runtime/XRI/Ubiq.XRI.asmdef b/Unity/Assets/Ubiq/Runtime/XRI/Ubiq.XRI.asmdef index 92865cce2..ea3897554 100644 --- a/Unity/Assets/Ubiq/Runtime/XRI/Ubiq.XRI.asmdef +++ b/Unity/Assets/Ubiq/Runtime/XRI/Ubiq.XRI.asmdef @@ -1,5 +1,5 @@ { - "name": "Ubiq.Examples.Players", + "name": "Ubiq.XRI", "rootNamespace": "", "references": [ "GUID:ab979a98ba0be4546bceb48f770b11c8", @@ -22,6 +22,11 @@ "name": "com.unity.xr.interaction.toolkit", "expression": "2.5.2", "define": "XRI_2_5_2_OR_NEWER" + }, + { + "name": "com.unity.xr.interaction.toolkit", + "expression": "2.5.3", + "define": "XRI_2_5_3_OR_NEWER" } ], "noEngineReferences": false diff --git a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/AddPackageXRI.cs b/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/AddPackageXRI.cs index 185f11598..8737da022 100644 --- a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/AddPackageXRI.cs +++ b/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/AddPackageXRI.cs @@ -1,6 +1,5 @@ -using UnityEngine; using UnityEditor; -using UbiqEditor; +using Ubiq.Editor.XRI; namespace Ubiq.Samples.Demo.Editor { @@ -9,28 +8,13 @@ public class AddPackageXRI { static AddPackageXRI() { -#if XRI_2_5_3_OR_NEWER && XRI_0_0_0_OR_NEWER - #if !UBIQ_SILENCEWARNING_XRIVERSION - Debug.LogWarning( - "Ubiq sample DemoScene (XRI) requires XRI = 2.5.2, but a" + - " different version is installed. The sample may not work" + - " correctly. To silence this warning, add the string" + - " UBIQ_SILENCEWARNING_XRIVERSION to your scripting define" + - " symbols"); - #endif -#endif // Safer to interact with Unity on main thread EditorApplication.update += Update; } static void Update() { -#if !XRI_0_0_0_OR_NEWER - PackageManagerHelper.AddPackage("com.unity.xr.interaction.toolkit@2.5.2"); -#else - PackageManagerHelper.RequireSample("com.unity.xr.interaction.toolkit","Starter Assets"); - PackageManagerHelper.RequireSample("com.unity.xr.interaction.toolkit","XR Device Simulator"); -#endif + XRIImportHelper.Import(); EditorApplication.update -= Update; } } diff --git a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/RequireSamplesXRI.cs b/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/RequireSamplesXRI.cs deleted file mode 100644 index efb35ea7b..000000000 --- a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/RequireSamplesXRI.cs +++ /dev/null @@ -1,156 +0,0 @@ -using UnityEngine; -using UnityEditor; -using UnityEngine.UIElements; -using UnityEngine.SceneManagement; -using UnityEditor.SceneManagement; - -namespace Ubiq.Samples.Demo.Editor -{ - internal static class RequireSamplesXRIUtil - { - public const string DEMO_SCENE_GUID = "2de505d34345ab340bdde30d419b24eb"; - public const string LOOPBACK_SCENE_GUID = "44835542044d9c1469efdf6740cdc7ba"; - public const string XRI_SAMPLE_PLAYER_GUID = "f6336ac4ac8b4d34bc5072418cdc62a0"; - public const string XRI_SAMPLE_SIMULATOR_GUID = "18ddb545287c546e19cc77dc9fbb2189"; - - public static bool IsSamplesLoaded() - { - return AssetExistsFromGUID(RequireSamplesXRIUtil.XRI_SAMPLE_PLAYER_GUID) - && AssetExistsFromGUID(RequireSamplesXRIUtil.XRI_SAMPLE_SIMULATOR_GUID); - } - - public static bool IsUbiqSampleScene(string guid) - { - return guid == DEMO_SCENE_GUID || guid == LOOPBACK_SCENE_GUID; - } - - public static bool AssetExistsFromGUID(string guid) - { - var path = AssetDatabase.GUIDToAssetPath(guid); - if (string.IsNullOrEmpty(path)) - { - return false; - } - - // If an asset previously existed in this editor session, Unity will - // cache the path and still return it, even if the asset is missing. - // We use the OnlyExistingAssets option (only available on - // AssetPathToGUID) to make sure it's really present. - var resultGuid = AssetDatabase.AssetPathToGUID(path,AssetPathToGUIDOptions.OnlyExistingAssets); - return !string.IsNullOrEmpty(resultGuid); - } - } - -#if XRI_2_5_2_OR_NEWER - [InitializeOnLoad] - public class RequireSamplesXRI - { - static RequireSamplesXRI() - { - if (RequireSamplesXRIUtil.IsSamplesLoaded()) - { - return; - } - - // Many things won't work in this static function, so do everything - // in callbacks. - EditorApplication.delayCall += Init; - EditorSceneManager.sceneOpened += SceneOpened; - } - - static void Init() - { - // We only need to run this init once per assembly reload - EditorApplication.delayCall -= Init; - - for (int i = 0; i < EditorSceneManager.sceneCount; i++) - { - SceneOpened(EditorSceneManager.GetSceneAt(i),OpenSceneMode.Single); - } - } - - static void SceneOpened(Scene scene, OpenSceneMode mode) - { - // Check if the scene we're opening is the demo scene - var openedSceneGuid = AssetDatabase.AssetPathToGUID(scene.path); - if (!RequireSamplesXRIUtil.IsUbiqSampleScene(openedSceneGuid)) - { - return; - } - - // Popup a window to let the user know they need the samples - RequireSamplesXRIWindow.Get(); - - // We don't need to check if the samples are imported again, or - // remove this callback. If the samples are imported, there'll - // be an assembly reload and this will all be cleared. - } - } -#endif - - public class RequireSamplesXRIWindow : EditorWindow - { - public static void Get() - { - var window = GetWindow(utility:true); - - var size = new Vector2(520, 180); - var center = EditorGUIUtility.GetMainWindowPosition().center; - var position = center - size * 0.5f; - - window.titleContent = new GUIContent("XRI Samples Required"); - window.minSize = size; - window.position = new Rect(position,size); - } - - void CreateGUI() - { - VisualElement root = rootVisualElement; - - var header = new Label( - "Ubiq Demo: Please import XRI Samples" - ); - header.style.unityTextAlign = new StyleEnum(TextAnchor.MiddleCenter); - header.style.fontSize = 18; - header.style.paddingTop = 18; - header.style.paddingBottom = 18; - root.Add(header); - - if (RequireSamplesXRIUtil.IsSamplesLoaded()) - { - // Starter assets loaded. This means the user has added them - // while this window was open. - var thanks = new Label( - "XRI Samples detected!\n\nThank you. Please close this" + - " window. It will not be shown again."); - thanks.style.whiteSpace = new StyleEnum(WhiteSpace.Normal); - thanks.style.paddingBottom = 18; - thanks.style.paddingLeft = 5; - thanks.style.paddingRight = 5; - root.Add(thanks); - return; - } - - // XRI StarterAssets not found. Give user instructions on importing - var instructions = new Label( - "This scene requires the Starter Assets and XR Device" + - " Simulator from Unity's XR" + - " Interaction Toolkit, and it looks like these are not" + - " yet imported in your project. To get this scene" + - " working correctly, please import them manually at the" + - " following:"); - instructions.style.whiteSpace = new StyleEnum(WhiteSpace.Normal); - instructions.style.paddingBottom = 18; - instructions.style.paddingLeft = 5; - instructions.style.paddingRight = 5; - root.Add(instructions); - - var path = new Label( - "1) Window > Package Manager > XR Interaction Toolkit > Samples > Starter Assets\n" + - "2) Window > Package Manager > XR Interaction Toolkit > Samples > XR Device Simulator"); - path.style.paddingLeft = 5; - path.style.paddingRight = 5; - root.Add(path); - } - } -} \ No newline at end of file diff --git a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/RequireSamplesXRI.cs.meta b/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/RequireSamplesXRI.cs.meta deleted file mode 100644 index 2e77f34e0..000000000 --- a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/RequireSamplesXRI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 22dcd157953aad94abb54c38ec347133 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/Ubiq.Demo.Editor.asmdef b/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/Ubiq.Demo.Editor.asmdef index 2b6201764..d9466fcef 100644 --- a/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/Ubiq.Demo.Editor.asmdef +++ b/Unity/Assets/Ubiq/Samples/Demo (XRI)/Assets/Scripts/Editor/Ubiq.Demo.Editor.asmdef @@ -2,7 +2,8 @@ "name": "Ubiq.Demo.Editor", "rootNamespace": "", "references": [ - "GUID:a8b0ee606e2d3ea47a04b62a948d4604" + "GUID:a8b0ee606e2d3ea47a04b62a948d4604", + "GUID:bad2b0f10eaa41942a2cb9c40b7000d9" ], "includePlatforms": [ "Editor" diff --git a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackageXRI_WebXR.cs.meta b/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackageXRI_WebXR.cs.meta deleted file mode 100644 index 1183d8cae..000000000 --- a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackageXRI_WebXR.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 711a98d15d8d95549b4016beb55b5213 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackagesWebXR.cs b/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackagesWebXR.cs index 9c558df28..a89c89102 100644 --- a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackagesWebXR.cs +++ b/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/AddPackagesWebXR.cs @@ -1,6 +1,7 @@ using UnityEngine; using UnityEditor; -using UbiqEditor; +using Ubiq.Editor; +using Ubiq.Editor.XRI; namespace Ubiq.Samples.WebXR.Editor { @@ -47,6 +48,8 @@ static void Update() #if WEBXRINTERACTIONS_0_22_0_OR_NEWER PackageManagerHelper.RequireSample("com.de-panther.webxr-interactions","XR Interaction Toolkit Sample"); #endif + XRIImportHelper.Import(); + EditorApplication.update -= Update; } } diff --git a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/RequireSamplesXRI_WebXR.cs b/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/RequireSamplesXRI_WebXR.cs deleted file mode 100644 index 31c16e8a8..000000000 --- a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/RequireSamplesXRI_WebXR.cs +++ /dev/null @@ -1,164 +0,0 @@ -using UnityEngine; -using UnityEditor; -using UnityEngine.UIElements; -using UnityEngine.SceneManagement; -using UnityEditor.SceneManagement; - -namespace Ubiq.Samples.WebXR.Editor -{ - internal static class RequireSamplesXRIUtil - { - public const string DEMO_SCENE_GUID = "2de505d34345ab340bdde30d419b24eb"; - public const string LOOPBACK_SCENE_GUID = "44835542044d9c1469efdf6740cdc7ba"; - public const string XRI_SAMPLE_PLAYER_GUID = "f6336ac4ac8b4d34bc5072418cdc62a0"; - public const string XRI_SAMPLE_SIMULATOR_GUID = "18ddb545287c546e19cc77dc9fbb2189"; - - public static bool IsSamplesLoaded() - { - return AssetExistsFromGUID(RequireSamplesXRIUtil.XRI_SAMPLE_PLAYER_GUID) - && AssetExistsFromGUID(RequireSamplesXRIUtil.XRI_SAMPLE_SIMULATOR_GUID); - } - - public static bool IsUbiqSampleScene(string guid) - { - return guid == DEMO_SCENE_GUID || guid == LOOPBACK_SCENE_GUID; - } - - public static bool AssetExistsFromGUID(string guid) - { - var path = AssetDatabase.GUIDToAssetPath(guid); - if (string.IsNullOrEmpty(path)) - { - return false; - } - - // If an asset previously existed in this editor session, Unity will - // cache the path and still return it, even if the asset is missing. - // We use the OnlyExistingAssets option (only available on - // AssetPathToGUID) to make sure it's really present. - var resultGuid = AssetDatabase.AssetPathToGUID(path,AssetPathToGUIDOptions.OnlyExistingAssets); - return !string.IsNullOrEmpty(resultGuid); - } - } - -#if XRI_2_5_2_OR_NEWER - [InitializeOnLoad] - public class RequireSamplesXRI_WebXR - { - static RequireSamplesXRI_WebXR() - { - // Custom for WebXR sample begins - if (RequireSamplesXRIUtil.AssetExistsFromGUID(RequireSamplesXRIUtil.DEMO_SCENE_GUID)) - { - // XRI sample is already in the project, let that handle it - return; - } - // Custom for WebXR sample ends - - if (RequireSamplesXRIUtil.IsSamplesLoaded()) - { - return; - } - - // Many things won't work in this static function, so do everything - // in callbacks. - EditorApplication.delayCall += Init; - EditorSceneManager.sceneOpened += SceneOpened; - } - - static void Init() - { - // We only need to run this init once per assembly reload - EditorApplication.delayCall -= Init; - - for (int i = 0; i < EditorSceneManager.sceneCount; i++) - { - SceneOpened(EditorSceneManager.GetSceneAt(i),OpenSceneMode.Single); - } - } - - static void SceneOpened(Scene scene, OpenSceneMode mode) - { - // Check if the scene we're opening is the demo scene - var openedSceneGuid = AssetDatabase.AssetPathToGUID(scene.path); - if (!RequireSamplesXRIUtil.IsUbiqSampleScene(openedSceneGuid)) - { - return; - } - - // Popup a window to let the user know they need the samples - RequireSamplesXRIWindow.Get(); - - // We don't need to check if the samples are imported again, or - // remove this callback. If the samples are imported, there'll - // be an assembly reload and this will all be cleared. - } - } -#endif - - public class RequireSamplesXRIWindow : EditorWindow - { - public static void Get() - { - var window = GetWindow(utility:true); - - var size = new Vector2(520, 180); - var center = EditorGUIUtility.GetMainWindowPosition().center; - var position = center - size * 0.5f; - - window.titleContent = new GUIContent("XRI Samples Required"); - window.minSize = size; - window.position = new Rect(position,size); - } - - void CreateGUI() - { - VisualElement root = rootVisualElement; - - var header = new Label( - "Ubiq Demo: Please import XRI Samples" - ); - header.style.unityTextAlign = new StyleEnum(TextAnchor.MiddleCenter); - header.style.fontSize = 18; - header.style.paddingTop = 18; - header.style.paddingBottom = 18; - root.Add(header); - - if (RequireSamplesXRIUtil.IsSamplesLoaded()) - { - // Starter assets loaded. This means the user has added them - // while this window was open. - var thanks = new Label( - "XRI Samples detected!\n\nThank you. Please close this" + - " window. It will not be shown again."); - thanks.style.whiteSpace = new StyleEnum(WhiteSpace.Normal); - thanks.style.paddingBottom = 18; - thanks.style.paddingLeft = 5; - thanks.style.paddingRight = 5; - root.Add(thanks); - return; - } - - // XRI StarterAssets not found. Give user instructions on importing - var instructions = new Label( - "This scene requires the Starter Assets and XR Device" + - " Simulator from Unity's XR" + - " Interaction Toolkit, and it looks like these are not" + - " yet imported in your project. To get this scene" + - " working correctly, please import them manually at the" + - " following:"); - instructions.style.whiteSpace = new StyleEnum(WhiteSpace.Normal); - instructions.style.paddingBottom = 18; - instructions.style.paddingLeft = 5; - instructions.style.paddingRight = 5; - root.Add(instructions); - - var path = new Label( - "1) Window > Package Manager > XR Interaction Toolkit > Samples > Starter Assets\n" + - "2) Window > Package Manager > XR Interaction Toolkit > Samples > XR Device Simulator"); - path.style.paddingLeft = 5; - path.style.paddingRight = 5; - root.Add(path); - } - } -} \ No newline at end of file diff --git a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/Ubiq.Player.Editor.asmdef b/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/Ubiq.Player.Editor.asmdef index ce359e5ff..e2e2d7709 100644 --- a/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/Ubiq.Player.Editor.asmdef +++ b/Unity/Assets/Ubiq/Samples/Player (XRI + WebXR)/Scripts/Editor/Ubiq.Player.Editor.asmdef @@ -3,7 +3,8 @@ "rootNamespace": "", "references": [ "GUID:fe685ec1767f73d42b749ea8045bfe43", - "GUID:a8b0ee606e2d3ea47a04b62a948d4604" + "GUID:a8b0ee606e2d3ea47a04b62a948d4604", + "GUID:bad2b0f10eaa41942a2cb9c40b7000d9" ], "includePlatforms": [ "Editor"