Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add project for SteamVR
This is the project where we practiced some "level design" and 3D
modeling. We also used the SteamVR plugin from the unity asset store
and got to test our builds in a Vive. FUN!
  • Loading branch information
mfs16101 committed Feb 11, 2020
1 parent b906ad1 commit 6e120e8
Show file tree
Hide file tree
Showing 11,019 changed files with 423,939 additions and 130 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
204 changes: 77 additions & 127 deletions Projects/MyGame/Library/CurrentLayout-default.dwlt

Large diffs are not rendered by default.

@@ -1 +1 @@
{"m_ScriptingRuntimeVersion":1,"m_DefineSymbols":[{"first":1,"second":"_FPAIO"},{"first":7,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":13,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":19,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":21,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":25,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":26,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":27,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":28,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":29,"second":"UNITY_POST_PROCESSING_STACK_V2"}],"m_AllowUnsafeCode":false}
{"m_ScriptingRuntimeVersion":1,"m_DefineSymbols":[{"first":1,"second":"_FPAIO;UNITY_POST_PROCESSING_STACK_V2"},{"first":7,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":13,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":19,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":21,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":25,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":26,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":27,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":28,"second":"UNITY_POST_PROCESSING_STACK_V2"},{"first":29,"second":"UNITY_POST_PROCESSING_STACK_V2"}],"m_AllowUnsafeCode":false}
2 changes: 1 addition & 1 deletion Projects/MyGame/Library/ProjectSettings.asset
Expand Up @@ -553,7 +553,7 @@ PlayerSettings:
webGLThreadsSupport: 0
webGLWasmStreaming: 0
scriptingDefineSymbols:
1: _FPAIO
1: _FPAIO;UNITY_POST_PROCESSING_STACK_V2
7: UNITY_POST_PROCESSING_STACK_V2
13: UNITY_POST_PROCESSING_STACK_V2
19: UNITY_POST_PROCESSING_STACK_V2
Expand Down
Binary file modified Projects/MyGame/Library/assetDatabase3
Binary file not shown.
2 changes: 1 addition & 1 deletion Projects/MyGame/ProjectSettings/ProjectSettings.asset
Expand Up @@ -553,7 +553,7 @@ PlayerSettings:
webGLThreadsSupport: 0
webGLWasmStreaming: 0
scriptingDefineSymbols:
1: _FPAIO
1: _FPAIO;UNITY_POST_PROCESSING_STACK_V2
7: UNITY_POST_PROCESSING_STACK_V2
13: UNITY_POST_PROCESSING_STACK_V2
19: UNITY_POST_PROCESSING_STACK_V2
Expand Down
8 changes: 8 additions & 0 deletions Projects/SteamVR/Assets/Scenes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Projects/SteamVR/Assets/Scenes/SampleScene.unity
Git LFS file not shown
7 changes: 7 additions & 0 deletions Projects/SteamVR/Assets/Scenes/SampleScene.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Projects/SteamVR/Assets/SteamVR.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Projects/SteamVR/Assets/SteamVR/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

231 changes: 231 additions & 0 deletions Projects/SteamVR/Assets/SteamVR/Editor/SteamVR_AutoEnableVR.cs
@@ -0,0 +1,231 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Prompt developers to use settings most compatible with SteamVR.
//
//=============================================================================

using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace Valve.VR
{
[InitializeOnLoad]
public class SteamVR_AutoEnableVR
{
static SteamVR_AutoEnableVR()
{
EditorApplication.update += Update;
}

protected const string openVRString = "OpenVR";
protected const string openVRPackageString = "com.unity.xr.openvr.standalone";

#if UNITY_2018_2_OR_NEWER
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;
#endif

public static void Update()
{
if (SteamVR_Settings.instance.autoEnableVR)
{
bool enabledVR = false;

if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
{
UnityEditor.PlayerSettings.virtualRealitySupported = true;
enabledVR = true;
Debug.Log("<b>[SteamVR Setup]</b> Enabled virtual reality support in Player Settings. (you can disable this by unchecking Assets/SteamVR/SteamVR_Settings.autoEnableVR)");
}

UnityEditor.BuildTargetGroup currentTarget = UnityEditor.EditorUserBuildSettings.selectedBuildTargetGroup;

#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(currentTarget);
#else
string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(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();
}

#if (UNITY_5_6 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
UnityEditorInternal.VR.VREditor.SetVREnabledDevices(currentTarget, newDevices);
#else
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(currentTarget, newDevices);
#endif
Debug.Log("<b>[SteamVR Setup]</b> Added OpenVR to supported VR SDKs list.");
}

#if UNITY_2018_2_OR_NEWER
//2018+ requires us to manually add the OpenVR package

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;
}

bool hasPackage = listRequest.Result.Any(package => package.name == openVRPackageString);

if (hasPackage == false)
{
//if we don't have the package - then install it
addRequest = UnityEditor.PackageManager.Client.Add(openVRPackageString);
packageState = PackageStates.WaitingForAdd;
addTryCount++;

Debug.Log("<b>[SteamVR Setup]</b> Installing OpenVR package...");
addingPackageTime.Start();
addingPackageTimeTotal.Start();
}
else
{
//if we do have the package do nothing
packageState = PackageStates.Installed; //already installed
}
}
break;

case PackageStates.WaitingForAdd:
if (addRequest.IsCompleted)
{
if (addRequest.Error != null || addRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
{
packageState = PackageStates.Failed;
break;
}
else
{
//if the package manager says we added it then confirm that with the list
listRequest = UnityEditor.PackageManager.Client.List(true);
packageState = PackageStates.WaitingForAddConfirm;
}
}
else
{
if (addingPackageTimeTotal.Elapsed.TotalSeconds > estimatedTimeToInstall)
estimatedTimeToInstall *= 2; // :)

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)
packageState = 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)
{
packageState = PackageStates.Failed;
break;
}

bool hasPackage = listRequest.Result.Any(package => package.name == openVRPackageString);

if (hasPackage == false)
{
if (addTryCount == 1)
{
addRequest = UnityEditor.PackageManager.Client.Add(openVRPackageString);
packageState = PackageStates.WaitingForAdd;
addTryCount++;

Debug.Log("<b>[SteamVR Setup]</b> Retrying OpenVR package install...");
}
else
{
packageState = PackageStates.Failed;
}
}
else
{
packageState = PackageStates.Installed; //installed successfully

Debug.Log("<b>[SteamVR Setup]</b> Successfully installed OpenVR package.");
}
}
break;
}

if (packageState == PackageStates.Failed || packageState == PackageStates.Installed)
{
addingPackageTime.Stop();
addingPackageTimeTotal.Stop();
UnityEditor.EditorUtility.ClearProgressBar();
UnityEditor.EditorApplication.update -= Update; //we're done trying to auto-enable vr

if (packageState == PackageStates.Failed)
{
string failtext = "The Unity Package Manager failed to automatically install the OpenVR 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);
}
}
#else
UnityEditor.EditorApplication.update -= Update;
#endif
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Projects/SteamVR/Assets/SteamVR/Editor/SteamVR_Editor.asmdef
@@ -0,0 +1,16 @@
{
"name": "SteamVR_Editor",
"references": [
"SteamVR"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6e120e8

Please sign in to comment.