mirror of
https://github.com/Raicuparta/nomai-vr.git
synced 2025-12-11 20:15:08 +01:00
Merge branch 'xr_plugin' into update_13
This commit is contained in:
commit
bca2a75fb3
@ -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<GameObject>(postCreditsBundle, "postcreditscamera.prefab");
|
||||
PostCreditsRenderTexture = LoadAsset<RenderTexture>(postCreditsBundle, "screen.renderTexture");
|
||||
|
||||
@ -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>();
|
||||
owCamera.renderSkybox = true;
|
||||
@ -72,12 +74,21 @@ namespace NomaiVR.Hands
|
||||
|
||||
private void SetUpWrapperInGame()
|
||||
{
|
||||
ActivateCameraTracking(Camera.main);
|
||||
wrapper = new GameObject("VrGameStage").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<TrackedPoseDriver>();
|
||||
hmdTracking.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRDevice, TrackedPoseDriver.TrackedPose.Head);
|
||||
hmdTracking.updateType = TrackedPoseDriver.UpdateType.BeforeRender;
|
||||
hmdTracking.UseRelativeTransform = false;
|
||||
}
|
||||
|
||||
private void SetUpHands()
|
||||
{
|
||||
var right = new GameObject("VrRightHand").AddComponent<Hand>();
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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<XRInputSubsystem> subsystems = new List<XRInputSubsystem>();
|
||||
SubsystemManager.GetInstances<XRInputSubsystem>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +68,14 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\SteamVR.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.XR.OpenVR">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\Unity.XR.OpenVR.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.XR.Management">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\Unity.XR.Management.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SteamVR_Actions">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\SteamVR_Actions.dll</HintPath>
|
||||
@ -145,6 +153,8 @@
|
||||
<Exec Command="copy /y "$(TargetPath)" "$(OwmlDir)\$(ModDir)"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\SteamVR.dll" "$(OwmlDir)\$(ModDir)\SteamVR.dll"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\SteamVR_Actions.dll" "$(OwmlDir)\$(ModDir)\SteamVR_Actions.dll"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\Unity.XR.OpenVR.dll" "$(OwmlDir)\$(ModDir)\Unity.XR.OpenVR.dll"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\Unity.XR.Management.dll" "$(OwmlDir)\$(ModDir)\Unity.XR.Management.dll"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Managed\Valve.Newtonsoft.Json.dll" "$(OwmlDir)\$(ModDir)\Valve.Newtonsoft.Json.dll"" />
|
||||
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\StreamingAssets\SteamVR\*" "$(OwmlDir)\$(ModDir)\bindings"" />
|
||||
|
||||
@ -24,7 +24,7 @@ namespace NomaiVRPatcher
|
||||
|
||||
CopyGameFiles(gamePath, Path.Combine(basePath, "files"));
|
||||
|
||||
PatchGlobalGameManagers(gameManagersPath, backupPath, basePath);
|
||||
//PatchGlobalGameManagers(gameManagersPath, backupPath, basePath);
|
||||
}
|
||||
|
||||
private static string GetExecutableName(string gamePath)
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
<Exec Command="copy /y "$(TargetDir)\Mono*.dll" "$(TargetDir)\..\..\dist"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\ClassDatabase\*" "$(TargetDir)\..\..\dist"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\StreamingAssets\SteamVR\*" "$(TargetDir)\..\..\dist\files\OuterWilds_Data\StreamingAssets\SteamVR"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\..\Unity\Build\OuterWildsVR_Data\Plugins\x86_64\XRSDKOpenVR.dll" "$(TargetDir)\..\..\dist\files\OuterWilds_Data\Plugins\x86_64\XRSDKOpenVR.dll"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\OpenVrFsr\openvr_api.dll" "$(TargetDir)\..\..\dist\files\OuterWilds_Data\Plugins\x86_64\openvr_api.dll"" />
|
||||
<Exec Command="copy /y "$(ProjectDir)\OpenVrFsr\openvr_mod.cfg" "$(TargetDir)\..\..\dist\files\OuterWilds_Data\Plugins\x86_64\openvr_mod.cfg"" />
|
||||
</Target>
|
||||
|
||||
8
Unity/Assets/Exported.meta
Normal file
8
Unity/Assets/Exported.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 856a644959c72ce4b903bac0ca7af702
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Unity/Assets/Plugins.meta
Normal file
8
Unity/Assets/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef055b6a6673ade498157dbd77c74d7f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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<OpenVRPackageInstaller>());
|
||||
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<OpenVRPackageInstaller>());
|
||||
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
|
||||
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 538300977557ee34892368a50c97bdd6
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca02308d9febaa442a742ecaaaa06d2c
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Unity/Assets/StreamingAssets/xrmanager
Normal file
BIN
Unity/Assets/StreamingAssets/xrmanager
Normal file
Binary file not shown.
27
Unity/Assets/StreamingAssets/xrmanager.manifest
Normal file
27
Unity/Assets/StreamingAssets/xrmanager.manifest
Normal file
@ -0,0 +1,27 @@
|
||||
ManifestFileVersion: 0
|
||||
CRC: 2292769626
|
||||
Hashes:
|
||||
AssetFileHash:
|
||||
serializedVersion: 2
|
||||
Hash: 137023b87e9090d4704063aaba55009f
|
||||
TypeTreeHash:
|
||||
serializedVersion: 2
|
||||
Hash: d19d84d07ff9ccc7950e324a2b2e401a
|
||||
HashAppended: 0
|
||||
ClassTypes:
|
||||
- Class: 114
|
||||
Script: {fileID: 11500000, guid: d236b7d11115f2143951f1e14045df39, type: 3}
|
||||
- Class: 114
|
||||
Script: {fileID: 11500000, guid: 7a32bfe54d957ec4581fa4a630f1647a, type: 3}
|
||||
- Class: 114
|
||||
Script: {fileID: 11500000, guid: 5685c6ec3d77efd409c20e6da27a4c72, type: 3}
|
||||
- Class: 114
|
||||
Script: {fileID: 11500000, guid: f4c3631f5e58749a59194e0cf6baf6d5, type: 3}
|
||||
- Class: 115
|
||||
Script: {instanceID: 0}
|
||||
SerializeReferenceClassIdentifiers: []
|
||||
Assets:
|
||||
- Assets/XR/XRGeneralSettings.asset
|
||||
- Assets/XR/Loaders/Open VR Loader.asset
|
||||
- Assets/XR/Settings/Open VR Settings.asset
|
||||
Dependencies: []
|
||||
7
Unity/Assets/StreamingAssets/xrmanager.manifest.meta
Normal file
7
Unity/Assets/StreamingAssets/xrmanager.manifest.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d948f53bf222d5d438b8f7559363e98b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
Unity/Assets/StreamingAssets/xrmanager.meta
Normal file
7
Unity/Assets/StreamingAssets/xrmanager.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7652a1cc237b2440a295b8362709e19
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Unity/Assets/XR.meta
Normal file
8
Unity/Assets/XR.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 179b0431528a48d4da939ddb49d5d7ba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Unity/Assets/XR/Loaders.meta
Normal file
8
Unity/Assets/XR/Loaders.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7c1b58853465654786f934a1ecf4a4e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Unity/Assets/XR/Loaders/Open VR Loader.asset
Normal file
14
Unity/Assets/XR/Loaders/Open VR Loader.asset
Normal file
@ -0,0 +1,14 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5685c6ec3d77efd409c20e6da27a4c72, type: 3}
|
||||
m_Name: Open VR Loader
|
||||
m_EditorClassIdentifier:
|
||||
8
Unity/Assets/XR/Loaders/Open VR Loader.asset.meta
Normal file
8
Unity/Assets/XR/Loaders/Open VR Loader.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fe4fc1b112b2fc468b9b92fac9f5dfc
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName: xrmanager
|
||||
assetBundleVariant:
|
||||
8
Unity/Assets/XR/Settings.meta
Normal file
8
Unity/Assets/XR/Settings.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83c5458145539e040a6d84ff4acfd3cb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Unity/Assets/XR/Settings/Open VR Settings.asset
Normal file
23
Unity/Assets/XR/Settings/Open VR Settings.asset
Normal file
@ -0,0 +1,23 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7a32bfe54d957ec4581fa4a630f1647a, type: 3}
|
||||
m_Name: Open VR Settings
|
||||
m_EditorClassIdentifier:
|
||||
PromptToUpgradePackage: 1
|
||||
PromptToUpgradePreviewPackages: 1
|
||||
SkipPromptForVersion:
|
||||
StereoRenderingMode: 0
|
||||
InitializationType: 1
|
||||
EditorAppKey: application.generated.unity.outerwildsvr.1173225600.exe
|
||||
ActionManifestFileRelativeFilePath: StreamingAssets\SteamVR\actions.json
|
||||
MirrorView: 2
|
||||
HasCopiedDefaults: 0
|
||||
8
Unity/Assets/XR/Settings/Open VR Settings.asset.meta
Normal file
8
Unity/Assets/XR/Settings/Open VR Settings.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cf7461dd40196c47b4a24839d599db9
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName: xrmanager
|
||||
assetBundleVariant:
|
||||
48
Unity/Assets/XR/XRGeneralSettings.asset
Normal file
48
Unity/Assets/XR/XRGeneralSettings.asset
Normal file
@ -0,0 +1,48 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d2dc886499c26824283350fa532d087d, type: 3}
|
||||
m_Name: XRGeneralSettings
|
||||
m_EditorClassIdentifier:
|
||||
Keys: 01000000
|
||||
Values:
|
||||
- {fileID: 3723299434278802999}
|
||||
--- !u!114 &3723299434278802999
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d236b7d11115f2143951f1e14045df39, type: 3}
|
||||
m_Name: Standalone Settings
|
||||
m_EditorClassIdentifier:
|
||||
m_LoaderManagerInstance: {fileID: 6126626890552299209}
|
||||
m_InitManagerOnStart: 1
|
||||
--- !u!114 &6126626890552299209
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4c3631f5e58749a59194e0cf6baf6d5, type: 3}
|
||||
m_Name: Standalone Providers
|
||||
m_EditorClassIdentifier:
|
||||
m_RequiresSettingsUpdate: 0
|
||||
m_AutomaticLoading: 0
|
||||
m_AutomaticRunning: 0
|
||||
m_Loaders:
|
||||
- {fileID: 11400000, guid: 9fe4fc1b112b2fc468b9b92fac9f5dfc, type: 2}
|
||||
8
Unity/Assets/XR/XRGeneralSettings.asset.meta
Normal file
8
Unity/Assets/XR/XRGeneralSettings.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13906739c9868ee489584241300fc5bc
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName: xrmanager
|
||||
assetBundleVariant:
|
||||
@ -6,7 +6,7 @@ EditorBuildSettings:
|
||||
serializedVersion: 2
|
||||
m_Scenes: []
|
||||
m_configObjects:
|
||||
Unity.XR.OpenVR.Settings: {fileID: 11400000, guid: 5a7a0c35877b217419dd98b5f80d9fbf,
|
||||
Unity.XR.OpenVR.Settings: {fileID: 11400000, guid: 6cf7461dd40196c47b4a24839d599db9,
|
||||
type: 2}
|
||||
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: bd54447987d8bd845bbb7e7341ebdf98,
|
||||
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 13906739c9868ee489584241300fc5bc,
|
||||
type: 2}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{
|
||||
"m_Settings": [
|
||||
"RemoveLegacyInputHelpersForReload"
|
||||
"RemoveLegacyInputHelpersForReload",
|
||||
"ShouldQueryLegacyPackageRemoval"
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user