Initialer Upload neues Unity-Projekt
This commit is contained in:
351
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_2018to2019.cs
Normal file
351
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_2018to2019.cs
Normal file
@ -0,0 +1,351 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Prompt developers to use settings most compatible with SteamVR.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
//2019 will use some of this
|
||||
#if (UNITY_2018_1_OR_NEWER && !UNITY_2020_1_OR_NEWER)
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using Valve.VR.InteractionSystem;
|
||||
using UnityEditor.Callbacks;
|
||||
|
||||
#pragma warning disable CS0618
|
||||
#pragma warning disable CS0219
|
||||
#pragma warning disable CS0414
|
||||
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
#if (UNITY_2018_1_OR_NEWER && !UNITY_2019_1_OR_NEWER)
|
||||
public class SteamVR_AutoEnableVR_2018to2019
|
||||
{
|
||||
[DidReloadScripts]
|
||||
private static void OnReload()
|
||||
{
|
||||
SteamVR_AutoEnableVR_UnityPackage.InstallAndEnableUnityVR();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public class SteamVR_AutoEnableVR_UnityPackage
|
||||
{
|
||||
private static bool? _forceInstall;
|
||||
private const string forceInstallKey = "steamvr.autoenablevr.forceInstall";
|
||||
private static bool? _forceEnable;
|
||||
private const string forceEnableKey = "steamvr.autoenablevr.forceEnable";
|
||||
private static PackageStates? _updateState;
|
||||
private const string updateStateKey = "steamvr.autoenablevr.updateState";
|
||||
|
||||
private static bool forceInstall
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_forceInstall.HasValue == false)
|
||||
{
|
||||
if (EditorPrefs.HasKey(forceInstallKey))
|
||||
_forceInstall = EditorPrefs.GetBool(forceInstallKey);
|
||||
else
|
||||
_forceInstall = false;
|
||||
}
|
||||
|
||||
return _forceInstall.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_forceInstall = value;
|
||||
EditorPrefs.SetBool(forceInstallKey, value);
|
||||
}
|
||||
}
|
||||
private static bool forceEnable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_forceEnable.HasValue == false)
|
||||
{
|
||||
if (EditorPrefs.HasKey(forceEnableKey))
|
||||
_forceEnable = EditorPrefs.GetBool(forceEnableKey);
|
||||
else
|
||||
_forceEnable = false;
|
||||
}
|
||||
|
||||
return _forceEnable.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_forceEnable = value;
|
||||
EditorPrefs.SetBool(forceEnableKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateUpdateStateFromPrefs()
|
||||
{
|
||||
if (_updateState.HasValue == false)
|
||||
{
|
||||
if (EditorPrefs.HasKey(updateStateKey))
|
||||
_updateState = (PackageStates)EditorPrefs.GetInt(updateStateKey);
|
||||
else
|
||||
_updateState = PackageStates.None;
|
||||
}
|
||||
}
|
||||
|
||||
private static PackageStates updateState
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_updateState.HasValue == false)
|
||||
UpdateUpdateStateFromPrefs();
|
||||
return _updateState.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
_updateState = value;
|
||||
EditorPrefs.SetInt(updateStateKey, (int)value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void InstallAndEnableUnityVR(bool forceInstall = false, bool forceEnable = false)
|
||||
{
|
||||
_forceInstall = forceInstall;
|
||||
_forceEnable = forceEnable;
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
protected const string openVRString = "OpenVR";
|
||||
protected const string unityOpenVRPackageString = "com.unity.xr.openvr.standalone";
|
||||
protected const string valveOpenVRPackageString = "com.valvesoftware.unity.openvr";
|
||||
|
||||
private enum PackageStates
|
||||
{
|
||||
None,
|
||||
WaitingForList,
|
||||
WaitingForAdd,
|
||||
WaitingForAddConfirm,
|
||||
Installed,
|
||||
Failed,
|
||||
}
|
||||
|
||||
private static UnityEditor.PackageManager.Requests.ListRequest listRequest;
|
||||
private static UnityEditor.PackageManager.Requests.AddRequest addRequest;
|
||||
private static System.Diagnostics.Stopwatch addingPackageTime = new System.Diagnostics.Stopwatch();
|
||||
private static System.Diagnostics.Stopwatch addingPackageTimeTotal = new System.Diagnostics.Stopwatch();
|
||||
private static float estimatedTimeToInstall = 80;
|
||||
private static int addTryCount = 0;
|
||||
|
||||
private static void End()
|
||||
{
|
||||
updateState = PackageStates.None;
|
||||
addingPackageTime.Stop();
|
||||
addingPackageTimeTotal.Stop();
|
||||
UnityEditor.EditorUtility.ClearProgressBar();
|
||||
EditorApplication.update -= Update;
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (!SteamVR_Settings.instance.autoEnableVR || Application.isPlaying)
|
||||
End();
|
||||
|
||||
if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
|
||||
{
|
||||
if (forceInstall == false)
|
||||
{
|
||||
int shouldInstall = UnityEditor.EditorUtility.DisplayDialogComplex("SteamVR", "Would you like to enable Virtual Reality mode?\n\nThis will install the OpenVR for Desktop package and enable it in Player Settings.", "Yes", "No, and don't ask again", "No");
|
||||
|
||||
switch (shouldInstall)
|
||||
{
|
||||
case 0: //yes
|
||||
UnityEditor.PlayerSettings.virtualRealitySupported = true;
|
||||
break;
|
||||
case 1: //no
|
||||
End();
|
||||
return;
|
||||
case 2: //no, don't ask
|
||||
SteamVR_Settings.instance.autoEnableVR = false;
|
||||
SteamVR_Settings.Save();
|
||||
End();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Enabled virtual reality support in Player Settings. (you can disable this by unchecking Assets/SteamVR/SteamVR_Settings.autoEnableVR)");
|
||||
}
|
||||
|
||||
switch (updateState)
|
||||
{
|
||||
case PackageStates.None:
|
||||
//see if we have the package
|
||||
listRequest = UnityEditor.PackageManager.Client.List(true);
|
||||
updateState = PackageStates.WaitingForList;
|
||||
break;
|
||||
|
||||
case PackageStates.WaitingForList:
|
||||
if (listRequest == null)
|
||||
{
|
||||
listRequest = UnityEditor.PackageManager.Client.List(true);
|
||||
updateState = PackageStates.WaitingForList;
|
||||
}
|
||||
else if (listRequest.IsCompleted)
|
||||
{
|
||||
if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
|
||||
{
|
||||
updateState = PackageStates.Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
string packageName = unityOpenVRPackageString;
|
||||
|
||||
bool hasPackage = listRequest.Result.Any(package => package.name == packageName);
|
||||
|
||||
if (hasPackage == false)
|
||||
{
|
||||
//if we don't have the package - then install it
|
||||
addRequest = UnityEditor.PackageManager.Client.Add(packageName);
|
||||
updateState = PackageStates.WaitingForAdd;
|
||||
addTryCount++;
|
||||
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Installing OpenVR package...");
|
||||
addingPackageTime.Start();
|
||||
addingPackageTimeTotal.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
//if we do have the package, make sure it's enabled.
|
||||
updateState = PackageStates.Installed; //already installed
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PackageStates.WaitingForAdd:
|
||||
if (addRequest.IsCompleted)
|
||||
{
|
||||
if (addRequest.Error != null || addRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
|
||||
{
|
||||
updateState = PackageStates.Failed;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
//if the package manager says we added it then confirm that with the list
|
||||
listRequest = UnityEditor.PackageManager.Client.List(true);
|
||||
updateState = PackageStates.WaitingForAddConfirm;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (addingPackageTimeTotal.Elapsed.TotalSeconds > estimatedTimeToInstall)
|
||||
{
|
||||
if (addTryCount == 1)
|
||||
estimatedTimeToInstall *= 2; //give us more time to retry
|
||||
else
|
||||
updateState = PackageStates.Failed;
|
||||
}
|
||||
|
||||
string dialogText;
|
||||
if (addTryCount == 1)
|
||||
dialogText = "Installing OpenVR from Unity Package Manager...";
|
||||
else
|
||||
dialogText = "Retrying OpenVR install from Unity Package Manager...";
|
||||
|
||||
bool cancel = UnityEditor.EditorUtility.DisplayCancelableProgressBar("SteamVR", dialogText, (float)addingPackageTimeTotal.Elapsed.TotalSeconds / estimatedTimeToInstall);
|
||||
if (cancel)
|
||||
updateState = PackageStates.Failed;
|
||||
|
||||
if (addingPackageTime.Elapsed.TotalSeconds > 10)
|
||||
{
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Waiting for package manager to install OpenVR package...");
|
||||
addingPackageTime.Stop();
|
||||
addingPackageTime.Reset();
|
||||
addingPackageTime.Start();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PackageStates.WaitingForAddConfirm:
|
||||
if (listRequest.IsCompleted)
|
||||
{
|
||||
if (listRequest.Error != null)
|
||||
{
|
||||
updateState = PackageStates.Failed;
|
||||
break;
|
||||
}
|
||||
string packageName = unityOpenVRPackageString;
|
||||
|
||||
bool hasPackage = listRequest.Result.Any(package => package.name == packageName);
|
||||
|
||||
if (hasPackage == false)
|
||||
{
|
||||
if (addTryCount == 1)
|
||||
{
|
||||
addRequest = UnityEditor.PackageManager.Client.Add(packageName);
|
||||
updateState = PackageStates.WaitingForAdd;
|
||||
addTryCount++;
|
||||
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Retrying OpenVR package install...");
|
||||
}
|
||||
else
|
||||
{
|
||||
updateState = PackageStates.Failed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
updateState = PackageStates.Installed; //installed successfully
|
||||
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Successfully installed OpenVR Desktop package.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PackageStates.Installed:
|
||||
UnityEditor.BuildTargetGroup currentTarget = UnityEditor.EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
|
||||
string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(currentTarget);
|
||||
|
||||
bool hasOpenVR = false;
|
||||
bool isFirst = false;
|
||||
|
||||
if (devices.Length != 0)
|
||||
{
|
||||
int index = Array.FindIndex(devices, device => string.Equals(device, openVRString, System.StringComparison.CurrentCultureIgnoreCase));
|
||||
hasOpenVR = index != -1;
|
||||
isFirst = index == 0;
|
||||
}
|
||||
|
||||
//list openvr as the first option if it was in the list already
|
||||
List<string> devicesList = new List<string>(devices);
|
||||
if (isFirst == false)
|
||||
{
|
||||
if (hasOpenVR == true)
|
||||
devicesList.Remove(openVRString);
|
||||
|
||||
devicesList.Insert(0, openVRString);
|
||||
string[] newDevices = devicesList.ToArray();
|
||||
|
||||
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(currentTarget, newDevices);
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Added OpenVR to supported VR SDKs list.");
|
||||
}
|
||||
|
||||
End();
|
||||
break;
|
||||
|
||||
case PackageStates.Failed:
|
||||
End();
|
||||
|
||||
string failtext = "The Unity Package Manager failed to automatically install the OpenVR Desktop package. Please open the Package Manager Window and try to install it manually.";
|
||||
UnityEditor.EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
|
||||
Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b894f6f57c99a1c46957650bc11d7824
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
323
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_2019plus.cs
Normal file
323
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_2019plus.cs
Normal file
@ -0,0 +1,323 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Prompt developers to use settings most compatible with SteamVR.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#if (UNITY_2019_1_OR_NEWER)
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using Valve.VR.InteractionSystem;
|
||||
using UnityEditor.Callbacks;
|
||||
|
||||
#if OPENVR_XR_API
|
||||
using UnityEditor.XR.Management.Metadata;
|
||||
using UnityEngine.XR.Management;
|
||||
using UnityEditor.XR.Management;
|
||||
#endif
|
||||
|
||||
#pragma warning disable CS0618
|
||||
#pragma warning disable CS0219
|
||||
#pragma warning disable CS0414
|
||||
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
#if (UNITY_2019_1_OR_NEWER && !UNITY_2020_1_OR_NEWER)
|
||||
public class SteamVR_AutoEnableVR_2019to2020
|
||||
{
|
||||
[DidReloadScripts]
|
||||
private static void OnReload()
|
||||
{
|
||||
#if !OPENVR_XR_API
|
||||
//if we don't have xr installed, check to see if we have vr installed. if we don't have vr installed, ask which they do want to install.
|
||||
SteamVR_AutoEnableVR_2019.CheckAndAsk();
|
||||
#else
|
||||
//since we already have xr installed, we know we just want to enable it
|
||||
SteamVR_AutoEnableVR_UnityXR.EnableUnityXR();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (UNITY_2020_1_OR_NEWER)
|
||||
public class SteamVR_AutoEnableVR_2020Plus
|
||||
{
|
||||
[DidReloadScripts]
|
||||
private static void OnReload()
|
||||
{
|
||||
#if !OPENVR_XR_API
|
||||
SteamVR_AutoEnableVR_UnityXR.InstallAndEnableUnityXR();
|
||||
#else
|
||||
//since we already have xr installed, we know we just want to enable it
|
||||
SteamVR_AutoEnableVR_UnityXR.EnableUnityXR();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (UNITY_2019_1_OR_NEWER && !UNITY_2020_1_OR_NEWER)
|
||||
public class SteamVR_AutoEnableVR_2019
|
||||
{
|
||||
public static void CheckAndAsk()
|
||||
{
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
protected const string openVRString = "OpenVR";
|
||||
protected const string unityOpenVRPackageString = "com.unity.xr.openvr.standalone";
|
||||
protected const string valveOpenVRPackageString = "com.valvesoftware.unity.openvr";
|
||||
|
||||
private enum PackageStates
|
||||
{
|
||||
None,
|
||||
WaitingForList,
|
||||
Complete,
|
||||
Failed,
|
||||
}
|
||||
|
||||
private static UnityEditor.PackageManager.Requests.ListRequest listRequest;
|
||||
private static PackageStates packageState = PackageStates.None;
|
||||
|
||||
private static void End()
|
||||
{
|
||||
packageState = PackageStates.None;
|
||||
UnityEditor.EditorUtility.ClearProgressBar();
|
||||
EditorApplication.update -= Update;
|
||||
}
|
||||
|
||||
private static void ShowDialog()
|
||||
{
|
||||
int shouldInstall = UnityEditor.EditorUtility.DisplayDialogComplex("SteamVR", "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 in legacy VR mode or for Unity XR?", "Legacy VR", "Cancel", "Unity XR");
|
||||
|
||||
switch (shouldInstall)
|
||||
{
|
||||
case 0: //legacy vr
|
||||
SteamVR_AutoEnableVR_UnityPackage.InstallAndEnableUnityVR();
|
||||
break;
|
||||
case 1: //cancel
|
||||
break;
|
||||
case 2: //unity xr
|
||||
SteamVR_AutoEnableVR_UnityXR.InstallAndEnableUnityXR();
|
||||
break;
|
||||
}
|
||||
|
||||
End();
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (!SteamVR_Settings.instance.autoEnableVR || Application.isPlaying)
|
||||
End();
|
||||
|
||||
if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
|
||||
{
|
||||
ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (packageState)
|
||||
{
|
||||
case PackageStates.None:
|
||||
//see if we have the package
|
||||
listRequest = UnityEditor.PackageManager.Client.List(true);
|
||||
packageState = PackageStates.WaitingForList;
|
||||
break;
|
||||
|
||||
case PackageStates.WaitingForList:
|
||||
if (listRequest.IsCompleted)
|
||||
{
|
||||
if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
|
||||
{
|
||||
packageState = PackageStates.Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
string packageName = unityOpenVRPackageString;
|
||||
|
||||
bool hasPackage = listRequest.Result.Any(package => package.name == packageName);
|
||||
|
||||
if (hasPackage == false)
|
||||
ShowDialog();
|
||||
else //if we do have the package, do nothing
|
||||
End();
|
||||
}
|
||||
break;
|
||||
|
||||
case PackageStates.Failed:
|
||||
End();
|
||||
|
||||
string failtext = "The Unity Package Manager failed to verify the OpenVR package. If you were trying to install it you may need to open the Package Manager Window and try to install it manually.";
|
||||
UnityEditor.EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
|
||||
Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// todo: split the below into an install and an enable section
|
||||
|
||||
public class SteamVR_AutoEnableVR_UnityXR
|
||||
{
|
||||
public static void InstallAndEnableUnityXR()
|
||||
{
|
||||
StartXRInstaller();
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
public static void EnableUnityXR()
|
||||
{
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
protected const string openVRString = "OpenVR";
|
||||
protected const string unityOpenVRPackageString = "com.unity.xr.openvr.standalone";
|
||||
protected const string valveOpenVRPackageString = "com.valvesoftware.unity.openvr";
|
||||
|
||||
|
||||
private enum PackageStates
|
||||
{
|
||||
None,
|
||||
WaitingForList,
|
||||
WaitingForAdd,
|
||||
WaitingForAddConfirm,
|
||||
Installed,
|
||||
Failed,
|
||||
}
|
||||
|
||||
private static UnityEditor.PackageManager.Requests.ListRequest listRequest;
|
||||
private static UnityEditor.PackageManager.Requests.AddRequest addRequest;
|
||||
private static PackageStates packageState = PackageStates.None;
|
||||
private static System.Diagnostics.Stopwatch addingPackageTime = new System.Diagnostics.Stopwatch();
|
||||
private static System.Diagnostics.Stopwatch addingPackageTimeTotal = new System.Diagnostics.Stopwatch();
|
||||
private static float estimatedTimeToInstall = 80;
|
||||
private static int addTryCount = 0;
|
||||
|
||||
private static string enabledLoaderKey = null;
|
||||
|
||||
private static MethodInfo isLoaderAssigned;
|
||||
private static MethodInfo installPackageAndAssignLoaderForBuildTarget;
|
||||
|
||||
private static Type[] isLoaderAssignedMethodParameters;
|
||||
private static object[] isLoaderAssignedCallParameters;
|
||||
|
||||
private static void End()
|
||||
{
|
||||
addingPackageTime.Stop();
|
||||
addingPackageTimeTotal.Stop();
|
||||
UnityEditor.EditorUtility.ClearProgressBar();
|
||||
EditorApplication.update -= Update;
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (!SteamVR_Settings.instance.autoEnableVR)
|
||||
End();
|
||||
|
||||
#if OPENVR_XR_API
|
||||
EnableLoader();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if OPENVR_XR_API
|
||||
|
||||
private static EditorWindow settingsWindow = null;
|
||||
private static int skipEditorFrames = 5;
|
||||
public static void EnableLoader()
|
||||
{
|
||||
if (skipEditorFrames > 0)
|
||||
{
|
||||
skipEditorFrames--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (enabledLoaderKey == null)
|
||||
enabledLoaderKey = string.Format(valveEnabledLoaderKeyTemplate, SteamVR_Settings.instance.editorAppKey);
|
||||
|
||||
if (EditorPrefs.HasKey(enabledLoaderKey) == false)
|
||||
{
|
||||
if (UnityEditor.PlayerSettings.virtualRealitySupported == true)
|
||||
{
|
||||
UnityEditor.PlayerSettings.virtualRealitySupported = false;
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Disabled virtual reality support in Player Settings. <b>Because you're using XR Manager. Make sure OpenVR Loader is enabled in XR Manager UI.</b> (you can disable this by unchecking Assets/SteamVR/SteamVR_Settings.autoEnableVR)");
|
||||
}
|
||||
|
||||
var generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone);
|
||||
if (generalSettings == null)
|
||||
{
|
||||
if (settingsWindow == null)
|
||||
{
|
||||
settingsWindow = SettingsService.OpenProjectSettings("Project/XR Plug-in Management");
|
||||
settingsWindow.Repaint();
|
||||
return;
|
||||
}
|
||||
|
||||
if (settingsWindow == null || generalSettings == null)
|
||||
{
|
||||
Debug.LogWarning("<b>[SteamVR Setup]</b> Unable to access standalone xr settings while trying to enable OpenVR Loader. <b>You may need to manually enable OpenVR Loader in XR Plug-in Management (Project Settings).</b> (you can disable this by unchecking Assets/SteamVR/SteamVR_Settings.autoEnableVR)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (generalSettings.AssignedSettings == null)
|
||||
{
|
||||
var assignedSettings = ScriptableObject.CreateInstance<XRManagerSettings>() as XRManagerSettings;
|
||||
generalSettings.AssignedSettings = assignedSettings;
|
||||
EditorUtility.SetDirty(generalSettings);
|
||||
}
|
||||
|
||||
bool existing = generalSettings.AssignedSettings.loaders.Any(loader => loader.name == valveOpenVRLoaderType);
|
||||
|
||||
foreach (var loader in generalSettings.AssignedSettings.loaders)
|
||||
{
|
||||
Debug.Log("loader: " + loader.name);
|
||||
}
|
||||
|
||||
if (!existing)
|
||||
{
|
||||
bool status = XRPackageMetadataStore.AssignLoader(generalSettings.AssignedSettings, valveOpenVRLoaderType, BuildTargetGroup.Standalone);
|
||||
if (status)
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Enabled OpenVR Loader in XR Management");
|
||||
else
|
||||
Debug.LogError("<b>[SteamVR Setup]</b> Failed to enable enable OpenVR Loader in XR Management. You may need to manually open the XR Plug-in Management tab in project settings and check the OpenVR Loader box.");
|
||||
}
|
||||
|
||||
EditorPrefs.SetBool(enabledLoaderKey, true);
|
||||
|
||||
}
|
||||
|
||||
End();
|
||||
}
|
||||
#endif
|
||||
|
||||
protected const string valveEnabledLoaderKeyTemplate = "valve.enabledxrloader.{0}";
|
||||
protected const string valveOpenVRLoaderType = "Unity.XR.OpenVR.OpenVRLoader";
|
||||
|
||||
private static void StartXRInstaller()
|
||||
{
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
for (int assemblyIndex = 0; assemblyIndex < assemblies.Length; assemblyIndex++)
|
||||
{
|
||||
Assembly assembly = assemblies[assemblyIndex];
|
||||
Type type = assembly.GetType("Unity.XR.OpenVR.OpenVRPackageInstaller");
|
||||
if (type != null)
|
||||
{
|
||||
MethodInfo preinitMethodInfo = type.GetMethod("Start");
|
||||
if (preinitMethodInfo != null)
|
||||
{
|
||||
preinitMethodInfo.Invoke(null, new object[] { true });
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_2019plus.cs.meta
Normal file
11
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_2019plus.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 524ac57f667bffd459f44076a7111efb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
123
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_5.4to2018.cs
Normal file
123
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_5.4to2018.cs
Normal file
@ -0,0 +1,123 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Prompt developers to use settings most compatible with SteamVR.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
#if (UNITY_5_4_OR_NEWER && !UNITY_2018_1_OR_NEWER)
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
using UnityEditor.Callbacks;
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
public class SteamVR_AutoEnableVR_54to2018
|
||||
{
|
||||
[DidReloadScripts]
|
||||
private static void OnReload()
|
||||
{
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
protected const string openVRString = "OpenVR";
|
||||
|
||||
private static void End()
|
||||
{
|
||||
EditorApplication.update -= Update;
|
||||
}
|
||||
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (!SteamVR_Settings.instance.autoEnableVR || Application.isPlaying)
|
||||
End();
|
||||
|
||||
bool enabledVR = false;
|
||||
|
||||
int shouldInstall = -1;
|
||||
if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
|
||||
{
|
||||
shouldInstall = UnityEditor.EditorUtility.DisplayDialogComplex("SteamVR", "Would you like to enable Virtual Reality mode?\n\nThis will enable Virtual Reality in Player Settings and add OpenVR as a target.", "Yes", "No, and don't ask again", "No");
|
||||
|
||||
switch (shouldInstall)
|
||||
{
|
||||
case 0: //yes
|
||||
UnityEditor.PlayerSettings.virtualRealitySupported = true;
|
||||
break;
|
||||
case 1: //no:
|
||||
UnityEditor.EditorApplication.update -= Update;
|
||||
return;
|
||||
case 2: //no, don't ask
|
||||
SteamVR_Settings.instance.autoEnableVR = false;
|
||||
SteamVR_Settings.Save();
|
||||
UnityEditor.EditorApplication.update -= Update;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UnityEditor.BuildTargetGroup currentTarget = UnityEditor.EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(currentTarget);
|
||||
#else
|
||||
string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(currentTarget);
|
||||
#endif
|
||||
|
||||
bool hasOpenVR = devices.Any(device => string.Equals(device, openVRString, System.StringComparison.CurrentCultureIgnoreCase));
|
||||
|
||||
if (hasOpenVR == false || enabledVR)
|
||||
{
|
||||
string[] newDevices;
|
||||
if (enabledVR && hasOpenVR == false)
|
||||
{
|
||||
newDevices = new string[] { openVRString }; //only list openvr if we enabled it
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> devicesList = new List<string>(devices); //list openvr as the first option if it wasn't in the list.
|
||||
if (hasOpenVR)
|
||||
devicesList.Remove(openVRString);
|
||||
|
||||
devicesList.Insert(0, openVRString);
|
||||
newDevices = devicesList.ToArray();
|
||||
}
|
||||
|
||||
int shouldEnable = -1;
|
||||
if (shouldInstall == 0)
|
||||
shouldEnable = 0;
|
||||
else
|
||||
shouldEnable = UnityEditor.EditorUtility.DisplayDialogComplex("SteamVR", "Would you like to enable OpenVR as a VR target?", "Yes", "No, and don't ask again", "No");
|
||||
|
||||
switch (shouldEnable)
|
||||
{
|
||||
case 0: //yes
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(currentTarget, newDevices);
|
||||
#else
|
||||
UnityEditorInternal.VR.VREditor.SetVREnabledDevices(currentTarget, newDevices);
|
||||
#endif
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Added OpenVR to supported VR SDKs list.");
|
||||
break;
|
||||
case 1: //no:
|
||||
break;
|
||||
case 2: //no, don't ask
|
||||
SteamVR_Settings.instance.autoEnableVR = false;
|
||||
SteamVR_Settings.Save();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UnityEditor.EditorApplication.update -= Update;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_5.4to2018.cs.meta
Normal file
11
Assets/SteamVR/Editor/SteamVR_AutoEnableVR_5.4to2018.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3c98d5dbcd01ee4ba302d8f71a8d55a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/SteamVR/Editor/SteamVR_Editor.asmdef
Normal file
36
Assets/SteamVR/Editor/SteamVR_Editor.asmdef
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "SteamVR_Editor",
|
||||
"references": [
|
||||
"SteamVR",
|
||||
"Unity.XR.OpenVR",
|
||||
"Unity.XR.Management.Editor",
|
||||
"Unity.XR.Management"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.valvesoftware.unity.openvr",
|
||||
"expression": "",
|
||||
"define": "OPENVR_XR_API"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.xr.management",
|
||||
"expression": "3.2.0",
|
||||
"define": "XR_MGMT_GTE_320"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.xr.management",
|
||||
"expression": "",
|
||||
"define": "XR_MGMT"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/SteamVR/Editor/SteamVR_Editor.asmdef.meta
Normal file
7
Assets/SteamVR/Editor/SteamVR_Editor.asmdef.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bac448de04a4f6448fee1acc220e5a1
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
127
Assets/SteamVR/Editor/SteamVR_Editor.cs
Normal file
127
Assets/SteamVR/Editor/SteamVR_Editor.cs
Normal file
@ -0,0 +1,127 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Custom inspector display for SteamVR_Camera
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using Valve.VR;
|
||||
|
||||
[CustomEditor(typeof(SteamVR_Camera)), CanEditMultipleObjects]
|
||||
public class SteamVR_Editor : Editor
|
||||
{
|
||||
int bannerHeight = 150;
|
||||
Texture logo;
|
||||
|
||||
SerializedProperty script, wireframe;
|
||||
|
||||
string GetResourcePath()
|
||||
{
|
||||
var ms = MonoScript.FromScriptableObject(this);
|
||||
var path = AssetDatabase.GetAssetPath(ms);
|
||||
path = Path.GetDirectoryName(path);
|
||||
return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
var resourcePath = GetResourcePath();
|
||||
|
||||
logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
|
||||
|
||||
script = serializedObject.FindProperty("m_Script");
|
||||
|
||||
wireframe = serializedObject.FindProperty("wireframe");
|
||||
|
||||
foreach (SteamVR_Camera target in targets)
|
||||
target.ForceLast();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
var rect = GUILayoutUtility.GetRect(Screen.width - 38, bannerHeight, GUI.skin.box);
|
||||
if (logo)
|
||||
GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
|
||||
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
var expand = false;
|
||||
var collapse = false;
|
||||
foreach (SteamVR_Camera target in targets)
|
||||
{
|
||||
if (AssetDatabase.Contains(target))
|
||||
continue;
|
||||
if (target.isExpanded)
|
||||
collapse = true;
|
||||
else
|
||||
expand = true;
|
||||
}
|
||||
|
||||
if (expand)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Expand"))
|
||||
{
|
||||
foreach (SteamVR_Camera target in targets)
|
||||
{
|
||||
if (AssetDatabase.Contains(target))
|
||||
continue;
|
||||
if (!target.isExpanded)
|
||||
{
|
||||
target.Expand();
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.Space(18);
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (collapse)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("Collapse"))
|
||||
{
|
||||
foreach (SteamVR_Camera target in targets)
|
||||
{
|
||||
if (AssetDatabase.Contains(target))
|
||||
continue;
|
||||
if (target.isExpanded)
|
||||
{
|
||||
target.Collapse();
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.Space(18);
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(script);
|
||||
EditorGUILayout.PropertyField(wireframe);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public static void ExportPackage()
|
||||
{
|
||||
AssetDatabase.ExportPackage(new string[] {
|
||||
"Assets/SteamVR",
|
||||
"Assets/Plugins/openvr_api.cs",
|
||||
"Assets/Plugins/openvr_api.bundle",
|
||||
"Assets/Plugins/x86/openvr_api.dll",
|
||||
"Assets/Plugins/x86/steam_api.dll",
|
||||
"Assets/Plugins/x86/libsteam_api.so",
|
||||
"Assets/Plugins/x86_64/openvr_api.dll",
|
||||
"Assets/Plugins/x86_64/steam_api.dll",
|
||||
"Assets/Plugins/x86_64/libsteam_api.so",
|
||||
"Assets/Plugins/x86_64/libopenvr_api.so",
|
||||
}, "steamvr.unitypackage", ExportPackageOptions.Recurse);
|
||||
EditorApplication.Exit(0);
|
||||
}
|
||||
}
|
||||
9
Assets/SteamVR/Editor/SteamVR_Editor.cs.meta
Normal file
9
Assets/SteamVR/Editor/SteamVR_Editor.cs.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ba22c80948c94e44a82b9fd1b3abd0d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
2
Assets/SteamVR/Editor/SteamVR_Preferences.cs
Normal file
2
Assets/SteamVR/Editor/SteamVR_Preferences.cs
Normal file
@ -0,0 +1,2 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//removed and added to the SteamVR_Settings asset so it can be configured per project
|
||||
12
Assets/SteamVR/Editor/SteamVR_Preferences.cs.meta
Normal file
12
Assets/SteamVR/Editor/SteamVR_Preferences.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29abf75f7265ccb45b799eac4ab0ca94
|
||||
timeCreated: 1487968203
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Assets/SteamVR/Editor/SteamVR_RenderModelEditor.cs
Normal file
106
Assets/SteamVR/Editor/SteamVR_RenderModelEditor.cs
Normal file
@ -0,0 +1,106 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Custom inspector display for SteamVR_RenderModel
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
[CustomEditor(typeof(SteamVR_RenderModel)), CanEditMultipleObjects]
|
||||
public class SteamVR_RenderModelEditor : Editor
|
||||
{
|
||||
SerializedProperty script, index, modelOverride, shader, verbose, createComponents, updateDynamically;
|
||||
|
||||
static string[] renderModelNames;
|
||||
int renderModelIndex;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
script = serializedObject.FindProperty("m_Script");
|
||||
index = serializedObject.FindProperty("index");
|
||||
modelOverride = serializedObject.FindProperty("modelOverride");
|
||||
shader = serializedObject.FindProperty("shader");
|
||||
verbose = serializedObject.FindProperty("verbose");
|
||||
createComponents = serializedObject.FindProperty("createComponents");
|
||||
updateDynamically = serializedObject.FindProperty("updateDynamically");
|
||||
|
||||
// Load render model names if necessary.
|
||||
if (renderModelNames == null)
|
||||
{
|
||||
renderModelNames = LoadRenderModelNames();
|
||||
}
|
||||
|
||||
// Update renderModelIndex based on current modelOverride value.
|
||||
if (modelOverride.stringValue != "")
|
||||
{
|
||||
for (int i = 0; i < renderModelNames.Length; i++)
|
||||
{
|
||||
if (modelOverride.stringValue == renderModelNames[i])
|
||||
{
|
||||
renderModelIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static string[] LoadRenderModelNames()
|
||||
{
|
||||
var results = new List<string>();
|
||||
results.Add("None");
|
||||
|
||||
using (var holder = new SteamVR_RenderModel.RenderModelInterfaceHolder())
|
||||
{
|
||||
var renderModels = holder.instance;
|
||||
if (renderModels != null)
|
||||
{
|
||||
uint count = renderModels.GetRenderModelCount();
|
||||
for (uint i = 0; i < count; i++)
|
||||
{
|
||||
var buffer = new StringBuilder();
|
||||
var requiredSize = renderModels.GetRenderModelName(i, buffer, 0);
|
||||
if (requiredSize == 0)
|
||||
continue;
|
||||
|
||||
buffer.EnsureCapacity((int)requiredSize);
|
||||
renderModels.GetRenderModelName(i, buffer, requiredSize);
|
||||
results.Add(buffer.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(script);
|
||||
EditorGUILayout.PropertyField(index);
|
||||
//EditorGUILayout.PropertyField(modelOverride);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label(new GUIContent("Model Override", SteamVR_RenderModel.modelOverrideWarning));
|
||||
var selected = EditorGUILayout.Popup(renderModelIndex, renderModelNames);
|
||||
if (selected != renderModelIndex)
|
||||
{
|
||||
renderModelIndex = selected;
|
||||
modelOverride.stringValue = (selected > 0) ? renderModelNames[selected] : "";
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.PropertyField(shader);
|
||||
EditorGUILayout.PropertyField(verbose);
|
||||
EditorGUILayout.PropertyField(createComponents);
|
||||
EditorGUILayout.PropertyField(updateDynamically);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Editor/SteamVR_RenderModelEditor.cs.meta
Normal file
12
Assets/SteamVR/Editor/SteamVR_RenderModelEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67867a20919f7db45a2e7034fda1c28e
|
||||
timeCreated: 1433373945
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
383
Assets/SteamVR/Editor/SteamVR_SkyboxEditor.cs
Normal file
383
Assets/SteamVR/Editor/SteamVR_SkyboxEditor.cs
Normal file
@ -0,0 +1,383 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Custom inspector display for SteamVR_Skybox
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Valve.VR;
|
||||
using System.IO;
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
[CustomEditor(typeof(SteamVR_Skybox)), CanEditMultipleObjects]
|
||||
public class SteamVR_SkyboxEditor : Editor
|
||||
{
|
||||
private const string nameFormat = "{0}/{1}-{2}.png";
|
||||
private const string helpText = "Take snapshot will use the current " +
|
||||
"position and rotation to capture six directional screenshots to use as this " +
|
||||
"skybox's textures. Note: This skybox is only used to override what shows up " +
|
||||
"in the compositor (e.g. when loading levels). Add a Camera component to this " +
|
||||
"object to override default settings like which layers to render. Additionally, " +
|
||||
"by specifying your own targetTexture, you can control the size of the textures " +
|
||||
"and other properties like antialiasing. Don't forget to disable the camera.\n\n" +
|
||||
"For stereo screenshots, a panorama is render for each eye using the specified " +
|
||||
"ipd (in millimeters) broken up into segments cellSize pixels square to optimize " +
|
||||
"generation.\n(32x32 takes about 10 seconds depending on scene complexity, 16x16 " +
|
||||
"takes around a minute, while will 8x8 take several minutes.)\n\nTo test, hit " +
|
||||
"play then pause - this will activate the skybox settings, and then drop you to " +
|
||||
"the compositor where the skybox is rendered.";
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
EditorGUILayout.HelpBox(helpText, MessageType.Info);
|
||||
|
||||
if (GUILayout.Button("Take snapshot"))
|
||||
{
|
||||
var directions = new Quaternion[] {
|
||||
Quaternion.LookRotation(Vector3.forward),
|
||||
Quaternion.LookRotation(Vector3.back),
|
||||
Quaternion.LookRotation(Vector3.left),
|
||||
Quaternion.LookRotation(Vector3.right),
|
||||
Quaternion.LookRotation(Vector3.up, Vector3.back),
|
||||
Quaternion.LookRotation(Vector3.down, Vector3.forward)
|
||||
};
|
||||
|
||||
Camera tempCamera = null;
|
||||
foreach (SteamVR_Skybox target in targets)
|
||||
{
|
||||
var targetScene = target.gameObject.scene;
|
||||
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
|
||||
var scenePath = Path.GetDirectoryName(targetScene.path);
|
||||
var assetPath = scenePath + "/" + sceneName;
|
||||
if (!AssetDatabase.IsValidFolder(assetPath))
|
||||
{
|
||||
var guid = AssetDatabase.CreateFolder(scenePath, sceneName);
|
||||
assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
}
|
||||
|
||||
var camera = target.GetComponent<Camera>();
|
||||
if (camera == null)
|
||||
{
|
||||
if (tempCamera == null)
|
||||
tempCamera = new GameObject().AddComponent<Camera>();
|
||||
camera = tempCamera;
|
||||
}
|
||||
|
||||
var targetTexture = camera.targetTexture;
|
||||
if (camera.targetTexture == null)
|
||||
{
|
||||
targetTexture = new RenderTexture(1024, 1024, 24);
|
||||
targetTexture.antiAliasing = 8;
|
||||
camera.targetTexture = targetTexture;
|
||||
}
|
||||
|
||||
var oldPosition = target.transform.localPosition;
|
||||
var oldRotation = target.transform.localRotation;
|
||||
var baseRotation = target.transform.rotation;
|
||||
|
||||
var t = camera.transform;
|
||||
t.position = target.transform.position;
|
||||
camera.orthographic = false;
|
||||
camera.fieldOfView = 90;
|
||||
|
||||
for (int i = 0; i < directions.Length; i++)
|
||||
{
|
||||
t.rotation = baseRotation * directions[i];
|
||||
camera.Render();
|
||||
|
||||
// Copy to texture and save to disk.
|
||||
RenderTexture.active = targetTexture;
|
||||
var texture = new Texture2D(targetTexture.width, targetTexture.height, TextureFormat.ARGB32, false);
|
||||
texture.ReadPixels(new Rect(0, 0, texture.width, texture.height), 0, 0);
|
||||
texture.Apply();
|
||||
RenderTexture.active = null;
|
||||
|
||||
var assetName = string.Format(nameFormat, assetPath, target.name, i);
|
||||
System.IO.File.WriteAllBytes(assetName, texture.EncodeToPNG());
|
||||
}
|
||||
|
||||
if (camera != tempCamera)
|
||||
{
|
||||
target.transform.localPosition = oldPosition;
|
||||
target.transform.localRotation = oldRotation;
|
||||
}
|
||||
}
|
||||
|
||||
if (tempCamera != null)
|
||||
{
|
||||
Object.DestroyImmediate(tempCamera.gameObject);
|
||||
}
|
||||
|
||||
// Now that everything has be written out, reload the associated assets and assign them.
|
||||
AssetDatabase.Refresh();
|
||||
foreach (SteamVR_Skybox target in targets)
|
||||
{
|
||||
var targetScene = target.gameObject.scene;
|
||||
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
|
||||
var scenePath = Path.GetDirectoryName(targetScene.path);
|
||||
var assetPath = scenePath + "/" + sceneName;
|
||||
|
||||
for (int i = 0; i < directions.Length; i++)
|
||||
{
|
||||
var assetName = string.Format(nameFormat, assetPath, target.name, i);
|
||||
var importer = AssetImporter.GetAtPath(assetName) as TextureImporter;
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
importer.textureFormat = TextureImporterFormat.RGB24;
|
||||
#else
|
||||
importer.textureCompression = TextureImporterCompression.Uncompressed;
|
||||
#endif
|
||||
importer.wrapMode = TextureWrapMode.Clamp;
|
||||
importer.mipmapEnabled = false;
|
||||
importer.SaveAndReimport();
|
||||
|
||||
var texture = AssetDatabase.LoadAssetAtPath<Texture>(assetName);
|
||||
target.SetTextureByIndex(i, texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GUILayout.Button("Take stereo snapshot"))
|
||||
{
|
||||
const int width = 4096;
|
||||
const int height = width / 2;
|
||||
const int halfHeight = height / 2;
|
||||
|
||||
var textures = new Texture2D[] {
|
||||
new Texture2D(width, height, TextureFormat.ARGB32, false),
|
||||
new Texture2D(width, height, TextureFormat.ARGB32, false) };
|
||||
|
||||
var timer = new System.Diagnostics.Stopwatch();
|
||||
|
||||
Camera tempCamera = null;
|
||||
foreach (SteamVR_Skybox target in targets)
|
||||
{
|
||||
timer.Start();
|
||||
|
||||
var targetScene = target.gameObject.scene;
|
||||
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
|
||||
var scenePath = Path.GetDirectoryName(targetScene.path);
|
||||
var assetPath = scenePath + "/" + sceneName;
|
||||
if (!AssetDatabase.IsValidFolder(assetPath))
|
||||
{
|
||||
var guid = AssetDatabase.CreateFolder(scenePath, sceneName);
|
||||
assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
}
|
||||
|
||||
var camera = target.GetComponent<Camera>();
|
||||
if (camera == null)
|
||||
{
|
||||
if (tempCamera == null)
|
||||
tempCamera = new GameObject().AddComponent<Camera>();
|
||||
camera = tempCamera;
|
||||
}
|
||||
|
||||
var fx = camera.gameObject.AddComponent<SteamVR_SphericalProjection>();
|
||||
|
||||
var oldTargetTexture = camera.targetTexture;
|
||||
var oldOrthographic = camera.orthographic;
|
||||
var oldFieldOfView = camera.fieldOfView;
|
||||
var oldAspect = camera.aspect;
|
||||
|
||||
var oldPosition = target.transform.localPosition;
|
||||
var oldRotation = target.transform.localRotation;
|
||||
var basePosition = target.transform.position;
|
||||
var baseRotation = target.transform.rotation;
|
||||
|
||||
var transform = camera.transform;
|
||||
|
||||
int cellSize = int.Parse(target.StereoCellSize.ToString().Substring(1));
|
||||
float ipd = target.StereoIpdMm / 1000.0f;
|
||||
int vTotal = halfHeight / cellSize;
|
||||
float dv = 90.0f / vTotal; // vertical degrees per segment
|
||||
float dvHalf = dv / 2.0f;
|
||||
|
||||
var targetTexture = new RenderTexture(cellSize, cellSize, 24);
|
||||
targetTexture.wrapMode = TextureWrapMode.Clamp;
|
||||
targetTexture.antiAliasing = 8;
|
||||
|
||||
camera.fieldOfView = dv;
|
||||
camera.orthographic = false;
|
||||
camera.targetTexture = targetTexture;
|
||||
|
||||
// Render sections of a sphere using a rectilinear projection
|
||||
// and resample using a sphereical projection into a single panorama
|
||||
// texture per eye. We break into sections in order to keep the eye
|
||||
// separation similar around the sphere. Rendering alternates between
|
||||
// top and bottom sections, sweeping horizontally around the sphere,
|
||||
// alternating left and right eyes.
|
||||
for (int v = 0; v < vTotal; v++)
|
||||
{
|
||||
var pitch = 90.0f - (v * dv) - dvHalf;
|
||||
var uTotal = width / targetTexture.width;
|
||||
var du = 360.0f / uTotal; // horizontal degrees per segment
|
||||
var duHalf = du / 2.0f;
|
||||
|
||||
var vTarget = v * halfHeight / vTotal;
|
||||
|
||||
for (int i = 0; i < 2; i++) // top, bottom
|
||||
{
|
||||
if (i == 1)
|
||||
{
|
||||
pitch = -pitch;
|
||||
vTarget = height - vTarget - cellSize;
|
||||
}
|
||||
|
||||
for (int u = 0; u < uTotal; u++)
|
||||
{
|
||||
var yaw = -180.0f + (u * du) + duHalf;
|
||||
|
||||
var uTarget = u * width / uTotal;
|
||||
|
||||
var xOffset = -ipd / 2 * Mathf.Cos(pitch * Mathf.Deg2Rad);
|
||||
|
||||
for (int j = 0; j < 2; j++) // left, right
|
||||
{
|
||||
var texture = textures[j];
|
||||
|
||||
if (j == 1)
|
||||
{
|
||||
xOffset = -xOffset;
|
||||
}
|
||||
|
||||
var offset = baseRotation * Quaternion.Euler(0, yaw, 0) * new Vector3(xOffset, 0, 0);
|
||||
transform.position = basePosition + offset;
|
||||
|
||||
var direction = Quaternion.Euler(pitch, yaw, 0.0f);
|
||||
transform.rotation = baseRotation * direction;
|
||||
|
||||
// vector pointing to center of this section
|
||||
var N = direction * Vector3.forward;
|
||||
|
||||
// horizontal span of this section in degrees
|
||||
var phi0 = yaw - (du / 2);
|
||||
var phi1 = phi0 + du;
|
||||
|
||||
// vertical span of this section in degrees
|
||||
var theta0 = pitch + (dv / 2);
|
||||
var theta1 = theta0 - dv;
|
||||
|
||||
var midPhi = (phi0 + phi1) / 2;
|
||||
var baseTheta = Mathf.Abs(theta0) < Mathf.Abs(theta1) ? theta0 : theta1;
|
||||
|
||||
// vectors pointing to corners of image closes to the equator
|
||||
var V00 = Quaternion.Euler(baseTheta, phi0, 0.0f) * Vector3.forward;
|
||||
var V01 = Quaternion.Euler(baseTheta, phi1, 0.0f) * Vector3.forward;
|
||||
|
||||
// vectors pointing to top and bottom midsection of image
|
||||
var V0M = Quaternion.Euler(theta0, midPhi, 0.0f) * Vector3.forward;
|
||||
var V1M = Quaternion.Euler(theta1, midPhi, 0.0f) * Vector3.forward;
|
||||
|
||||
// intersection points for each of the above
|
||||
var P00 = V00 / Vector3.Dot(V00, N);
|
||||
var P01 = V01 / Vector3.Dot(V01, N);
|
||||
var P0M = V0M / Vector3.Dot(V0M, N);
|
||||
var P1M = V1M / Vector3.Dot(V1M, N);
|
||||
|
||||
// calculate basis vectors for plane
|
||||
var P00_P01 = P01 - P00;
|
||||
var P0M_P1M = P1M - P0M;
|
||||
|
||||
var uMag = P00_P01.magnitude;
|
||||
var vMag = P0M_P1M.magnitude;
|
||||
|
||||
var uScale = 1.0f / uMag;
|
||||
var vScale = 1.0f / vMag;
|
||||
|
||||
var uAxis = P00_P01 * uScale;
|
||||
var vAxis = P0M_P1M * vScale;
|
||||
|
||||
// update material constant buffer
|
||||
fx.Set(N, phi0, phi1, theta0, theta1,
|
||||
uAxis, P00, uScale,
|
||||
vAxis, P0M, vScale);
|
||||
|
||||
camera.aspect = uMag / vMag;
|
||||
camera.Render();
|
||||
|
||||
RenderTexture.active = targetTexture;
|
||||
texture.ReadPixels(new Rect(0, 0, targetTexture.width, targetTexture.height), uTarget, vTarget);
|
||||
RenderTexture.active = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save textures to disk.
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
var texture = textures[i];
|
||||
|
||||
texture.Apply();
|
||||
var assetName = string.Format(nameFormat, assetPath, target.name, i);
|
||||
File.WriteAllBytes(assetName, texture.EncodeToPNG());
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
if (camera != tempCamera)
|
||||
{
|
||||
camera.targetTexture = oldTargetTexture;
|
||||
camera.orthographic = oldOrthographic;
|
||||
camera.fieldOfView = oldFieldOfView;
|
||||
camera.aspect = oldAspect;
|
||||
|
||||
target.transform.localPosition = oldPosition;
|
||||
target.transform.localRotation = oldRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
tempCamera.targetTexture = null;
|
||||
}
|
||||
|
||||
DestroyImmediate(targetTexture);
|
||||
DestroyImmediate(fx);
|
||||
|
||||
timer.Stop();
|
||||
Debug.Log(string.Format("<b>[SteamVR]</b> Screenshot took {0} seconds.", timer.Elapsed));
|
||||
}
|
||||
|
||||
if (tempCamera != null)
|
||||
{
|
||||
DestroyImmediate(tempCamera.gameObject);
|
||||
}
|
||||
|
||||
DestroyImmediate(textures[0]);
|
||||
DestroyImmediate(textures[1]);
|
||||
|
||||
// Now that everything has be written out, reload the associated assets and assign them.
|
||||
AssetDatabase.Refresh();
|
||||
foreach (SteamVR_Skybox target in targets)
|
||||
{
|
||||
var targetScene = target.gameObject.scene;
|
||||
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
|
||||
var scenePath = Path.GetDirectoryName(targetScene.path);
|
||||
var assetPath = scenePath + "/" + sceneName;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
var assetName = string.Format(nameFormat, assetPath, target.name, i);
|
||||
var importer = AssetImporter.GetAtPath(assetName) as TextureImporter;
|
||||
importer.mipmapEnabled = false;
|
||||
importer.wrapMode = TextureWrapMode.Repeat;
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
importer.SetPlatformTextureSettings("Standalone", width, TextureImporterFormat.RGB24);
|
||||
#else
|
||||
var settings = importer.GetPlatformTextureSettings("Standalone");
|
||||
settings.textureCompression = TextureImporterCompression.Uncompressed;
|
||||
settings.maxTextureSize = width;
|
||||
importer.SetPlatformTextureSettings(settings);
|
||||
#endif
|
||||
importer.SaveAndReimport();
|
||||
|
||||
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(assetName);
|
||||
target.SetTextureByIndex(i, texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Editor/SteamVR_SkyboxEditor.cs.meta
Normal file
12
Assets/SteamVR/Editor/SteamVR_SkyboxEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80087fbbf7bf93a46bb4aea276b19568
|
||||
timeCreated: 1446765449
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
692
Assets/SteamVR/Editor/SteamVR_UnitySettingsWindow.cs
Normal file
692
Assets/SteamVR/Editor/SteamVR_UnitySettingsWindow.cs
Normal file
@ -0,0 +1,692 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Prompt developers to use settings most compatible with SteamVR.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class SteamVR_UnitySettingsWindow : EditorWindow
|
||||
{
|
||||
const bool forceShow = false; // Set to true to get the dialog to show back up in the case you clicked Ignore All.
|
||||
|
||||
const string ignore = "ignore.";
|
||||
const string useRecommended = "Use recommended ({0})";
|
||||
const string currentValue = " (current = {0})";
|
||||
|
||||
const string buildTarget = "Build Target";
|
||||
const string showUnitySplashScreen = "Show Unity Splashscreen";
|
||||
const string defaultIsFullScreen = "Default is Fullscreen";
|
||||
const string defaultScreenSize = "Default Screen Size";
|
||||
const string runInBackground = "Run In Background";
|
||||
const string displayResolutionDialog = "Display Resolution Dialog";
|
||||
const string resizableWindow = "Resizable Window";
|
||||
const string fullscreenMode = "D3D11 Fullscreen Mode";
|
||||
const string visibleInBackground = "Visible In Background";
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
const string renderingPath = "Rendering Path";
|
||||
#endif
|
||||
const string colorSpace = "Color Space";
|
||||
const string gpuSkinning = "GPU Skinning";
|
||||
#if false // skyboxes are currently broken
|
||||
const string singlePassStereoRendering = "Single-Pass Stereo Rendering";
|
||||
#endif
|
||||
|
||||
const BuildTarget recommended_BuildTarget = BuildTarget.StandaloneWindows64;
|
||||
const bool recommended_ShowUnitySplashScreen = false;
|
||||
const bool recommended_DefaultIsFullScreen = false;
|
||||
const int recommended_DefaultScreenWidth = 1024;
|
||||
const int recommended_DefaultScreenHeight = 768;
|
||||
const bool recommended_RunInBackground = true;
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
const ResolutionDialogSetting recommended_DisplayResolutionDialog = ResolutionDialogSetting.HiddenByDefault;
|
||||
#endif
|
||||
const bool recommended_ResizableWindow = true;
|
||||
const D3D11FullscreenMode recommended_FullscreenMode = D3D11FullscreenMode.FullscreenWindow;
|
||||
const bool recommended_VisibleInBackground = true;
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
const RenderingPath recommended_RenderPath = RenderingPath.Forward;
|
||||
#endif
|
||||
const ColorSpace recommended_ColorSpace = ColorSpace.Linear;
|
||||
const bool recommended_GpuSkinning = true;
|
||||
#if false
|
||||
const bool recommended_SinglePassStereoRendering = true;
|
||||
#endif
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
const FullScreenMode recommended_FullScreenMode = FullScreenMode.FullScreenWindow;
|
||||
#endif
|
||||
static SteamVR_UnitySettingsWindow window;
|
||||
|
||||
static SteamVR_UnitySettingsWindow()
|
||||
{
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
static void Update()
|
||||
{
|
||||
bool show =
|
||||
(!EditorPrefs.HasKey(ignore + buildTarget) &&
|
||||
EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) ||
|
||||
(!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) ||
|
||||
#else
|
||||
PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) ||
|
||||
#endif
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
(!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
|
||||
PlayerSettings.fullScreenMode != recommended_FullScreenMode) ||
|
||||
#else
|
||||
(!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
|
||||
PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) ||
|
||||
(!EditorPrefs.HasKey(ignore + fullscreenMode) &&
|
||||
PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) ||
|
||||
#endif
|
||||
(!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
|
||||
(PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
|
||||
PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) ||
|
||||
(!EditorPrefs.HasKey(ignore + runInBackground) &&
|
||||
PlayerSettings.runInBackground != recommended_RunInBackground) ||
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
(!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
|
||||
PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) ||
|
||||
#endif
|
||||
(!EditorPrefs.HasKey(ignore + resizableWindow) &&
|
||||
PlayerSettings.resizableWindow != recommended_ResizableWindow) ||
|
||||
(!EditorPrefs.HasKey(ignore + visibleInBackground) &&
|
||||
PlayerSettings.visibleInBackground != recommended_VisibleInBackground) ||
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
(!EditorPrefs.HasKey(ignore + renderingPath) &&
|
||||
PlayerSettings.renderingPath != recommended_RenderPath) ||
|
||||
#endif
|
||||
(!EditorPrefs.HasKey(ignore + colorSpace) &&
|
||||
PlayerSettings.colorSpace != recommended_ColorSpace) ||
|
||||
(!EditorPrefs.HasKey(ignore + gpuSkinning) &&
|
||||
PlayerSettings.gpuSkinning != recommended_GpuSkinning) ||
|
||||
#if false
|
||||
(!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
|
||||
PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) ||
|
||||
#endif
|
||||
forceShow;
|
||||
|
||||
if (show)
|
||||
{
|
||||
window = GetWindow<SteamVR_UnitySettingsWindow>(true);
|
||||
window.minSize = new Vector2(320, 440);
|
||||
//window.title = "SteamVR";
|
||||
}
|
||||
|
||||
string[] dlls = new string[]
|
||||
{
|
||||
"Plugins/x86/openvr_api.dll",
|
||||
"Plugins/x86_64/openvr_api.dll"
|
||||
};
|
||||
|
||||
foreach (string path in dlls)
|
||||
{
|
||||
if (!File.Exists(Application.dataPath + "/" + path))
|
||||
continue;
|
||||
|
||||
if (AssetDatabase.DeleteAsset("Assets/" + path))
|
||||
Debug.Log("<b>[SteamVR Setup]</b> Deleting " + path);
|
||||
else
|
||||
{
|
||||
Debug.Log("<b>[SteamVR Setup]</b> " + path + " in use; cannot delete. Please restart Unity to complete upgrade.");
|
||||
}
|
||||
}
|
||||
|
||||
EditorApplication.update -= Update;
|
||||
}
|
||||
|
||||
Vector2 scrollPosition;
|
||||
|
||||
string GetResourcePath()
|
||||
{
|
||||
var ms = MonoScript.FromScriptableObject(this);
|
||||
var path = AssetDatabase.GetAssetPath(ms);
|
||||
path = Path.GetDirectoryName(path);
|
||||
return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
var resourcePath = GetResourcePath();
|
||||
var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
|
||||
var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);
|
||||
if (logo)
|
||||
GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
|
||||
|
||||
EditorGUILayout.HelpBox("Recommended project settings for SteamVR:", MessageType.Warning);
|
||||
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
|
||||
|
||||
int numItems = 0;
|
||||
|
||||
if (!EditorPrefs.HasKey(ignore + buildTarget) &&
|
||||
EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(buildTarget + string.Format(currentValue, EditorUserBuildSettings.activeBuildTarget));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_BuildTarget)))
|
||||
{
|
||||
#if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
|
||||
#else
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget);
|
||||
#endif
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + buildTarget, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
|
||||
PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.showUnitySplashScreen));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen)))
|
||||
{
|
||||
PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#else
|
||||
if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
|
||||
PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen)))
|
||||
{
|
||||
PlayerSettings.SplashScreen.show = recommended_ShowUnitySplashScreen;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
#else
|
||||
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
|
||||
PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(defaultIsFullScreen + string.Format(currentValue, PlayerSettings.defaultIsFullScreen));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_DefaultIsFullScreen)))
|
||||
{
|
||||
PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
|
||||
(PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
|
||||
PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight))
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(defaultScreenSize + string.Format(" ({0}x{1})", PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format("Use recommended ({0}x{1})", recommended_DefaultScreenWidth, recommended_DefaultScreenHeight)))
|
||||
{
|
||||
PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth;
|
||||
PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + defaultScreenSize, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (!EditorPrefs.HasKey(ignore + runInBackground) &&
|
||||
PlayerSettings.runInBackground != recommended_RunInBackground)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(runInBackground + string.Format(currentValue, PlayerSettings.runInBackground));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_RunInBackground)))
|
||||
{
|
||||
PlayerSettings.runInBackground = recommended_RunInBackground;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + runInBackground, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
if (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
|
||||
PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(displayResolutionDialog + string.Format(currentValue, PlayerSettings.displayResolutionDialog));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_DisplayResolutionDialog)))
|
||||
{
|
||||
PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!EditorPrefs.HasKey(ignore + resizableWindow) &&
|
||||
PlayerSettings.resizableWindow != recommended_ResizableWindow)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(resizableWindow + string.Format(currentValue, PlayerSettings.resizableWindow));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_ResizableWindow)))
|
||||
{
|
||||
PlayerSettings.resizableWindow = recommended_ResizableWindow;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + resizableWindow, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
|
||||
PlayerSettings.fullScreenMode != recommended_FullScreenMode)
|
||||
#else
|
||||
if (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
|
||||
PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
|
||||
#endif
|
||||
{
|
||||
++numItems;
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.fullScreenMode));
|
||||
#else
|
||||
GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.d3d11FullscreenMode));
|
||||
#endif
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_FullscreenMode)))
|
||||
{
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
PlayerSettings.fullScreenMode = recommended_FullScreenMode;
|
||||
#else
|
||||
PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
|
||||
#endif
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + fullscreenMode, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
|
||||
PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(visibleInBackground + string.Format(currentValue, PlayerSettings.visibleInBackground));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_VisibleInBackground)))
|
||||
{
|
||||
PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + visibleInBackground, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
if (!EditorPrefs.HasKey(ignore + renderingPath) &&
|
||||
PlayerSettings.renderingPath != recommended_RenderPath)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(renderingPath + string.Format(currentValue, PlayerSettings.renderingPath));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_RenderPath) + " - required for MSAA"))
|
||||
{
|
||||
PlayerSettings.renderingPath = recommended_RenderPath;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + renderingPath, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#endif
|
||||
if (!EditorPrefs.HasKey(ignore + colorSpace) &&
|
||||
PlayerSettings.colorSpace != recommended_ColorSpace)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(colorSpace + string.Format(currentValue, PlayerSettings.colorSpace));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_ColorSpace) + " - requires reloading scene"))
|
||||
{
|
||||
PlayerSettings.colorSpace = recommended_ColorSpace;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + colorSpace, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (!EditorPrefs.HasKey(ignore + gpuSkinning) &&
|
||||
PlayerSettings.gpuSkinning != recommended_GpuSkinning)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(gpuSkinning + string.Format(currentValue, PlayerSettings.gpuSkinning));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_GpuSkinning)))
|
||||
{
|
||||
PlayerSettings.gpuSkinning = recommended_GpuSkinning;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + gpuSkinning, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
#if false
|
||||
if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
|
||||
PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
|
||||
{
|
||||
++numItems;
|
||||
|
||||
GUILayout.Label(singlePassStereoRendering + string.Format(currentValue, PlayerSettings.singlePassStereoRendering));
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button(string.Format(useRecommended, recommended_SinglePassStereoRendering)))
|
||||
{
|
||||
PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Ignore"))
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
#endif
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Clear All Ignores"))
|
||||
{
|
||||
EditorPrefs.DeleteKey(ignore + buildTarget);
|
||||
EditorPrefs.DeleteKey(ignore + showUnitySplashScreen);
|
||||
EditorPrefs.DeleteKey(ignore + defaultIsFullScreen);
|
||||
EditorPrefs.DeleteKey(ignore + defaultScreenSize);
|
||||
EditorPrefs.DeleteKey(ignore + runInBackground);
|
||||
EditorPrefs.DeleteKey(ignore + displayResolutionDialog);
|
||||
EditorPrefs.DeleteKey(ignore + resizableWindow);
|
||||
EditorPrefs.DeleteKey(ignore + fullscreenMode);
|
||||
EditorPrefs.DeleteKey(ignore + visibleInBackground);
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
EditorPrefs.DeleteKey(ignore + renderingPath);
|
||||
#endif
|
||||
EditorPrefs.DeleteKey(ignore + colorSpace);
|
||||
EditorPrefs.DeleteKey(ignore + gpuSkinning);
|
||||
#if false
|
||||
EditorPrefs.DeleteKey(ignore + singlePassStereoRendering);
|
||||
#endif
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.EndScrollView();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (numItems > 0)
|
||||
{
|
||||
if (GUILayout.Button("Accept All"))
|
||||
{
|
||||
// Only set those that have not been explicitly ignored.
|
||||
if (!EditorPrefs.HasKey(ignore + buildTarget))
|
||||
#if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
|
||||
#else
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget);
|
||||
#endif
|
||||
if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen))
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
|
||||
#else
|
||||
PlayerSettings.SplashScreen.show = recommended_ShowUnitySplashScreen;
|
||||
#endif
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen))
|
||||
PlayerSettings.fullScreenMode = recommended_FullScreenMode;
|
||||
#else
|
||||
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen))
|
||||
PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
|
||||
if (!EditorPrefs.HasKey(ignore + fullscreenMode))
|
||||
PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
|
||||
#endif
|
||||
if (!EditorPrefs.HasKey(ignore + defaultScreenSize))
|
||||
{
|
||||
PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth;
|
||||
PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
|
||||
}
|
||||
if (!EditorPrefs.HasKey(ignore + runInBackground))
|
||||
PlayerSettings.runInBackground = recommended_RunInBackground;
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
if (!EditorPrefs.HasKey(ignore + displayResolutionDialog))
|
||||
PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
|
||||
#endif
|
||||
if (!EditorPrefs.HasKey(ignore + resizableWindow))
|
||||
PlayerSettings.resizableWindow = recommended_ResizableWindow;
|
||||
if (!EditorPrefs.HasKey(ignore + visibleInBackground))
|
||||
PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
if (!EditorPrefs.HasKey(ignore + renderingPath))
|
||||
PlayerSettings.renderingPath = recommended_RenderPath;
|
||||
#endif
|
||||
if (!EditorPrefs.HasKey(ignore + colorSpace))
|
||||
PlayerSettings.colorSpace = recommended_ColorSpace;
|
||||
if (!EditorPrefs.HasKey(ignore + gpuSkinning))
|
||||
PlayerSettings.gpuSkinning = recommended_GpuSkinning;
|
||||
#if false
|
||||
if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering))
|
||||
PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
|
||||
#endif
|
||||
|
||||
EditorUtility.DisplayDialog("Accept All", "You made the right choice!", "Ok");
|
||||
|
||||
Close();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Ignore All"))
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Ignore All", "Are you sure?", "Yes, Ignore All", "Cancel"))
|
||||
{
|
||||
// Only ignore those that do not currently match our recommended settings.
|
||||
if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
|
||||
EditorPrefs.SetBool(ignore + buildTarget, true);
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
if (PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
|
||||
#else
|
||||
if (PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen)
|
||||
#endif
|
||||
EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
|
||||
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
if (PlayerSettings.fullScreenMode != recommended_FullScreenMode)
|
||||
{
|
||||
EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
|
||||
EditorPrefs.SetBool(ignore + fullscreenMode, true);
|
||||
}
|
||||
#else
|
||||
if (PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
|
||||
EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
|
||||
if (PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
|
||||
EditorPrefs.SetBool(ignore + fullscreenMode, true);
|
||||
#endif
|
||||
if (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
|
||||
PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)
|
||||
EditorPrefs.SetBool(ignore + defaultScreenSize, true);
|
||||
if (PlayerSettings.runInBackground != recommended_RunInBackground)
|
||||
EditorPrefs.SetBool(ignore + runInBackground, true);
|
||||
#if !UNITY_2019_1_OR_NEWER
|
||||
if (PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
|
||||
EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
|
||||
#endif
|
||||
if (PlayerSettings.resizableWindow != recommended_ResizableWindow)
|
||||
EditorPrefs.SetBool(ignore + resizableWindow, true);
|
||||
if (PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
|
||||
EditorPrefs.SetBool(ignore + visibleInBackground, true);
|
||||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
|
||||
if (PlayerSettings.renderingPath != recommended_RenderPath)
|
||||
EditorPrefs.SetBool(ignore + renderingPath, true);
|
||||
#endif
|
||||
if (PlayerSettings.colorSpace != recommended_ColorSpace)
|
||||
EditorPrefs.SetBool(ignore + colorSpace, true);
|
||||
if (PlayerSettings.gpuSkinning != recommended_GpuSkinning)
|
||||
EditorPrefs.SetBool(ignore + gpuSkinning, true);
|
||||
#if false
|
||||
if (PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
|
||||
EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
|
||||
#endif
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (GUILayout.Button("Close"))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Editor/SteamVR_UnitySettingsWindow.cs.meta
Normal file
12
Assets/SteamVR/Editor/SteamVR_UnitySettingsWindow.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2244eee8a3a4784fb40d1123ff69301
|
||||
timeCreated: 1438809573
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
180
Assets/SteamVR/Editor/SteamVR_Update.cs
Normal file
180
Assets/SteamVR/Editor/SteamVR_Update.cs
Normal file
@ -0,0 +1,180 @@
|
||||
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
|
||||
//
|
||||
// Purpose: Notify developers when a new version of the plugin is available.
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
#pragma warning disable CS0618
|
||||
#endif
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class SteamVR_Update : EditorWindow
|
||||
{
|
||||
const string currentVersion = "2.8";
|
||||
const string versionUrl = "https://media.steampowered.com/apps/steamvr/unitypluginversion.txt";
|
||||
const string notesUrl = "https://media.steampowered.com/apps/steamvr/unityplugin-v{0}.txt";
|
||||
const string pluginUrl = "https://u3d.as/content/valve-corporation/steam-vr-plugin";
|
||||
const string doNotShowKey = "SteamVR.DoNotShow.v{0}";
|
||||
|
||||
static bool gotVersion = false;
|
||||
static WWW wwwVersion, wwwNotes;
|
||||
static string version, notes;
|
||||
static SteamVR_Update window;
|
||||
|
||||
static SteamVR_Update()
|
||||
{
|
||||
EditorApplication.update += Update;
|
||||
}
|
||||
|
||||
static void Update()
|
||||
{
|
||||
if (!gotVersion)
|
||||
{
|
||||
if (wwwVersion == null)
|
||||
wwwVersion = new WWW(versionUrl);
|
||||
|
||||
if (!wwwVersion.isDone)
|
||||
return;
|
||||
|
||||
if (UrlSuccess(wwwVersion))
|
||||
version = wwwVersion.text;
|
||||
|
||||
wwwVersion = null;
|
||||
gotVersion = true;
|
||||
|
||||
if (ShouldDisplay())
|
||||
{
|
||||
var url = string.Format(notesUrl, version);
|
||||
wwwNotes = new WWW(url);
|
||||
|
||||
window = GetWindow<SteamVR_Update>(true);
|
||||
window.minSize = new Vector2(320, 440);
|
||||
//window.title = "SteamVR";
|
||||
}
|
||||
}
|
||||
|
||||
if (wwwNotes != null)
|
||||
{
|
||||
if (!wwwNotes.isDone)
|
||||
return;
|
||||
|
||||
if (UrlSuccess(wwwNotes))
|
||||
notes = wwwNotes.text;
|
||||
|
||||
wwwNotes = null;
|
||||
|
||||
if (notes != "")
|
||||
window.Repaint();
|
||||
}
|
||||
|
||||
EditorApplication.update -= Update;
|
||||
}
|
||||
|
||||
static bool UrlSuccess(WWW www)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(www.error))
|
||||
return false;
|
||||
if (Regex.IsMatch(www.text, "404 not found", RegexOptions.IgnoreCase))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ShouldDisplay()
|
||||
{
|
||||
if (string.IsNullOrEmpty(version))
|
||||
return false;
|
||||
if (version == currentVersion)
|
||||
return false;
|
||||
if (EditorPrefs.HasKey(string.Format(doNotShowKey, version)))
|
||||
return false;
|
||||
|
||||
// parse to see if newer (e.g. 1.0.4 vs 1.0.3)
|
||||
var versionSplit = version.Split('.');
|
||||
var currentVersionSplit = currentVersion.Split('.');
|
||||
for (int i = 0; i < versionSplit.Length && i < currentVersionSplit.Length; i++)
|
||||
{
|
||||
int versionValue, currentVersionValue;
|
||||
if (int.TryParse(versionSplit[i], out versionValue) &&
|
||||
int.TryParse(currentVersionSplit[i], out currentVersionValue))
|
||||
{
|
||||
if (versionValue > currentVersionValue)
|
||||
return true;
|
||||
if (versionValue < currentVersionValue)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// same up to this point, now differentiate based on number of sub values (e.g. 1.0.4.1 vs 1.0.4)
|
||||
if (versionSplit.Length <= currentVersionSplit.Length)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2 scrollPosition;
|
||||
bool toggleState;
|
||||
|
||||
string GetResourcePath()
|
||||
{
|
||||
var ms = MonoScript.FromScriptableObject(this);
|
||||
var path = AssetDatabase.GetAssetPath(ms);
|
||||
path = Path.GetDirectoryName(path);
|
||||
return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
EditorGUILayout.HelpBox("A new version of the SteamVR plugin is available!", MessageType.Warning);
|
||||
|
||||
var resourcePath = GetResourcePath();
|
||||
var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
|
||||
var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);
|
||||
if (logo)
|
||||
GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
|
||||
|
||||
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
|
||||
|
||||
GUILayout.Label("Current version: " + currentVersion);
|
||||
GUILayout.Label("New version: " + version);
|
||||
|
||||
if (notes != "")
|
||||
{
|
||||
GUILayout.Label("Release notes:");
|
||||
EditorGUILayout.HelpBox(notes, MessageType.Info);
|
||||
}
|
||||
|
||||
GUILayout.EndScrollView();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Get Latest Version"))
|
||||
{
|
||||
Application.OpenURL(pluginUrl);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var doNotShow = GUILayout.Toggle(toggleState, "Do not prompt for this version again.");
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
toggleState = doNotShow;
|
||||
var key = string.Format(doNotShowKey, version);
|
||||
if (doNotShow)
|
||||
EditorPrefs.SetBool(key, true);
|
||||
else
|
||||
EditorPrefs.DeleteKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
#pragma warning restore CS0618
|
||||
#endif
|
||||
12
Assets/SteamVR/Editor/SteamVR_Update.cs.meta
Normal file
12
Assets/SteamVR/Editor/SteamVR_Update.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73a0556bda803bf4e898751dcfcf21a8
|
||||
timeCreated: 1433880062
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/SteamVR/Editor/SteamVR_UpdateModeEditor.cs
Normal file
26
Assets/SteamVR/Editor/SteamVR_UpdateModeEditor.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using System.CodeDom;
|
||||
using Microsoft.CSharp;
|
||||
using System.IO;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq.Expressions;
|
||||
using System;
|
||||
|
||||
|
||||
namespace Valve.VR
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SteamVR_UpdateModes))]
|
||||
public class SteamVR_UpdateModesEditor : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label)
|
||||
{
|
||||
_property.intValue = EditorGUI.MaskField(_position, _label, _property.intValue, _property.enumNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/SteamVR/Editor/SteamVR_UpdateModeEditor.cs.meta
Normal file
12
Assets/SteamVR/Editor/SteamVR_UpdateModeEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 656e3d05f0a289d4ab6f3d44f65c9b6d
|
||||
timeCreated: 1521584981
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user