From ac537cb4ccc82d0f2073d3a5e1eb77ae275d0ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacopo=20Lib=C3=A8?= Date: Thu, 18 Nov 2021 23:08:46 +0100 Subject: [PATCH 1/2] Changes to re-enable xr plugin --- NomaiVR/Assets/AssetLoader.cs | 3 ++ NomaiVR/Hands/HandsController.cs | 11 +++++ NomaiVR/Helpers/GraphicsHelper.cs | 10 ++++- NomaiVR/NomaiVR.cs | 45 +++++++++++++++++++ NomaiVR/NomaiVR.csproj | 10 +++++ NomaiVRPatcher/NomaiVREnabler.cs | 4 +- NomaiVRPatcher/NomaiVRPatcher.csproj | 1 + Unity/ProjectSettings/ProjectSettings.asset | 9 ++-- Unity/ProjectSettings/XRPackageSettings.asset | 3 +- 9 files changed, 86 insertions(+), 10 deletions(-) diff --git a/NomaiVR/Assets/AssetLoader.cs b/NomaiVR/Assets/AssetLoader.cs index a327863..cf9ae3f 100644 --- a/NomaiVR/Assets/AssetLoader.cs +++ b/NomaiVR/Assets/AssetLoader.cs @@ -29,6 +29,7 @@ namespace NomaiVR.Assets public static GameObject ProbeLauncherHandheldScreenPrefab; public static GameObject SignalscopeHandheldButtonsPrefab; public static AssetBundle VRBindingTextures; + public static AssetBundle XRManager; public static Sprite SplashSprite; public static Texture2D EmptyTexture; @@ -41,6 +42,8 @@ namespace NomaiVR.Assets VRBindingTextures = LoadBundle("vrbindings-textures"); ShaderLoader.LoadBundle(LoadBundle("steamvr-shaders")); + XRManager = LoadBundle("xrmanager"); + var postCreditsBundle = LoadBundle("cinema-camera"); PostCreditsPrefab = LoadAsset(postCreditsBundle, "postcreditscamera.prefab"); PostCreditsRenderTexture = LoadAsset(postCreditsBundle, "screen.renderTexture"); diff --git a/NomaiVR/Hands/HandsController.cs b/NomaiVR/Hands/HandsController.cs index 110c70c..97fbf1d 100644 --- a/NomaiVR/Hands/HandsController.cs +++ b/NomaiVR/Hands/HandsController.cs @@ -2,6 +2,7 @@ using NomaiVR.Helpers; using NomaiVR.ModConfig; using UnityEngine; +using UnityEngine.SpatialTracking; using UnityEngine.XR; using Valve.VR; @@ -60,6 +61,7 @@ namespace NomaiVR.Hands camera.cullingMask = activeCamera.cullingMask; camera.depth = activeCamera.mainCamera.depth; camera.tag = activeCamera.tag; + ActivateCameraTracking(camera); var owCamera = cameraObject.AddComponent(); owCamera.renderSkybox = true; @@ -72,12 +74,21 @@ namespace NomaiVR.Hands private void SetUpWrapperInGame() { + ActivateCameraTracking(Camera.main); wrapper = new GameObject().transform; wrapper.parent = Camera.main.transform.parent; wrapper.localRotation = Quaternion.identity; wrapper.localPosition = Camera.main.transform.localPosition; } + private void ActivateCameraTracking(Camera camera) + { + var hmdTracking = camera.gameObject.AddComponent(); + hmdTracking.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRDevice, TrackedPoseDriver.TrackedPose.Head); + hmdTracking.updateType = TrackedPoseDriver.UpdateType.BeforeRender; + hmdTracking.UseRelativeTransform = false; + } + private void SetUpHands() { var right = new GameObject().AddComponent(); diff --git a/NomaiVR/Helpers/GraphicsHelper.cs b/NomaiVR/Helpers/GraphicsHelper.cs index f4f8500..00af675 100644 --- a/NomaiVR/Helpers/GraphicsHelper.cs +++ b/NomaiVR/Helpers/GraphicsHelper.cs @@ -6,6 +6,7 @@ namespace NomaiVR.Helpers public static class GraphicsHelper { private static readonly Matrix4x4 scaleBiasDXToGL = Matrix4x4.TRS(Vector3.back, Quaternion.identity, new Vector3(1, 1, 2)); + private static readonly Matrix4x4 scaleBiasGLToDX = Matrix4x4.TRS(Vector3.forward, Quaternion.identity, new Vector3(1, 1, 0.5f)); public static void ForceCameraToEye(Camera targetCamera, Transform headTransform, EVREye eye) { targetCamera.transform.position = headTransform.TransformPoint(SteamVR.instance.eyes[(int)eye].pos); @@ -14,12 +15,17 @@ namespace NomaiVR.Helpers public static void SetCameraEyeProjectionMatrix(Camera targetCamera, EVREye eye) { - targetCamera.projectionMatrix = scaleBiasDXToGL * GetSteamVREyeProjection(targetCamera, eye); + targetCamera.projectionMatrix = GetSteamVREyeProjection(targetCamera, eye); + } + + public static Matrix4x4 ToDX(Matrix4x4 matrix) + { + return scaleBiasGLToDX * matrix; } public static Matrix4x4 GetSteamVREyeProjection(Camera cam, EVREye eye) { - return HmdMatrix44ToMatrix4X4(SteamVR.instance.hmd.GetProjectionMatrix(eye, cam.nearClipPlane, cam.farClipPlane)); + return scaleBiasDXToGL * HmdMatrix44ToMatrix4X4(SteamVR.instance.hmd.GetProjectionMatrix(eye, cam.nearClipPlane, cam.farClipPlane)); } public static Matrix4x4 HmdMatrix44ToMatrix4X4(HmdMatrix44_t mat) diff --git a/NomaiVR/NomaiVR.cs b/NomaiVR/NomaiVR.cs index 2f6800e..37932f4 100644 --- a/NomaiVR/NomaiVR.cs +++ b/NomaiVR/NomaiVR.cs @@ -10,6 +10,11 @@ using NomaiVR.Loaders.Harmony; using NomaiVR.Player; using NomaiVR.Saves; using NomaiVR.Ship; +using UnityEngine.XR.Management; +using Unity.XR.OpenVR; +using UnityEngine.XR; +using System.Collections.Generic; +using UnityEngine; namespace NomaiVR { @@ -76,6 +81,7 @@ namespace NomaiVR private static void InitSteamVR() { SteamVR_Actions.PreInitialize(); + LoadXRModule(); SteamVR.Initialize(); SteamVR_Settings.instance.pauseGameWhenDashboardVisible = true; @@ -88,6 +94,45 @@ namespace NomaiVR steamAppId: 753640); OpenVR.Input.SetActionManifestPath(ModFolderPath + @"\bindings\actions.json"); + + if (XRGeneralSettings.Instance != null && XRGeneralSettings.Instance.Manager != null + && XRGeneralSettings.Instance.Manager.activeLoader != null) + { + XRGeneralSettings.Instance.Manager.StartSubsystems(); + } + else + throw new System.Exception("Cannot initialize VRSubsystem"); + + //Change tracking origin to headset + List subsystems = new List(); + SubsystemManager.GetInstances(subsystems); + for (int i = 0; i < subsystems.Count; i++) + { + subsystems[i].TrySetTrackingOriginMode(TrackingOriginModeFlags.Device); + subsystems[i].TryRecenter(); + } + } + + private static void LoadXRModule() + { + foreach (var xrManager in AssetLoader.XRManager.LoadAllAssets()) + Logs.WriteInfo($"Loaded xrManager: {xrManager.name}"); + + XRGeneralSettings instance = XRGeneralSettings.Instance; + if (instance == null) throw new System.Exception("XRGeneralSettings instance is null"); + + var xrManagerSettings = instance.Manager; + if (xrManagerSettings == null) throw new System.Exception("XRManagerSettings instance is null"); + + xrManagerSettings.InitializeLoaderSync(); + if (xrManagerSettings.activeLoader == null) throw new System.Exception("Cannot initialize OpenVR Loader"); + + OpenVRSettings openVrSettings = OpenVRSettings.GetSettings(false); + openVrSettings.EditorAppKey = "steam.app.753640"; + openVrSettings.InitializationType = OpenVRSettings.InitializationTypes.Scene; + if (openVrSettings == null) throw new System.Exception("OpenVRSettings instance is null"); + + openVrSettings.SetMirrorViewMode(OpenVRSettings.MirrorViewModes.Right); } } } diff --git a/NomaiVR/NomaiVR.csproj b/NomaiVR/NomaiVR.csproj index f1f7324..eb23d5d 100644 --- a/NomaiVR/NomaiVR.csproj +++ b/NomaiVR/NomaiVR.csproj @@ -68,6 +68,14 @@ False $(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\SteamVR.dll + + False + $(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\Unity.XR.OpenVR.dll + + + False + $(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\Unity.XR.Management.dll + False $(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\SteamVR_Actions.dll @@ -145,6 +153,8 @@ + + diff --git a/NomaiVRPatcher/NomaiVREnabler.cs b/NomaiVRPatcher/NomaiVREnabler.cs index a42af26..a09d9d1 100644 --- a/NomaiVRPatcher/NomaiVREnabler.cs +++ b/NomaiVRPatcher/NomaiVREnabler.cs @@ -25,7 +25,7 @@ namespace NomaiVRPatcher CopyGameFiles(AppDomain.CurrentDomain.BaseDirectory, Path.Combine(basePath, "files")); - PatchGlobalGameManagers(gameManagersPath, backupPath, basePath); + //PatchGlobalGameManagers(gameManagersPath, backupPath, basePath); } // List of assemblies to patch @@ -46,7 +46,7 @@ namespace NomaiVRPatcher CopyGameFiles(executablePath, Path.Combine(patchersPath, "files")); - PatchGlobalGameManagers(gameManagersPath, backupPath, patchersPath); + //PatchGlobalGameManagers(gameManagersPath, backupPath, patchersPath); } // Clean up files left from previous versions of the mod diff --git a/NomaiVRPatcher/NomaiVRPatcher.csproj b/NomaiVRPatcher/NomaiVRPatcher.csproj index 1b157c8..025a88f 100644 --- a/NomaiVRPatcher/NomaiVRPatcher.csproj +++ b/NomaiVRPatcher/NomaiVRPatcher.csproj @@ -21,6 +21,7 @@ + diff --git a/Unity/ProjectSettings/ProjectSettings.asset b/Unity/ProjectSettings/ProjectSettings.asset index b1b54ec..5fd06b8 100644 --- a/Unity/ProjectSettings/ProjectSettings.asset +++ b/Unity/ProjectSettings/ProjectSettings.asset @@ -126,7 +126,8 @@ PlayerSettings: Others: 1 bundleVersion: 0.1 preloadedAssets: - - {fileID: 5477527979194124351, guid: bd54447987d8bd845bbb7e7341ebdf98, type: 2} + - {fileID: 0} + - {fileID: 3723299434278802999, guid: 13906739c9868ee489584241300fc5bc, type: 2} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -329,10 +330,8 @@ PlayerSettings: m_Automatic: 1 m_BuildTargetVRSettings: - m_BuildTarget: Standalone - m_Enabled: 1 - m_Devices: - - OpenVR - - Oculus + m_Enabled: 0 + m_Devices: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 openGLRequireES32: 0 diff --git a/Unity/ProjectSettings/XRPackageSettings.asset b/Unity/ProjectSettings/XRPackageSettings.asset index 7e791e1..e6eb497 100644 --- a/Unity/ProjectSettings/XRPackageSettings.asset +++ b/Unity/ProjectSettings/XRPackageSettings.asset @@ -1,5 +1,6 @@ { "m_Settings": [ - "RemoveLegacyInputHelpersForReload" + "RemoveLegacyInputHelpersForReload", + "ShouldQueryLegacyPackageRemoval" ] } \ No newline at end of file From 5d0d09d0bf30d157d01b433c56ddd419375a6da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacopo=20Lib=C3=A8?= Date: Thu, 18 Nov 2021 23:27:47 +0100 Subject: [PATCH 2/2] Added missing files --- Unity/Assets/Exported.meta | 8 + Unity/Assets/Plugins.meta | 8 + .../Editor/OpenVRPackageInstaller.cs | 470 ------ .../Editor/OpenVRPackageInstaller.cs.meta | 10 - .../Editor/OpenVRSimpleJSON.cs | 1352 ----------------- .../Editor/OpenVRSimpleJSON.cs.meta | 10 - Unity/Assets/StreamingAssets/StreamingAssets | Bin 1170 -> 1203 bytes .../StreamingAssets/StreamingAssets.manifest | 29 +- .../StreamingAssets/cockpit-buttons.manifest | 2 +- .../StreamingAssets/handheld-buttons.manifest | 4 +- Unity/Assets/StreamingAssets/xrmanager | Bin 0 -> 1963 bytes .../Assets/StreamingAssets/xrmanager.manifest | 27 + .../StreamingAssets/xrmanager.manifest.meta | 7 + Unity/Assets/StreamingAssets/xrmanager.meta | 7 + Unity/Assets/XR.meta | 8 + Unity/Assets/XR/Loaders.meta | 8 + Unity/Assets/XR/Loaders/Open VR Loader.asset | 14 + .../XR/Loaders/Open VR Loader.asset.meta | 8 + Unity/Assets/XR/Settings.meta | 8 + .../Assets/XR/Settings/Open VR Settings.asset | 23 + .../XR/Settings/Open VR Settings.asset.meta | 8 + Unity/Assets/XR/XRGeneralSettings.asset | 48 + Unity/Assets/XR/XRGeneralSettings.asset.meta | 8 + .../ProjectSettings/EditorBuildSettings.asset | 4 +- 24 files changed, 211 insertions(+), 1860 deletions(-) create mode 100644 Unity/Assets/Exported.meta create mode 100644 Unity/Assets/Plugins.meta delete mode 100644 Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs delete mode 100644 Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs.meta delete mode 100644 Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs delete mode 100644 Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs.meta create mode 100644 Unity/Assets/StreamingAssets/xrmanager create mode 100644 Unity/Assets/StreamingAssets/xrmanager.manifest create mode 100644 Unity/Assets/StreamingAssets/xrmanager.manifest.meta create mode 100644 Unity/Assets/StreamingAssets/xrmanager.meta create mode 100644 Unity/Assets/XR.meta create mode 100644 Unity/Assets/XR/Loaders.meta create mode 100644 Unity/Assets/XR/Loaders/Open VR Loader.asset create mode 100644 Unity/Assets/XR/Loaders/Open VR Loader.asset.meta create mode 100644 Unity/Assets/XR/Settings.meta create mode 100644 Unity/Assets/XR/Settings/Open VR Settings.asset create mode 100644 Unity/Assets/XR/Settings/Open VR Settings.asset.meta create mode 100644 Unity/Assets/XR/XRGeneralSettings.asset create mode 100644 Unity/Assets/XR/XRGeneralSettings.asset.meta diff --git a/Unity/Assets/Exported.meta b/Unity/Assets/Exported.meta new file mode 100644 index 0000000..420abc8 --- /dev/null +++ b/Unity/Assets/Exported.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 856a644959c72ce4b903bac0ca7af702 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/Plugins.meta b/Unity/Assets/Plugins.meta new file mode 100644 index 0000000..52c81fb --- /dev/null +++ b/Unity/Assets/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef055b6a6673ade498157dbd77c74d7f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs b/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs deleted file mode 100644 index 774a5f5..0000000 --- a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs +++ /dev/null @@ -1,470 +0,0 @@ -#if (UNITY_EDITOR && UNITY_2019_1_OR_NEWER) - -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Unity.XR.OpenVR.SimpleJSON; -using UnityEditor; -using UnityEditor.PackageManager; -using UnityEditor.PackageManager.Requests; -using UnityEditor.PackageManager.UI; -using UnityEngine; -using UnityEngine.Networking; - -namespace Unity.XR.OpenVR -{ - [InitializeOnLoad] - public class OpenVRPackageInstaller : ScriptableObject - { - private const string valveOpenVRPackageString = "com.valvesoftware.unity.openvr"; - - - private static ListRequest listRequest; - private static AddRequest addRequest; - - private static System.Diagnostics.Stopwatch packageTime = new System.Diagnostics.Stopwatch(); - private const float estimatedTimeToInstall = 90; // in seconds - - private const string updaterKeyTemplate = "com.valvesoftware.unity.openvr.updateState.{0}"; - private static string updaterKey - { - get { return string.Format(updaterKeyTemplate, Application.productName); } - } - - private static UpdateStates updateState - { - get { return _updateState; } - set - { -#if VALVE_DEBUG - Debug.Log("[DEBUG] Update State: " + value.ToString()); -#endif - _updateState = value; - EditorPrefs.SetInt(updaterKey, (int)value); - } - } - private static UpdateStates _updateState = UpdateStates.Idle; - - private static double runningSeconds - { - get - { - if (packageTime.IsRunning == false) - packageTime.Start(); - return packageTime.Elapsed.TotalSeconds; - } - } - - private static bool forced = false; - - public static void Start(bool force = false) - { - EditorApplication.update -= Update; - EditorApplication.update += Update; - - if (force) - { - RemoveScopedRegistry(); - } - } - - static OpenVRPackageInstaller() - { - #if OPENVR_XR_API //if we're updating, go ahead and just start - Start(); - #endif - } - - /// - /// State Machine - /// Idle: Start from last known state. If none is known, ask user if they want to install, if yes goto remove scoped registry step - /// WaitingOnExistingCheck: - /// RemoveScopedRegistry: Remove the scoped registry entry if it exists - /// WaitingForAdd: if the add request has been nulled or completed successfully, request a list of packages for confirmation - /// WaitingForAddConfirmation: enumerate the packages and verify the add succeeded. If it failed, try again. - /// If it succeeded request removal of this script - /// RemoveSelf: delete the key that we've been using to maintain state. Delete this script and the containing folder if it's empty. - /// - private static void Update() - { - switch (updateState) - { - case UpdateStates.Idle: - if (EditorPrefs.HasKey(updaterKey)) - { - _updateState = (UpdateStates)EditorPrefs.GetInt(updaterKey); - packageTime.Start(); - } - else - { - RequestExisting(); - } - break; - - case UpdateStates.WaitingOnExistingCheck: - if (listRequest == null) - { - //the list request got nulled for some reason. Request it again. - RequestExisting(); - } - else if (listRequest != null && listRequest.IsCompleted) - { - if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure) - { - DisplayErrorAndStop("Error while checking for an existing OpenVR package.", listRequest); - } - else - { - if (listRequest.Result.Any(package => package.name == valveOpenVRPackageString)) - { - var existingPackage = listRequest.Result.FirstOrDefault(package => package.name == valveOpenVRPackageString); - - string latestTarball = GetLatestTarballVersion(); - - if (latestTarball != null && latestTarball.CompareTo(existingPackage.version) == 1) - { - //we have a tarball higher than the currently installed version - string upgradeString = string.Format("This SteamVR Unity Plugin has a newer version of the Unity XR OpenVR package than you have installed. Would you like to upgrade?\n\nCurrent: {0}\nUpgrade: {1} (recommended)", existingPackage.version, latestTarball); - bool upgrade = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Updater", upgradeString, "Upgrade", "Cancel"); - if (upgrade) - RemoveScopedRegistry(); - else - { - bool delete = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Updater", "Would you like to remove this updater script so we don't ask again?", "Remove updater", "Keep"); - if (delete) - { - Stop(); - return; - } - else - { - GentleStop(); - return; - } - } - } - } - else - { - #if UNITY_2020_1_OR_NEWER - RemoveScopedRegistry(); //just install if we're on 2020 and they don't have the package - return; - #else - //they don't have the package yet. Ask if they want to install (only for 2019) - bool blankInstall = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Installer", "The SteamVR Unity Plugin can be used with the legacy Unity VR API (Unity 5.4 - 2019) or with the Unity XR API (2019+). Would you like to install OpenVR for Unity XR?", "Install", "Cancel"); - if (blankInstall) - RemoveScopedRegistry(); - else - { - bool delete = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Installer", "Would you like to remove this installer script so we don't ask again?", "Remove installer", "Keep"); - if (delete) - { - Stop(); - return; - } - else - { - GentleStop(); - return; - } - } - #endif - } - } - } - break; - - case UpdateStates.WaitingForAdd: - if (addRequest == null) - { - //the add request got nulled for some reason. Request an add confirmation - RequestAddConfirmation(); - } - else if (addRequest != null && addRequest.IsCompleted) - { - if (addRequest.Error != null || addRequest.Status == UnityEditor.PackageManager.StatusCode.Failure) - { - DisplayErrorAndStop("Error adding new version of OpenVR package.", addRequest); - } - else - { - //verify that the package has been added (then stop) - RequestAddConfirmation(); - } - } - else - { - if (packageTime.Elapsed.TotalSeconds > estimatedTimeToInstall) - DisplayErrorAndStop("Error while trying to add package.", addRequest); - else - DisplayProgressBar(); - } - break; - - case UpdateStates.WaitingForAddConfirmation: - if (listRequest == null) - { - //the list request got nulled for some reason. Request it again. - RequestAddConfirmation(); - } - else if (listRequest != null && listRequest.IsCompleted) - { - if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure) - { - DisplayErrorAndStop("Error while confirming the OpenVR package has been added.", listRequest); - } - else - { - if (listRequest.Result.Any(package => package.name == valveOpenVRPackageString)) - { - updateState = UpdateStates.RemoveSelf; - UnityEditor.EditorUtility.DisplayDialog("OpenVR Unity XR Installer", "OpenVR Unity XR successfully installed.\n\nA restart of the Unity Editor may be necessary.", "Ok"); - } - else - { - //try to add again if it's not there and we don't know why - RequestAdd(); - } - } - } - else - { - if (runningSeconds > estimatedTimeToInstall) - { - DisplayErrorAndStop("Error while confirming the OpenVR package has been added.", listRequest); - } - else - DisplayProgressBar(); - } - break; - - case UpdateStates.RemoveSelf: - EditorPrefs.DeleteKey(updaterKey); - EditorUtility.ClearProgressBar(); - EditorApplication.update -= Update; - -#if VALVE_SKIP_DELETE - Debug.Log("[DEBUG] skipping script deletion. Complete."); - return; -#endif - - var script = MonoScript.FromScriptableObject(OpenVRPackageInstaller.CreateInstance()); - var path = AssetDatabase.GetAssetPath(script); - FileInfo updaterScript = new FileInfo(path); updaterScript.IsReadOnly = false; - FileInfo updaterScriptMeta = new FileInfo(path + ".meta"); - FileInfo simpleJSONScript = new FileInfo(Path.Combine(updaterScript.Directory.FullName, "OpenVRSimpleJSON.cs")); - FileInfo simpleJSONScriptMeta = new FileInfo(Path.Combine(updaterScript.Directory.FullName, "OpenVRSimpleJSON.cs.meta")); - - updaterScript.IsReadOnly = false; - updaterScriptMeta.IsReadOnly = false; - simpleJSONScript.IsReadOnly = false; - simpleJSONScriptMeta.IsReadOnly = false; - - updaterScriptMeta.Delete(); - if (updaterScriptMeta.Exists) - { - DisplayErrorAndStop("Error while removing package installer script. Please delete manually.", listRequest); - return; - } - - simpleJSONScript.Delete(); - simpleJSONScriptMeta.Delete(); - updaterScript.Delete(); - - AssetDatabase.Refresh(); - break; - } - } - - private static string GetLatestTarballVersion() - { - FileInfo[] files; - FileInfo latest = GetAvailableTarballs(out files); - - if (latest == null) - return null; - - return GetTarballVersion(latest); - } - - private static FileInfo GetAvailableTarballs(out FileInfo[] packages) - { - var installerScript = MonoScript.FromScriptableObject(OpenVRPackageInstaller.CreateInstance()); - var scriptPath = AssetDatabase.GetAssetPath(installerScript); - FileInfo thisScript = new FileInfo(scriptPath); - - packages = thisScript.Directory.GetFiles("*.tgz"); - - if (packages.Length > 0) - { - if (packages.Length > 1) - { - var descending = packages.OrderByDescending(file => file.Name); - var latest = descending.First(); - packages = descending.Where(file => file != latest).ToArray(); - return latest; - } - - var onlyPackage = packages[0]; - packages = new FileInfo[0]; - return onlyPackage; - } - else - return null; - } - - private static string GetTarballVersion(FileInfo file) - { - int startIndex = file.Name.IndexOf('-') + 1; - int endIndex = file.Name.IndexOf(".tgz"); - int len = endIndex - startIndex; - return file.Name.Substring(startIndex, len); - } - - private const string packageManifestPath = "Packages/manifest.json"; - private const string scopedRegistryKey = "scopedRegistries"; - private const string npmRegistryName = "Valve"; - - //load packages.json - //check for existing scoped registries - //check for our scoped registry - //if no to either then add it - //save file - //reload - private static void RemoveScopedRegistry() - { - updateState = UpdateStates.RemoveOldRegistry; - packageTime.Start(); - - if (File.Exists(packageManifestPath) == false) - { - Debug.LogWarning("[OpenVR Installer] Could not find package manifest at: " + packageManifestPath); - - RequestAdd(); - return; - } - - string jsonText = File.ReadAllText(packageManifestPath); - JSONNode manifest = JSON.Parse(jsonText); - - if (manifest.HasKey(scopedRegistryKey) == true) - { - if (manifest[scopedRegistryKey].HasKey(npmRegistryName)) - { - manifest[scopedRegistryKey].Remove(npmRegistryName); - - File.WriteAllText(packageManifestPath, manifest.ToString(2)); - Debug.Log("[OpenVR Installer] Removed Valve entry from scoped registry."); - } - } - - RequestAdd(); - } - - private static void RequestAdd() - { - updateState = UpdateStates.WaitingForAdd; - - FileInfo[] oldFiles; - FileInfo latest = GetAvailableTarballs(out oldFiles); - - if (latest != null) - { - if (oldFiles.Length > 0) - { - var oldFilesNames = oldFiles.Select(file => file.Name); - string oldFilesString = string.Join("\n", oldFilesNames); - bool delete = UnityEditor.EditorUtility.DisplayDialog("OpenVR XR Installer", "Would you like to delete the old OpenVR packages?\n\n" + oldFilesString, "Delete old files", "Keep"); - if (delete) - { - foreach (FileInfo file in oldFiles) - { - FileInfo meta = new FileInfo(file.FullName + ".meta"); - if (meta.Exists) - { - meta.IsReadOnly = false; - meta.Delete(); - } - - if (file.Exists) - { - file.IsReadOnly = false; - file.Delete(); - } - } - } - } - - string packagePath = latest.FullName; - if (packagePath != null) - { - string packageAbsolute = packagePath.Replace("\\", "/"); - string packageRelative = packageAbsolute.Substring(packageAbsolute.IndexOf("/Assets/")); - string packageURI = System.Uri.EscapeUriString(packageRelative); - addRequest = UnityEditor.PackageManager.Client.Add("file:.." + packageURI); - } - else - { - updateState = UpdateStates.RemoveSelf; - } - } - } - - private static void RequestAddConfirmation() - { - updateState = UpdateStates.WaitingForAddConfirmation; - listRequest = Client.List(true, true); - } - - private static void RequestExisting() - { - updateState = UpdateStates.WaitingOnExistingCheck; - listRequest = Client.List(true, true); - } - - private static string dialogText = "Installing OpenVR Unity XR package from local storage using Unity Package Manager..."; - - private static void DisplayProgressBar() - { - bool cancel = UnityEditor.EditorUtility.DisplayCancelableProgressBar("SteamVR", dialogText, (float)packageTime.Elapsed.TotalSeconds / estimatedTimeToInstall); - if (cancel) - Stop(); - } - - private static void DisplayErrorAndStop(string stepInfo, Request request) - { - string error = ""; - if (request != null) - error = request.Error.message; - - string errorMessage = string.Format("{0}:\n\t{1}\n\nPlease manually reinstall the package through the package manager.", stepInfo, error); - - UnityEngine.Debug.LogError(errorMessage); - - Stop(); - - UnityEditor.EditorUtility.DisplayDialog("OpenVR Error", errorMessage, "Ok"); - } - - private static void Stop() - { - updateState = UpdateStates.RemoveSelf; - } - - private static void GentleStop() - { - EditorApplication.update -= Update; - } - - private enum UpdateStates - { - Idle, - WaitingOnExistingCheck, - RemoveOldRegistry, - WaitingForAdd, - WaitingForAddConfirmation, - RemoveSelf, - } - } -} -#endif \ No newline at end of file diff --git a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs.meta b/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs.meta deleted file mode 100644 index 4df3077..0000000 --- a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRPackageInstaller.cs.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 538300977557ee34892368a50c97bdd6 -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs b/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs deleted file mode 100644 index e60979b..0000000 --- a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs +++ /dev/null @@ -1,1352 +0,0 @@ -/* * * * * - * A simple JSON Parser / builder - * ------------------------------ - * - * It mainly has been written as a simple JSON parser. It can build a JSON string - * from the node-tree, or generate a node tree from any valid JSON string. - * - * Written by Bunny83 - * 2012-06-09 - * - * Changelog now external. See Changelog.txt - * - * The MIT License (MIT) - * - * Copyright (c) 2012-2019 Markus Göbel (Bunny83) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * * * * */ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; - -namespace Unity.XR.OpenVR.SimpleJSON -{ - public enum JSONNodeType - { - Array = 1, - Object = 2, - String = 3, - Number = 4, - NullValue = 5, - Boolean = 6, - None = 7, - Custom = 0xFF, - } - public enum JSONTextMode - { - Compact, - Indent - } - - public abstract partial class JSONNode - { - #region Enumerators - public struct Enumerator - { - private enum Type { None, Array, Object } - private Type type; - private Dictionary.Enumerator m_Object; - private List.Enumerator m_Array; - public bool IsValid { get { return type != Type.None; } } - public Enumerator(List.Enumerator aArrayEnum) - { - type = Type.Array; - m_Object = default(Dictionary.Enumerator); - m_Array = aArrayEnum; - } - public Enumerator(Dictionary.Enumerator aDictEnum) - { - type = Type.Object; - m_Object = aDictEnum; - m_Array = default(List.Enumerator); - } - public KeyValuePair Current - { - get - { - if (type == Type.Array) - return new KeyValuePair(string.Empty, m_Array.Current); - else if (type == Type.Object) - return m_Object.Current; - return new KeyValuePair(string.Empty, null); - } - } - public bool MoveNext() - { - if (type == Type.Array) - return m_Array.MoveNext(); - else if (type == Type.Object) - return m_Object.MoveNext(); - return false; - } - } - public struct ValueEnumerator - { - private Enumerator m_Enumerator; - public ValueEnumerator(List.Enumerator aArrayEnum) : this(new Enumerator(aArrayEnum)) { } - public ValueEnumerator(Dictionary.Enumerator aDictEnum) : this(new Enumerator(aDictEnum)) { } - public ValueEnumerator(Enumerator aEnumerator) { m_Enumerator = aEnumerator; } - public JSONNode Current { get { return m_Enumerator.Current.Value; } } - public bool MoveNext() { return m_Enumerator.MoveNext(); } - public ValueEnumerator GetEnumerator() { return this; } - } - public struct KeyEnumerator - { - private Enumerator m_Enumerator; - public KeyEnumerator(List.Enumerator aArrayEnum) : this(new Enumerator(aArrayEnum)) { } - public KeyEnumerator(Dictionary.Enumerator aDictEnum) : this(new Enumerator(aDictEnum)) { } - public KeyEnumerator(Enumerator aEnumerator) { m_Enumerator = aEnumerator; } - public string Current { get { return m_Enumerator.Current.Key; } } - public bool MoveNext() { return m_Enumerator.MoveNext(); } - public KeyEnumerator GetEnumerator() { return this; } - } - - public class LinqEnumerator : IEnumerator>, IEnumerable> - { - private JSONNode m_Node; - private Enumerator m_Enumerator; - internal LinqEnumerator(JSONNode aNode) - { - m_Node = aNode; - if (m_Node != null) - m_Enumerator = m_Node.GetEnumerator(); - } - public KeyValuePair Current { get { return m_Enumerator.Current; } } - object IEnumerator.Current { get { return m_Enumerator.Current; } } - public bool MoveNext() { return m_Enumerator.MoveNext(); } - - public void Dispose() - { - m_Node = null; - m_Enumerator = new Enumerator(); - } - - public IEnumerator> GetEnumerator() - { - return new LinqEnumerator(m_Node); - } - - public void Reset() - { - if (m_Node != null) - m_Enumerator = m_Node.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return new LinqEnumerator(m_Node); - } - } - - #endregion Enumerators - - #region common interface - - public static bool forceASCII = false; // Use Unicode by default - public static bool longAsString = false; // lazy creator creates a JSONString instead of JSONNumber - public static bool allowLineComments = true; // allow "//"-style comments at the end of a line - - public abstract JSONNodeType Tag { get; } - - public virtual JSONNode this[int aIndex] { get { return null; } set { } } - - public virtual JSONNode this[string aKey] { get { return null; } set { } } - - public virtual string Value { get { return ""; } set { } } - - public virtual int Count { get { return 0; } } - - public virtual bool IsNumber { get { return false; } } - public virtual bool IsString { get { return false; } } - public virtual bool IsBoolean { get { return false; } } - public virtual bool IsNull { get { return false; } } - public virtual bool IsArray { get { return false; } } - public virtual bool IsObject { get { return false; } } - - public virtual bool Inline { get { return false; } set { } } - - public virtual void Add(string aKey, JSONNode aItem) - { - } - public virtual void Add(JSONNode aItem) - { - Add("", aItem); - } - - public virtual JSONNode Remove(string aKey) - { - return null; - } - - public virtual JSONNode Remove(int aIndex) - { - return null; - } - - public virtual JSONNode Remove(JSONNode aNode) - { - return aNode; - } - - public virtual JSONNode Clone() - { - return null; - } - - public virtual IEnumerable Children - { - get - { - yield break; - } - } - - public IEnumerable DeepChildren - { - get - { - foreach (var C in Children) - foreach (var D in C.DeepChildren) - yield return D; - } - } - - public virtual bool HasKey(string aKey) - { - return false; - } - - public virtual JSONNode GetValueOrDefault(string aKey, JSONNode aDefault) - { - return aDefault; - } - - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - WriteToStringBuilder(sb, 0, 0, JSONTextMode.Compact); - return sb.ToString(); - } - - public virtual string ToString(int aIndent) - { - StringBuilder sb = new StringBuilder(); - WriteToStringBuilder(sb, 0, aIndent, JSONTextMode.Indent); - return sb.ToString(); - } - internal abstract void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode); - - public abstract Enumerator GetEnumerator(); - public IEnumerable> Linq { get { return new LinqEnumerator(this); } } - public KeyEnumerator Keys { get { return new KeyEnumerator(GetEnumerator()); } } - public ValueEnumerator Values { get { return new ValueEnumerator(GetEnumerator()); } } - - #endregion common interface - - #region typecasting properties - - - public virtual double AsDouble - { - get - { - double v = 0.0; - if (double.TryParse(Value, NumberStyles.Float, CultureInfo.InvariantCulture, out v)) - return v; - return 0.0; - } - set - { - Value = value.ToString(CultureInfo.InvariantCulture); - } - } - - public virtual int AsInt - { - get { return (int)AsDouble; } - set { AsDouble = value; } - } - - public virtual float AsFloat - { - get { return (float)AsDouble; } - set { AsDouble = value; } - } - - public virtual bool AsBool - { - get - { - bool v = false; - if (bool.TryParse(Value, out v)) - return v; - return !string.IsNullOrEmpty(Value); - } - set - { - Value = (value) ? "true" : "false"; - } - } - - public virtual long AsLong - { - get - { - long val = 0; - if (long.TryParse(Value, out val)) - return val; - return 0L; - } - set - { - Value = value.ToString(); - } - } - - public virtual JSONArray AsArray - { - get - { - return this as JSONArray; - } - } - - public virtual JSONObject AsObject - { - get - { - return this as JSONObject; - } - } - - - #endregion typecasting properties - - #region operators - - public static implicit operator JSONNode(string s) - { - return new JSONString(s); - } - public static implicit operator string(JSONNode d) - { - return (d == null) ? null : d.Value; - } - - public static implicit operator JSONNode(double n) - { - return new JSONNumber(n); - } - public static implicit operator double(JSONNode d) - { - return (d == null) ? 0 : d.AsDouble; - } - - public static implicit operator JSONNode(float n) - { - return new JSONNumber(n); - } - public static implicit operator float(JSONNode d) - { - return (d == null) ? 0 : d.AsFloat; - } - - public static implicit operator JSONNode(int n) - { - return new JSONNumber(n); - } - public static implicit operator int(JSONNode d) - { - return (d == null) ? 0 : d.AsInt; - } - - public static implicit operator JSONNode(long n) - { - if (longAsString) - return new JSONString(n.ToString()); - return new JSONNumber(n); - } - public static implicit operator long(JSONNode d) - { - return (d == null) ? 0L : d.AsLong; - } - - public static implicit operator JSONNode(bool b) - { - return new JSONBool(b); - } - public static implicit operator bool(JSONNode d) - { - return (d == null) ? false : d.AsBool; - } - - public static implicit operator JSONNode(KeyValuePair aKeyValue) - { - return aKeyValue.Value; - } - - public static bool operator ==(JSONNode a, object b) - { - if (ReferenceEquals(a, b)) - return true; - bool aIsNull = a is JSONNull || ReferenceEquals(a, null) || a is JSONLazyCreator; - bool bIsNull = b is JSONNull || ReferenceEquals(b, null) || b is JSONLazyCreator; - if (aIsNull && bIsNull) - return true; - return !aIsNull && a.Equals(b); - } - - public static bool operator !=(JSONNode a, object b) - { - return !(a == b); - } - - public override bool Equals(object obj) - { - return ReferenceEquals(this, obj); - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - #endregion operators - - [ThreadStatic] - private static StringBuilder m_EscapeBuilder; - internal static StringBuilder EscapeBuilder - { - get - { - if (m_EscapeBuilder == null) - m_EscapeBuilder = new StringBuilder(); - return m_EscapeBuilder; - } - } - internal static string Escape(string aText) - { - var sb = EscapeBuilder; - sb.Length = 0; - if (sb.Capacity < aText.Length + aText.Length / 10) - sb.Capacity = aText.Length + aText.Length / 10; - foreach (char c in aText) - { - switch (c) - { - case '\\': - sb.Append("\\\\"); - break; - case '\"': - sb.Append("\\\""); - break; - case '\n': - sb.Append("\\n"); - break; - case '\r': - sb.Append("\\r"); - break; - case '\t': - sb.Append("\\t"); - break; - case '\b': - sb.Append("\\b"); - break; - case '\f': - sb.Append("\\f"); - break; - default: - if (c < ' ' || (forceASCII && c > 127)) - { - ushort val = c; - sb.Append("\\u").Append(val.ToString("X4")); - } - else - sb.Append(c); - break; - } - } - string result = sb.ToString(); - sb.Length = 0; - return result; - } - - private static JSONNode ParseElement(string token, bool quoted) - { - if (quoted) - return token; - string tmp = token.ToLower(); - if (tmp == "false" || tmp == "true") - return tmp == "true"; - if (tmp == "null") - return JSONNull.CreateOrGet(); - double val; - if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out val)) - return val; - else - return token; - } - - public static JSONNode Parse(string aJSON) - { - Stack stack = new Stack(); - JSONNode ctx = null; - int i = 0; - StringBuilder Token = new StringBuilder(); - string TokenName = ""; - bool QuoteMode = false; - bool TokenIsQuoted = false; - while (i < aJSON.Length) - { - switch (aJSON[i]) - { - case '{': - if (QuoteMode) - { - Token.Append(aJSON[i]); - break; - } - stack.Push(new JSONObject()); - if (ctx != null) - { - ctx.Add(TokenName, stack.Peek()); - } - TokenName = ""; - Token.Length = 0; - ctx = stack.Peek(); - break; - - case '[': - if (QuoteMode) - { - Token.Append(aJSON[i]); - break; - } - - stack.Push(new JSONArray()); - if (ctx != null) - { - ctx.Add(TokenName, stack.Peek()); - } - TokenName = ""; - Token.Length = 0; - ctx = stack.Peek(); - break; - - case '}': - case ']': - if (QuoteMode) - { - - Token.Append(aJSON[i]); - break; - } - if (stack.Count == 0) - throw new Exception("JSON Parse: Too many closing brackets"); - - stack.Pop(); - if (Token.Length > 0 || TokenIsQuoted) - ctx.Add(TokenName, ParseElement(Token.ToString(), TokenIsQuoted)); - TokenIsQuoted = false; - TokenName = ""; - Token.Length = 0; - if (stack.Count > 0) - ctx = stack.Peek(); - break; - - case ':': - if (QuoteMode) - { - Token.Append(aJSON[i]); - break; - } - TokenName = Token.ToString(); - Token.Length = 0; - TokenIsQuoted = false; - break; - - case '"': - QuoteMode ^= true; - TokenIsQuoted |= QuoteMode; - break; - - case ',': - if (QuoteMode) - { - Token.Append(aJSON[i]); - break; - } - if (Token.Length > 0 || TokenIsQuoted) - ctx.Add(TokenName, ParseElement(Token.ToString(), TokenIsQuoted)); - TokenIsQuoted = false; - TokenName = ""; - Token.Length = 0; - TokenIsQuoted = false; - break; - - case '\r': - case '\n': - break; - - case ' ': - case '\t': - if (QuoteMode) - Token.Append(aJSON[i]); - break; - - case '\\': - ++i; - if (QuoteMode) - { - char C = aJSON[i]; - switch (C) - { - case 't': - Token.Append('\t'); - break; - case 'r': - Token.Append('\r'); - break; - case 'n': - Token.Append('\n'); - break; - case 'b': - Token.Append('\b'); - break; - case 'f': - Token.Append('\f'); - break; - case 'u': - { - string s = aJSON.Substring(i + 1, 4); - Token.Append((char)int.Parse( - s, - System.Globalization.NumberStyles.AllowHexSpecifier)); - i += 4; - break; - } - default: - Token.Append(C); - break; - } - } - break; - case '/': - if (allowLineComments && !QuoteMode && i + 1 < aJSON.Length && aJSON[i + 1] == '/') - { - while (++i < aJSON.Length && aJSON[i] != '\n' && aJSON[i] != '\r') ; - break; - } - Token.Append(aJSON[i]); - break; - case '\uFEFF': // remove / ignore BOM (Byte Order Mark) - break; - - default: - Token.Append(aJSON[i]); - break; - } - ++i; - } - if (QuoteMode) - { - throw new Exception("JSON Parse: Quotation marks seems to be messed up."); - } - if (ctx == null) - return ParseElement(Token.ToString(), TokenIsQuoted); - return ctx; - } - - } - // End of JSONNode - - public partial class JSONArray : JSONNode - { - private List m_List = new List(); - private bool inline = false; - public override bool Inline - { - get { return inline; } - set { inline = value; } - } - - public override JSONNodeType Tag { get { return JSONNodeType.Array; } } - public override bool IsArray { get { return true; } } - public override Enumerator GetEnumerator() { return new Enumerator(m_List.GetEnumerator()); } - - public override JSONNode this[int aIndex] - { - get - { - if (aIndex < 0 || aIndex >= m_List.Count) - return new JSONLazyCreator(this); - return m_List[aIndex]; - } - set - { - if (value == null) - value = JSONNull.CreateOrGet(); - if (aIndex < 0 || aIndex >= m_List.Count) - m_List.Add(value); - else - m_List[aIndex] = value; - } - } - - public override JSONNode this[string aKey] - { - get { return new JSONLazyCreator(this); } - set - { - if (value == null) - value = JSONNull.CreateOrGet(); - m_List.Add(value); - } - } - - public override int Count - { - get { return m_List.Count; } - } - - public override void Add(string aKey, JSONNode aItem) - { - if (aItem == null) - aItem = JSONNull.CreateOrGet(); - m_List.Add(aItem); - } - - public override JSONNode Remove(int aIndex) - { - if (aIndex < 0 || aIndex >= m_List.Count) - return null; - JSONNode tmp = m_List[aIndex]; - m_List.RemoveAt(aIndex); - return tmp; - } - - public override JSONNode Remove(JSONNode aNode) - { - m_List.Remove(aNode); - return aNode; - } - - public override JSONNode Clone() - { - var node = new JSONArray(); - node.m_List.Capacity = m_List.Capacity; - foreach (var n in m_List) - { - if (n != null) - node.Add(n.Clone()); - else - node.Add(null); - } - return node; - } - - public override IEnumerable Children - { - get - { - foreach (JSONNode N in m_List) - yield return N; - } - } - - - internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) - { - aSB.Append('['); - int count = m_List.Count; - if (inline) - aMode = JSONTextMode.Compact; - for (int i = 0; i < count; i++) - { - if (i > 0) - aSB.Append(','); - if (aMode == JSONTextMode.Indent) - aSB.AppendLine(); - - if (aMode == JSONTextMode.Indent) - aSB.Append(' ', aIndent + aIndentInc); - m_List[i].WriteToStringBuilder(aSB, aIndent + aIndentInc, aIndentInc, aMode); - } - if (aMode == JSONTextMode.Indent) - aSB.AppendLine().Append(' ', aIndent); - aSB.Append(']'); - } - } - // End of JSONArray - - public partial class JSONObject : JSONNode - { - private Dictionary m_Dict = new Dictionary(); - - private bool inline = false; - public override bool Inline - { - get { return inline; } - set { inline = value; } - } - - public override JSONNodeType Tag { get { return JSONNodeType.Object; } } - public override bool IsObject { get { return true; } } - - public override Enumerator GetEnumerator() { return new Enumerator(m_Dict.GetEnumerator()); } - - - public override JSONNode this[string aKey] - { - get - { - if (m_Dict.ContainsKey(aKey)) - return m_Dict[aKey]; - else - return new JSONLazyCreator(this, aKey); - } - set - { - if (value == null) - value = JSONNull.CreateOrGet(); - if (m_Dict.ContainsKey(aKey)) - m_Dict[aKey] = value; - else - m_Dict.Add(aKey, value); - } - } - - public override JSONNode this[int aIndex] - { - get - { - if (aIndex < 0 || aIndex >= m_Dict.Count) - return null; - return m_Dict.ElementAt(aIndex).Value; - } - set - { - if (value == null) - value = JSONNull.CreateOrGet(); - if (aIndex < 0 || aIndex >= m_Dict.Count) - return; - string key = m_Dict.ElementAt(aIndex).Key; - m_Dict[key] = value; - } - } - - public override int Count - { - get { return m_Dict.Count; } - } - - public override void Add(string aKey, JSONNode aItem) - { - if (aItem == null) - aItem = JSONNull.CreateOrGet(); - - if (aKey != null) - { - if (m_Dict.ContainsKey(aKey)) - m_Dict[aKey] = aItem; - else - m_Dict.Add(aKey, aItem); - } - else - m_Dict.Add(Guid.NewGuid().ToString(), aItem); - } - - public override JSONNode Remove(string aKey) - { - if (!m_Dict.ContainsKey(aKey)) - return null; - JSONNode tmp = m_Dict[aKey]; - m_Dict.Remove(aKey); - return tmp; - } - - public override JSONNode Remove(int aIndex) - { - if (aIndex < 0 || aIndex >= m_Dict.Count) - return null; - var item = m_Dict.ElementAt(aIndex); - m_Dict.Remove(item.Key); - return item.Value; - } - - public override JSONNode Remove(JSONNode aNode) - { - try - { - var item = m_Dict.Where(k => k.Value == aNode).First(); - m_Dict.Remove(item.Key); - return aNode; - } - catch - { - return null; - } - } - - public override JSONNode Clone() - { - var node = new JSONObject(); - foreach (var n in m_Dict) - { - node.Add(n.Key, n.Value.Clone()); - } - return node; - } - - public override bool HasKey(string aKey) - { - return m_Dict.ContainsKey(aKey); - } - - public override JSONNode GetValueOrDefault(string aKey, JSONNode aDefault) - { - JSONNode res; - if (m_Dict.TryGetValue(aKey, out res)) - return res; - return aDefault; - } - - public override IEnumerable Children - { - get - { - foreach (KeyValuePair N in m_Dict) - yield return N.Value; - } - } - - internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) - { - aSB.Append('{'); - bool first = true; - if (inline) - aMode = JSONTextMode.Compact; - foreach (var k in m_Dict) - { - if (!first) - aSB.Append(','); - first = false; - if (aMode == JSONTextMode.Indent) - aSB.AppendLine(); - if (aMode == JSONTextMode.Indent) - aSB.Append(' ', aIndent + aIndentInc); - aSB.Append('\"').Append(Escape(k.Key)).Append('\"'); - if (aMode == JSONTextMode.Compact) - aSB.Append(':'); - else - aSB.Append(" : "); - k.Value.WriteToStringBuilder(aSB, aIndent + aIndentInc, aIndentInc, aMode); - } - if (aMode == JSONTextMode.Indent) - aSB.AppendLine().Append(' ', aIndent); - aSB.Append('}'); - } - - } - // End of JSONObject - - public partial class JSONString : JSONNode - { - private string m_Data; - - public override JSONNodeType Tag { get { return JSONNodeType.String; } } - public override bool IsString { get { return true; } } - - public override Enumerator GetEnumerator() { return new Enumerator(); } - - - public override string Value - { - get { return m_Data; } - set - { - m_Data = value; - } - } - - public JSONString(string aData) - { - m_Data = aData; - } - public override JSONNode Clone() - { - return new JSONString(m_Data); - } - - internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) - { - aSB.Append('\"').Append(Escape(m_Data)).Append('\"'); - } - public override bool Equals(object obj) - { - if (base.Equals(obj)) - return true; - string s = obj as string; - if (s != null) - return m_Data == s; - JSONString s2 = obj as JSONString; - if (s2 != null) - return m_Data == s2.m_Data; - return false; - } - public override int GetHashCode() - { - return m_Data.GetHashCode(); - } - } - // End of JSONString - - public partial class JSONNumber : JSONNode - { - private double m_Data; - - public override JSONNodeType Tag { get { return JSONNodeType.Number; } } - public override bool IsNumber { get { return true; } } - public override Enumerator GetEnumerator() { return new Enumerator(); } - - public override string Value - { - get { return m_Data.ToString(CultureInfo.InvariantCulture); } - set - { - double v; - if (double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out v)) - m_Data = v; - } - } - - public override double AsDouble - { - get { return m_Data; } - set { m_Data = value; } - } - public override long AsLong - { - get { return (long)m_Data; } - set { m_Data = value; } - } - - public JSONNumber(double aData) - { - m_Data = aData; - } - - public JSONNumber(string aData) - { - Value = aData; - } - - public override JSONNode Clone() - { - return new JSONNumber(m_Data); - } - - internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) - { - aSB.Append(Value); - } - private static bool IsNumeric(object value) - { - return value is int || value is uint - || value is float || value is double - || value is decimal - || value is long || value is ulong - || value is short || value is ushort - || value is sbyte || value is byte; - } - public override bool Equals(object obj) - { - if (obj == null) - return false; - if (base.Equals(obj)) - return true; - JSONNumber s2 = obj as JSONNumber; - if (s2 != null) - return m_Data == s2.m_Data; - if (IsNumeric(obj)) - return Convert.ToDouble(obj) == m_Data; - return false; - } - public override int GetHashCode() - { - return m_Data.GetHashCode(); - } - } - // End of JSONNumber - - public partial class JSONBool : JSONNode - { - private bool m_Data; - - public override JSONNodeType Tag { get { return JSONNodeType.Boolean; } } - public override bool IsBoolean { get { return true; } } - public override Enumerator GetEnumerator() { return new Enumerator(); } - - public override string Value - { - get { return m_Data.ToString(); } - set - { - bool v; - if (bool.TryParse(value, out v)) - m_Data = v; - } - } - public override bool AsBool - { - get { return m_Data; } - set { m_Data = value; } - } - - public JSONBool(bool aData) - { - m_Data = aData; - } - - public JSONBool(string aData) - { - Value = aData; - } - - public override JSONNode Clone() - { - return new JSONBool(m_Data); - } - - internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) - { - aSB.Append((m_Data) ? "true" : "false"); - } - public override bool Equals(object obj) - { - if (obj == null) - return false; - if (obj is bool) - return m_Data == (bool)obj; - return false; - } - public override int GetHashCode() - { - return m_Data.GetHashCode(); - } - } - // End of JSONBool - - public partial class JSONNull : JSONNode - { - static JSONNull m_StaticInstance = new JSONNull(); - public static bool reuseSameInstance = true; - public static JSONNull CreateOrGet() - { - if (reuseSameInstance) - return m_StaticInstance; - return new JSONNull(); - } - private JSONNull() { } - - public override JSONNodeType Tag { get { return JSONNodeType.NullValue; } } - public override bool IsNull { get { return true; } } - public override Enumerator GetEnumerator() { return new Enumerator(); } - - public override string Value - { - get { return "null"; } - set { } - } - public override bool AsBool - { - get { return false; } - set { } - } - - public override JSONNode Clone() - { - return CreateOrGet(); - } - - public override bool Equals(object obj) - { - if (object.ReferenceEquals(this, obj)) - return true; - return (obj is JSONNull); - } - public override int GetHashCode() - { - return 0; - } - - internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) - { - aSB.Append("null"); - } - } - // End of JSONNull - - internal partial class JSONLazyCreator : JSONNode - { - private JSONNode m_Node = null; - private string m_Key = null; - public override JSONNodeType Tag { get { return JSONNodeType.None; } } - public override Enumerator GetEnumerator() { return new Enumerator(); } - - public JSONLazyCreator(JSONNode aNode) - { - m_Node = aNode; - m_Key = null; - } - - public JSONLazyCreator(JSONNode aNode, string aKey) - { - m_Node = aNode; - m_Key = aKey; - } - - private T Set(T aVal) where T : JSONNode - { - if (m_Key == null) - m_Node.Add(aVal); - else - m_Node.Add(m_Key, aVal); - m_Node = null; // Be GC friendly. - return aVal; - } - - public override JSONNode this[int aIndex] - { - get { return new JSONLazyCreator(this); } - set { Set(new JSONArray()).Add(value); } - } - - public override JSONNode this[string aKey] - { - get { return new JSONLazyCreator(this, aKey); } - set { Set(new JSONObject()).Add(aKey, value); } - } - - public override void Add(JSONNode aItem) - { - Set(new JSONArray()).Add(aItem); - } - - public override void Add(string aKey, JSONNode aItem) - { - Set(new JSONObject()).Add(aKey, aItem); - } - - public static bool operator ==(JSONLazyCreator a, object b) - { - if (b == null) - return true; - return System.Object.ReferenceEquals(a, b); - } - - public static bool operator !=(JSONLazyCreator a, object b) - { - return !(a == b); - } - - public override bool Equals(object obj) - { - if (obj == null) - return true; - return System.Object.ReferenceEquals(this, obj); - } - - public override int GetHashCode() - { - return 0; - } - - public override int AsInt - { - get { Set(new JSONNumber(0)); return 0; } - set { Set(new JSONNumber(value)); } - } - - public override float AsFloat - { - get { Set(new JSONNumber(0.0f)); return 0.0f; } - set { Set(new JSONNumber(value)); } - } - - public override double AsDouble - { - get { Set(new JSONNumber(0.0)); return 0.0; } - set { Set(new JSONNumber(value)); } - } - - public override long AsLong - { - get - { - if (longAsString) - Set(new JSONString("0")); - else - Set(new JSONNumber(0.0)); - return 0L; - } - set - { - if (longAsString) - Set(new JSONString(value.ToString())); - else - Set(new JSONNumber(value)); - } - } - - public override bool AsBool - { - get { Set(new JSONBool(false)); return false; } - set { Set(new JSONBool(value)); } - } - - public override JSONArray AsArray - { - get { return Set(new JSONArray()); } - } - - public override JSONObject AsObject - { - get { return Set(new JSONObject()); } - } - internal override void WriteToStringBuilder(StringBuilder aSB, int aIndent, int aIndentInc, JSONTextMode aMode) - { - aSB.Append("null"); - } - } - // End of JSONLazyCreator - - public static class JSON - { - public static JSONNode Parse(string aJSON) - { - return JSONNode.Parse(aJSON); - } - } -} \ No newline at end of file diff --git a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs.meta b/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs.meta deleted file mode 100644 index 7ef1d6a..0000000 --- a/Unity/Assets/SteamVR/OpenVRUnityXRPackage/Editor/OpenVRSimpleJSON.cs.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: ca02308d9febaa442a742ecaaaa06d2c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Unity/Assets/StreamingAssets/StreamingAssets b/Unity/Assets/StreamingAssets/StreamingAssets index d51bd09af7bf394ea9f9d154e0cb6d0d26c98f3d..acf96ef6006fee65ef42d0d29146953d5c195605 100644 GIT binary patch delta 1091 zcmV-J1ibr_39|{1B>}UMCL;x~000CskxoBO~ zS(&bHMa+)Cj4X~2yySXlxAOebS@HKT{Yx`v3*GOW7J>k>BD&Wsl3w)@z7T|gwL$=Y zbtvH9QW;e+lG>OvL;OlC0wjA-cN>9dO>At8d$@2{c^YT8Gvc{mYZ%?P+}$h5Nvath zPlBmxa(>M+LAERUndD{6#1iEkiZ2lYwrXd#!A^5NO6N897)Prk=L9M55m2Z-o;3^e z#9<5d__0do#*L?bGVs~p8%BK7w1+^enh!O!KOFg_Y#3moL2lsIGFk@V8VpgBA_3K&I^RUCGStJLOz zqGci+gtzj$NjTdRdO-K#Yef?dNT!ch>Gvq{LAfujj}6h@?r(!}lM=PN2H9SJ)5R-f zn!=W_2PrMOfj_LmV3jXCRS0jG`nyJ>kLI+RE|a}^4%csiAqrZ?gndVu1{ZCz3rT^ZfX~qQ|I(E=l?R}Jbyyk zLT?3Y00A{2`umk&a0cJ0Vr~-yB7W=>Pq|7GBQ~Y3JusZIid9jOpC9n+D`?Pgof+&y1njp>a%V{GMs>-@RDFkD4Gfu{^et8BBRty zis}38v<0{I1EmHnD>y;bJbBiA^LTHzit3|IX`T_sd~3=JzY@zc^Gj$SoLfm> zcW?WV1%YTadicgJCo4V1>>IsS=KmM2yJ~cDK5;cfYKxQcx_3?ZuEj>DIHnebFeHC< JUjMf?NsxR}8mIsO delta 1058 zcmV+-1l{|y36cqrB>|F=CL;xe000CLkxoBq&kbF#tZBCO7u2!2QaDlMhYs!RR!_ z+vx<`vJ{-x#_A{L+r%z6QHbvPYQT1XekO$-W$^B}oj=u!o4?!01MD^8++6r1m9WFx zpYq#H#hM_jP$Kc{k2In8l1Hp`U=#$1P6eyAWo>*{^dJ%vqQYpk)G!?oAqz+jOHVg@ z^|i!AQ|h5bR{M$>67?DFD2BZnG6-!f;?hHAo!W-Kf84i9Td-X)cA}7PH{RQSq;fUp zSGHO|K-_tUjfyQ&Ll0q8l~+$&YXRI?C6rRpqmBQ+2#0Fo&KZ$E>6c;HvIZr3T};Ge zZV_iuD_WYi&S@=gMfepHsC$`I!qgNRyx&6Bd@o8N%*s(oC%o2#ee<|K7i#^uWplj7 zgpOfGW(xiiuj-BPVsd{%U8I?Rqsm=@@E~`a#*-1is*M7GAqs}SCW@RgReB8Qrd$K( zMT<*8Omk@!Or&PU(ENSxhd!oS+e#79RF}TA&ImGGXvkq(|A>-74Tct=N?~hdRwCSrqq_{d%pKaR-xZJNiJF!GwZ3SV>NS7sn zoHLMHC=(Z4Zc=BPrq`o?jYnsL((Y!FJz8L8p$}r4;LAH=Oo5#+DWvYzB&n+ cxfpEj>aw?)n}RS6{6**wm3Lsr6ZVnE$z|#cO#lD@ diff --git a/Unity/Assets/StreamingAssets/StreamingAssets.manifest b/Unity/Assets/StreamingAssets/StreamingAssets.manifest index 60d9488..73298fd 100644 --- a/Unity/Assets/StreamingAssets/StreamingAssets.manifest +++ b/Unity/Assets/StreamingAssets/StreamingAssets.manifest @@ -1,20 +1,23 @@ ManifestFileVersion: 0 -CRC: 1052433192 +CRC: 296101864 AssetBundleManifest: AssetBundleInfos: Info_0: - Name: vrbindings-textures - Dependencies: {} - Info_1: - Name: steamvr-shaders - Dependencies: {} - Info_2: - Name: autopilot-button - Dependencies: {} - Info_3: - Name: cockpit-buttons - Dependencies: {} - Info_4: Name: handheld-buttons Dependencies: Dependency_0: cockpit-buttons + Info_1: + Name: cockpit-buttons + Dependencies: {} + Info_2: + Name: vrbindings-textures + Dependencies: {} + Info_3: + Name: autopilot-button + Dependencies: {} + Info_4: + Name: steamvr-shaders + Dependencies: {} + Info_5: + Name: xrmanager + Dependencies: {} diff --git a/Unity/Assets/StreamingAssets/cockpit-buttons.manifest b/Unity/Assets/StreamingAssets/cockpit-buttons.manifest index f15bab9..e070636 100644 --- a/Unity/Assets/StreamingAssets/cockpit-buttons.manifest +++ b/Unity/Assets/StreamingAssets/cockpit-buttons.manifest @@ -3,7 +3,7 @@ CRC: 3083433590 Hashes: AssetFileHash: serializedVersion: 2 - Hash: 33369c80450e16e9a822bb418b79798f + Hash: cbf3af2b6fe41877ccffd1e73c016a9b TypeTreeHash: serializedVersion: 2 Hash: c7c5dc534e7357b33d15743fbed05b86 diff --git a/Unity/Assets/StreamingAssets/handheld-buttons.manifest b/Unity/Assets/StreamingAssets/handheld-buttons.manifest index d6a04ac..6fc01c5 100644 --- a/Unity/Assets/StreamingAssets/handheld-buttons.manifest +++ b/Unity/Assets/StreamingAssets/handheld-buttons.manifest @@ -3,7 +3,7 @@ CRC: 486693342 Hashes: AssetFileHash: serializedVersion: 2 - Hash: 8a843ffc73fb5334b006d9028aaeca26 + Hash: 88e5d2adc94bd64e72dbef1bac41c0b8 TypeTreeHash: serializedVersion: 2 Hash: c7c5dc534e7357b33d15743fbed05b86 @@ -35,4 +35,4 @@ Assets: - Assets/HandheldTools/SignalscopeButtons.prefab - Assets/HandheldTools/Models/ProbeLauncherScreen.fbx Dependencies: -- C:/Users/rai/Repos/nomai-vr/Unity/Assets/StreamingAssets/cockpit-buttons +- E:/ArtumRepos/Modding/OuterWilds/nomai-upstream/Unity/Assets/StreamingAssets/cockpit-buttons diff --git a/Unity/Assets/StreamingAssets/xrmanager b/Unity/Assets/StreamingAssets/xrmanager new file mode 100644 index 0000000000000000000000000000000000000000..dc6eb2b671041a01d5d7ba1582be52e00e755ef5 GIT binary patch literal 1963 zcmV;c2UPe~ZfSIRMpFO)000LyE_g0@05UK!IW9CVGB;*10000000007s{jB1K>z>% zTL1t6LjV8(00000000000000U009890RR9XNB{r_DgZ$a00;p902%=B7ytxAK|(Dy zH#cH4HDWelG%+_YH928rGdW{pVmW3vWietiIb<*ZT>tCah9!QLJ4Vi%j#>{>kTIFRVPLOUOAhIifc4^arn{F=L!VM;JT4M= zg1HR219?&SGDMIPzYBr6*Jjcnc>@JQ);+r|cG^@CLja-SzP9G06CV?AN-5g0$-bT! z_5@j7SYYgvAE5iHM?O`2;mLkJE^@7`mat{GdrenhSq33R6AWxb5m0^WA)zepe(6IZ zS5Quyc$}i+Fz#Y_`RU@{_(^W**c-FnHOsbdDh2s^@0xGdV2>!f)zPk@zy@XhAuvgt znUP;_P_F%)dJS$YecL3WiMJEoa4r!tXqx^A&Xf)(#BUvCT4^Ha$=u-&LhjCwCdQGJ zkCY5^SeJJu#xBEN=p}y{e22X&$7vyTgBFDni6t=Pp&*4ut6?_^#p1JTX`A1vC8Di6 z^!1g-5LujWecBc;ue=<_a`K_Dm`rWwwyoA~hoAQ^&-1iy{lk3=@0eQdRa=494|@84 z0x;?H*u!q%NKB$dTAQTk$i^qU8McOJ!?3c)PpPGP{-cbDcjkZQcDA~vkB}H9ddpN3 zO;c%a?IlZ}OrI8nZIs&fi@pXUrQ>G&5G=Cf*i__8QwS|v3{Ufk*eza=QJ+1131nx1 zy%E9h<4Xk!X(?RBg`8mD8Iv#`HrXrAn4{)EE82Pv0x^=+HS^~HvQw*Gi?lzx=$v+z zi(jt7FA^zPE*qDSVu?Uj(m9*yW;e6frsWZtQX?meMST=Xa5rMke5XS{Qqib>k!E3nIA=! z_j%nL{1JWmj?VzSP+rz|AAR2TI*Q>n^PI@FqlIfW0|ZFQ^fS8DrH3_E^yUE>JxQog z*Z@*cVX1!y>wwnBAbi|D;c;_kQhT2lwsasRk=<-Za@|TToAQwSf5|-%1J=sAi-DLk zQgD_0upRS8MGv<6>V<9P=v{HLGTcHkT@+DrJ7**{L5rE_VqM8MBF}*%vJA~q>9iSL z7fbEQ=;i%RT|jYw>DMWipZ>&((qiAYjvjY9CL1~_%MhVox(xuWY)_=Og~Hy2);_66 z90U-4_P|l3TWaLfpZ{&z;Uz?6Vhd`pqXtnfXtH5dMu^HpMqLrt>AL zRAsx9CAz(63#mI5pQQyk?DHA~$uGfL3(#aeL2yTD)9ygfexS9zo%Ls^c2f&;|9b(M zvXouaRDr5Hy2OA%&`bUD8_vAZ=Id-?)?Tgu((GB1K@poq3tO^yH4w5CF)Ynfs_|8u z+{Twn!)7a1rOPG&CijS z3Ro+MstVOPT~rdCPYP1`B%SAoYq#(Pm}!nai(NQvNTR_0RvOTUS{D1g)V|m?OmfEd z*BUt54-_M6;Amk>|QqbG%__7-Q^ zHu&fsu^8~@hT2c%`RrBxf2(rnZWRbMLhE24sI>jBcJIN9)eJ;^N){Wl43iN7`Qx33 zqy`1CzdI-4TKqWWIR7mgAyfuvQ#gKcfD%seUYOQD#^lsMCVgt79xH%&Nqv|?zaK{b z;DS-}&m~7}|H0+1qrbGCv}fL?pk!14F81+2PEJNDGSm{!P{=Cw2^g%RQb!?Kv#fe8 zN8m;$=h{@?rM2R8+RAsEH{jE4-f>G&>*Dt*m#<%i|FFR6opW@cC|Du1^@JTTX08_9s;gv@b= xE|nK;8yDs~qewjNf}*A$i*v^$G