This commit is contained in:
2016-05-18 20:02:15 +02:00
parent 62c8cf021f
commit 1e9b3a1498
225 changed files with 111146 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 42fb0e598b84205489ee2b9467f30737
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+129
View File
@@ -0,0 +1,129 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Custom inspector display for SteamVR_Camera
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.IO;
[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();
#if UNITY_5_0
logo = Resources.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
#else
logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
#endif
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
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5ba22c80948c94e44a82b9fd1b3abd0d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+105
View File
@@ -0,0 +1,105 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Custom inspector display for SteamVR_RenderModel
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.Text;
using System.Collections.Generic;
using 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("Model Override");
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
View 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:
+724
View File
@@ -0,0 +1,724 @@
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Prompt developers to use settings most compatible with SteamVR.
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.IO;
[InitializeOnLoad]
public class SteamVR_Settings : 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";
const string renderingPath = "Rendering Path";
const string colorSpace = "Color Space";
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
const string gpuSkinning = "GPU Skinning";
#endif
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) && false // skyboxes are currently broken
const string singlePassStereoRendering = "Single-Pass Stereo Rendering";
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
const string stereoscopicRendering = "Stereoscopic Rendering";
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1)
const string virtualRealitySupported = "Virtual Reality Support";
#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;
const ResolutionDialogSetting recommended_DisplayResolutionDialog = ResolutionDialogSetting.HiddenByDefault;
const bool recommended_ResizableWindow = true;
const D3D11FullscreenMode recommended_FullscreenMode = D3D11FullscreenMode.FullscreenWindow;
const bool recommended_VisibleInBackground = true;
const RenderingPath recommended_RenderPath = RenderingPath.Forward;
const ColorSpace recommended_ColorSpace = ColorSpace.Linear;
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
const bool recommended_GpuSkinning = true;
#endif
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) && false
const bool recommended_SinglePassStereoRendering = true;
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
const bool recommended_StereoscopicRendering = false;
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1)
const bool recommended_VirtualRealitySupported = false;
#endif
static SteamVR_Settings window;
static SteamVR_Settings()
{
EditorApplication.update += Update;
}
static void Update()
{
bool show =
(!EditorPrefs.HasKey(ignore + buildTarget) &&
EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) ||
(!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) ||
(!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) ||
(!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
(PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) ||
(!EditorPrefs.HasKey(ignore + runInBackground) &&
PlayerSettings.runInBackground != recommended_RunInBackground) ||
(!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) ||
(!EditorPrefs.HasKey(ignore + resizableWindow) &&
PlayerSettings.resizableWindow != recommended_ResizableWindow) ||
(!EditorPrefs.HasKey(ignore + fullscreenMode) &&
PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) ||
(!EditorPrefs.HasKey(ignore + visibleInBackground) &&
PlayerSettings.visibleInBackground != recommended_VisibleInBackground) ||
(!EditorPrefs.HasKey(ignore + renderingPath) &&
PlayerSettings.renderingPath != recommended_RenderPath) ||
(!EditorPrefs.HasKey(ignore + colorSpace) &&
PlayerSettings.colorSpace != recommended_ColorSpace) ||
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
(!EditorPrefs.HasKey(ignore + gpuSkinning) &&
PlayerSettings.gpuSkinning != recommended_GpuSkinning) ||
#endif
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) && false
(!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) ||
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
(!EditorPrefs.HasKey(ignore + stereoscopicRendering) &&
PlayerSettings.stereoscopic3D != recommended_StereoscopicRendering) ||
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1)
(!EditorPrefs.HasKey(ignore + virtualRealitySupported) &&
PlayerSettings.virtualRealitySupported != recommended_VirtualRealitySupported) ||
#endif
forceShow;
if (show)
{
window = GetWindow<SteamVR_Settings>(true);
window.minSize = new Vector2(320, 440);
//window.title = "SteamVR";
}
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
// Switch to native OpenVR support.
var updated = false;
if (!PlayerSettings.virtualRealitySupported)
{
PlayerSettings.virtualRealitySupported = true;
updated = true;
}
var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(BuildTargetGroup.Standalone);
var hasOpenVR = false;
foreach (var device in devices)
if (device.ToLower() == "openvr")
hasOpenVR = true;
if (!hasOpenVR)
{
string[] newDevices;
if (updated)
{
newDevices = new string[] { "OpenVR" };
}
else
{
newDevices = new string[devices.Length + 1];
for (int i = 0; i < devices.Length; i++)
newDevices[i] = devices[i];
newDevices[devices.Length] = "OpenVR";
updated = true;
}
UnityEditorInternal.VR.VREditor.SetVREnabledDevices(BuildTargetGroup.Standalone, newDevices);
}
if (updated)
Debug.Log("Switching to native OpenVR support.");
var dlls = new string[]
{
"Plugins/x86/openvr_api.dll",
"Plugins/x86_64/openvr_api.dll"
};
foreach (var path in dlls)
{
if (!File.Exists(Application.dataPath + "/" + path))
continue;
if (AssetDatabase.DeleteAsset("Assets/" + path))
Debug.Log("Deleting " + path);
else
{
Debug.Log(path + " in use; cannot delete. Please restart Unity to complete upgrade.");
}
}
#endif
EditorApplication.update -= Update;
}
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()
{
var resourcePath = GetResourcePath();
#if !(UNITY_5_0)
var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
#else
var logo = Resources.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
#endif
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)))
{
EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + buildTarget, true);
}
GUILayout.EndHorizontal();
}
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();
}
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();
}
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 (!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();
}
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 (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
{
++numItems;
GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.d3d11FullscreenMode));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_FullscreenMode)))
{
PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
}
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 (!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();
}
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 !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
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();
}
#endif
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) && 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
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (!EditorPrefs.HasKey(ignore + stereoscopicRendering) &&
PlayerSettings.stereoscopic3D != recommended_StereoscopicRendering)
{
++numItems;
GUILayout.Label(stereoscopicRendering + string.Format(currentValue, PlayerSettings.stereoscopic3D));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_StereoscopicRendering)))
{
PlayerSettings.stereoscopic3D = recommended_StereoscopicRendering;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + stereoscopicRendering, true);
}
GUILayout.EndHorizontal();
}
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1)
if (!EditorPrefs.HasKey(ignore + virtualRealitySupported) &&
PlayerSettings.virtualRealitySupported != recommended_VirtualRealitySupported)
{
++numItems;
GUILayout.Label(virtualRealitySupported + string.Format(currentValue, PlayerSettings.virtualRealitySupported));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_VirtualRealitySupported)))
{
PlayerSettings.virtualRealitySupported = recommended_VirtualRealitySupported;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + virtualRealitySupported, 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);
EditorPrefs.DeleteKey(ignore + renderingPath);
EditorPrefs.DeleteKey(ignore + colorSpace);
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
EditorPrefs.DeleteKey(ignore + gpuSkinning);
#endif
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) && false
EditorPrefs.DeleteKey(ignore + singlePassStereoRendering);
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
EditorPrefs.DeleteKey(ignore + stereoscopicRendering);
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1)
EditorPrefs.DeleteKey(ignore + virtualRealitySupported);
#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))
EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen))
PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen))
PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
if (!EditorPrefs.HasKey(ignore + defaultScreenSize))
{
PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth;
PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
}
if (!EditorPrefs.HasKey(ignore + runInBackground))
PlayerSettings.runInBackground = recommended_RunInBackground;
if (!EditorPrefs.HasKey(ignore + displayResolutionDialog))
PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
if (!EditorPrefs.HasKey(ignore + resizableWindow))
PlayerSettings.resizableWindow = recommended_ResizableWindow;
if (!EditorPrefs.HasKey(ignore + fullscreenMode))
PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
if (!EditorPrefs.HasKey(ignore + visibleInBackground))
PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
if (!EditorPrefs.HasKey(ignore + renderingPath))
PlayerSettings.renderingPath = recommended_RenderPath;
if (!EditorPrefs.HasKey(ignore + colorSpace))
PlayerSettings.colorSpace = recommended_ColorSpace;
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (!EditorPrefs.HasKey(ignore + gpuSkinning))
PlayerSettings.gpuSkinning = recommended_GpuSkinning;
#endif
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) && false
if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering))
PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (!EditorPrefs.HasKey(ignore + stereoscopicRendering))
PlayerSettings.stereoscopic3D = recommended_StereoscopicRendering;
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1)
if (!EditorPrefs.HasKey(ignore + virtualRealitySupported))
PlayerSettings.virtualRealitySupported = recommended_VirtualRealitySupported;
#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 (PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
if (PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
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 (PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
if (PlayerSettings.resizableWindow != recommended_ResizableWindow)
EditorPrefs.SetBool(ignore + resizableWindow, true);
if (PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
EditorPrefs.SetBool(ignore + fullscreenMode, true);
if (PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
EditorPrefs.SetBool(ignore + visibleInBackground, true);
if (PlayerSettings.renderingPath != recommended_RenderPath)
EditorPrefs.SetBool(ignore + renderingPath, true);
if (PlayerSettings.colorSpace != recommended_ColorSpace)
EditorPrefs.SetBool(ignore + colorSpace, true);
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (PlayerSettings.gpuSkinning != recommended_GpuSkinning)
EditorPrefs.SetBool(ignore + gpuSkinning, true);
#endif
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) && false
if (PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (PlayerSettings.stereoscopic3D != recommended_StereoscopicRendering)
EditorPrefs.SetBool(ignore + stereoscopicRendering, true);
#endif
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1)
if (PlayerSettings.virtualRealitySupported != recommended_VirtualRealitySupported)
EditorPrefs.SetBool(ignore + virtualRealitySupported, true);
#endif
Close();
}
}
}
else if (GUILayout.Button("Close"))
{
Close();
}
GUILayout.EndHorizontal();
}
}
+12
View 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:
+384
View File
@@ -0,0 +1,384 @@
//========= Copyright 2014, 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;
[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();
#if !(UNITY_5_0 || UNITY_5_1)
EditorGUILayout.HelpBox(helpText, MessageType.Info);
if (GUILayout.Button("Take snapshot"))
{
#if (UNITY_5_2)
var sceneName = Path.GetFileNameWithoutExtension(EditorApplication.currentScene);
var scenePath = Path.GetDirectoryName(EditorApplication.currentScene);
var assetPath = scenePath +"/" + sceneName;
if (!AssetDatabase.IsValidFolder(assetPath))
{
var guid = AssetDatabase.CreateFolder(scenePath, sceneName);
assetPath = AssetDatabase.GUIDToAssetPath(guid);
}
#endif
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)
{
#if !(UNITY_5_2)
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);
}
#endif
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)
{
#if !(UNITY_5_2)
var targetScene = target.gameObject.scene;
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
var scenePath = Path.GetDirectoryName(targetScene.path);
var assetPath = scenePath + "/" + sceneName;
#endif
for (int i = 0; i < directions.Length; i++)
{
var assetName = string.Format(nameFormat, assetPath, target.name, i);
var importer = AssetImporter.GetAtPath(assetName) as TextureImporter;
importer.textureFormat = TextureImporterFormat.RGB24;
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();
#if !(UNITY_5_2)
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);
}
#endif
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("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)
{
#if !(UNITY_5_2)
var targetScene = target.gameObject.scene;
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
var scenePath = Path.GetDirectoryName(targetScene.path);
var assetPath = scenePath + "/" + sceneName;
#endif
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;
importer.SetPlatformTextureSettings("Standalone", width, TextureImporterFormat.RGB24);
importer.SaveAndReimport();
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(assetName);
target.SetTextureByIndex(i, texture);
}
}
}
#endif
}
}
+12
View 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:
+170
View File
@@ -0,0 +1,170 @@
//========= Copyright 2015, 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;
[InitializeOnLoad]
public class SteamVR_Update : EditorWindow
{
const string currentVersion = "1.1.0";
const string versionUrl = "http://media.steampowered.com/apps/steamvr/unitypluginversion.txt";
const string notesUrl = "http://media.steampowered.com/apps/steamvr/unityplugin-v{0}.txt";
const string pluginUrl = "http://u3d.as/content/valve-corporation/steam-vr-plugin";
const string doNotShowKey = "SteamVR.DoNotShow.v{0}";
static WWW wwwVersion, wwwNotes;
static string version, notes;
static SteamVR_Update window;
static SteamVR_Update()
{
wwwVersion = new WWW(versionUrl);
EditorApplication.update += Update;
}
static void Update()
{
if (wwwVersion != null)
{
if (!wwwVersion.isDone)
return;
if (UrlSuccess(wwwVersion))
version = wwwVersion.text;
wwwVersion = null;
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();
#if UNITY_5_0
var logo = Resources.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
#else
var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
#endif
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);
}
}
}
+12
View 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:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: cac56563961ef1e4794a37c36c3510b4
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+87
View File
@@ -0,0 +1,87 @@
using UnityEngine;
using System.Collections;
public struct GazeEventArgs
{
public float distance;
}
public delegate void GazeEventHandler(object sender, GazeEventArgs e);
public class SteamVR_GazeTracker : MonoBehaviour
{
public bool isInGaze = false;
public event GazeEventHandler GazeOn;
public event GazeEventHandler GazeOff;
public float gazeInCutoff = 0.15f;
public float gazeOutCutoff = 0.4f;
// Contains a HMD tracked object that we can use to find the user's gaze
Transform hmdTrackedObject = null;
// Use this for initialization
void Start ()
{
}
public virtual void OnGazeOn(GazeEventArgs e)
{
if (GazeOn != null)
GazeOn(this, e);
}
public virtual void OnGazeOff(GazeEventArgs e)
{
if (GazeOff != null)
GazeOff(this, e);
}
// Update is called once per frame
void Update ()
{
// If we haven't set up hmdTrackedObject find what the user is looking at
if (hmdTrackedObject == null)
{
SteamVR_TrackedObject[] trackedObjects = FindObjectsOfType<SteamVR_TrackedObject>();
foreach (SteamVR_TrackedObject tracked in trackedObjects)
{
if (tracked.index == SteamVR_TrackedObject.EIndex.Hmd)
{
hmdTrackedObject = tracked.transform;
break;
}
}
}
if (hmdTrackedObject)
{
Ray r = new Ray(hmdTrackedObject.position, hmdTrackedObject.forward);
Plane p = new Plane(hmdTrackedObject.forward, transform.position);
float enter = 0.0f;
if (p.Raycast(r, out enter))
{
Vector3 intersect = hmdTrackedObject.position + hmdTrackedObject.forward * enter;
float dist = Vector3.Distance(intersect, transform.position);
//Debug.Log("Gaze dist = " + dist);
if (dist < gazeInCutoff && !isInGaze)
{
isInGaze = true;
GazeEventArgs e;
e.distance = dist;
OnGazeOn(e);
}
else if (dist >= gazeOutCutoff && isInGaze)
{
isInGaze = false;
GazeEventArgs e;
e.distance = dist;
OnGazeOff(e);
}
}
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 501eb8b744f73714fbe7dbdd5e3ef66e
timeCreated: 1426193800
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+138
View File
@@ -0,0 +1,138 @@
using UnityEngine;
using System.Collections;
public struct PointerEventArgs
{
public uint controllerIndex;
public uint flags;
public float distance;
public Transform target;
}
public delegate void PointerEventHandler(object sender, PointerEventArgs e);
public class SteamVR_LaserPointer : MonoBehaviour
{
public bool active = true;
public Color color;
public float thickness = 0.002f;
public GameObject holder;
public GameObject pointer;
bool isActive = false;
public bool addRigidBody = false;
public Transform reference;
public event PointerEventHandler PointerIn;
public event PointerEventHandler PointerOut;
Transform previousContact = null;
// Use this for initialization
void Start ()
{
holder = new GameObject();
holder.transform.parent = this.transform;
holder.transform.localPosition = Vector3.zero;
pointer = GameObject.CreatePrimitive(PrimitiveType.Cube);
pointer.transform.parent = holder.transform;
pointer.transform.localScale = new Vector3(thickness, thickness, 100f);
pointer.transform.localPosition = new Vector3(0f, 0f, 50f);
BoxCollider collider = pointer.GetComponent<BoxCollider>();
if (addRigidBody)
{
if (collider)
{
collider.isTrigger = true;
}
Rigidbody rigidBody = pointer.AddComponent<Rigidbody>();
rigidBody.isKinematic = true;
}
else
{
if(collider)
{
Object.Destroy(collider);
}
}
Material newMaterial = new Material(Shader.Find("Unlit/Color"));
newMaterial.SetColor("_Color", color);
pointer.GetComponent<MeshRenderer>().material = newMaterial;
}
public virtual void OnPointerIn(PointerEventArgs e)
{
if (PointerIn != null)
PointerIn(this, e);
}
public virtual void OnPointerOut(PointerEventArgs e)
{
if (PointerOut != null)
PointerOut(this, e);
}
// Update is called once per frame
void Update ()
{
if (!isActive)
{
isActive = true;
this.transform.GetChild(0).gameObject.SetActive(true);
}
float dist = 100f;
SteamVR_TrackedController controller = GetComponent<SteamVR_TrackedController>();
Ray raycast = new Ray(transform.position, transform.forward);
RaycastHit hit;
bool bHit = Physics.Raycast(raycast, out hit);
if(previousContact && previousContact != hit.transform)
{
PointerEventArgs args = new PointerEventArgs();
if (controller != null)
{
args.controllerIndex = controller.controllerIndex;
}
args.distance = 0f;
args.flags = 0;
args.target = previousContact;
OnPointerOut(args);
previousContact = null;
}
if(bHit && previousContact != hit.transform)
{
PointerEventArgs argsIn = new PointerEventArgs();
if (controller != null)
{
argsIn.controllerIndex = controller.controllerIndex;
}
argsIn.distance = hit.distance;
argsIn.flags = 0;
argsIn.target = hit.transform;
OnPointerIn(argsIn);
previousContact = hit.transform;
}
if(!bHit)
{
previousContact = null;
}
if (bHit && hit.distance < 100f)
{
dist = hit.distance;
}
if (controller != null && controller.triggerPressed)
{
pointer.transform.localScale = new Vector3(thickness * 5f, thickness * 5f, dist);
}
else
{
pointer.transform.localScale = new Vector3(thickness, thickness, dist);
}
pointer.transform.localPosition = new Vector3(0f, 0f, dist/2f);
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d4e8a839a7c5b7e4580c59e305fb5f01
timeCreated: 1430337756
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+84
View File
@@ -0,0 +1,84 @@
using UnityEngine;
using System.Collections;
public class SteamVR_Teleporter : MonoBehaviour
{
public enum TeleportType
{
TeleportTypeUseTerrain,
TeleportTypeUseCollider,
TeleportTypeUseZeroY
}
public bool teleportOnClick = false;
public TeleportType teleportType = TeleportType.TeleportTypeUseZeroY;
Transform reference
{
get
{
var top = SteamVR_Render.Top();
return (top != null) ? top.origin : null;
}
}
void Start ()
{
var trackedController = GetComponent<SteamVR_TrackedController>();
if (trackedController == null)
{
trackedController = gameObject.AddComponent<SteamVR_TrackedController>();
}
trackedController.TriggerClicked += new ClickedEventHandler(DoClick);
if (teleportType == TeleportType.TeleportTypeUseTerrain)
{
// Start the player at the level of the terrain
var t = reference;
if (t != null)
t.position = new Vector3(t.position.x, Terrain.activeTerrain.SampleHeight(t.position), t.position.z);
}
}
void DoClick(object sender, ClickedEventArgs e)
{
if (teleportOnClick)
{
var t = reference;
if (t == null)
return;
float refY = t.position.y;
Plane plane = new Plane(Vector3.up, -refY);
Ray ray = new Ray(this.transform.position, transform.forward);
bool hasGroundTarget = false;
float dist = 0f;
if (teleportType == TeleportType.TeleportTypeUseTerrain)
{
RaycastHit hitInfo;
TerrainCollider tc = Terrain.activeTerrain.GetComponent<TerrainCollider>();
hasGroundTarget = tc.Raycast(ray, out hitInfo, 1000f);
dist = hitInfo.distance;
}
else if (teleportType == TeleportType.TeleportTypeUseCollider)
{
RaycastHit hitInfo;
Physics.Raycast(ray, out hitInfo);
dist = hitInfo.distance;
}
else
{
hasGroundTarget = plane.Raycast(ray, out dist);
}
if (hasGroundTarget)
{
Vector3 headPosOnGround = new Vector3(SteamVR_Render.Top().head.localPosition.x, 0.0f, SteamVR_Render.Top().head.localPosition.z);
t.position = ray.origin + ray.direction * dist - new Vector3(t.GetChild(0).localPosition.x, 0f, t.GetChild(0).localPosition.z) - headPosOnGround;
}
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 24c7d7d77dd0d2a4b8e1ad129b170ee3
timeCreated: 1430337756
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4b6669fb4e4df9c48926f02b694be9d1
timeCreated: 1437433018
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+57
View File
@@ -0,0 +1,57 @@
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(SteamVR_TrackedObject))]
public class SteamVR_TestThrow : MonoBehaviour
{
public GameObject prefab;
public Rigidbody attachPoint;
SteamVR_TrackedObject trackedObj;
FixedJoint joint;
void Awake()
{
trackedObj = GetComponent<SteamVR_TrackedObject>();
}
void FixedUpdate()
{
var device = SteamVR_Controller.Input((int)trackedObj.index);
if (joint == null && device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
{
var go = GameObject.Instantiate(prefab);
go.transform.position = attachPoint.transform.position;
joint = go.AddComponent<FixedJoint>();
joint.connectedBody = attachPoint;
}
else if (joint != null && device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
{
var go = joint.gameObject;
var rigidbody = go.GetComponent<Rigidbody>();
Object.DestroyImmediate(joint);
joint = null;
Object.Destroy(go, 15.0f);
// We should probably apply the offset between trackedObj.transform.position
// and device.transform.pos to insert into the physics sim at the correct
// location, however, we would then want to predict ahead the visual representation
// by the same amount we are predicting our render poses.
var origin = trackedObj.origin ? trackedObj.origin : trackedObj.transform.parent;
if (origin != null)
{
rigidbody.velocity = origin.TransformVector(device.velocity);
rigidbody.angularVelocity = origin.TransformVector(device.angularVelocity);
}
else
{
rigidbody.velocity = device.velocity;
rigidbody.angularVelocity = device.angularVelocity;
}
rigidbody.maxAngularVelocity = rigidbody.angularVelocity.magnitude;
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ff4f36585e15b1942827390ff1a92502
timeCreated: 1437513988
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0d936163b5e9a5047b5e4ba5afaf5126
timeCreated: 1437513966
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+249
View File
@@ -0,0 +1,249 @@
using UnityEngine;
using Valve.VR;
public struct ClickedEventArgs
{
public uint controllerIndex;
public uint flags;
public float padX, padY;
}
public delegate void ClickedEventHandler(object sender, ClickedEventArgs e);
public class SteamVR_TrackedController : MonoBehaviour
{
public uint controllerIndex;
public VRControllerState_t controllerState;
public bool triggerPressed = false;
public bool steamPressed = false;
public bool menuPressed = false;
public bool padPressed = false;
public bool padTouched = false;
public bool gripped = false;
public event ClickedEventHandler MenuButtonClicked;
public event ClickedEventHandler MenuButtonUnclicked;
public event ClickedEventHandler TriggerClicked;
public event ClickedEventHandler TriggerUnclicked;
public event ClickedEventHandler SteamClicked;
public event ClickedEventHandler PadClicked;
public event ClickedEventHandler PadUnclicked;
public event ClickedEventHandler PadTouched;
public event ClickedEventHandler PadUntouched;
public event ClickedEventHandler Gripped;
public event ClickedEventHandler Ungripped;
// Use this for initialization
void Start()
{
if (this.GetComponent<SteamVR_TrackedObject>() == null)
{
gameObject.AddComponent<SteamVR_TrackedObject>();
}
if (controllerIndex != 0)
{
this.GetComponent<SteamVR_TrackedObject>().index = (SteamVR_TrackedObject.EIndex)controllerIndex;
if (this.GetComponent<SteamVR_RenderModel>() != null)
{
this.GetComponent<SteamVR_RenderModel>().index = (SteamVR_TrackedObject.EIndex)controllerIndex;
}
}
else
{
controllerIndex = (uint) this.GetComponent<SteamVR_TrackedObject>().index;
}
}
public void SetDeviceIndex(int index)
{
this.controllerIndex = (uint) index;
}
public virtual void OnTriggerClicked(ClickedEventArgs e)
{
if (TriggerClicked != null)
TriggerClicked(this, e);
}
public virtual void OnTriggerUnclicked(ClickedEventArgs e)
{
if (TriggerUnclicked != null)
TriggerUnclicked(this, e);
}
public virtual void OnMenuClicked(ClickedEventArgs e)
{
if (MenuButtonClicked != null)
MenuButtonClicked(this, e);
}
public virtual void OnMenuUnclicked(ClickedEventArgs e)
{
if (MenuButtonUnclicked != null)
MenuButtonUnclicked(this, e);
}
public virtual void OnSteamClicked(ClickedEventArgs e)
{
if (SteamClicked != null)
SteamClicked(this, e);
}
public virtual void OnPadClicked(ClickedEventArgs e)
{
if (PadClicked != null)
PadClicked(this, e);
}
public virtual void OnPadUnclicked(ClickedEventArgs e)
{
if (PadUnclicked != null)
PadUnclicked(this, e);
}
public virtual void OnPadTouched(ClickedEventArgs e)
{
if (PadTouched != null)
PadTouched(this, e);
}
public virtual void OnPadUntouched(ClickedEventArgs e)
{
if (PadUntouched != null)
PadUntouched(this, e);
}
public virtual void OnGripped(ClickedEventArgs e)
{
if (Gripped != null)
Gripped(this, e);
}
public virtual void OnUngripped(ClickedEventArgs e)
{
if (Ungripped != null)
Ungripped(this, e);
}
// Update is called once per frame
void Update()
{
var system = OpenVR.System;
if (system != null && system.GetControllerState(controllerIndex, ref controllerState))
{
ulong trigger = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_SteamVR_Trigger));
if (trigger > 0L && !triggerPressed)
{
triggerPressed = true;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnTriggerClicked(e);
}
else if (trigger == 0L && triggerPressed)
{
triggerPressed = false;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnTriggerUnclicked(e);
}
ulong grip = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_Grip));
if (grip > 0L && !gripped)
{
gripped = true;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnGripped(e);
}
else if (grip == 0L && gripped)
{
gripped = false;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnUngripped(e);
}
ulong pad = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_SteamVR_Touchpad));
if (pad > 0L && !padPressed)
{
padPressed = true;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnPadClicked(e);
}
else if (pad == 0L && padPressed)
{
padPressed = false;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnPadUnclicked(e);
}
ulong menu = controllerState.ulButtonPressed & (1UL << ((int)EVRButtonId.k_EButton_ApplicationMenu));
if (menu > 0L && !menuPressed)
{
menuPressed = true;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnMenuClicked(e);
}
else if (menu == 0L && menuPressed)
{
menuPressed = false;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnMenuUnclicked(e);
}
pad = controllerState.ulButtonTouched & (1UL << ((int)EVRButtonId.k_EButton_SteamVR_Touchpad));
if (pad > 0L && !padTouched)
{
padTouched = true;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnPadTouched(e);
}
else if (pad == 0L && padTouched)
{
padTouched = false;
ClickedEventArgs e;
e.controllerIndex = controllerIndex;
e.flags = (uint)controllerState.ulButtonPressed;
e.padX = controllerState.rAxis0.x;
e.padY = controllerState.rAxis0.y;
OnPadUntouched(e);
}
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7346a42905a29b347b1f492e8ad7b49f
timeCreated: 1430337756
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 089f7f17f35346a4eb0d4ff45f86c047
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+25
View File
@@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 5
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: workshop
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: a57cd5c56c9d75c4ba0ee9fbc6e1d8df, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats: {}
m_Colors: {}
+5
View File
@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 712cd3a70a5a1da41a6594aac6a97abe
NativeFormatImporter:
userData:
assetBundleName:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3eee7403344f7a04aaa184dddf595fc6
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+530
View File
@@ -0,0 +1,530 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &123270
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 439042}
- 81: {fileID: 8198212}
- 114: {fileID: 11453390}
m_Layer: 0
m_Name: Camera (ears)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &124034
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 458974}
- 114: {fileID: 11411726}
m_Layer: 0
m_Name: Controller (left)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &146900
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 420908}
- 114: {fileID: 11416958}
- 23: {fileID: 2348914}
- 33: {fileID: 3380982}
- 114: {fileID: 11489174}
m_Layer: 0
m_Name: '[CameraRig]'
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &147176
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 482514}
- 114: {fileID: 11417306}
m_Layer: 0
m_Name: Model
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &155680
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 408470}
- 20: {fileID: 2008320}
- 114: {fileID: 11420968}
- 114: {fileID: 11470538}
- 92: {fileID: 9213436}
m_Layer: 0
m_Name: Camera (head)
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &159396
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 402434}
- 114: {fileID: 11463128}
m_Layer: 0
m_Name: Controller (right)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &189822
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 413432}
- 20: {fileID: 2082592}
- 124: {fileID: 12409152}
- 114: {fileID: 11411836}
m_Layer: 0
m_Name: Camera (eye)
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &192944
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 478542}
- 114: {fileID: 11417168}
m_Layer: 0
m_Name: Model
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &402434
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 159396}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 478542}
m_Father: {fileID: 420908}
m_RootOrder: 1
--- !u!4 &408470
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155680}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 413432}
- {fileID: 439042}
m_Father: {fileID: 420908}
m_RootOrder: 2
--- !u!4 &413432
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 189822}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 408470}
m_RootOrder: 0
--- !u!4 &420908
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146900}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 458974}
- {fileID: 402434}
- {fileID: 408470}
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!4 &439042
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 123270}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 408470}
m_RootOrder: 1
--- !u!4 &458974
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 124034}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 482514}
m_Father: {fileID: 420908}
m_RootOrder: 0
--- !u!4 &478542
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 192944}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 402434}
m_RootOrder: 0
--- !u!4 &482514
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 147176}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 458974}
m_RootOrder: 0
--- !u!20 &2008320
Camera:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155680}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 4
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0
far clip plane: 1
field of view: 60
orthographic: 1
orthographic size: 1
m_Depth: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 0
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_OcclusionCulling: 0
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!20 &2082592
Camera:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 189822}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.05
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
m_StereoMirrorMode: 0
--- !u!23 &2348914
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146900}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 0
m_ReflectionProbeUsage: 0
m_ProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!33 &3380982
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146900}
m_Mesh: {fileID: 0}
--- !u!81 &8198212
AudioListener:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 123270}
m_Enabled: 1
--- !u!92 &9213436
Behaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155680}
m_Enabled: 1
--- !u!114 &11411726
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 124034}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d37c2cf88f7c59f4c8cf5d3812568143, type: 3}
m_Name:
m_EditorClassIdentifier:
index: -1
origin: {fileID: 0}
isValid: 0
--- !u!114 &11411836
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 189822}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bca9ccf900ccc84c887d783321d27e2, type: 3}
m_Name:
m_EditorClassIdentifier:
_head: {fileID: 408470}
_ears: {fileID: 439042}
wireframe: 0
render: {fileID: 0}
--- !u!114 &11416958
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146900}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3b47c2980b93bc48844a54641dab5b8, type: 3}
m_Name:
m_EditorClassIdentifier:
left: {fileID: 124034}
right: {fileID: 159396}
objects: []
--- !u!114 &11417168
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 192944}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5890e3cad70bea64d91aef9145ba3454, type: 3}
m_Name:
m_EditorClassIdentifier:
index: -1
modelOverride:
shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
verbose: 0
createComponents: 1
updateDynamically: 1
--- !u!114 &11417306
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 147176}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5890e3cad70bea64d91aef9145ba3454, type: 3}
m_Name:
m_EditorClassIdentifier:
index: -1
modelOverride:
shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
verbose: 0
createComponents: 1
updateDynamically: 1
--- !u!114 &11420968
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155680}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: be96d45fe21847a4a805d408a8015c84, type: 3}
m_Name:
m_EditorClassIdentifier:
scale: 1.5
drawOverlay: 1
--- !u!114 &11453390
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 123270}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 49a86c1078ce4314b9c4224560e031b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &11463128
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 159396}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d37c2cf88f7c59f4c8cf5d3812568143, type: 3}
m_Name:
m_EditorClassIdentifier:
index: -1
origin: {fileID: 0}
isValid: 0
--- !u!114 &11470538
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155680}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d37c2cf88f7c59f4c8cf5d3812568143, type: 3}
m_Name:
m_EditorClassIdentifier:
index: 0
origin: {fileID: 0}
isValid: 0
--- !u!114 &11489174
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146900}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1f0522eaef74d984591c060d05a095c8, type: 3}
m_Name:
m_EditorClassIdentifier:
borderThickness: 0.15
wireframeHeight: 2
drawWireframeWhenSelectedOnly: 0
drawInGame: 0
size: 2
color: {r: 0, g: 1, b: 1, a: 1}
vertices:
- {x: 1.5, y: 0.01, z: 1.125}
- {x: 1.5, y: 0.01, z: -1.125}
- {x: -1.5, y: 0.01, z: -1.125}
- {x: -1.5, y: 0.01, z: 1.125}
- {x: 1.65, y: 0.01, z: 1.275}
- {x: 1.65, y: 0.01, z: -1.275}
- {x: -1.65, y: 0.01, z: -1.275}
- {x: -1.65, y: 0.01, z: 1.275}
--- !u!124 &12409152
Behaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 189822}
m_Enabled: 1
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 146900}
m_IsPrefabParent: 1
+5
View File
@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 4d293c8e162f3874b982baadd71153d2
NativeFormatImporter:
userData:
assetBundleName:
+489
View File
@@ -0,0 +1,489 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &100000
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400000}
- 132: {fileID: 13200000}
- 114: {fileID: 11400000}
m_Layer: 0
m_Name: SteamInitFailure
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &100002
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400002}
- 20: {fileID: 2000000}
- 92: {fileID: 9200000}
- 132: {fileID: 13200002}
- 114: {fileID: 11400002}
- 114: {fileID: 11400004}
m_Layer: 8
m_Name: _Stats
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &100004
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400004}
- 132: {fileID: 13200004}
- 114: {fileID: 11400006}
m_Layer: 8
m_Name: Calibration
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &100006
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400006}
- 132: {fileID: 13200006}
- 114: {fileID: 11400008}
m_Layer: 8
m_Name: TrackingRestored
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &100008
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400008}
m_Layer: 8
m_Name: '[Status]'
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &110680
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 426596}
- 114: {fileID: 11412486}
m_Layer: 8
m_Name: Overlay
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &146306
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 471342}
- 132: {fileID: 13283676}
- 114: {fileID: 11456694}
m_Layer: 8
m_Name: TrackingLost
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &400000
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .5, y: .430000007, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 400008}
m_RootOrder: 4
--- !u!4 &400002
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100002}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .100000001, y: .75, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 400008}
m_RootOrder: 1
--- !u!4 &400004
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100004}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .5, y: .519999981, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 400008}
m_RootOrder: 0
--- !u!4 &400006
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100006}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .5, y: .389999986, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 400008}
m_RootOrder: 3
--- !u!4 &400008
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100008}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 400004}
- {fileID: 400002}
- {fileID: 471342}
- {fileID: 400006}
- {fileID: 400000}
- {fileID: 426596}
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!4 &426596
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110680}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 400008}
m_RootOrder: 5
--- !u!4 &471342
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146306}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: .5, y: .370000005, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 400008}
m_RootOrder: 2
--- !u!20 &2000000
Camera:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100002}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: .300000012
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 256
m_RenderingPath: -1
m_TargetTexture: {fileID: 8400000, guid: 005ed5a6df2f5ff468efd6497d37fefa, type: 2}
m_TargetDisplay: 0
m_HDR: 0
m_OcclusionCulling: 0
m_StereoConvergence: 10
m_StereoSeparation: .0219999999
--- !u!92 &9200000
Behaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100002}
m_Enabled: 1
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 734380cdf472d0948a48549e5d5e7aa4, type: 3}
m_Name:
m_EditorClassIdentifier:
message: steam_init_failure
duration: 90
fade: .100000001
mode: 0
--- !u!114 &11400002
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100002}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8c3faa610c019764a81eb8497109e2d4, type: 3}
m_Name:
m_EditorClassIdentifier:
menu: {fileID: 0}
text: {fileID: 0}
fadeColor: {r: 0, g: 0, b: 0, a: 1}
fadeDuration: 1
--- !u!114 &11400004
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100002}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e7afc8c74d1f73b458705e0b946292a0, type: 3}
m_Name:
m_EditorClassIdentifier:
cursor: {fileID: 2800000, guid: 2db89a771043d7b4eb9d26622f6b97c7, type: 3}
background: {fileID: 2800000, guid: bb00cc87e146a414fbf2c4d3c0d31151, type: 3}
logo: {fileID: 2800000, guid: 09db43b3b77bf744287ba587fea02f8b, type: 3}
logoHeight: 340
menuOffset: 40
scaleLimits: {x: .100000001, y: 5}
scaleRate: .5
--- !u!114 &11400006
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 734380cdf472d0948a48549e5d5e7aa4, type: 3}
m_Name:
m_EditorClassIdentifier:
message: calibrating
duration: 0
fade: .5
mode: 2
--- !u!114 &11400008
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100006}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 734380cdf472d0948a48549e5d5e7aa4, type: 3}
m_Name:
m_EditorClassIdentifier:
message: out_of_range
duration: 2
fade: .100000001
mode: 1
--- !u!114 &11412486
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 110680}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 46fe9e0b23166454c8cb73040321d78c, type: 3}
m_Name:
m_EditorClassIdentifier:
texture: {fileID: 8400000, guid: 005ed5a6df2f5ff468efd6497d37fefa, type: 2}
curved: 1
antialias: 1
scale: 3
distance: 1.25
alpha: 1
uvOffset: {x: 0, y: 0, z: 1, w: 1}
--- !u!114 &11456694
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146306}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 734380cdf472d0948a48549e5d5e7aa4, type: 3}
m_Name:
m_EditorClassIdentifier:
message: out_of_range
duration: 2
fade: .100000001
mode: 0
--- !u!132 &13200000
GUIText:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100000}
m_Enabled: 0
serializedVersion: 3
m_Text: 'Failed to initialize SteamAPI!
Make sure Steam is running.'
m_Anchor: 4
m_Alignment: 1
m_PixelOffset: {x: 0, y: 0}
m_LineSpacing: 1
m_TabSize: 4
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Material: {fileID: 0}
m_FontSize: 32
m_FontStyle: 1
m_Color:
serializedVersion: 2
rgba: 4278234879
m_PixelCorrect: 1
m_RichText: 1
--- !u!132 &13200002
GUIText:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100002}
m_Enabled: 1
serializedVersion: 3
m_Text:
m_Anchor: 0
m_Alignment: 0
m_PixelOffset: {x: 0, y: 0}
m_LineSpacing: 1
m_TabSize: 4
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Material: {fileID: 0}
m_FontSize: 32
m_FontStyle: 1
m_Color:
serializedVersion: 2
rgba: 4278221311
m_PixelCorrect: 1
m_RichText: 1
--- !u!132 &13200004
GUIText:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100004}
m_Enabled: 0
serializedVersion: 3
m_Text: Calibrating - look straight forward and hold still...
m_Anchor: 4
m_Alignment: 1
m_PixelOffset: {x: 0, y: 0}
m_LineSpacing: 1
m_TabSize: 4
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Material: {fileID: 0}
m_FontSize: 32
m_FontStyle: 1
m_Color:
serializedVersion: 2
rgba: 4294967295
m_PixelCorrect: 1
m_RichText: 1
--- !u!132 &13200006
GUIText:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100006}
m_Enabled: 0
serializedVersion: 3
m_Text: Absolute position tracking restored.
m_Anchor: 4
m_Alignment: 1
m_PixelOffset: {x: 0, y: 0}
m_LineSpacing: 1
m_TabSize: 4
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Material: {fileID: 0}
m_FontSize: 32
m_FontStyle: 1
m_Color:
serializedVersion: 2
rgba: 4291982669
m_PixelCorrect: 1
m_RichText: 1
--- !u!132 &13283676
GUIText:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 146306}
m_Enabled: 0
serializedVersion: 3
m_Text: Absolute position tracking lost.
m_Anchor: 4
m_Alignment: 1
m_PixelOffset: {x: 0, y: 0}
m_LineSpacing: 1
m_TabSize: 4
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_Material: {fileID: 0}
m_FontSize: 32
m_FontStyle: 1
m_Color:
serializedVersion: 2
rgba: 4285848063
m_PixelCorrect: 1
m_RichText: 1
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 100008}
m_IsPrefabParent: 1
+5
View File
@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 255333d57084e4e46b3d948279746a47
NativeFormatImporter:
userData:
assetBundleName:
+120
View File
@@ -0,0 +1,120 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &132594
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 458990}
- 114: {fileID: 11432822}
m_Layer: 0
m_Name: '[SteamVR]'
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &458990
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 132594}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &11432822
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 132594}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e979227f3384fac4b8ca0b3550bf005c, type: 3}
m_Name:
m_EditorClassIdentifier:
helpSeconds: 10
helpText: You may now put on your headset.
helpStyle:
m_Name:
m_Normal:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Hover:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Active:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Focused:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnNormal:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnHover:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnActive:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_OnFocused:
m_Background: {fileID: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
m_Border:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Margin:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Overflow:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_Font: {fileID: 0}
m_FontSize: 0
m_FontStyle: 0
m_Alignment: 0
m_WordWrap: 0
m_RichText: 1
m_TextClipping: 0
m_ImagePosition: 0
m_ContentOffset: {x: 0, y: 0}
m_FixedWidth: 0
m_FixedHeight: 0
m_StretchWidth: 1
m_StretchHeight: 0
leftMask:
serializedVersion: 2
m_Bits: 0
rightMask:
serializedVersion: 2
m_Bits: 0
trackingSpace: 1
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 132594}
m_IsPrefabParent: 1
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4f35fa249b5008c44ac2998be6f82d4d
timeCreated: 1429757514
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b7cb70a58087a554d9457652cda819fe
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+46
View File
@@ -0,0 +1,46 @@
Shader "Custom/SteamVR_AlphaOut" {
Properties { _MainTex ("Base (RGB)", 2D) = "white" {} }
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.tex = v.texcoord;
return o;
}
float luminance(float3 color)
{
return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
}
float4 frag(v2f i) : COLOR {
float4 color = tex2D(_MainTex, i.tex);
float a = saturate(color.a + luminance(color.rgb));
return float4(a, a, a, a);
}
ENDCG
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: da25bb0dccfd3894181fc5e84714cd17
timeCreated: 1456189850
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
+52
View File
@@ -0,0 +1,52 @@
Shader "Custom/SteamVR_Blit" {
Properties { _MainTex ("Base (RGB)", 2D) = "white" {} }
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = v.vertex;
o.tex = v.texcoord;
return o;
}
float4 frag(v2f i) : COLOR {
return tex2D(_MainTex, i.tex);
}
float4 frag_linear(v2f i) : COLOR {
return pow(tex2D(_MainTex, i.tex), 1.0 / 2.2);
}
ENDCG
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag_linear
ENDCG
}
}
}
+6
View File
@@ -0,0 +1,6 @@
fileFormatVersion: 2
guid: 6403027b84bd2824dafa520459aa107d
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
+40
View File
@@ -0,0 +1,40 @@
Shader "Custom/SteamVR_BlitFlip" {
Properties { _MainTex ("Base (RGB)", 2D) = "white" {} }
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.tex.x = v.texcoord.x;
o.tex.y = 1 - v.texcoord.y;
return o;
}
float4 frag(v2f i) : COLOR {
return tex2D(_MainTex, i.tex);
}
ENDCG
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2adcf81282c27bc4098ee69d2419bc48
timeCreated: 1430872950
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
+41
View File
@@ -0,0 +1,41 @@
Shader "Custom/SteamVR_ClearAll" {
Properties { _MainTex ("Base (RGB)", 2D) = "white" {} }
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.tex = v.texcoord;
return o;
}
float4 frag(v2f i) : COLOR {
return float4(0, 0, 0, 0);
}
ENDCG
SubShader {
Tags{ "Queue" = "Background" }
Pass {
ZTest Always Cull Off ZWrite On
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: c1eded52540dd0a4988d5d4d76382da9
timeCreated: 1457042024
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
+46
View File
@@ -0,0 +1,46 @@
Shader "Custom/SteamVR_ColorOut" {
Properties { _MainTex ("Base (RGB)", 2D) = "white" {} }
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.tex = v.texcoord;
return o;
}
float luminance(float3 color)
{
return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b;
}
float4 frag(v2f i) : COLOR {
float4 color = tex2D(_MainTex, i.tex);
return float4(color.rgb, 1);
}
ENDCG
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 04d03a6e2ff64bf47911d08912140c31
timeCreated: 1456866489
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
+114
View File
@@ -0,0 +1,114 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &128450
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 417074}
- 114: {fileID: 11479102}
m_Layer: 0
m_Name: SteamVR_ExternalCamera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &129796
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 444732}
- 114: {fileID: 11487396}
- 114: {fileID: 11472986}
m_Layer: 0
m_Name: Controller (third)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &417074
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 128450}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 444732}
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!4 &444732
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 129796}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 417074}
m_RootOrder: 0
--- !u!114 &11472986
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 129796}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d37c2cf88f7c59f4c8cf5d3812568143, type: 3}
m_Name:
m_EditorClassIdentifier:
index: -1
origin: {fileID: 0}
isValid: 0
--- !u!114 &11479102
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 128450}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3b47c2980b93bc48844a54641dab5b8, type: 3}
m_Name:
m_EditorClassIdentifier:
left: {fileID: 0}
right: {fileID: 0}
objects:
- {fileID: 129796}
--- !u!114 &11487396
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 129796}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c9da270df5147d24597cc106058c1fa7, type: 3}
m_Name:
m_EditorClassIdentifier:
offset: {fileID: 0}
frontCam: {fileID: 0}
backCam: {fileID: 0}
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 128450}
m_IsPrefabParent: 1
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6b259143c09ffc447ad059e5b8d8cf89
timeCreated: 1456288801
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
+6
View File
@@ -0,0 +1,6 @@
Shader "Custom/SteamVR_Fade" {
SubShader { Pass {
Blend SrcAlpha OneMinusSrcAlpha
ZTest Always Cull Off ZWrite Off Fog { Mode Off }
BindChannels { Bind "vertex", vertex Bind "color", color }
} } }
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 9f884441bea153347be721454dc13716
timeCreated: 1433284862
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
+24
View File
@@ -0,0 +1,24 @@
Shader "Custom/SteamVR_HiddenArea" {
CGINCLUDE
#include "UnityCG.cginc"
float4 vert(appdata_base v) : SV_POSITION { return v.vertex; }
float4 frag(float4 v : SV_POSITION) : COLOR { return float4(0,0,0,0); }
ENDCG
SubShader {
Tags { "Queue" = "Background" }
Pass {
ZTest Always Cull Off ZWrite On
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7687f525efe9f4b449dfe5a7fe0b7c8e
timeCreated: 1428972938
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
+54
View File
@@ -0,0 +1,54 @@
Shader "Custom/SteamVR_Overlay" {
Properties { _MainTex ("Base (RGB)", 2D) = "white" {} }
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = v.vertex;
o.tex = v.texcoord;
return o;
}
float4 frag(v2f i) : COLOR {
return tex2D(_MainTex, i.tex);
}
float4 frag_linear(v2f i) : COLOR {
return pow(tex2D(_MainTex, i.tex), 2.2);
}
ENDCG
SubShader {
Pass {
Blend SrcAlpha OneMinusSrcAlpha
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
Pass {
Blend SrcAlpha OneMinusSrcAlpha
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag_linear
ENDCG
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: cd9d4af6e66af1c4d8abe3384397ee14
timeCreated: 1433793509
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,73 @@
Shader "Custom/SteamVR_SphericalProjection" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_N ("N (normal of plane)", Vector) = (0,0,0,0)
_Phi0 ("Phi0", Float) = 0
_Phi1 ("Phi1", Float) = 1
_Theta0 ("Theta0", Float) = 0
_Theta1 ("Theta1", Float) = 1
_UAxis ("uAxis", Vector) = (0,0,0,0)
_VAxis ("vAxis", Vector) = (0,0,0,0)
_UOrigin ("uOrigin", Vector) = (0,0,0,0)
_VOrigin ("vOrigin", Vector) = (0,0,0,0)
_UScale ("uScale", Float) = 1
_VScale ("vScale", Float) = 1
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _N;
float _Phi0, _Phi1, _Theta0, _Theta1;
float4 _UAxis, _VAxis;
float4 _UOrigin, _VOrigin;
float _UScale, _VScale;
struct v2f {
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.tex = float2(
lerp(_Phi0, _Phi1, v.texcoord.x),
lerp(_Theta0, _Theta1, v.texcoord.y));
return o;
}
float3 cartesian(float phi, float theta)
{
float sinTheta = sin(theta);
return float3(
sinTheta * sin(phi),
cos(theta),
sinTheta * cos(phi));
}
float4 frag(v2f i) : COLOR {
float3 V = cartesian(i.tex.x, i.tex.y);
float3 P = V / dot(V, _N.xyz); // intersection point on plane
float2 uv = float2(
dot(P - _UOrigin.xyz, _UAxis.xyz) * _UScale,
dot(P - _VOrigin.xyz, _VAxis.xyz) * _VScale);
return tex2D(_MainTex, uv);
}
ENDCG
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode Off }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 43b10deca54ca524c8cd9a0fcb622325
timeCreated: 1462380123
licenseType: Store
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e48a8be58243ea9459f61ff9d1da90e2
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+2897
View File
File diff suppressed because one or more lines are too long
+5
View File
@@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: 274ae687a94e2444b85ce2bcf56c1df3
DefaultImporter:
userData:
assetBundleName:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0056ebccc9be0034283b0f55e8834f88
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+391
View File
@@ -0,0 +1,391 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Access to SteamVR system (hmd) and compositor (distort) interfaces.
//
//=============================================================================
using UnityEngine;
using System.Runtime.InteropServices;
using Valve.VR;
public class SteamVR : System.IDisposable
{
// Use this to check if SteamVR is currently active without attempting
// to activate it in the process.
public static bool active { get { return _instance != null; } }
// Set this to false to keep from auto-initializing when calling SteamVR.instance.
private static bool _enabled = true;
public static bool enabled
{
get { return _enabled; }
set
{
_enabled = value;
if (!_enabled)
SafeDispose();
}
}
private static SteamVR _instance;
public static SteamVR instance
{
get
{
#if UNITY_EDITOR
if (!Application.isPlaying)
return null;
#endif
if (!enabled)
return null;
if (_instance == null)
{
_instance = CreateInstance();
// If init failed, then auto-disable so scripts don't continue trying to re-initialize things.
if (_instance == null)
_enabled = false;
}
return _instance;
}
}
public static bool usingNativeSupport
{
get
{
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
return UnityEngine.VR.VRDevice.GetNativePtr() != System.IntPtr.Zero;
#else
return false;
#endif
}
}
static SteamVR CreateInstance()
{
try
{
var error = EVRInitError.None;
if (!SteamVR.usingNativeSupport)
{
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
Debug.Log("OpenVR initialization failed. Ensure 'Virtual Reality Supported' is checked in Player Settings, and OpenVR is added to the list of Virtual Reality SDKs.");
return null;
#else
OpenVR.Init(ref error);
if (error != EVRInitError.None)
{
ReportError(error);
ShutdownSystems();
return null;
}
#endif
}
// Verify common interfaces are valid.
OpenVR.GetGenericInterface(OpenVR.IVRCompositor_Version, ref error);
if (error != EVRInitError.None)
{
ReportError(error);
ShutdownSystems();
return null;
}
OpenVR.GetGenericInterface(OpenVR.IVROverlay_Version, ref error);
if (error != EVRInitError.None)
{
ReportError(error);
ShutdownSystems();
return null;
}
}
catch (System.Exception e)
{
Debug.LogError(e);
return null;
}
return new SteamVR();
}
static void ReportError(EVRInitError error)
{
switch (error)
{
case EVRInitError.None:
break;
case EVRInitError.VendorSpecific_UnableToConnectToOculusRuntime:
Debug.Log("SteamVR Initialization Failed! Make sure device is on, Oculus runtime is installed, and OVRService_*.exe is running.");
break;
case EVRInitError.Init_VRClientDLLNotFound:
Debug.Log("SteamVR drivers not found! They can be installed via Steam under Library > Tools. Visit http://steampowered.com to install Steam.");
break;
case EVRInitError.Driver_RuntimeOutOfDate:
Debug.Log("SteamVR Initialization Failed! Make sure device's runtime is up to date.");
break;
default:
Debug.Log(OpenVR.GetStringForHmdError(error));
break;
}
}
// native interfaces
public CVRSystem hmd { get; private set; }
public CVRCompositor compositor { get; private set; }
public CVROverlay overlay { get; private set; }
// tracking status
static public bool initializing { get; private set; }
static public bool calibrating { get; private set; }
static public bool outOfRange { get; private set; }
static public bool[] connected = new bool[OpenVR.k_unMaxTrackedDeviceCount];
// render values
public float sceneWidth { get; private set; }
public float sceneHeight { get; private set; }
public float aspect { get; private set; }
public float fieldOfView { get; private set; }
public Vector2 tanHalfFov { get; private set; }
public VRTextureBounds_t[] textureBounds { get; private set; }
public SteamVR_Utils.RigidTransform[] eyes { get; private set; }
public EGraphicsAPIConvention graphicsAPI;
// hmd properties
public string hmd_TrackingSystemName { get { return GetStringProperty(ETrackedDeviceProperty.Prop_TrackingSystemName_String); } }
public string hmd_ModelNumber { get { return GetStringProperty(ETrackedDeviceProperty.Prop_ModelNumber_String); } }
public string hmd_SerialNumber { get { return GetStringProperty(ETrackedDeviceProperty.Prop_SerialNumber_String); } }
public float hmd_SecondsFromVsyncToPhotons { get { return GetFloatProperty(ETrackedDeviceProperty.Prop_SecondsFromVsyncToPhotons_Float); } }
public float hmd_DisplayFrequency { get { return GetFloatProperty(ETrackedDeviceProperty.Prop_DisplayFrequency_Float); } }
public string GetTrackedDeviceString(uint deviceId)
{
var error = ETrackedPropertyError.TrackedProp_Success;
var capacity = hmd.GetStringTrackedDeviceProperty(deviceId, ETrackedDeviceProperty.Prop_AttachedDeviceId_String, null, 0, ref error);
if (capacity > 1)
{
var result = new System.Text.StringBuilder((int)capacity);
hmd.GetStringTrackedDeviceProperty(deviceId, ETrackedDeviceProperty.Prop_AttachedDeviceId_String, result, capacity, ref error);
return result.ToString();
}
return null;
}
string GetStringProperty(ETrackedDeviceProperty prop)
{
var error = ETrackedPropertyError.TrackedProp_Success;
var capactiy = hmd.GetStringTrackedDeviceProperty(OpenVR.k_unTrackedDeviceIndex_Hmd, prop, null, 0, ref error);
if (capactiy > 1)
{
var result = new System.Text.StringBuilder((int)capactiy);
hmd.GetStringTrackedDeviceProperty(OpenVR.k_unTrackedDeviceIndex_Hmd, prop, result, capactiy, ref error);
return result.ToString();
}
return (error != ETrackedPropertyError.TrackedProp_Success) ? error.ToString() : "<unknown>";
}
float GetFloatProperty(ETrackedDeviceProperty prop)
{
var error = ETrackedPropertyError.TrackedProp_Success;
return hmd.GetFloatTrackedDeviceProperty(OpenVR.k_unTrackedDeviceIndex_Hmd, prop, ref error);
}
#region Event callbacks
private void OnInitializing(params object[] args)
{
initializing = (bool)args[0];
}
private void OnCalibrating(params object[] args)
{
calibrating = (bool)args[0];
}
private void OnOutOfRange(params object[] args)
{
outOfRange = (bool)args[0];
}
private void OnDeviceConnected(params object[] args)
{
var i = (int)args[0];
connected[i] = (bool)args[1];
}
private void OnNewPoses(params object[] args)
{
var poses = (TrackedDevicePose_t[])args[0];
// Update eye offsets to account for IPD changes.
eyes[0] = new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(EVREye.Eye_Left));
eyes[1] = new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(EVREye.Eye_Right));
for (int i = 0; i < poses.Length; i++)
{
var connected = poses[i].bDeviceIsConnected;
if (connected != SteamVR.connected[i])
{
SteamVR_Utils.Event.Send("device_connected", i, connected);
}
}
if (poses.Length > OpenVR.k_unTrackedDeviceIndex_Hmd)
{
var result = poses[OpenVR.k_unTrackedDeviceIndex_Hmd].eTrackingResult;
var initializing = result == ETrackingResult.Uninitialized;
if (initializing != SteamVR.initializing)
{
SteamVR_Utils.Event.Send("initializing", initializing);
}
var calibrating =
result == ETrackingResult.Calibrating_InProgress ||
result == ETrackingResult.Calibrating_OutOfRange;
if (calibrating != SteamVR.calibrating)
{
SteamVR_Utils.Event.Send("calibrating", calibrating);
}
var outOfRange =
result == ETrackingResult.Running_OutOfRange ||
result == ETrackingResult.Calibrating_OutOfRange;
if (outOfRange != SteamVR.outOfRange)
{
SteamVR_Utils.Event.Send("out_of_range", outOfRange);
}
}
}
#endregion
private SteamVR()
{
hmd = OpenVR.System;
Debug.Log("Connected to " + hmd_TrackingSystemName + ":" + hmd_SerialNumber);
compositor = OpenVR.Compositor;
overlay = OpenVR.Overlay;
// Setup render values
uint w = 0, h = 0;
hmd.GetRecommendedRenderTargetSize(ref w, ref h);
sceneWidth = (float)w;
sceneHeight = (float)h;
float l_left = 0.0f, l_right = 0.0f, l_top = 0.0f, l_bottom = 0.0f;
hmd.GetProjectionRaw(EVREye.Eye_Left, ref l_left, ref l_right, ref l_top, ref l_bottom);
float r_left = 0.0f, r_right = 0.0f, r_top = 0.0f, r_bottom = 0.0f;
hmd.GetProjectionRaw(EVREye.Eye_Right, ref r_left, ref r_right, ref r_top, ref r_bottom);
tanHalfFov = new Vector2(
Mathf.Max(-l_left, l_right, -r_left, r_right),
Mathf.Max(-l_top, l_bottom, -r_top, r_bottom));
textureBounds = new VRTextureBounds_t[2];
textureBounds[0].uMin = 0.5f + 0.5f * l_left / tanHalfFov.x;
textureBounds[0].uMax = 0.5f + 0.5f * l_right / tanHalfFov.x;
textureBounds[0].vMin = 0.5f - 0.5f * l_bottom / tanHalfFov.y;
textureBounds[0].vMax = 0.5f - 0.5f * l_top / tanHalfFov.y;
textureBounds[1].uMin = 0.5f + 0.5f * r_left / tanHalfFov.x;
textureBounds[1].uMax = 0.5f + 0.5f * r_right / tanHalfFov.x;
textureBounds[1].vMin = 0.5f - 0.5f * r_bottom / tanHalfFov.y;
textureBounds[1].vMax = 0.5f - 0.5f * r_top / tanHalfFov.y;
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
SteamVR.Unity.SetSubmitParams(textureBounds[0], textureBounds[1], EVRSubmitFlags.Submit_Default);
#endif
// Grow the recommended size to account for the overlapping fov
sceneWidth = sceneWidth / Mathf.Max(textureBounds[0].uMax - textureBounds[0].uMin, textureBounds[1].uMax - textureBounds[1].uMin);
sceneHeight = sceneHeight / Mathf.Max(textureBounds[0].vMax - textureBounds[0].vMin, textureBounds[1].vMax - textureBounds[1].vMin);
aspect = tanHalfFov.x / tanHalfFov.y;
fieldOfView = 2.0f * Mathf.Atan(tanHalfFov.y) * Mathf.Rad2Deg;
eyes = new SteamVR_Utils.RigidTransform[] {
new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(EVREye.Eye_Left)),
new SteamVR_Utils.RigidTransform(hmd.GetEyeToHeadTransform(EVREye.Eye_Right)) };
if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL"))
graphicsAPI = EGraphicsAPIConvention.API_OpenGL;
else
graphicsAPI = EGraphicsAPIConvention.API_DirectX;
SteamVR_Utils.Event.Listen("initializing", OnInitializing);
SteamVR_Utils.Event.Listen("calibrating", OnCalibrating);
SteamVR_Utils.Event.Listen("out_of_range", OnOutOfRange);
SteamVR_Utils.Event.Listen("device_connected", OnDeviceConnected);
SteamVR_Utils.Event.Listen("new_poses", OnNewPoses);
}
~SteamVR()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
System.GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
SteamVR_Utils.Event.Remove("initializing", OnInitializing);
SteamVR_Utils.Event.Remove("calibrating", OnCalibrating);
SteamVR_Utils.Event.Remove("out_of_range", OnOutOfRange);
SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
SteamVR_Utils.Event.Remove("new_poses", OnNewPoses);
ShutdownSystems();
_instance = null;
}
private static void ShutdownSystems()
{
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
OpenVR.Shutdown();
#endif
}
// Use this interface to avoid accidentally creating the instance in the process of attempting to dispose of it.
public static void SafeDispose()
{
if (_instance != null)
_instance.Dispose();
}
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
// Unityhooks in openvr_api.
public class Unity
{
public const int k_nRenderEventID_WaitGetPoses = 201510020;
public const int k_nRenderEventID_SubmitL = 201510021;
public const int k_nRenderEventID_SubmitR = 201510022;
public const int k_nRenderEventID_Flush = 201510023;
public const int k_nRenderEventID_PostPresentHandoff = 201510024;
[DllImport("openvr_api", EntryPoint = "UnityHooks_GetRenderEventFunc")]
public static extern System.IntPtr GetRenderEventFunc();
[DllImport("openvr_api", EntryPoint = "UnityHooks_SetSubmitParams")]
public static extern void SetSubmitParams(VRTextureBounds_t boundsL, VRTextureBounds_t boundsR, EVRSubmitFlags nSubmitFlags);
[DllImport("openvr_api", EntryPoint = "UnityHooks_SetColorSpace")]
public static extern void SetColorSpace(EColorSpace eColorSpace);
[DllImport("openvr_api", EntryPoint = "UnityHooks_EventWriteString")]
public static extern void EventWriteString([In, MarshalAs(UnmanagedType.LPWStr)] string sEvent);
}
#endif
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7fae0ddab09ac324c85494471274d6a4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+448
View File
@@ -0,0 +1,448 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Adds SteamVR render support to existing camera objects
//
//=============================================================================
using UnityEngine;
using System.Collections;
using System.Reflection;
using Valve.VR;
[RequireComponent(typeof(Camera))]
public class SteamVR_Camera : MonoBehaviour
{
[SerializeField]
private Transform _head;
public Transform head { get { return _head; } }
public Transform offset { get { return _head; } } // legacy
public Transform origin { get { return _head.parent; } }
[SerializeField]
private Transform _ears;
public Transform ears { get { return _ears; } }
public Ray GetRay()
{
return new Ray(_head.position, _head.forward);
}
public bool wireframe = false;
[SerializeField]
private SteamVR_CameraFlip flip;
#region Materials
static public Material blitMaterial;
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
// Using a single shared offscreen buffer to render the scene. This needs to be larger
// than the backbuffer to account for distortion correction. The default resolution
// gives us 1:1 sized pixels in the center of view, but quality can be adjusted up or
// down using the following scale value to balance performance.
static public float sceneResolutionScale = 1.0f;
static private RenderTexture _sceneTexture;
static public RenderTexture GetSceneTexture(bool hdr)
{
var vr = SteamVR.instance;
if (vr == null)
return null;
int w = (int)(vr.sceneWidth * sceneResolutionScale);
int h = (int)(vr.sceneHeight * sceneResolutionScale);
int aa = QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing;
var format = hdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32;
if (_sceneTexture != null)
{
if (_sceneTexture.width != w || _sceneTexture.height != h || _sceneTexture.antiAliasing != aa || _sceneTexture.format != format)
{
Debug.Log(string.Format("Recreating scene texture.. Old: {0}x{1} MSAA={2} [{3}] New: {4}x{5} MSAA={6} [{7}]",
_sceneTexture.width, _sceneTexture.height, _sceneTexture.antiAliasing, _sceneTexture.format, w, h, aa, format));
Object.Destroy(_sceneTexture);
_sceneTexture = null;
}
}
if (_sceneTexture == null)
{
_sceneTexture = new RenderTexture(w, h, 0, format);
_sceneTexture.antiAliasing = aa;
// OpenVR assumes floating point render targets are linear unless otherwise specified.
var colorSpace = (hdr && QualitySettings.activeColorSpace == ColorSpace.Gamma) ? EColorSpace.Gamma : EColorSpace.Auto;
SteamVR.Unity.SetColorSpace(colorSpace);
}
return _sceneTexture;
}
#else
static public float sceneResolutionScale
{
get { return UnityEngine.VR.VRSettings.renderScale; }
set { UnityEngine.VR.VRSettings.renderScale = value; }
}
#endif
#endregion
#region Enable / Disable
void OnDisable()
{
SteamVR_Render.Remove(this);
}
void OnEnable()
{
// Bail if no hmd is connected
var vr = SteamVR.instance;
if (vr == null)
{
if (head != null)
{
head.GetComponent<SteamVR_GameView>().enabled = false;
head.GetComponent<SteamVR_TrackedObject>().enabled = false;
}
if (flip != null)
flip.enabled = false;
enabled = false;
return;
}
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
// Convert camera rig for native OpenVR integration.
var t = transform;
if (head != t)
{
Expand();
t.parent = origin;
while (head.childCount > 0)
head.GetChild(0).parent = t;
// Keep the head around, but parent to the camera now since it moves with the hmd
// but existing content may still have references to this object.
head.parent = t;
head.localPosition = Vector3.zero;
head.localRotation = Quaternion.identity;
head.localScale = Vector3.one;
head.gameObject.SetActive(false);
_head = t;
}
if (flip != null)
{
DestroyImmediate(flip);
flip = null;
}
#else
// Ensure rig is properly set up
Expand();
if (blitMaterial == null)
{
blitMaterial = new Material(Shader.Find("Custom/SteamVR_Blit"));
}
// Set remaining hmd specific settings
var camera = GetComponent<Camera>();
camera.fieldOfView = vr.fieldOfView;
camera.aspect = vr.aspect;
camera.eventMask = 0; // disable mouse events
camera.orthographic = false; // force perspective
camera.enabled = false; // manually rendered by SteamVR_Render
if (camera.actualRenderingPath != RenderingPath.Forward && QualitySettings.antiAliasing > 1)
{
Debug.LogWarning("MSAA only supported in Forward rendering path. (disabling MSAA)");
QualitySettings.antiAliasing = 0;
}
// Ensure game view camera hdr setting matches
var headCam = head.GetComponent<Camera>();
if (headCam != null)
{
headCam.hdr = camera.hdr;
headCam.renderingPath = camera.renderingPath;
}
#endif
if (ears == null)
{
var e = transform.GetComponentInChildren<SteamVR_Ears>();
if (e != null)
_ears = e.transform;
}
if (ears != null)
ears.GetComponent<SteamVR_Ears>().vrcam = this;
SteamVR_Render.Add(this);
}
#endregion
#region Functionality to ensure SteamVR_Camera component is always the last component on an object
void Awake() { ForceLast(); }
static Hashtable values;
public void ForceLast()
{
if (values != null)
{
// Restore values on new instance
foreach (DictionaryEntry entry in values)
{
var f = entry.Key as FieldInfo;
f.SetValue(this, entry.Value);
}
values = null;
}
else
{
// Make sure it's the last component
var components = GetComponents<Component>();
// But first make sure there aren't any other SteamVR_Cameras on this object.
for (int i = 0; i < components.Length; i++)
{
var c = components[i] as SteamVR_Camera;
if (c != null && c != this)
{
if (c.flip != null)
DestroyImmediate(c.flip);
DestroyImmediate(c);
}
}
components = GetComponents<Component>();
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (this != components[components.Length - 1])
{
#else
if (this != components[components.Length - 1] || flip == null)
{
if (flip == null)
flip = gameObject.AddComponent<SteamVR_CameraFlip>();
#endif
// Store off values to be restored on new instance
values = new Hashtable();
var fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
foreach (var f in fields)
if (f.IsPublic || f.IsDefined(typeof(SerializeField), true))
values[f] = f.GetValue(this);
var go = gameObject;
DestroyImmediate(this);
go.AddComponent<SteamVR_Camera>().ForceLast();
}
}
}
#endregion
#region Expand / Collapse object hierarchy
#if UNITY_EDITOR
public bool isExpanded { get { return head != null && transform.parent == head; } }
#endif
const string eyeSuffix = " (eye)";
const string earsSuffix = " (ears)";
const string headSuffix = " (head)";
const string originSuffix = " (origin)";
public string baseName { get { return name.EndsWith(eyeSuffix) ? name.Substring(0, name.Length - eyeSuffix.Length) : name; } }
// Object hierarchy creation to make it easy to parent other objects appropriately,
// otherwise this gets called on demand at runtime. Remaining initialization is
// performed at startup, once the hmd has been identified.
public void Expand()
{
var _origin = transform.parent;
if (_origin == null)
{
_origin = new GameObject(name + originSuffix).transform;
_origin.localPosition = transform.localPosition;
_origin.localRotation = transform.localRotation;
_origin.localScale = transform.localScale;
}
if (head == null)
{
_head = new GameObject(name + headSuffix, typeof(SteamVR_GameView), typeof(SteamVR_TrackedObject)).transform;
head.parent = _origin;
head.position = transform.position;
head.rotation = transform.rotation;
head.localScale = Vector3.one;
head.tag = tag;
var camera = head.GetComponent<Camera>();
camera.clearFlags = CameraClearFlags.Nothing;
camera.cullingMask = 0;
camera.eventMask = 0;
camera.orthographic = true;
camera.orthographicSize = 1;
camera.nearClipPlane = 0;
camera.farClipPlane = 1;
camera.useOcclusionCulling = false;
}
if (transform.parent != head)
{
transform.parent = head;
transform.localPosition = Vector3.zero;
transform.localRotation = Quaternion.identity;
transform.localScale = Vector3.one;
while (transform.childCount > 0)
transform.GetChild(0).parent = head;
var guiLayer = GetComponent<GUILayer>();
if (guiLayer != null)
{
DestroyImmediate(guiLayer);
head.gameObject.AddComponent<GUILayer>();
}
var audioListener = GetComponent<AudioListener>();
if (audioListener != null)
{
DestroyImmediate(audioListener);
_ears = new GameObject(name + earsSuffix, typeof(SteamVR_Ears)).transform;
ears.parent = _head;
ears.localPosition = Vector3.zero;
ears.localRotation = Quaternion.identity;
ears.localScale = Vector3.one;
}
}
if (!name.EndsWith(eyeSuffix))
name += eyeSuffix;
}
public void Collapse()
{
transform.parent = null;
// Move children and components from head back to camera.
while (head.childCount > 0)
head.GetChild(0).parent = transform;
var guiLayer = head.GetComponent<GUILayer>();
if (guiLayer != null)
{
DestroyImmediate(guiLayer);
gameObject.AddComponent<GUILayer>();
}
if (ears != null)
{
while (ears.childCount > 0)
ears.GetChild(0).parent = transform;
DestroyImmediate(ears.gameObject);
_ears = null;
gameObject.AddComponent(typeof(AudioListener));
}
if (origin != null)
{
// If we created the origin originally, destroy it now.
if (origin.name.EndsWith(originSuffix))
{
// Reparent any children so we don't accidentally delete them.
var _origin = origin;
while (_origin.childCount > 0)
_origin.GetChild(0).parent = _origin.parent;
DestroyImmediate(_origin.gameObject);
}
else
{
transform.parent = origin;
}
}
DestroyImmediate(head.gameObject);
_head = null;
if (name.EndsWith(eyeSuffix))
name = name.Substring(0, name.Length - eyeSuffix.Length);
}
#endregion
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
#region Render callbacks
void OnPreRender()
{
if (flip)
flip.enabled = (SteamVR_Render.Top() == this && SteamVR.instance.graphicsAPI == EGraphicsAPIConvention.API_DirectX);
var headCam = head.GetComponent<Camera>();
if (headCam != null)
headCam.enabled = (SteamVR_Render.Top() == this);
if (wireframe)
GL.wireframe = true;
}
void OnPostRender()
{
if (wireframe)
GL.wireframe = false;
}
void OnRenderImage(RenderTexture src, RenderTexture dest)
{
if (SteamVR_Render.Top() == this)
{
int eventID;
if (SteamVR_Render.eye == EVREye.Eye_Left)
{
// Get gpu started on work early to avoid bubbles at the top of the frame.
SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_Flush);
eventID = SteamVR.Unity.k_nRenderEventID_SubmitL;
}
else
{
eventID = SteamVR.Unity.k_nRenderEventID_SubmitR;
}
// Queue up a call on the render thread to Submit our render target to the compositor.
SteamVR_Utils.QueueEventOnRenderThread(eventID);
}
Graphics.SetRenderTarget(dest);
SteamVR_Camera.blitMaterial.mainTexture = src;
GL.PushMatrix();
GL.LoadOrtho();
SteamVR_Camera.blitMaterial.SetPass(0);
GL.Begin(GL.QUADS);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(-1, 1, 0);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(1, 1, 0);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(1, -1, 0);
GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(-1, -1, 0);
GL.End();
GL.PopMatrix();
Graphics.SetRenderTarget(null);
}
#endregion
#endif
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6bca9ccf900ccc84c887d783321d27e2
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+25
View File
@@ -0,0 +1,25 @@
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Flips the camera output back to normal for D3D.
//
//=============================================================================
using UnityEngine;
using System.Collections;
public class SteamVR_CameraFlip : MonoBehaviour
{
static Material blitMaterial;
void OnEnable()
{
if (blitMaterial == null)
blitMaterial = new Material(Shader.Find("Custom/SteamVR_BlitFlip"));
}
void OnRenderImage(RenderTexture src, RenderTexture dest)
{
Graphics.Blit(src, dest, blitMaterial);
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f5be45115742b07478e21c85fcc233ec
timeCreated: 1430851231
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+51
View File
@@ -0,0 +1,51 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Masks out pixels that cannot be seen through the connected hmd.
//
//=============================================================================
using UnityEngine;
using System.Collections;
using UnityEngine.Rendering;
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class SteamVR_CameraMask : MonoBehaviour
{
static Material material;
static Mesh[] hiddenAreaMeshes = new Mesh[] { null, null };
MeshFilter meshFilter;
void Awake()
{
meshFilter = GetComponent<MeshFilter>();
if (material == null)
material = new Material(Shader.Find("Custom/SteamVR_HiddenArea"));
var mr = GetComponent<MeshRenderer>();
mr.material = material;
mr.shadowCastingMode = ShadowCastingMode.Off;
mr.receiveShadows = false;
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
mr.lightProbeUsage = LightProbeUsage.Off;
#else
mr.useLightProbes = false;
#endif
mr.reflectionProbeUsage = ReflectionProbeUsage.Off;
}
public void Set(SteamVR vr, Valve.VR.EVREye eye)
{
int i = (int)eye;
if (hiddenAreaMeshes[i] == null)
hiddenAreaMeshes[i] = SteamVR_Utils.CreateHiddenAreaMesh(vr.hmd.GetHiddenAreaMesh(eye), vr.textureBounds[i]);
meshFilter.mesh = hiddenAreaMeshes[i];
}
public void Clear()
{
meshFilter.mesh = null;
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5828f252c3c228f4b931f66c21e525c4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+235
View File
@@ -0,0 +1,235 @@
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Wrapper for working with SteamVR controller input
//
// Example usage:
//
// var deviceIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost);
// if (deviceIndex != -1 && SteamVR_Controller.Input(deviceIndex).GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
// SteamVR_Controller.Input(deviceIndex).TriggerHapticPulse(1000);
//
//=============================================================================
using UnityEngine;
using Valve.VR;
public class SteamVR_Controller
{
public class ButtonMask
{
public const ulong System = (1ul << (int)EVRButtonId.k_EButton_System); // reserved
public const ulong ApplicationMenu = (1ul << (int)EVRButtonId.k_EButton_ApplicationMenu);
public const ulong Grip = (1ul << (int)EVRButtonId.k_EButton_Grip);
public const ulong Axis0 = (1ul << (int)EVRButtonId.k_EButton_Axis0);
public const ulong Axis1 = (1ul << (int)EVRButtonId.k_EButton_Axis1);
public const ulong Axis2 = (1ul << (int)EVRButtonId.k_EButton_Axis2);
public const ulong Axis3 = (1ul << (int)EVRButtonId.k_EButton_Axis3);
public const ulong Axis4 = (1ul << (int)EVRButtonId.k_EButton_Axis4);
public const ulong Touchpad = (1ul << (int)EVRButtonId.k_EButton_SteamVR_Touchpad);
public const ulong Trigger = (1ul << (int)EVRButtonId.k_EButton_SteamVR_Trigger);
}
public class Device
{
public Device(uint i) { index = i; }
public uint index { get; private set; }
public bool valid { get; private set; }
public bool connected { get { Update(); return pose.bDeviceIsConnected; } }
public bool hasTracking { get { Update(); return pose.bPoseIsValid; } }
public bool outOfRange { get { Update(); return pose.eTrackingResult == ETrackingResult.Running_OutOfRange || pose.eTrackingResult == ETrackingResult.Calibrating_OutOfRange; } }
public bool calibrating { get { Update(); return pose.eTrackingResult == ETrackingResult.Calibrating_InProgress || pose.eTrackingResult == ETrackingResult.Calibrating_OutOfRange; } }
public bool uninitialized { get { Update(); return pose.eTrackingResult == ETrackingResult.Uninitialized; } }
// These values are only accurate for the last controller state change (e.g. trigger release), and by definition, will always lag behind
// the predicted visual poses that drive SteamVR_TrackedObjects since they are sync'd to the input timestamp that caused them to update.
public SteamVR_Utils.RigidTransform transform { get { Update(); return new SteamVR_Utils.RigidTransform(pose.mDeviceToAbsoluteTracking); } }
public Vector3 velocity { get { Update(); return new Vector3(pose.vVelocity.v0, pose.vVelocity.v1, -pose.vVelocity.v2); } }
public Vector3 angularVelocity { get { Update(); return new Vector3(-pose.vAngularVelocity.v0, -pose.vAngularVelocity.v1, pose.vAngularVelocity.v2); } }
public VRControllerState_t GetState() { Update(); return state; }
public VRControllerState_t GetPrevState() { Update(); return prevState; }
public TrackedDevicePose_t GetPose() { Update(); return pose; }
VRControllerState_t state, prevState;
TrackedDevicePose_t pose;
int prevFrameCount = -1;
public void Update()
{
if (Time.frameCount != prevFrameCount)
{
prevFrameCount = Time.frameCount;
prevState = state;
var system = OpenVR.System;
if (system != null)
{
valid = system.GetControllerStateWithPose(SteamVR_Render.instance.trackingSpace, index, ref state, ref pose);
UpdateHairTrigger();
}
}
}
public bool GetPress(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) != 0; }
public bool GetPressDown(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) != 0 && (prevState.ulButtonPressed & buttonMask) == 0; }
public bool GetPressUp(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) == 0 && (prevState.ulButtonPressed & buttonMask) != 0; }
public bool GetPress(EVRButtonId buttonId) { return GetPress(1ul << (int)buttonId); }
public bool GetPressDown(EVRButtonId buttonId) { return GetPressDown(1ul << (int)buttonId); }
public bool GetPressUp(EVRButtonId buttonId) { return GetPressUp(1ul << (int)buttonId); }
public bool GetTouch(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) != 0; }
public bool GetTouchDown(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) != 0 && (prevState.ulButtonTouched & buttonMask) == 0; }
public bool GetTouchUp(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) == 0 && (prevState.ulButtonTouched & buttonMask) != 0; }
public bool GetTouch(EVRButtonId buttonId) { return GetTouch(1ul << (int)buttonId); }
public bool GetTouchDown(EVRButtonId buttonId) { return GetTouchDown(1ul << (int)buttonId); }
public bool GetTouchUp(EVRButtonId buttonId) { return GetTouchUp(1ul << (int)buttonId); }
public Vector2 GetAxis(EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad)
{
Update();
var axisId = (uint)buttonId - (uint)EVRButtonId.k_EButton_Axis0;
switch (axisId)
{
case 0: return new Vector2(state.rAxis0.x, state.rAxis0.y);
case 1: return new Vector2(state.rAxis1.x, state.rAxis1.y);
case 2: return new Vector2(state.rAxis2.x, state.rAxis2.y);
case 3: return new Vector2(state.rAxis3.x, state.rAxis3.y);
case 4: return new Vector2(state.rAxis4.x, state.rAxis4.y);
}
return Vector2.zero;
}
public void TriggerHapticPulse(ushort durationMicroSec = 500, EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad)
{
var system = OpenVR.System;
if (system != null)
{
var axisId = (uint)buttonId - (uint)EVRButtonId.k_EButton_Axis0;
system.TriggerHapticPulse(index, axisId, (char)durationMicroSec);
}
}
public float hairTriggerDelta = 0.1f; // amount trigger must be pulled or released to change state
float hairTriggerLimit;
bool hairTriggerState, hairTriggerPrevState;
void UpdateHairTrigger()
{
hairTriggerPrevState = hairTriggerState;
var value = state.rAxis1.x; // trigger
if (hairTriggerState)
{
if (value < hairTriggerLimit - hairTriggerDelta || value <= 0.0f)
hairTriggerState = false;
}
else
{
if (value > hairTriggerLimit + hairTriggerDelta || value >= 1.0f)
hairTriggerState = true;
}
hairTriggerLimit = hairTriggerState ? Mathf.Max(hairTriggerLimit, value) : Mathf.Min(hairTriggerLimit, value);
}
public bool GetHairTrigger() { Update(); return hairTriggerState; }
public bool GetHairTriggerDown() { Update(); return hairTriggerState && !hairTriggerPrevState; }
public bool GetHairTriggerUp() { Update(); return !hairTriggerState && hairTriggerPrevState; }
}
private static Device[] devices;
public static Device Input(int deviceIndex)
{
if (devices == null)
{
devices = new Device[OpenVR.k_unMaxTrackedDeviceCount];
for (uint i = 0; i < devices.Length; i++)
devices[i] = new Device(i);
}
return devices[deviceIndex];
}
public static void Update()
{
for (int i = 0; i < OpenVR.k_unMaxTrackedDeviceCount; i++)
Input(i).Update();
}
// This helper can be used in a variety of ways. Beware that indices may change
// as new devices are dynamically added or removed, controllers are physically
// swapped between hands, arms crossed, etc.
public enum DeviceRelation
{
First,
// radially
Leftmost,
Rightmost,
// distance - also see vr.hmd.GetSortedTrackedDeviceIndicesOfClass
FarthestLeft,
FarthestRight,
}
public static int GetDeviceIndex(DeviceRelation relation,
ETrackedDeviceClass deviceClass = ETrackedDeviceClass.Controller,
int relativeTo = (int)OpenVR.k_unTrackedDeviceIndex_Hmd) // use -1 for absolute tracking space
{
var result = -1;
var invXform = ((uint)relativeTo < OpenVR.k_unMaxTrackedDeviceCount) ?
Input(relativeTo).transform.GetInverse() : SteamVR_Utils.RigidTransform.identity;
var system = OpenVR.System;
if (system == null)
return result;
var best = -float.MaxValue;
for (int i = 0; i < OpenVR.k_unMaxTrackedDeviceCount; i++)
{
if (i == relativeTo || system.GetTrackedDeviceClass((uint)i) != deviceClass)
continue;
var device = Input(i);
if (!device.connected)
continue;
if (relation == DeviceRelation.First)
return i;
float score;
var pos = invXform * device.transform.pos;
if (relation == DeviceRelation.FarthestRight)
{
score = pos.x;
}
else if (relation == DeviceRelation.FarthestLeft)
{
score = -pos.x;
}
else
{
var dir = new Vector3(pos.x, 0.0f, pos.z).normalized;
var dot = Vector3.Dot(dir, Vector3.forward);
var cross = Vector3.Cross(dir, Vector3.forward);
if (relation == DeviceRelation.Leftmost)
{
score = (cross.y > 0.0f) ? 2.0f - dot : dot;
}
else
{
score = (cross.y < 0.0f) ? 2.0f - dot : dot;
}
}
if (score > best)
{
result = i;
best = score;
}
}
return result;
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f9c6e0c408020c341b3c329ec30355a1
timeCreated: 1429900414
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+237
View File
@@ -0,0 +1,237 @@
//========= Copyright 2016, Valve Corporation, All rights reserved. ===========
//
// Purpose: Enables/disables objects based on connectivity and assigned roles.
//
//=============================================================================
using UnityEngine;
using System.Collections.Generic;
using Valve.VR;
public class SteamVR_ControllerManager : MonoBehaviour
{
public GameObject left, right;
public GameObject[] objects; // populate with objects you want to assign to additional controllers
uint[] indices; // assigned
bool[] connected = new bool[OpenVR.k_unMaxTrackedDeviceCount]; // controllers only
// cached roles - may or may not be connected
uint leftIndex = OpenVR.k_unTrackedDeviceIndexInvalid;
uint rightIndex = OpenVR.k_unTrackedDeviceIndexInvalid;
void Awake()
{
// Add left and right entries to the head of the list so we only have to operate on the list itself.
var additional = (this.objects != null) ? this.objects.Length : 0;
var objects = new GameObject[2 + additional];
indices = new uint[2 + additional];
objects[0] = right;
indices[0] = OpenVR.k_unTrackedDeviceIndexInvalid;
objects[1] = left;
indices[1] = OpenVR.k_unTrackedDeviceIndexInvalid;
for (int i = 0; i < additional; i++)
{
objects[2 + i] = this.objects[i];
indices[2 + i] = OpenVR.k_unTrackedDeviceIndexInvalid;
}
this.objects = objects;
}
void OnEnable()
{
for (int i = 0; i < objects.Length; i++)
{
var obj = objects[i];
if (obj != null)
obj.SetActive(false);
}
OnTrackedDeviceRoleChanged();
for (int i = 0; i < SteamVR.connected.Length; i++)
if (SteamVR.connected[i])
OnDeviceConnected(i, true);
SteamVR_Utils.Event.Listen("input_focus", OnInputFocus);
SteamVR_Utils.Event.Listen("device_connected", OnDeviceConnected);
SteamVR_Utils.Event.Listen("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChanged);
}
void OnDisable()
{
SteamVR_Utils.Event.Remove("input_focus", OnInputFocus);
SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
SteamVR_Utils.Event.Remove("TrackedDeviceRoleChanged", OnTrackedDeviceRoleChanged);
}
static string[] labels = { "left", "right" };
// Hide controllers when the dashboard is up.
private void OnInputFocus(params object[] args)
{
bool hasFocus = (bool)args[0];
if (hasFocus)
{
for (int i = 0; i < objects.Length; i++)
{
var obj = objects[i];
if (obj != null)
{
var label = (i < 2) ? labels[i] : (i - 1).ToString();
ShowObject(obj.transform, "hidden (" + label + ")");
}
}
}
else
{
for (int i = 0; i < objects.Length; i++)
{
var obj = objects[i];
if (obj != null)
{
var label = (i < 2) ? labels[i] : (i - 1).ToString();
HideObject(obj.transform, "hidden (" + label + ")");
}
}
}
}
// Reparents to a new object and deactivates that object (this allows
// us to call SetActive in OnDeviceConnected independently.
private void HideObject(Transform t, string name)
{
var hidden = new GameObject(name).transform;
hidden.parent = t.parent;
t.parent = hidden;
hidden.gameObject.SetActive(false);
}
private void ShowObject(Transform t, string name)
{
var hidden = t.parent;
if (hidden.gameObject.name != name)
return;
t.parent = hidden.parent;
Destroy(hidden.gameObject);
}
private void SetTrackedDeviceIndex(int objectIndex, uint trackedDeviceIndex)
{
// First make sure no one else is already using this index.
if (trackedDeviceIndex != OpenVR.k_unTrackedDeviceIndexInvalid)
{
for (int i = 0; i < objects.Length; i++)
{
if (i != objectIndex && indices[i] == trackedDeviceIndex)
{
var obj = objects[i];
if (obj != null)
obj.SetActive(false);
indices[i] = OpenVR.k_unTrackedDeviceIndexInvalid;
}
}
}
// Only set when changed.
if (trackedDeviceIndex != indices[objectIndex])
{
indices[objectIndex] = trackedDeviceIndex;
var obj = objects[objectIndex];
if (obj != null)
{
if (trackedDeviceIndex == OpenVR.k_unTrackedDeviceIndexInvalid)
obj.SetActive(false);
else
{
obj.SetActive(true);
obj.BroadcastMessage("SetDeviceIndex", (int)trackedDeviceIndex, SendMessageOptions.DontRequireReceiver);
}
}
}
}
// Keep track of assigned roles.
private void OnTrackedDeviceRoleChanged(params object[] args)
{
Refresh();
}
// Keep track of connected controller indices.
private void OnDeviceConnected(params object[] args)
{
var index = (uint)(int)args[0];
bool changed = this.connected[index];
this.connected[index] = false;
var connected = (bool)args[1];
if (connected)
{
var system = OpenVR.System;
if (system != null && system.GetTrackedDeviceClass(index) == ETrackedDeviceClass.Controller)
{
this.connected[index] = true;
changed = !changed; // if we clear and set the same index, nothing has changed
}
}
if (changed)
Refresh();
}
public void Refresh()
{
int objectIndex = 0;
var system = OpenVR.System;
if (system != null)
{
leftIndex = system.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
rightIndex = system.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.RightHand);
}
// If neither role has been assigned yet, try hooking up at least the right controller.
if (leftIndex == OpenVR.k_unTrackedDeviceIndexInvalid && rightIndex == OpenVR.k_unTrackedDeviceIndexInvalid)
{
for (uint deviceIndex = 0; deviceIndex < connected.Length; deviceIndex++)
{
if (connected[deviceIndex])
{
SetTrackedDeviceIndex(objectIndex++, deviceIndex);
break;
}
}
}
else
{
SetTrackedDeviceIndex(objectIndex++, (rightIndex < connected.Length && connected[rightIndex]) ? rightIndex : OpenVR.k_unTrackedDeviceIndexInvalid);
SetTrackedDeviceIndex(objectIndex++, (leftIndex < connected.Length && connected[leftIndex]) ? leftIndex : OpenVR.k_unTrackedDeviceIndexInvalid);
// Assign out any additional controllers only after both left and right have been assigned.
if (leftIndex != OpenVR.k_unTrackedDeviceIndexInvalid && rightIndex != OpenVR.k_unTrackedDeviceIndexInvalid)
{
for (uint deviceIndex = 0; deviceIndex < connected.Length; deviceIndex++)
{
if (objectIndex >= objects.Length)
break;
if (!connected[deviceIndex])
continue;
if (deviceIndex != leftIndex && deviceIndex != rightIndex)
{
SetTrackedDeviceIndex(objectIndex++, deviceIndex);
}
}
}
}
// Reset the rest.
while (objectIndex < objects.Length)
{
SetTrackedDeviceIndex(objectIndex++, OpenVR.k_unTrackedDeviceIndexInvalid);
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e3b47c2980b93bc48844a54641dab5b8
timeCreated: 1437430318
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+52
View File
@@ -0,0 +1,52 @@
//========= Copyright 2016, Valve Corporation, All rights reserved. ===========
//
// Purpose: Handles aligning audio listener when using speakers.
//
//=============================================================================
using UnityEngine;
using Valve.VR;
[RequireComponent(typeof(AudioListener))]
public class SteamVR_Ears : MonoBehaviour
{
public SteamVR_Camera vrcam;
bool usingSpeakers;
Quaternion offset;
private void OnNewPosesApplied(params object[] args)
{
var origin = vrcam.origin;
var baseRotation = origin != null ? origin.rotation : Quaternion.identity;
transform.rotation = baseRotation * offset;
}
void OnEnable()
{
usingSpeakers = false;
var settings = OpenVR.Settings;
if (settings != null)
{
var error = EVRSettingsError.None;
if (settings.GetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_UsingSpeakers_Bool, false, ref error))
{
usingSpeakers = true;
var yawOffset = settings.GetFloat(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float, 0.0f, ref error);
offset = Quaternion.Euler(0.0f, yawOffset, 0.0f);
}
}
if (usingSpeakers)
SteamVR_Utils.Event.Listen("new_poses_applied", OnNewPosesApplied);
}
void OnDisable()
{
if (usingSpeakers)
SteamVR_Utils.Event.Remove("new_poses_applied", OnNewPosesApplied);
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 49a86c1078ce4314b9c4224560e031b9
timeCreated: 1457243016
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+320
View File
@@ -0,0 +1,320 @@
//========= Copyright 2016, Valve Corporation, All rights reserved. ===========
//
// Purpose: Used to render an external camera of vr player (split front/back).
//
//=============================================================================
using UnityEngine;
using UnityEngine.Rendering;
using Valve.VR;
public class SteamVR_ExternalCamera : MonoBehaviour
{
public struct Config
{
public float x, y, z;
public float rx, ry, rz;
public float fov;
public float near, far;
public float sceneResolutionScale;
public float frameSkip;
public float nearOffset, farOffset;
public float hmdOffset;
public bool disableStandardAssets;
}
public Config config;
public string configPath;
public void ReadConfig()
{
try
{
var mCam = new HmdMatrix34_t();
var readCamMatrix = false;
object c = config; // box
var lines = System.IO.File.ReadAllLines(configPath);
foreach (var line in lines)
{
var split = line.Split('=');
if (split.Length == 2)
{
var key = split[0];
if (key == "m")
{
var values = split[1].Split(',');
if (values.Length == 12)
{
mCam.m0 = float.Parse(values[0]);
mCam.m1 = float.Parse(values[1]);
mCam.m2 = float.Parse(values[2]);
mCam.m3 = float.Parse(values[3]);
mCam.m4 = float.Parse(values[4]);
mCam.m5 = float.Parse(values[5]);
mCam.m6 = float.Parse(values[6]);
mCam.m7 = float.Parse(values[7]);
mCam.m8 = float.Parse(values[8]);
mCam.m9 = float.Parse(values[9]);
mCam.m10 = float.Parse(values[10]);
mCam.m11 = float.Parse(values[11]);
readCamMatrix = true;
}
}
else if (key == "disableStandardAssets")
{
var field = c.GetType().GetField(key);
if (field != null)
field.SetValue(c, bool.Parse(split[1]));
}
else
{
var field = c.GetType().GetField(key);
if (field != null)
field.SetValue(c, float.Parse(split[1]));
}
}
}
config = (Config)c; //unbox
// Convert calibrated camera matrix settings.
if (readCamMatrix)
{
var t = new SteamVR_Utils.RigidTransform(mCam);
config.x = t.pos.x;
config.y = t.pos.y;
config.z = t.pos.z;
var angles = t.rot.eulerAngles;
config.rx = angles.x;
config.ry = angles.y;
config.rz = angles.z;
}
}
catch { }
}
Camera cam;
Transform target;
GameObject clipQuad;
Material clipMaterial;
public void AttachToCamera(SteamVR_Camera vrcam)
{
if (target == vrcam.head)
return;
target = vrcam.head;
var root = transform.parent;
var origin = vrcam.head.parent;
root.parent = origin;
root.localPosition = Vector3.zero;
root.localRotation = Quaternion.identity;
root.localScale = Vector3.one;
// Make a copy of the eye camera to pick up any camera fx.
vrcam.enabled = false;
var go = Instantiate(vrcam.gameObject);
vrcam.enabled = true;
go.name = "camera";
DestroyImmediate(go.GetComponent<SteamVR_Camera>());
DestroyImmediate(go.GetComponent<SteamVR_CameraFlip>());
cam = go.GetComponent<Camera>();
cam.fieldOfView = config.fov;
cam.useOcclusionCulling = false;
cam.enabled = false; // manually rendered
colorMat = new Material(Shader.Find("Custom/SteamVR_ColorOut"));
alphaMat = new Material(Shader.Find("Custom/SteamVR_AlphaOut"));
clipMaterial = new Material(Shader.Find("Custom/SteamVR_ClearAll"));
var offset = go.transform;
offset.parent = transform;
offset.localPosition = new Vector3(config.x, config.y, config.z);
offset.localRotation = Quaternion.Euler(config.rx, config.ry, config.rz);
offset.localScale = Vector3.one;
// Strip children of cloned object (AudioListener in particular).
while (offset.childCount > 0)
DestroyImmediate(offset.GetChild(0).gameObject);
// Setup clipping quad (using camera clip causes problems with shadows).
clipQuad = GameObject.CreatePrimitive(PrimitiveType.Quad);
clipQuad.name = "ClipQuad";
DestroyImmediate(clipQuad.GetComponent<MeshCollider>());
var clipRenderer = clipQuad.GetComponent<MeshRenderer>();
clipRenderer.material = clipMaterial;
clipRenderer.shadowCastingMode = ShadowCastingMode.Off;
clipRenderer.receiveShadows = false;
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
clipRenderer.lightProbeUsage = LightProbeUsage.Off;
#else
clipRenderer.useLightProbes = false;
#endif
clipRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off;
var clipTransform = clipQuad.transform;
clipTransform.parent = offset;
clipTransform.localScale = new Vector3(1000.0f, 1000.0f, 1.0f);
clipTransform.localRotation = Quaternion.identity;
clipQuad.SetActive(false);
}
public float GetTargetDistance()
{
if (target == null)
return config.near + 0.01f;
var offset = cam.transform;
var forward = new Vector3(offset.forward.x, 0.0f, offset.forward.z).normalized;
var targetPos = target.position + new Vector3(target.forward.x, 0.0f, target.forward.z).normalized * config.hmdOffset;
var distance = -(new Plane(forward, targetPos)).GetDistanceToPoint(offset.position);
return Mathf.Clamp(distance, config.near + 0.01f, config.far - 0.01f);
}
Material colorMat, alphaMat;
public void RenderNear()
{
var w = Screen.width / 2;
var h = Screen.height / 2;
if (cam.targetTexture == null || cam.targetTexture.width != w || cam.targetTexture.height != h)
{
cam.targetTexture = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);
cam.targetTexture.antiAliasing = QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing;
}
cam.nearClipPlane = config.near;
cam.farClipPlane = config.far;
var clearFlags = cam.clearFlags;
var backgroundColor = cam.backgroundColor;
cam.clearFlags = CameraClearFlags.Color;
cam.backgroundColor = Color.clear;
float dist = Mathf.Clamp(GetTargetDistance() + config.nearOffset, config.near, config.far);
var clipParent = clipQuad.transform.parent;
clipQuad.transform.position = clipParent.position + clipParent.forward * dist;
MonoBehaviour[] behaviours = null;
bool[] wasEnabled = null;
if (config.disableStandardAssets)
{
behaviours = cam.gameObject.GetComponents<MonoBehaviour>();
wasEnabled = new bool[behaviours.Length];
for (int i = 0; i < behaviours.Length; i++)
{
var behaviour = behaviours[i];
if (behaviour.enabled && behaviour.GetType().ToString().StartsWith("UnityStandardAssets."))
{
behaviour.enabled = false;
wasEnabled[i] = true;
}
}
}
clipQuad.SetActive(true);
cam.Render();
clipQuad.SetActive(false);
if (behaviours != null)
{
for (int i = 0; i < behaviours.Length; i++)
{
if (wasEnabled[i])
{
behaviours[i].enabled = true;
}
}
}
cam.clearFlags = clearFlags;
cam.backgroundColor = backgroundColor;
Graphics.DrawTexture(new Rect(0, 0, w, h), cam.targetTexture, colorMat);
Graphics.DrawTexture(new Rect(w, 0, w, h), cam.targetTexture, alphaMat);
}
public void RenderFar()
{
cam.nearClipPlane = config.near;
cam.farClipPlane = config.far;
cam.Render();
var w = Screen.width / 2;
var h = Screen.height / 2;
Graphics.DrawTexture(new Rect(0, h, w, h), cam.targetTexture, colorMat);
}
void OnGUI()
{
// Necessary for Graphics.DrawTexture to work even though we don't do anything here.
}
Camera[] cameras;
Rect[] cameraRects;
float sceneResolutionScale;
void OnEnable()
{
// Move game view cameras to lower-right quadrant.
cameras = FindObjectsOfType<Camera>() as Camera[];
if (cameras != null)
{
var numCameras = cameras.Length;
cameraRects = new Rect[numCameras];
for (int i = 0; i < numCameras; i++)
{
var cam = cameras[i];
cameraRects[i] = cam.rect;
if (cam == this.cam)
continue;
if (cam.targetTexture != null)
continue;
if (cam.GetComponent<SteamVR_Camera>() != null)
continue;
cam.rect = new Rect(0.5f, 0.0f, 0.5f, 0.5f);
}
}
if (config.sceneResolutionScale > 0.0f)
{
sceneResolutionScale = SteamVR_Camera.sceneResolutionScale;
SteamVR_Camera.sceneResolutionScale = config.sceneResolutionScale;
}
}
void OnDisable()
{
// Restore game view cameras.
if (cameras != null)
{
var numCameras = cameras.Length;
for (int i = 0; i < numCameras; i++)
{
var cam = cameras[i];
if (cam != null)
cam.rect = cameraRects[i];
}
cameras = null;
cameraRects = null;
}
if (config.sceneResolutionScale > 0.0f)
{
SteamVR_Camera.sceneResolutionScale = sceneResolutionScale;
}
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c9da270df5147d24597cc106058c1fa7
timeCreated: 1455761349
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+133
View File
@@ -0,0 +1,133 @@
//#define TEST_FADE_VIEW
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: CameraFade script adapted to work with SteamVR.
//
// Usage: Add to your top level SteamVR_Camera (the one with ApplyDistoration
// checked) and drag a reference to this component into SteamVR_Camera
// RenderComponents list. Then call the static helper function
// SteamVR_Fade.Start with the desired color and duration.
// Use a duration of zero to set the start color.
//
// Example: Fade down from black over one second.
// SteamVR_Fade.Start(Color.black, 0);
// SteamVR_Fade.Start(Color.clear, 1);
//
// Note: This component is provided to fade out a single camera layer's
// scene view. If instead you want to fade the entire view, use:
// SteamVR_Fade.View(Color.black, 1);
// (Does not affect the game view, however.)
//
//=============================================================================
using UnityEngine;
using Valve.VR;
public class SteamVR_Fade : MonoBehaviour
{
private Color currentColor = new Color(0, 0, 0, 0); // default starting color: black and fully transparent
private Color targetColor = new Color(0, 0, 0, 0); // default target color: black and fully transparent
private Color deltaColor = new Color(0, 0, 0, 0); // the delta-color is basically the "speed / second" at which the current color should change
private bool fadeOverlay = false;
static public void Start(Color newColor, float duration, bool fadeOverlay = false)
{
SteamVR_Utils.Event.Send("fade", newColor, duration, fadeOverlay);
}
static public void View(Color newColor, float duration)
{
var compositor = OpenVR.Compositor;
if (compositor != null)
compositor.FadeToColor(duration, newColor.r, newColor.g, newColor.b, newColor.a, false);
}
#if TEST_FADE_VIEW
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
SteamVR_Fade.View(Color.black, 0);
SteamVR_Fade.View(Color.clear, 1);
}
}
#endif
public void OnStartFade(params object[] args)
{
var newColor = (Color)args[0];
var duration = (float)args[1];
fadeOverlay = (args.Length > 2) && (bool)args[2];
if (duration > 0.0f)
{
targetColor = newColor;
deltaColor = (targetColor - currentColor) / duration;
}
else
{
currentColor = newColor;
}
}
static Material fadeMaterial = null;
void OnEnable()
{
if (fadeMaterial == null)
{
fadeMaterial = new Material(Shader.Find("Custom/SteamVR_Fade"));
}
SteamVR_Utils.Event.Listen("fade", OnStartFade);
SteamVR_Utils.Event.Send("fade_ready");
}
void OnDisable()
{
SteamVR_Utils.Event.Remove("fade", OnStartFade);
}
void OnPostRender()
{
if (currentColor != targetColor)
{
// if the difference between the current alpha and the desired alpha is smaller than delta-alpha * deltaTime, then we're pretty much done fading:
if (Mathf.Abs(currentColor.a - targetColor.a) < Mathf.Abs(deltaColor.a) * Time.deltaTime)
{
currentColor = targetColor;
deltaColor = new Color(0, 0, 0, 0);
}
else
{
currentColor += deltaColor * Time.deltaTime;
}
if (fadeOverlay)
{
var overlay = SteamVR_Overlay.instance;
if (overlay != null)
{
overlay.alpha = 1.0f - currentColor.a;
}
}
}
if (currentColor.a > 0 && fadeMaterial)
{
GL.PushMatrix();
GL.LoadOrtho();
fadeMaterial.SetPass(0);
GL.Begin(GL.QUADS);
GL.Color(currentColor);
GL.Vertex3(0, 0, 0);
GL.Vertex3(1, 0, 0);
GL.Vertex3(1, 1, 0);
GL.Vertex3(0, 1, 0);
GL.End();
GL.PopMatrix();
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2ad1e469d4e3e04489f9a36419f1a4f8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+153
View File
@@ -0,0 +1,153 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Generates a mesh based on field of view.
//
//=============================================================================
using UnityEngine;
using Valve.VR;
[ExecuteInEditMode, RequireComponent(typeof(MeshRenderer), typeof(MeshFilter))]
public class SteamVR_Frustum : MonoBehaviour
{
public SteamVR_TrackedObject.EIndex index;
public float fovLeft = 45, fovRight = 45, fovTop = 45, fovBottom = 45, nearZ = 0.5f, farZ = 2.5f;
public void UpdateModel()
{
fovLeft = Mathf.Clamp(fovLeft, 1, 89);
fovRight = Mathf.Clamp(fovRight, 1, 89);
fovTop = Mathf.Clamp(fovTop, 1, 89);
fovBottom = Mathf.Clamp(fovBottom, 1, 89);
farZ = Mathf.Max(farZ, nearZ + 0.01f);
nearZ = Mathf.Clamp(nearZ, 0.01f, farZ - 0.01f);
var lsin = Mathf.Sin(-fovLeft * Mathf.Deg2Rad);
var rsin = Mathf.Sin(fovRight * Mathf.Deg2Rad);
var tsin = Mathf.Sin(fovTop * Mathf.Deg2Rad);
var bsin = Mathf.Sin(-fovBottom * Mathf.Deg2Rad);
var lcos = Mathf.Cos(-fovLeft * Mathf.Deg2Rad);
var rcos = Mathf.Cos(fovRight * Mathf.Deg2Rad);
var tcos = Mathf.Cos(fovTop * Mathf.Deg2Rad);
var bcos = Mathf.Cos(-fovBottom * Mathf.Deg2Rad);
var corners = new Vector3[] {
new Vector3(lsin * nearZ / lcos, tsin * nearZ / tcos, nearZ), //tln
new Vector3(rsin * nearZ / rcos, tsin * nearZ / tcos, nearZ), //trn
new Vector3(rsin * nearZ / rcos, bsin * nearZ / bcos, nearZ), //brn
new Vector3(lsin * nearZ / lcos, bsin * nearZ / bcos, nearZ), //bln
new Vector3(lsin * farZ / lcos, tsin * farZ / tcos, farZ ), //tlf
new Vector3(rsin * farZ / rcos, tsin * farZ / tcos, farZ ), //trf
new Vector3(rsin * farZ / rcos, bsin * farZ / bcos, farZ ), //brf
new Vector3(lsin * farZ / lcos, bsin * farZ / bcos, farZ ), //blf
};
var triangles = new int[] {
// 0, 1, 2, 0, 2, 3, // near
// 0, 2, 1, 0, 3, 2, // near
// 4, 5, 6, 4, 6, 7, // far
// 4, 6, 5, 4, 7, 6, // far
0, 4, 7, 0, 7, 3, // left
0, 7, 4, 0, 3, 7, // left
1, 5, 6, 1, 6, 2, // right
1, 6, 5, 1, 2, 6, // right
0, 4, 5, 0, 5, 1, // top
0, 5, 4, 0, 1, 5, // top
2, 3, 7, 2, 7, 6, // bottom
2, 7, 3, 2, 6, 7, // bottom
};
int j = 0;
var vertices = new Vector3[triangles.Length];
var normals = new Vector3[triangles.Length];
for (int i = 0; i < triangles.Length / 3; i++)
{
var a = corners[triangles[i * 3 + 0]];
var b = corners[triangles[i * 3 + 1]];
var c = corners[triangles[i * 3 + 2]];
var n = Vector3.Cross(b - a, c - a).normalized;
normals[i * 3 + 0] = n;
normals[i * 3 + 1] = n;
normals[i * 3 + 2] = n;
vertices[i * 3 + 0] = a;
vertices[i * 3 + 1] = b;
vertices[i * 3 + 2] = c;
triangles[i * 3 + 0] = j++;
triangles[i * 3 + 1] = j++;
triangles[i * 3 + 2] = j++;
}
var mesh = new Mesh();
mesh.vertices = vertices;
mesh.normals = normals;
mesh.triangles = triangles;
GetComponent<MeshFilter>().mesh = mesh;
}
private void OnDeviceConnected(params object[] args)
{
var i = (int)args[0];
if (i != (int)index)
return;
GetComponent<MeshFilter>().mesh = null;
var connected = (bool)args[1];
if (connected)
{
var system = OpenVR.System;
if (system != null && system.GetTrackedDeviceClass((uint)i) == ETrackedDeviceClass.TrackingReference)
{
var error = ETrackedPropertyError.TrackedProp_Success;
var result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewLeftDegrees_Float, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
fovLeft = result;
result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewRightDegrees_Float, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
fovRight = result;
result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewTopDegrees_Float, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
fovTop = result;
result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewBottomDegrees_Float, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
fovBottom = result;
result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_TrackingRangeMinimumMeters_Float, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
nearZ = result;
result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_TrackingRangeMaximumMeters_Float, ref error);
if (error == ETrackedPropertyError.TrackedProp_Success)
farZ = result;
UpdateModel();
}
}
}
void OnEnable()
{
GetComponent<MeshFilter>().mesh = null;
SteamVR_Utils.Event.Listen("device_connected", OnDeviceConnected);
}
void OnDisable()
{
SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
GetComponent<MeshFilter>().mesh = null;
}
#if UNITY_EDITOR
void Update()
{
if (!Application.isPlaying)
UpdateModel();
}
#endif
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b2d1785fa0c551e408b6c94398847b76
timeCreated: 1427400484
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+84
View File
@@ -0,0 +1,84 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Handles rendering to the game view window
//
//=============================================================================
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class SteamVR_GameView : MonoBehaviour
{
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) // DEPRECATED in Unity 5.4+
public float scale = 1.5f;
public bool drawOverlay = true;
static Material overlayMaterial;
void OnEnable()
{
if (overlayMaterial == null)
{
overlayMaterial = new Material(Shader.Find("Custom/SteamVR_Overlay"));
}
}
void OnPostRender()
{
var vr = SteamVR.instance;
var camera = GetComponent<Camera>();
var aspect = scale * camera.aspect / vr.aspect;
var x0 = -scale;
var x1 = scale;
var y0 = aspect;
var y1 = -aspect;
var blitMaterial = SteamVR_Camera.blitMaterial;
blitMaterial.mainTexture = SteamVR_Camera.GetSceneTexture(camera.hdr);
GL.PushMatrix();
GL.LoadOrtho();
#if !(UNITY_5_0)
blitMaterial.SetPass(0);
#else
blitMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0);
#endif
GL.Begin(GL.QUADS);
GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(x0, y0, 0);
GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(x1, y0, 0);
GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(x1, y1, 0);
GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(x0, y1, 0);
GL.End();
GL.PopMatrix();
var overlay = SteamVR_Overlay.instance;
if (overlay && overlay.texture && overlayMaterial && drawOverlay)
{
var texture = overlay.texture;
overlayMaterial.mainTexture = texture;
var u0 = 0.0f;
var v0 = 1.0f - (float)Screen.height / texture.height;
var u1 = (float)Screen.width / texture.width;
var v1 = 1.0f;
GL.PushMatrix();
GL.LoadOrtho();
#if !(UNITY_5_0)
overlayMaterial.SetPass(QualitySettings.activeColorSpace == ColorSpace.Linear ? 1 : 0);
#else
overlayMaterial.SetPass(0);
#endif
GL.Begin(GL.QUADS);
GL.TexCoord2(u0, v0); GL.Vertex3(-1, -1, 0);
GL.TexCoord2(u1, v0); GL.Vertex3( 1, -1, 0);
GL.TexCoord2(u1, v1); GL.Vertex3( 1, 1, 0);
GL.TexCoord2(u0, v1); GL.Vertex3(-1, 1, 0);
GL.End();
GL.PopMatrix();
}
}
#endif
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: be96d45fe21847a4a805d408a8015c84
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+170
View File
@@ -0,0 +1,170 @@
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Simple two bone ik solver.
//
//=============================================================================
using UnityEngine;
public class SteamVR_IK : MonoBehaviour
{
public Transform target;
public Transform start, joint, end;
public Transform poleVector, upVector;
public float blendPct = 1.0f;
[HideInInspector]
public Transform startXform, jointXform, endXform;
void LateUpdate()
{
const float epsilon = 0.001f;
if (blendPct < epsilon)
return;
var preUp = upVector ? upVector.up : Vector3.Cross(end.position - start.position, joint.position - start.position).normalized;
var targetPosition = target.position;
var targetRotation = target.rotation;
Vector3 forward, up, result = joint.position;
Solve(start.position, targetPosition, poleVector.position,
(joint.position - start.position).magnitude,
(end.position - joint.position).magnitude,
ref result, out forward, out up);
if (up == Vector3.zero)
return;
var startPosition = start.position;
var jointPosition = joint.position;
var endPosition = end.position;
var startRotationLocal = start.localRotation;
var jointRotationLocal = joint.localRotation;
var endRotationLocal = end.localRotation;
var startParent = start.parent;
var jointParent = joint.parent;
var endParent = end.parent;
var startScale = start.localScale;
var jointScale = joint.localScale;
var endScale = end.localScale;
if (startXform == null)
{
startXform = new GameObject("startXform").transform;
startXform.parent = transform;
}
startXform.position = startPosition;
startXform.LookAt(joint, preUp);
start.parent = startXform;
if (jointXform == null)
{
jointXform = new GameObject("jointXform").transform;
jointXform.parent = startXform;
}
jointXform.position = jointPosition;
jointXform.LookAt(end, preUp);
joint.parent = jointXform;
if (endXform == null)
{
endXform = new GameObject("endXform").transform;
endXform.parent = jointXform;
}
endXform.position = endPosition;
end.parent = endXform;
startXform.LookAt(result, up);
jointXform.LookAt(targetPosition, up);
endXform.rotation = targetRotation;
start.parent = startParent;
joint.parent = jointParent;
end.parent = endParent;
end.rotation = targetRotation; // optionally blend?
// handle blending in/out
if (blendPct < 1.0f)
{
start.localRotation = Quaternion.Slerp(startRotationLocal, start.localRotation, blendPct);
joint.localRotation = Quaternion.Slerp(jointRotationLocal, joint.localRotation, blendPct);
end.localRotation = Quaternion.Slerp(endRotationLocal, end.localRotation, blendPct);
}
// restore scale so it doesn't blow out
start.localScale = startScale;
joint.localScale = jointScale;
end.localScale = endScale;
}
public static bool Solve(
Vector3 start, // shoulder / hip
Vector3 end, // desired hand / foot position
Vector3 poleVector, // point to aim elbow / knee toward
float jointDist, // distance from start to elbow / knee
float targetDist, // distance from joint to hand / ankle
ref Vector3 result, // original and output elbow / knee position
out Vector3 forward, out Vector3 up) // plane formed by root, joint and target
{
var totalDist = jointDist + targetDist;
var start2end = end - start;
var poleVectorDir = (poleVector - start).normalized;
var baseDist = start2end.magnitude;
result = start;
const float epsilon = 0.001f;
if (baseDist < epsilon)
{
// move jointDist toward jointTarget
result += poleVectorDir * jointDist;
forward = Vector3.Cross(poleVectorDir, Vector3.up);
up = Vector3.Cross(forward, poleVectorDir).normalized;
}
else
{
forward = start2end * (1.0f / baseDist);
up = Vector3.Cross(forward, poleVectorDir).normalized;
if (baseDist + epsilon < totalDist)
{
// calculate the area of the triangle to determine its height
var p = (totalDist + baseDist) * 0.5f; // half perimeter
if (p > jointDist + epsilon && p > targetDist + epsilon)
{
var A = Mathf.Sqrt(p * (p - jointDist) * (p - targetDist) * (p - baseDist));
var height = 2.0f * A / baseDist; // distance of joint from line between root and target
var dist = Mathf.Sqrt((jointDist * jointDist) - (height * height));
var right = Vector3.Cross(up, forward); // no need to normalized - already orthonormal
result += (forward * dist) + (right * height);
return true; // in range
}
else
{
// move jointDist toward jointTarget
result += poleVectorDir * jointDist;
}
}
else
{
// move elboDist toward target
result += forward * jointDist;
}
}
return false; // edge cases
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ea22dba3baf2ecc4d886bf2444444228
timeCreated: 1437502789
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+525
View File
@@ -0,0 +1,525 @@
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Helper for smoothing over transitions between levels.
//
//=============================================================================
using UnityEngine;
using System.Collections;
using Valve.VR;
using System.IO;
public class SteamVR_LoadLevel : MonoBehaviour
{
private static SteamVR_LoadLevel _active = null;
public static bool loading { get { return _active != null; } }
public static float progress
{
get { return (_active != null && _active.async != null) ? _active.async.progress : 0.0f; }
}
public static Texture progressTexture
{
get { return (_active != null) ? _active.renderTexture : null; }
}
// Name of level to load.
public string levelName;
// If loading an external application
public bool loadExternalApp;
// Name of external application to load
public string externalAppPath;
// The command-line args for the external application to load
public string externalAppArgs;
// If true, call LoadLevelAdditiveAsync instead of LoadLevelAsync.
public bool loadAdditive;
// Async load causes crashes in some apps.
public bool loadAsync = true;
// Optional logo texture.
public Texture loadingScreen;
// Optional progress bar textures.
public Texture progressBarEmpty, progressBarFull;
// Sizes of overlays.
public float loadingScreenWidthInMeters = 6.0f;
public float progressBarWidthInMeters = 3.0f;
// If specified, the loading screen will be positioned in the player's view this far away.
public float loadingScreenDistance = 0.0f;
// Optional overrides for where to display loading screen and progress bar overlays.
// Otherwise defaults to using this object's transform.
public Transform loadingScreenTransform, progressBarTransform;
// Optional skybox override textures.
public Texture front, back, left, right, top, bottom;
// Colors to use when dropping to the compositor between levels if no skybox is set.
public Color backgroundColor = Color.black;
// If false, the background color above gets applied as the foreground color in the compositor.
// This does not have any effect when using a skybox instead.
public bool showGrid = false;
// Time to fade from current scene to the compositor and back.
public float fadeOutTime = 0.5f;
public float fadeInTime = 0.5f;
// Additional time to wait after finished loading before we start fading the new scene back in.
// This is to cover up any initial hitching that takes place right at the start of levels.
// Most scenes should hopefully not require this.
public float postLoadSettleTime = 0.0f;
// Time to fade loading screen in and out (also used for progress bar).
public float loadingScreenFadeInTime = 1.0f;
public float loadingScreenFadeOutTime = 0.25f;
float fadeRate = 1.0f;
float alpha = 0.0f;
AsyncOperation async; // used to track level load progress
RenderTexture renderTexture; // used to render progress bar
ulong loadingScreenOverlayHandle = OpenVR.k_ulOverlayHandleInvalid;
ulong progressBarOverlayHandle = OpenVR.k_ulOverlayHandleInvalid;
public bool autoTriggerOnEnable = false;
void OnEnable()
{
if (autoTriggerOnEnable)
Trigger();
}
public void Trigger()
{
if (!loading && !string.IsNullOrEmpty(levelName))
StartCoroutine("LoadLevel");
}
// Helper function to quickly and simply load a level from script.
public static void Begin(string levelName,
bool showGrid = false, float fadeOutTime = 0.5f,
float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f)
{
var loader = new GameObject("loader").AddComponent<SteamVR_LoadLevel>();
loader.levelName = levelName;
loader.showGrid = showGrid;
loader.fadeOutTime = fadeOutTime;
loader.backgroundColor = new Color(r, g, b, a);
loader.Trigger();
}
// Updates progress bar.
void OnGUI()
{
if (_active != this)
return;
// Optionally create an overlay for our progress bar to use, separate from the loading screen.
if (progressBarEmpty != null && progressBarFull != null)
{
if (progressBarOverlayHandle == OpenVR.k_ulOverlayHandleInvalid)
progressBarOverlayHandle = GetOverlayHandle("progressBar", progressBarTransform != null ? progressBarTransform : transform, progressBarWidthInMeters);
if (progressBarOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
{
var progress = (async != null) ? async.progress : 0.0f;
// Use the full bar size for everything.
var w = progressBarFull.width;
var h = progressBarFull.height;
// Create a separate render texture so we can composite the full image on top of the empty one.
if (renderTexture == null)
{
renderTexture = new RenderTexture(w, h, 0);
renderTexture.Create();
}
var prevActive = RenderTexture.active;
RenderTexture.active = renderTexture;
if (Event.current.type == EventType.Repaint)
GL.Clear(false, true, Color.clear);
GUILayout.BeginArea(new Rect(0, 0, w, h));
GUI.DrawTexture(new Rect(0, 0, w, h), progressBarEmpty);
// Reveal the full bar texture based on progress.
GUI.DrawTextureWithTexCoords(new Rect(0, 0, progress * w, h), progressBarFull, new Rect(0.0f, 0.0f, progress, 1.0f));
GUILayout.EndArea();
RenderTexture.active = prevActive;
// Texture needs to be set every frame after it is updated since SteamVR makes a copy internally to a shared texture.
var overlay = OpenVR.Overlay;
if (overlay != null)
{
var texture = new Texture_t();
texture.handle = renderTexture.GetNativeTexturePtr();
texture.eType = SteamVR.instance.graphicsAPI;
texture.eColorSpace = EColorSpace.Auto;
overlay.SetOverlayTexture(progressBarOverlayHandle, ref texture);
}
}
}
#if false
// Draw loading screen and progress bar to 2d companion window as well.
if (loadingScreen != null)
{
var screenAspect = (float)Screen.width / Screen.height;
var textureAspect = (float)loadingScreen.width / loadingScreen.height;
float w, h;
if (screenAspect < textureAspect)
{
// Clamp horizontally
w = Screen.width * 0.9f;
h = w / textureAspect;
}
else
{
// Clamp vertically
h = Screen.height * 0.9f;
w = h * textureAspect;
}
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
var x = Screen.width / 2 - w / 2;
var y = Screen.height / 2 - h / 2;
GUI.DrawTexture(new Rect(x, y, w, h), loadingScreen);
GUILayout.EndArea();
}
if (renderTexture != null)
{
var x = Screen.width / 2 - renderTexture.width / 2;
var y = Screen.height * 0.9f - renderTexture.height;
GUI.DrawTexture(new Rect(x, y, renderTexture.width, renderTexture.height), renderTexture);
}
#endif
}
// Fade our overlays in/out over time.
void Update()
{
if (_active != this)
return;
alpha = Mathf.Clamp01(alpha + fadeRate * Time.deltaTime);
var overlay = OpenVR.Overlay;
if (overlay != null)
{
if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
overlay.SetOverlayAlpha(loadingScreenOverlayHandle, alpha);
if (progressBarOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
overlay.SetOverlayAlpha(progressBarOverlayHandle, alpha);
}
}
// Corourtine to handle all the steps across loading boundaries.
IEnumerator LoadLevel()
{
// Optionally rotate loading screen transform around the camera into view.
// We assume here that the loading screen is already facing toward the origin,
// and that the progress bar transform (if any) is a child and will follow along.
if (loadingScreen != null && loadingScreenDistance > 0.0f)
{
// Wait until we have tracking.
var hmd = SteamVR_Controller.Input((int)OpenVR.k_unTrackedDeviceIndex_Hmd);
while (!hmd.hasTracking)
yield return null;
var tloading = hmd.transform;
tloading.rot = Quaternion.Euler(0.0f, tloading.rot.eulerAngles.y, 0.0f);
tloading.pos += tloading.rot * new Vector3(0.0f, 0.0f, loadingScreenDistance);
var t = loadingScreenTransform != null ? loadingScreenTransform : transform;
t.position = tloading.pos;
t.rotation = tloading.rot;
}
_active = this;
SteamVR_Utils.Event.Send("loading", true);
// Calculate rate for fading in loading screen and progress bar.
if (loadingScreenFadeInTime > 0.0f)
{
fadeRate = 1.0f / loadingScreenFadeInTime;
}
else
{
alpha = 1.0f;
}
var overlay = OpenVR.Overlay;
// Optionally create our loading screen overlay.
if (loadingScreen != null && overlay != null)
{
loadingScreenOverlayHandle = GetOverlayHandle("loadingScreen", loadingScreenTransform != null ? loadingScreenTransform : transform, loadingScreenWidthInMeters);
if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
{
var texture = new Texture_t();
texture.handle = loadingScreen.GetNativeTexturePtr();
texture.eType = SteamVR.instance.graphicsAPI;
texture.eColorSpace = EColorSpace.Auto;
overlay.SetOverlayTexture(loadingScreenOverlayHandle, ref texture);
}
}
bool fadedForeground = false;
// Fade out to compositor
SteamVR_Utils.Event.Send("loading_fade_out", fadeOutTime);
// Optionally set a skybox to use as a backdrop in the compositor.
var compositor = OpenVR.Compositor;
if (compositor != null)
{
if (front != null)
{
SteamVR_Skybox.SetOverride(front, back, left, right, top, bottom);
// Explicitly fade to the compositor since loading will cause us to stop rendering.
compositor.FadeGrid(fadeOutTime, true);
yield return new WaitForSeconds(fadeOutTime);
}
else if (backgroundColor != Color.clear)
{
// Otherwise, use the specified background color.
if (showGrid)
{
// Set compositor background color immediately, and start fading to it.
compositor.FadeToColor(0.0f, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, true);
compositor.FadeGrid(fadeOutTime, true);
yield return new WaitForSeconds(fadeOutTime);
}
else
{
// Fade the foreground color in (which will blend on top of the scene), and then cut to the compositor.
compositor.FadeToColor(fadeOutTime, backgroundColor.r, backgroundColor.g, backgroundColor.b, backgroundColor.a, false);
yield return new WaitForSeconds(fadeOutTime + 0.1f);
compositor.FadeGrid(0.0f, true);
fadedForeground = true;
}
}
}
// Now that we're fully faded out, we can stop submitting frames to the compositor.
SteamVR_Render.pauseRendering = true;
// Continue waiting for the overlays to fully fade in before continuing.
while (alpha < 1.0f)
yield return null;
// Keep us from getting destroyed when loading the new level, otherwise this coroutine will get stopped prematurely.
transform.parent = null;
DontDestroyOnLoad(gameObject);
if (loadExternalApp)
{
Debug.Log("Launching external application...");
var applications = OpenVR.Applications;
if (applications == null)
{
Debug.Log("Failed to get OpenVR.Applications interface!");
}
else
{
var workingDirectory = Directory.GetCurrentDirectory();
var fullPath = Path.Combine( workingDirectory, externalAppPath );
Debug.Log("LaunchingInternalProcess");
Debug.Log("ExternalAppPath = " + externalAppPath);
Debug.Log("FullPath = " + fullPath);
Debug.Log("ExternalAppArgs = " + externalAppArgs);
Debug.Log("WorkingDirectory = " + workingDirectory);
var error = applications.LaunchInternalProcess(fullPath, externalAppArgs, workingDirectory);
Debug.Log("LaunchInternalProcessError: " + error);
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
System.Diagnostics.Process.GetCurrentProcess().Kill();
#endif
}
}
else
{
#if !(UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
var mode = loadAdditive ? UnityEngine.SceneManagement.LoadSceneMode.Additive : UnityEngine.SceneManagement.LoadSceneMode.Single;
if (loadAsync)
{
Application.backgroundLoadingPriority = ThreadPriority.Low;
async = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(levelName, mode);
// Performing this in a while loop instead seems to help smooth things out.
//yield return async;
while (!async.isDone)
{
yield return null;
}
}
else
{
UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, mode);
}
#else
if (loadAsync)
{
async = loadAdditive ? Application.LoadLevelAdditiveAsync(levelName) : Application.LoadLevelAsync(levelName);
// Performing this in a while loop instead seems to help smooth things out.
//yield return async;
while (!async.isDone)
{
yield return null;
}
}
else if (loadAdditive)
{
Application.LoadLevelAdditive(levelName);
}
else
{
Application.LoadLevel(levelName);
}
#endif
}
yield return null;
System.GC.Collect();
yield return null;
Shader.WarmupAllShaders();
// Optionally wait a short period of time after loading everything back in, but before we start rendering again
// in order to give everything a change to settle down to avoid any hitching at the start of the new level.
yield return new WaitForSeconds(postLoadSettleTime);
SteamVR_Render.pauseRendering = false;
// Fade out loading screen.
if (loadingScreenFadeOutTime > 0.0f)
{
fadeRate = -1.0f / loadingScreenFadeOutTime;
}
else
{
alpha = 0.0f;
}
// Fade out to compositor
SteamVR_Utils.Event.Send("loading_fade_in", fadeInTime);
if (compositor != null)
{
// Fade out foreground color if necessary.
if (fadedForeground)
{
compositor.FadeGrid(0.0f, false);
compositor.FadeToColor(fadeInTime, 0.0f, 0.0f, 0.0f, 0.0f, false);
yield return new WaitForSeconds(fadeInTime);
}
else
{
// Fade scene back in, and reset skybox once no longer visible.
compositor.FadeGrid(fadeInTime, false);
yield return new WaitForSeconds(fadeInTime);
if (front != null)
{
SteamVR_Skybox.ClearOverride();
}
}
}
// Finally, stick around long enough for our overlays to fully fade out.
while (alpha > 0.0f)
yield return null;
if (overlay != null)
{
if (progressBarOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
overlay.HideOverlay(progressBarOverlayHandle);
if (loadingScreenOverlayHandle != OpenVR.k_ulOverlayHandleInvalid)
overlay.HideOverlay(loadingScreenOverlayHandle);
}
Destroy(gameObject);
_active = null;
SteamVR_Utils.Event.Send("loading", false);
}
// Helper to create (or reuse if possible) each of our different overlay types.
ulong GetOverlayHandle(string overlayName, Transform transform, float widthInMeters = 1.0f)
{
ulong handle = OpenVR.k_ulOverlayHandleInvalid;
var overlay = OpenVR.Overlay;
if (overlay == null)
return handle;
var key = SteamVR_Overlay.key + "." + overlayName;
var error = overlay.FindOverlay(key, ref handle);
if (error != EVROverlayError.None)
error = overlay.CreateOverlay(key, overlayName, ref handle);
if (error == EVROverlayError.None)
{
overlay.ShowOverlay(handle);
overlay.SetOverlayAlpha(handle, alpha);
overlay.SetOverlayWidthInMeters(handle, widthInMeters);
// D3D textures are upside-down in Unity to match OpenGL.
if (SteamVR.instance.graphicsAPI == EGraphicsAPIConvention.API_DirectX)
{
var textureBounds = new VRTextureBounds_t();
textureBounds.uMin = 0;
textureBounds.vMin = 1;
textureBounds.uMax = 1;
textureBounds.vMax = 0;
overlay.SetOverlayTextureBounds(handle, ref textureBounds);
}
// Convert from world space to tracking space using the top-most camera.
var vrcam = (loadingScreenDistance == 0.0f) ? SteamVR_Render.Top() : null;
if (vrcam != null && vrcam.origin != null)
{
var offset = new SteamVR_Utils.RigidTransform(vrcam.origin, transform);
offset.pos.x /= vrcam.origin.localScale.x;
offset.pos.y /= vrcam.origin.localScale.y;
offset.pos.z /= vrcam.origin.localScale.z;
var t = offset.ToHmdMatrix34();
overlay.SetOverlayTransformAbsolute(handle, SteamVR_Render.instance.trackingSpace, ref t);
}
else
{
var t = new SteamVR_Utils.RigidTransform(transform).ToHmdMatrix34();
overlay.SetOverlayTransformAbsolute(handle, SteamVR_Render.instance.trackingSpace, ref t);
}
}
return handle;
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a5a6a70209b6e6345bfe18b02314a54e
timeCreated: 1446783318
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+332
View File
@@ -0,0 +1,332 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Example menu using OnGUI with SteamVR_Camera's overlay support
//
//=============================================================================
using UnityEngine;
using Valve.VR;
public class SteamVR_Menu : MonoBehaviour
{
public Texture cursor, background, logo;
public float logoHeight, menuOffset;
public Vector2 scaleLimits = new Vector2(0.1f, 5.0f);
public float scaleRate = 0.5f;
SteamVR_Overlay overlay;
Camera overlayCam;
Vector4 uvOffset;
float distance;
public RenderTexture texture { get { return overlay ? overlay.texture as RenderTexture : null; } }
public float scale { get; private set; }
string scaleLimitX, scaleLimitY, scaleRateText;
CursorLockMode savedCursorLockState;
bool savedCursorVisible;
void Awake()
{
scaleLimitX = string.Format("{0:N1}", scaleLimits.x);
scaleLimitY = string.Format("{0:N1}", scaleLimits.y);
scaleRateText = string.Format("{0:N1}", scaleRate);
var overlay = SteamVR_Overlay.instance;
if (overlay != null)
{
uvOffset = overlay.uvOffset;
distance = overlay.distance;
}
}
void OnGUI()
{
if (overlay == null)
return;
var texture = overlay.texture as RenderTexture;
var prevActive = RenderTexture.active;
RenderTexture.active = texture;
if (Event.current.type == EventType.Repaint)
GL.Clear(false, true, Color.clear);
var area = new Rect(0, 0, texture.width, texture.height);
// Account for screen smaller than texture (since mouse position gets clamped)
if (Screen.width < texture.width)
{
area.width = Screen.width;
overlay.uvOffset.x = -(float)(texture.width - Screen.width) / (2 * texture.width);
}
if (Screen.height < texture.height)
{
area.height = Screen.height;
overlay.uvOffset.y = (float)(texture.height - Screen.height) / (2 * texture.height);
}
GUILayout.BeginArea(area);
if (background != null)
{
GUI.DrawTexture(new Rect(
(area.width - background.width) / 2,
(area.height - background.height) / 2,
background.width, background.height), background);
}
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
if (logo != null)
{
GUILayout.Space(area.height / 2 - logoHeight);
GUILayout.Box(logo);
}
GUILayout.Space(menuOffset);
bool bHideMenu = GUILayout.Button("[Esc] - Close menu");
GUILayout.BeginHorizontal();
GUILayout.Label(string.Format("Scale: {0:N4}", scale));
{
var result = GUILayout.HorizontalSlider(scale, scaleLimits.x, scaleLimits.y);
if (result != scale)
{
SetScale(result);
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label(string.Format("Scale limits:"));
{
var result = GUILayout.TextField(scaleLimitX);
if (result != scaleLimitX)
{
if (float.TryParse(result, out scaleLimits.x))
scaleLimitX = result;
}
}
{
var result = GUILayout.TextField(scaleLimitY);
if (result != scaleLimitY)
{
if (float.TryParse(result, out scaleLimits.y))
scaleLimitY = result;
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label(string.Format("Scale rate:"));
{
var result = GUILayout.TextField(scaleRateText);
if (result != scaleRateText)
{
if (float.TryParse(result, out scaleRate))
scaleRateText = result;
}
}
GUILayout.EndHorizontal();
if (SteamVR.active)
{
var vr = SteamVR.instance;
GUILayout.BeginHorizontal();
{
var t = SteamVR_Camera.sceneResolutionScale;
int w = (int)(vr.sceneWidth * t);
int h = (int)(vr.sceneHeight * t);
int pct = (int)(100.0f * t);
GUILayout.Label(string.Format("Scene quality: {0}x{1} ({2}%)", w, h, pct));
var result = Mathf.RoundToInt(GUILayout.HorizontalSlider(pct, 50, 200));
if (result != pct)
{
SteamVR_Camera.sceneResolutionScale = (float)result / 100.0f;
}
}
GUILayout.EndHorizontal();
}
overlay.highquality = GUILayout.Toggle(overlay.highquality, "High quality");
if (overlay.highquality)
{
overlay.curved = GUILayout.Toggle(overlay.curved, "Curved overlay");
overlay.antialias = GUILayout.Toggle(overlay.antialias, "Overlay RGSS(2x2)");
}
else
{
overlay.curved = false;
overlay.antialias = false;
}
var tracker = SteamVR_Render.Top();
if (tracker != null)
{
tracker.wireframe = GUILayout.Toggle(tracker.wireframe, "Wireframe");
var render = SteamVR_Render.instance;
if (render.trackingSpace == ETrackingUniverseOrigin.TrackingUniverseSeated)
{
if (GUILayout.Button("Switch to Standing"))
render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseStanding;
if (GUILayout.Button("Center View"))
{
var system = OpenVR.System;
if (system != null)
system.ResetSeatedZeroPose();
}
}
else
{
if (GUILayout.Button("Switch to Seated"))
render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseSeated;
}
}
#if !UNITY_EDITOR
if (GUILayout.Button("Exit"))
Application.Quit();
#endif
GUILayout.Space(menuOffset);
var env = System.Environment.GetEnvironmentVariable("VR_OVERRIDE");
if (env != null)
{
GUILayout.Label("VR_OVERRIDE=" + env);
}
GUILayout.Label("Graphics device: " + SystemInfo.graphicsDeviceVersion);
GUILayout.EndVertical();
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.EndArea();
if (cursor != null)
{
float x = Input.mousePosition.x, y = Screen.height - Input.mousePosition.y;
float w = cursor.width, h = cursor.height;
GUI.DrawTexture(new Rect(x, y, w, h), cursor);
}
RenderTexture.active = prevActive;
if (bHideMenu)
HideMenu();
}
public void ShowMenu()
{
var overlay = SteamVR_Overlay.instance;
if (overlay == null)
return;
var texture = overlay.texture as RenderTexture;
if (texture == null)
{
Debug.LogError("Menu requires overlay texture to be a render texture.");
return;
}
SaveCursorState();
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
this.overlay = overlay;
uvOffset = overlay.uvOffset;
distance = overlay.distance;
// If an existing camera is rendering into the overlay texture, we need
// to temporarily disable it to keep it from clearing the texture on us.
var cameras = Object.FindObjectsOfType(typeof(Camera)) as Camera[];
foreach (var cam in cameras)
{
if (cam.enabled && cam.targetTexture == texture)
{
overlayCam = cam;
overlayCam.enabled = false;
break;
}
}
var tracker = SteamVR_Render.Top();
if (tracker != null)
scale = tracker.origin.localScale.x;
}
public void HideMenu()
{
RestoreCursorState();
if (overlayCam != null)
overlayCam.enabled = true;
if (overlay != null)
{
overlay.uvOffset = uvOffset;
overlay.distance = distance;
overlay = null;
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Joystick1Button7))
{
if (overlay == null)
{
ShowMenu();
}
else
{
HideMenu();
}
}
else if (Input.GetKeyDown(KeyCode.Home))
{
SetScale(1.0f);
}
else if (Input.GetKey(KeyCode.PageUp))
{
SetScale(Mathf.Clamp(scale + scaleRate * Time.deltaTime, scaleLimits.x, scaleLimits.y));
}
else if (Input.GetKey(KeyCode.PageDown))
{
SetScale(Mathf.Clamp(scale - scaleRate * Time.deltaTime, scaleLimits.x, scaleLimits.y));
}
}
void SetScale(float scale)
{
this.scale = scale;
var tracker = SteamVR_Render.Top();
if (tracker != null)
tracker.origin.localScale = new Vector3(scale, scale, scale);
}
void SaveCursorState()
{
savedCursorVisible = Cursor.visible;
savedCursorLockState = Cursor.lockState;
}
void RestoreCursorState()
{
Cursor.visible = savedCursorVisible;
Cursor.lockState = savedCursorLockState;
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e7afc8c74d1f73b458705e0b946292a0
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+183
View File
@@ -0,0 +1,183 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Displays 2d content on a large virtual screen.
//
//=============================================================================
using UnityEngine;
using System.Collections;
using Valve.VR;
public class SteamVR_Overlay : MonoBehaviour
{
public Texture texture;
public bool curved = true;
public bool antialias = true;
public bool highquality = true;
public float scale = 3.0f; // size of overlay view
public float distance = 1.25f; // distance from surface
public float alpha = 1.0f; // opacity 0..1
public Vector4 uvOffset = new Vector4(0, 0, 1, 1);
public Vector2 mouseScale = new Vector2(1, 1);
public Vector2 curvedRange = new Vector2(1, 2);
public VROverlayInputMethod inputMethod = VROverlayInputMethod.None;
static public SteamVR_Overlay instance { get; private set; }
static public string key { get { return "unity:" + Application.companyName + "." + Application.productName; } }
private ulong handle = OpenVR.k_ulOverlayHandleInvalid;
void OnEnable()
{
var overlay = OpenVR.Overlay;
if (overlay != null)
{
var error = overlay.CreateOverlay(key, gameObject.name, ref handle);
if (error != EVROverlayError.None)
{
Debug.Log(overlay.GetOverlayErrorNameFromEnum(error));
enabled = false;
return;
}
}
SteamVR_Overlay.instance = this;
}
void OnDisable()
{
if (handle != OpenVR.k_ulOverlayHandleInvalid)
{
var overlay = OpenVR.Overlay;
if (overlay != null)
{
overlay.DestroyOverlay(handle);
}
handle = OpenVR.k_ulOverlayHandleInvalid;
}
SteamVR_Overlay.instance = null;
}
public void UpdateOverlay()
{
var overlay = OpenVR.Overlay;
if (overlay == null)
return;
if (texture != null)
{
var error = overlay.ShowOverlay(handle);
if (error == EVROverlayError.InvalidHandle || error == EVROverlayError.UnknownOverlay)
{
if (overlay.FindOverlay(key, ref handle) != EVROverlayError.None)
return;
}
var tex = new Texture_t();
tex.handle = texture.GetNativeTexturePtr();
tex.eType = SteamVR.instance.graphicsAPI;
tex.eColorSpace = EColorSpace.Auto;
overlay.SetOverlayTexture(handle, ref tex);
overlay.SetOverlayAlpha(handle, alpha);
overlay.SetOverlayWidthInMeters(handle, scale);
overlay.SetOverlayAutoCurveDistanceRangeInMeters(handle, curvedRange.x, curvedRange.y);
var textureBounds = new VRTextureBounds_t();
textureBounds.uMin = (0 + uvOffset.x) * uvOffset.z;
textureBounds.vMin = (1 + uvOffset.y) * uvOffset.w;
textureBounds.uMax = (1 + uvOffset.x) * uvOffset.z;
textureBounds.vMax = (0 + uvOffset.y) * uvOffset.w;
overlay.SetOverlayTextureBounds(handle, ref textureBounds);
var vecMouseScale = new HmdVector2_t();
vecMouseScale.v0 = mouseScale.x;
vecMouseScale.v1 = mouseScale.y;
overlay.SetOverlayMouseScale(handle, ref vecMouseScale);
var vrcam = SteamVR_Render.Top();
if (vrcam != null && vrcam.origin != null)
{
var offset = new SteamVR_Utils.RigidTransform(vrcam.origin, transform);
offset.pos.x /= vrcam.origin.localScale.x;
offset.pos.y /= vrcam.origin.localScale.y;
offset.pos.z /= vrcam.origin.localScale.z;
offset.pos.z += distance;
var t = offset.ToHmdMatrix34();
overlay.SetOverlayTransformAbsolute(handle, SteamVR_Render.instance.trackingSpace, ref t);
}
overlay.SetOverlayInputMethod(handle, inputMethod);
if (curved || antialias)
highquality = true;
if (highquality)
{
overlay.SetHighQualityOverlay(handle);
overlay.SetOverlayFlag(handle, VROverlayFlags.Curved, curved);
overlay.SetOverlayFlag(handle, VROverlayFlags.RGSS4X, antialias);
}
else if (overlay.GetHighQualityOverlay() == handle)
{
overlay.SetHighQualityOverlay(OpenVR.k_ulOverlayHandleInvalid);
}
}
else
{
overlay.HideOverlay(handle);
}
}
public bool PollNextEvent(ref VREvent_t pEvent)
{
var overlay = OpenVR.Overlay;
if (overlay == null)
return false;
var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Valve.VR.VREvent_t));
return overlay.PollNextOverlayEvent(handle, ref pEvent, size);
}
public struct IntersectionResults
{
public Vector3 point;
public Vector3 normal;
public Vector2 UVs;
public float distance;
}
public bool ComputeIntersection(Vector3 source, Vector3 direction, ref IntersectionResults results)
{
var overlay = OpenVR.Overlay;
if (overlay == null)
return false;
var input = new VROverlayIntersectionParams_t();
input.eOrigin = SteamVR_Render.instance.trackingSpace;
input.vSource.v0 = source.x;
input.vSource.v1 = source.y;
input.vSource.v2 = -source.z;
input.vDirection.v0 = direction.x;
input.vDirection.v1 = direction.y;
input.vDirection.v2 = -direction.z;
var output = new VROverlayIntersectionResults_t();
if (!overlay.ComputeOverlayIntersection(handle, ref input, ref output))
return false;
results.point = new Vector3(output.vPoint.v0, output.vPoint.v1, -output.vPoint.v2);
results.normal = new Vector3(output.vNormal.v0, output.vNormal.v1, -output.vNormal.v2);
results.UVs = new Vector2(output.vUVs.v0, output.vUVs.v1);
results.distance = output.fDistance;
return true;
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 46fe9e0b23166454c8cb73040321d78c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+287
View File
@@ -0,0 +1,287 @@
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Draws different sized room-scale play areas for targeting content
//
//=============================================================================
using UnityEngine;
using UnityEngine.Rendering;
using System.Collections;
using Valve.VR;
[ExecuteInEditMode, RequireComponent(typeof(MeshRenderer), typeof(MeshFilter))]
public class SteamVR_PlayArea : MonoBehaviour
{
public float borderThickness = 0.15f;
public float wireframeHeight = 2.0f;
public bool drawWireframeWhenSelectedOnly = false;
public bool drawInGame = true;
public enum Size
{
Calibrated,
_400x300,
_300x225,
_200x150
}
public Size size;
public Color color = Color.cyan;
[HideInInspector]
public Vector3[] vertices;
public static bool GetBounds( Size size, ref HmdQuad_t pRect )
{
if (size == Size.Calibrated)
{
var initOpenVR = (!SteamVR.active && !SteamVR.usingNativeSupport);
if (initOpenVR)
{
var error = EVRInitError.None;
OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
}
var chaperone = OpenVR.Chaperone;
bool success = (chaperone != null) && chaperone.GetPlayAreaRect(ref pRect);
if (!success)
Debug.LogWarning("Failed to get Calibrated Play Area bounds! Make sure you have tracking first, and that your space is calibrated.");
if (initOpenVR)
OpenVR.Shutdown();
return success;
}
else
{
try
{
var str = size.ToString().Substring(1);
var arr = str.Split(new char[] {'x'}, 2);
// convert to half size in meters (from cm)
var x = float.Parse(arr[0]) / 200;
var z = float.Parse(arr[1]) / 200;
pRect.vCorners0.v0 = x;
pRect.vCorners0.v1 = 0;
pRect.vCorners0.v2 = z;
pRect.vCorners1.v0 = x;
pRect.vCorners1.v1 = 0;
pRect.vCorners1.v2 = -z;
pRect.vCorners2.v0 = -x;
pRect.vCorners2.v1 = 0;
pRect.vCorners2.v2 = -z;
pRect.vCorners3.v0 = -x;
pRect.vCorners3.v1 = 0;
pRect.vCorners3.v2 = z;
return true;
}
catch {}
}
return false;
}
public void BuildMesh()
{
var rect = new HmdQuad_t();
if ( !GetBounds( size, ref rect ) )
return;
var corners = new HmdVector3_t[] { rect.vCorners0, rect.vCorners1, rect.vCorners2, rect.vCorners3 };
vertices = new Vector3[corners.Length * 2];
for (int i = 0; i < corners.Length; i++)
{
var c = corners[i];
vertices[i] = new Vector3(c.v0, 0.01f, c.v2);
}
if (borderThickness == 0.0f)
{
GetComponent<MeshFilter>().mesh = null;
return;
}
for (int i = 0; i < corners.Length; i++)
{
int next = (i + 1) % corners.Length;
int prev = (i + corners.Length - 1) % corners.Length;
var nextSegment = (vertices[next] - vertices[i]).normalized;
var prevSegment = (vertices[prev] - vertices[i]).normalized;
var vert = vertices[i];
vert += Vector3.Cross(nextSegment, Vector3.up) * borderThickness;
vert += Vector3.Cross(prevSegment, Vector3.down) * borderThickness;
vertices[corners.Length + i] = vert;
}
var triangles = new int[]
{
0, 1, 4,
1, 5, 4,
1, 2, 5,
2, 6, 5,
2, 3, 6,
3, 7, 6,
3, 0, 7,
0, 4, 7
};
var uv = new Vector2[]
{
new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 0.0f),
new Vector2(1.0f, 0.0f),
new Vector2(0.0f, 1.0f),
new Vector2(1.0f, 1.0f),
new Vector2(0.0f, 1.0f),
new Vector2(1.0f, 1.0f)
};
var colors = new Color[]
{
color,
color,
color,
color,
new Color(color.r, color.g, color.b, 0.0f),
new Color(color.r, color.g, color.b, 0.0f),
new Color(color.r, color.g, color.b, 0.0f),
new Color(color.r, color.g, color.b, 0.0f)
};
var mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
mesh.vertices = vertices;
mesh.uv = uv;
mesh.colors = colors;
mesh.triangles = triangles;
var renderer = GetComponent<MeshRenderer>();
#if UNITY_EDITOR && !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
renderer.material = UnityEditor.AssetDatabase.GetBuiltinExtraResource<Material>("Sprites-Default.mat");
#else
renderer.material = Resources.GetBuiltinResource<Material>("Sprites-Default.mat");
#endif
renderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off;
renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
renderer.receiveShadows = false;
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
renderer.lightProbeUsage = LightProbeUsage.Off;
#else
renderer.useLightProbes = false;
#endif
}
#if UNITY_EDITOR
Hashtable values;
void Update()
{
if (!Application.isPlaying)
{
var fields = GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
bool rebuild = false;
if (values == null || (borderThickness != 0.0f && GetComponent<MeshFilter>().sharedMesh == null))
{
rebuild = true;
}
else
{
foreach (var f in fields)
{
if (!values.Contains(f) || !f.GetValue(this).Equals(values[f]))
{
rebuild = true;
break;
}
}
}
if (rebuild)
{
BuildMesh();
values = new Hashtable();
foreach (var f in fields)
values[f] = f.GetValue(this);
}
}
}
#endif
void OnDrawGizmos()
{
if (!drawWireframeWhenSelectedOnly)
DrawWireframe();
}
void OnDrawGizmosSelected()
{
if (drawWireframeWhenSelectedOnly)
DrawWireframe();
}
public void DrawWireframe()
{
if (vertices == null || vertices.Length == 0)
return;
var offset = transform.TransformVector(Vector3.up * wireframeHeight);
for (int i = 0; i < 4; i++)
{
int next = (i + 1) % 4;
var a = transform.TransformPoint(vertices[i]);
var b = a + offset;
var c = transform.TransformPoint(vertices[next]);
var d = c + offset;
Gizmos.DrawLine(a, b);
Gizmos.DrawLine(a, c);
Gizmos.DrawLine(b, d);
}
}
public void OnEnable()
{
if (Application.isPlaying)
{
GetComponent<MeshRenderer>().enabled = drawInGame;
// No need to remain enabled at runtime.
// Anyone that wants to change properties at runtime
// should call BuildMesh themselves.
//enabled = false;
// If we want the configured bounds of the user,
// we need to wait for tracking.
if (drawInGame && size == Size.Calibrated)
StartCoroutine("UpdateBounds");
}
}
IEnumerator UpdateBounds()
{
GetComponent<MeshFilter>().mesh = null; // clear existing
var chaperone = OpenVR.Chaperone;
if (chaperone == null)
yield break;
while (chaperone.GetCalibrationState() != ChaperoneCalibrationState.OK)
yield return null;
BuildMesh();
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1f0522eaef74d984591c060d05a095c8
timeCreated: 1438043592
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+435
View File
@@ -0,0 +1,435 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Handles rendering of all SteamVR_Cameras
//
//=============================================================================
using UnityEngine;
using System.Collections;
using Valve.VR;
public class SteamVR_Render : MonoBehaviour
{
public bool pauseGameWhenDashboardIsVisible = true;
public bool lockPhysicsUpdateRateToRenderFrequency = true;
public SteamVR_ExternalCamera externalCamera;
public string externalCameraConfigPath = "externalcamera.cfg";
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
public LayerMask leftMask, rightMask;
SteamVR_CameraMask cameraMask;
#endif
public ETrackingUniverseOrigin trackingSpace = ETrackingUniverseOrigin.TrackingUniverseStanding;
static public EVREye eye { get; private set; }
static private SteamVR_Render _instance;
static public SteamVR_Render instance
{
get
{
if (_instance == null)
{
_instance = GameObject.FindObjectOfType<SteamVR_Render>();
if (_instance == null)
_instance = new GameObject("[SteamVR]").AddComponent<SteamVR_Render>();
}
return _instance;
}
}
void OnDestroy()
{
_instance = null;
}
static private bool isQuitting;
void OnApplicationQuit()
{
isQuitting = true;
SteamVR.SafeDispose();
}
static public void Add(SteamVR_Camera vrcam)
{
if (!isQuitting)
instance.AddInternal(vrcam);
}
static public void Remove(SteamVR_Camera vrcam)
{
if (!isQuitting && _instance != null)
instance.RemoveInternal(vrcam);
}
static public SteamVR_Camera Top()
{
if (!isQuitting)
return instance.TopInternal();
return null;
}
private SteamVR_Camera[] cameras = new SteamVR_Camera[0];
void AddInternal(SteamVR_Camera vrcam)
{
var camera = vrcam.GetComponent<Camera>();
var length = cameras.Length;
var sorted = new SteamVR_Camera[length + 1];
int insert = 0;
for (int i = 0; i < length; i++)
{
var c = cameras[i].GetComponent<Camera>();
if (i == insert && c.depth > camera.depth)
sorted[insert++] = vrcam;
sorted[insert++] = cameras[i];
}
if (insert == length)
sorted[insert] = vrcam;
cameras = sorted;
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
enabled = true;
#endif
}
void RemoveInternal(SteamVR_Camera vrcam)
{
var length = cameras.Length;
int count = 0;
for (int i = 0; i < length; i++)
{
var c = cameras[i];
if (c == vrcam)
++count;
}
if (count == 0)
return;
var sorted = new SteamVR_Camera[length - count];
int insert = 0;
for (int i = 0; i < length; i++)
{
var c = cameras[i];
if (c != vrcam)
sorted[insert++] = c;
}
cameras = sorted;
}
SteamVR_Camera TopInternal()
{
if (cameras.Length > 0)
return cameras[cameras.Length - 1];
return null;
}
public TrackedDevicePose_t[] poses = new TrackedDevicePose_t[OpenVR.k_unMaxTrackedDeviceCount];
public TrackedDevicePose_t[] gamePoses = new TrackedDevicePose_t[0];
static private bool _pauseRendering;
static public bool pauseRendering
{
get { return _pauseRendering; }
set
{
_pauseRendering = value;
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
var compositor = OpenVR.Compositor;
if (compositor != null)
compositor.SuspendRendering(value);
#endif
}
}
private IEnumerator RenderLoop()
{
while (true)
{
yield return new WaitForEndOfFrame();
if (pauseRendering)
continue;
var compositor = OpenVR.Compositor;
if (compositor != null)
{
if (!compositor.CanRenderScene())
continue;
compositor.SetTrackingSpace(trackingSpace);
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_WaitGetPoses);
// Hack to flush render event that was queued in Update (this ensures WaitGetPoses has returned before we grab the new values).
SteamVR.Unity.EventWriteString("[UnityMain] GetNativeTexturePtr - Begin");
SteamVR_Camera.GetSceneTexture(cameras[0].GetComponent<Camera>().hdr).GetNativeTexturePtr();
SteamVR.Unity.EventWriteString("[UnityMain] GetNativeTexturePtr - End");
compositor.GetLastPoses(poses, gamePoses);
SteamVR_Utils.Event.Send("new_poses", poses);
SteamVR_Utils.Event.Send("new_poses_applied");
#endif
}
var overlay = SteamVR_Overlay.instance;
if (overlay != null)
overlay.UpdateOverlay();
RenderExternalCamera();
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
var vr = SteamVR.instance;
RenderEye(vr, EVREye.Eye_Left);
RenderEye(vr, EVREye.Eye_Right);
// Move cameras back to head position so they can be tracked reliably
foreach (var c in cameras)
{
c.transform.localPosition = Vector3.zero;
c.transform.localRotation = Quaternion.identity;
}
if (cameraMask != null)
cameraMask.Clear();
#endif
}
}
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
void RenderEye(SteamVR vr, EVREye eye)
{
int i = (int)eye;
SteamVR_Render.eye = eye;
if (cameraMask != null)
cameraMask.Set(vr, eye);
foreach (var c in cameras)
{
c.transform.localPosition = vr.eyes[i].pos;
c.transform.localRotation = vr.eyes[i].rot;
// Update position to keep from getting culled
cameraMask.transform.position = c.transform.position;
var camera = c.GetComponent<Camera>();
camera.targetTexture = SteamVR_Camera.GetSceneTexture(camera.hdr);
int cullingMask = camera.cullingMask;
if (eye == EVREye.Eye_Left)
{
camera.cullingMask &= ~rightMask;
camera.cullingMask |= leftMask;
}
else
{
camera.cullingMask &= ~leftMask;
camera.cullingMask |= rightMask;
}
camera.Render();
camera.cullingMask = cullingMask;
}
}
#endif
void RenderExternalCamera()
{
if (externalCamera == null)
return;
if (!externalCamera.gameObject.activeInHierarchy)
return;
var frameSkip = (int)Mathf.Max(externalCamera.config.frameSkip, 0.0f);
if (Time.frameCount % (frameSkip + 1) != 0)
return;
// Keep external camera relative to the most relevant vr camera.
externalCamera.AttachToCamera(TopInternal());
externalCamera.RenderNear();
externalCamera.RenderFar();
}
float sceneResolutionScale = 1.0f, timeScale = 1.0f;
private void OnInputFocus(params object[] args)
{
bool hasFocus = (bool)args[0];
if (hasFocus)
{
if (pauseGameWhenDashboardIsVisible)
{
Time.timeScale = timeScale;
}
SteamVR_Camera.sceneResolutionScale = sceneResolutionScale;
}
else
{
if (pauseGameWhenDashboardIsVisible)
{
timeScale = Time.timeScale;
Time.timeScale = 0.0f;
}
sceneResolutionScale = SteamVR_Camera.sceneResolutionScale;
SteamVR_Camera.sceneResolutionScale = 0.5f;
}
}
void OnQuit(params object[] args)
{
#if UNITY_EDITOR
foreach (System.Reflection.Assembly a in System.AppDomain.CurrentDomain.GetAssemblies())
{
var t = a.GetType("UnityEditor.EditorApplication");
if (t != null)
{
t.GetProperty("isPlaying").SetValue(null, false, null);
break;
}
}
#else
Application.Quit();
#endif
}
void OnEnable()
{
StartCoroutine("RenderLoop");
SteamVR_Utils.Event.Listen("input_focus", OnInputFocus);
SteamVR_Utils.Event.Listen("Quit", OnQuit);
}
void OnDisable()
{
StopAllCoroutines();
SteamVR_Utils.Event.Remove("input_focus", OnInputFocus);
SteamVR_Utils.Event.Remove("Quit", OnQuit);
}
void Awake()
{
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
var go = new GameObject("cameraMask");
go.transform.parent = transform;
cameraMask = go.AddComponent<SteamVR_CameraMask>();
#endif
if (externalCamera == null && System.IO.File.Exists(externalCameraConfigPath))
{
var prefab = Resources.Load<GameObject>("SteamVR_ExternalCamera");
var instance = Instantiate(prefab);
instance.gameObject.name = "External Camera";
externalCamera = instance.transform.GetChild(0).GetComponent<SteamVR_ExternalCamera>();
externalCamera.configPath = externalCameraConfigPath;
externalCamera.ReadConfig();
}
}
void FixedUpdate()
{
#if (UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
// We want to call this as soon after Present as possible.
SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_PostPresentHandoff);
#endif
}
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
private SteamVR_UpdatePoses poseUpdater;
#endif
void Update()
{
#if !(UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (poseUpdater == null)
{
var go = new GameObject("poseUpdater");
go.transform.parent = transform;
poseUpdater = go.AddComponent<SteamVR_UpdatePoses>();
}
#else
if (cameras.Length == 0)
{
enabled = false;
return;
}
// If our FixedUpdate rate doesn't match our render framerate, then catch the handoff here.
SteamVR_Utils.QueueEventOnRenderThread(SteamVR.Unity.k_nRenderEventID_PostPresentHandoff);
#endif
// Force controller update in case no one else called this frame to ensure prevState gets updated.
SteamVR_Controller.Update();
// Dispatch any OpenVR events.
var system = OpenVR.System;
if (system != null)
{
var vrEvent = new VREvent_t();
var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VREvent_t));
for (int i = 0; i < 64; i++)
{
if (!system.PollNextEvent(ref vrEvent, size))
break;
switch ((EVREventType)vrEvent.eventType)
{
case EVREventType.VREvent_InputFocusCaptured: // another app has taken focus (likely dashboard)
if (vrEvent.data.process.oldPid == 0)
{
SteamVR_Utils.Event.Send("input_focus", false);
}
break;
case EVREventType.VREvent_InputFocusReleased: // that app has released input focus
if (vrEvent.data.process.pid == 0)
{
SteamVR_Utils.Event.Send("input_focus", true);
}
break;
case EVREventType.VREvent_ShowRenderModels:
SteamVR_Utils.Event.Send("hide_render_models", false);
break;
case EVREventType.VREvent_HideRenderModels:
SteamVR_Utils.Event.Send("hide_render_models", true);
break;
default:
var name = System.Enum.GetName(typeof(EVREventType), vrEvent.eventType);
if (name != null)
SteamVR_Utils.Event.Send(name.Substring(8) /*strip VREvent_*/, vrEvent);
break;
}
}
}
// Ensure various settings to minimize latency.
Application.targetFrameRate = -1;
Application.runInBackground = true; // don't require companion window focus
QualitySettings.maxQueuedFrames = -1;
QualitySettings.vSyncCount = 0; // this applies to the companion window
if (lockPhysicsUpdateRateToRenderFrequency && Time.timeScale > 0.0f)
{
var vr = SteamVR.instance;
if (vr != null)
{
var timing = new Compositor_FrameTiming();
timing.m_nSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming));
vr.compositor.GetFrameTiming(ref timing, 0);
Time.fixedDeltaTime = Time.timeScale / vr.hmd_DisplayFrequency;
Time.maximumDeltaTime = Time.fixedDeltaTime * timing.m_nNumFramePresents;
}
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e979227f3384fac4b8ca0b3550bf005c
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: -32000
icon: {instanceID: 0}
userData:
assetBundleName:
+730
View File
@@ -0,0 +1,730 @@
//========= Copyright 2014, Valve Corporation, All rights reserved. ===========
//
// Purpose: Render model of associated tracked object
//
//=============================================================================
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
using Valve.VR;
[ExecuteInEditMode]
public class SteamVR_RenderModel : MonoBehaviour
{
public SteamVR_TrackedObject.EIndex index = SteamVR_TrackedObject.EIndex.None;
public string modelOverride;
// Shader to apply to model.
public Shader shader;
// Enable to print out when render models are loaded.
public bool verbose = false;
// If available, break down into separate components instead of loading as a single mesh.
public bool createComponents = true;
// Update transforms of components at runtime to reflect user action.
public bool updateDynamically = true;
// Additional controller settings for showing scrollwheel, etc.
public RenderModel_ControllerMode_State_t controllerModeState;
// Name of the sub-object which represents the "local" coordinate space for each component.
public const string k_localTransformName = "attach";
// Cached name of this render model for updating component transforms at runtime.
public string renderModelName { get; private set; }
// If someone knows how to keep these from getting cleaned up every time
// you exit play mode, let me know. I've tried marking the RenderModel
// class below as [System.Serializable] and switching to normal public
// variables for mesh and material to get them to serialize properly,
// as well as tried marking the mesh and material objects as
// DontUnloadUnusedAsset, but Unity was still unloading them.
// The hashtable is preserving its entries, but the mesh and material
// variables are going null.
public class RenderModel
{
public RenderModel(Mesh mesh, Material material)
{
this.mesh = mesh;
this.material = material;
}
public Mesh mesh { get; private set; }
public Material material { get; private set; }
}
public static Hashtable models = new Hashtable();
public static Hashtable materials = new Hashtable();
// Helper class to load render models interface on demand and clean up when done.
public sealed class RenderModelInterfaceHolder : System.IDisposable
{
private bool needsShutdown, failedLoadInterface;
private CVRRenderModels _instance;
public CVRRenderModels instance
{
get
{
if (_instance == null && !failedLoadInterface)
{
if (!SteamVR.active && !SteamVR.usingNativeSupport)
{
var error = EVRInitError.None;
OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other);
needsShutdown = true;
}
_instance = OpenVR.RenderModels;
if (_instance == null)
{
Debug.LogError("Failed to load IVRRenderModels interface version " + OpenVR.IVRRenderModels_Version);
failedLoadInterface = true;
}
}
return _instance;
}
}
public void Dispose()
{
if (needsShutdown)
OpenVR.Shutdown();
}
}
private void OnModelSkinSettingsHaveChanged(params object[] args)
{
if (!string.IsNullOrEmpty(renderModelName))
{
renderModelName = "";
UpdateModel();
}
}
private void OnHideRenderModels(params object[] args)
{
bool hidden = (bool)args[0];
var meshRenderer = GetComponent<MeshRenderer>();
if (meshRenderer != null)
meshRenderer.enabled = !hidden;
foreach (var child in transform.GetComponentsInChildren<MeshRenderer>())
child.enabled = !hidden;
}
private void OnDeviceConnected(params object[] args)
{
var i = (int)args[0];
if (i != (int)index)
return;
var connected = (bool)args[1];
if (connected)
{
UpdateModel();
}
}
public void UpdateModel()
{
var system = OpenVR.System;
if (system == null)
return;
var error = ETrackedPropertyError.TrackedProp_Success;
var capacity = system.GetStringTrackedDeviceProperty((uint)index, ETrackedDeviceProperty.Prop_RenderModelName_String, null, 0, ref error);
if (capacity <= 1)
{
Debug.LogError("Failed to get render model name for tracked object " + index);
return;
}
var buffer = new System.Text.StringBuilder((int)capacity);
system.GetStringTrackedDeviceProperty((uint)index, ETrackedDeviceProperty.Prop_RenderModelName_String, buffer, capacity, ref error);
var s = buffer.ToString();
if (renderModelName != s)
{
renderModelName = s;
StartCoroutine(SetModelAsync(s));
}
}
IEnumerator SetModelAsync(string renderModelName)
{
if (string.IsNullOrEmpty(renderModelName))
yield break;
// Preload all render models before asking for the data to create meshes.
using (var holder = new RenderModelInterfaceHolder())
{
var renderModels = holder.instance;
if (renderModels == null)
yield break;
// Gather names of render models to preload.
string[] renderModelNames;
var count = renderModels.GetComponentCount(renderModelName);
if (count > 0)
{
renderModelNames = new string[count];
for (int i = 0; i < count; i++)
{
var capacity = renderModels.GetComponentName(renderModelName, (uint)i, null, 0);
if (capacity == 0)
continue;
var componentName = new System.Text.StringBuilder((int)capacity);
if (renderModels.GetComponentName(renderModelName, (uint)i, componentName, capacity) == 0)
continue;
capacity = renderModels.GetComponentRenderModelName(renderModelName, componentName.ToString(), null, 0);
if (capacity == 0)
continue;
var name = new System.Text.StringBuilder((int)capacity);
if (renderModels.GetComponentRenderModelName(renderModelName, componentName.ToString(), name, capacity) == 0)
continue;
var s = name.ToString();
// Only need to preload if not already cached.
var model = models[s] as RenderModel;
if (model == null || model.mesh == null)
{
renderModelNames[i] = s;
}
}
}
else
{
// Only need to preload if not already cached.
var model = models[renderModelName] as RenderModel;
if (model == null || model.mesh == null)
{
renderModelNames = new string[] { renderModelName };
}
else
{
renderModelNames = new string[0];
}
}
// Keep trying every 100ms until all components finish loading.
while (true)
{
var loading = false;
foreach (var name in renderModelNames)
{
if (string.IsNullOrEmpty(name))
continue;
var pRenderModel = System.IntPtr.Zero;
var error = renderModels.LoadRenderModel_Async(name, ref pRenderModel);
if (error == EVRRenderModelError.Loading)
{
loading = true;
}
else if (error == EVRRenderModelError.None)
{
// Preload textures as well.
var renderModel = (RenderModel_t)Marshal.PtrToStructure(pRenderModel, typeof(RenderModel_t));
// Check the cache first.
var material = materials[renderModel.diffuseTextureId] as Material;
if (material == null || material.mainTexture == null)
{
var pDiffuseTexture = System.IntPtr.Zero;
error = renderModels.LoadTexture_Async(renderModel.diffuseTextureId, ref pDiffuseTexture);
if (error == EVRRenderModelError.Loading)
{
loading = true;
}
}
}
}
if (loading)
{
yield return new WaitForSeconds(0.1f);
}
else
{
break;
}
}
}
bool success = SetModel(renderModelName);
SteamVR_Utils.Event.Send("render_model_loaded", this, success);
}
private bool SetModel(string renderModelName)
{
StripMesh(gameObject);
using (var holder = new RenderModelInterfaceHolder())
{
if (createComponents)
{
if (LoadComponents(holder, renderModelName))
{
UpdateComponents();
return true;
}
Debug.Log("[" + gameObject.name + "] Render model does not support components, falling back to single mesh.");
}
if (!string.IsNullOrEmpty(renderModelName))
{
var model = models[renderModelName] as RenderModel;
if (model == null || model.mesh == null)
{
var renderModels = holder.instance;
if (renderModels == null)
return false;
if (verbose)
Debug.Log("Loading render model " + renderModelName);
model = LoadRenderModel(renderModels, renderModelName, renderModelName);
if (model == null)
return false;
models[renderModelName] = model;
}
gameObject.AddComponent<MeshFilter>().mesh = model.mesh;
gameObject.AddComponent<MeshRenderer>().sharedMaterial = model.material;
return true;
}
}
return false;
}
RenderModel LoadRenderModel(CVRRenderModels renderModels, string renderModelName, string baseName)
{
var pRenderModel = System.IntPtr.Zero;
EVRRenderModelError error;
while ( true )
{
error = renderModels.LoadRenderModel_Async(renderModelName, ref pRenderModel);
if (error != EVRRenderModelError.Loading)
break;
System.Threading.Thread.Sleep(1);
}
if (error != EVRRenderModelError.None)
{
Debug.LogError(string.Format("Failed to load render model {0} - {1}", renderModelName, error.ToString()));
return null;
}
var renderModel = (RenderModel_t)Marshal.PtrToStructure(pRenderModel, typeof(RenderModel_t));
var vertices = new Vector3[renderModel.unVertexCount];
var normals = new Vector3[renderModel.unVertexCount];
var uv = new Vector2[renderModel.unVertexCount];
var type = typeof(RenderModel_Vertex_t);
for (int iVert = 0; iVert < renderModel.unVertexCount; iVert++)
{
var ptr = new System.IntPtr(renderModel.rVertexData.ToInt64() + iVert * Marshal.SizeOf(type));
var vert = (RenderModel_Vertex_t)Marshal.PtrToStructure(ptr, type);
vertices[iVert] = new Vector3(vert.vPosition.v0, vert.vPosition.v1, -vert.vPosition.v2);
normals[iVert] = new Vector3(vert.vNormal.v0, vert.vNormal.v1, -vert.vNormal.v2);
uv[iVert] = new Vector2(vert.rfTextureCoord0, vert.rfTextureCoord1);
}
int indexCount = (int)renderModel.unTriangleCount * 3;
var indices = new short[indexCount];
Marshal.Copy(renderModel.rIndexData, indices, 0, indices.Length);
var triangles = new int[indexCount];
for (int iTri = 0; iTri < renderModel.unTriangleCount; iTri++)
{
triangles[iTri * 3 + 0] = (int)indices[iTri * 3 + 2];
triangles[iTri * 3 + 1] = (int)indices[iTri * 3 + 1];
triangles[iTri * 3 + 2] = (int)indices[iTri * 3 + 0];
}
var mesh = new Mesh();
mesh.vertices = vertices;
mesh.normals = normals;
mesh.uv = uv;
mesh.triangles = triangles;
mesh.Optimize();
//mesh.hideFlags = HideFlags.DontUnloadUnusedAsset;
// Check cache before loading texture.
var material = materials[renderModel.diffuseTextureId] as Material;
if (material == null || material.mainTexture == null)
{
var pDiffuseTexture = System.IntPtr.Zero;
while (true)
{
error = renderModels.LoadTexture_Async(renderModel.diffuseTextureId, ref pDiffuseTexture);
if (error != EVRRenderModelError.Loading)
break;
System.Threading.Thread.Sleep(1);
}
if (error == EVRRenderModelError.None)
{
var diffuseTexture = (RenderModel_TextureMap_t)Marshal.PtrToStructure(pDiffuseTexture, typeof(RenderModel_TextureMap_t));
var texture = new Texture2D(diffuseTexture.unWidth, diffuseTexture.unHeight, TextureFormat.ARGB32, false);
if (SystemInfo.graphicsDeviceVersion.StartsWith("OpenGL"))
{
var textureMapData = new byte[diffuseTexture.unWidth * diffuseTexture.unHeight * 4]; // RGBA
Marshal.Copy(diffuseTexture.rubTextureMapData, textureMapData, 0, textureMapData.Length);
var colors = new Color32[diffuseTexture.unWidth * diffuseTexture.unHeight];
int iColor = 0;
for (int iHeight = 0; iHeight < diffuseTexture.unHeight; iHeight++)
{
for (int iWidth = 0; iWidth < diffuseTexture.unWidth; iWidth++)
{
var r = textureMapData[iColor++];
var g = textureMapData[iColor++];
var b = textureMapData[iColor++];
var a = textureMapData[iColor++];
colors[iHeight * diffuseTexture.unWidth + iWidth] = new Color32(r, g, b, a);
}
}
texture.SetPixels32(colors);
texture.Apply();
}
else
{
texture.Apply();
while (true)
{
error = renderModels.LoadIntoTextureD3D11_Async(renderModel.diffuseTextureId, texture.GetNativeTexturePtr());
if (error != EVRRenderModelError.Loading)
break;
System.Threading.Thread.Sleep(1);
}
}
material = new Material(shader != null ? shader : Shader.Find("Standard"));
material.mainTexture = texture;
//material.hideFlags = HideFlags.DontUnloadUnusedAsset;
materials[renderModel.diffuseTextureId] = material;
renderModels.FreeTexture(pDiffuseTexture);
}
else
{
Debug.Log("Failed to load render model texture for render model " + renderModelName);
}
}
// Delay freeing when we can since we'll often get multiple requests for the same model right
// after another (e.g. two controllers or two basestations).
#if UNITY_EDITOR
if (!Application.isPlaying)
renderModels.FreeRenderModel(pRenderModel);
else
#endif
StartCoroutine(FreeRenderModel(pRenderModel));
return new RenderModel(mesh, material);
}
IEnumerator FreeRenderModel(System.IntPtr pRenderModel)
{
yield return new WaitForSeconds(1.0f);
using (var holder = new RenderModelInterfaceHolder())
{
var renderModels = holder.instance;
renderModels.FreeRenderModel(pRenderModel);
}
}
public Transform FindComponent(string componentName)
{
var t = transform;
for (int i = 0; i < t.childCount; i++)
{
var child = t.GetChild(i);
if (child.name == componentName)
return child;
}
return null;
}
private void StripMesh(GameObject go)
{
var meshRenderer = go.GetComponent<MeshRenderer>();
if (meshRenderer != null)
DestroyImmediate(meshRenderer);
var meshFilter = go.GetComponent<MeshFilter>();
if (meshFilter != null)
DestroyImmediate(meshFilter);
}
private bool LoadComponents(RenderModelInterfaceHolder holder, string renderModelName)
{
// Disable existing components (we will re-enable them if referenced by this new model).
// Also strip mesh filter and renderer since these will get re-added if the new component needs them.
var t = transform;
for (int i = 0; i < t.childCount; i++)
{
var child = t.GetChild(i);
child.gameObject.SetActive(false);
StripMesh(child.gameObject);
}
// If no model specified, we're done; return success.
if (string.IsNullOrEmpty(renderModelName))
return true;
var renderModels = holder.instance;
if (renderModels == null)
return false;
var count = renderModels.GetComponentCount(renderModelName);
if (count == 0)
return false;
for (int i = 0; i < count; i++)
{
var capacity = renderModels.GetComponentName(renderModelName, (uint)i, null, 0);
if (capacity == 0)
continue;
var componentName = new System.Text.StringBuilder((int)capacity);
if (renderModels.GetComponentName(renderModelName, (uint)i, componentName, capacity) == 0)
continue;
// Create (or reuse) a child object for this component (some components are dynamic and don't have meshes).
t = FindComponent(componentName.ToString());
if (t != null)
{
t.gameObject.SetActive(true);
}
else
{
t = new GameObject(componentName.ToString()).transform;
t.parent = transform;
t.gameObject.layer = gameObject.layer;
// Also create a child 'attach' object for attaching things.
var attach = new GameObject(k_localTransformName).transform;
attach.parent = t;
attach.localPosition = Vector3.zero;
attach.localRotation = Quaternion.identity;
attach.localScale = Vector3.one;
attach.gameObject.layer = gameObject.layer;
}
// Reset transform.
t.localPosition = Vector3.zero;
t.localRotation = Quaternion.identity;
t.localScale = Vector3.one;
capacity = renderModels.GetComponentRenderModelName(renderModelName, componentName.ToString(), null, 0);
if (capacity == 0)
continue;
var componentRenderModelName = new System.Text.StringBuilder((int)capacity);
if (renderModels.GetComponentRenderModelName(renderModelName, componentName.ToString(), componentRenderModelName, capacity) == 0)
continue;
// Check the cache or load into memory.
var model = models[componentRenderModelName] as RenderModel;
if (model == null || model.mesh == null)
{
if (verbose)
Debug.Log("Loading render model " + componentRenderModelName);
model = LoadRenderModel(renderModels, componentRenderModelName.ToString(), renderModelName);
if (model == null)
continue;
models[componentRenderModelName] = model;
}
t.gameObject.AddComponent<MeshFilter>().mesh = model.mesh;
t.gameObject.AddComponent<MeshRenderer>().sharedMaterial = model.material;
}
return true;
}
void OnEnable()
{
#if UNITY_EDITOR
if (!Application.isPlaying)
return;
#endif
if (!string.IsNullOrEmpty(modelOverride))
{
Debug.Log("Model override is really only meant to be used in the scene view for lining things up; using it at runtime is discouraged. Use tracked device index instead to ensure the correct model is displayed for all users.");
enabled = false;
return;
}
var system = OpenVR.System;
if (system != null && system.IsTrackedDeviceConnected((uint)index))
{
UpdateModel();
}
SteamVR_Utils.Event.Listen("device_connected", OnDeviceConnected);
SteamVR_Utils.Event.Listen("hide_render_models", OnHideRenderModels);
SteamVR_Utils.Event.Listen("ModelSkinSettingsHaveChanged", OnModelSkinSettingsHaveChanged);
}
void OnDisable()
{
#if UNITY_EDITOR
if (!Application.isPlaying)
return;
#endif
SteamVR_Utils.Event.Remove("device_connected", OnDeviceConnected);
SteamVR_Utils.Event.Remove("hide_render_models", OnHideRenderModels);
SteamVR_Utils.Event.Remove("ModelSkinSettingsHaveChanged", OnModelSkinSettingsHaveChanged);
}
#if UNITY_EDITOR
Hashtable values;
#endif
void Update()
{
#if UNITY_EDITOR
if (!Application.isPlaying)
{
// See if anything has changed since this gets called whenever anything gets touched.
var fields = GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public);
bool modified = false;
if (values == null)
{
modified = true;
}
else
{
foreach (var f in fields)
{
if (!values.Contains(f))
{
modified = true;
break;
}
var v0 = values[f];
var v1 = f.GetValue(this);
if (v1 != null)
{
if (!v1.Equals(v0))
{
modified = true;
break;
}
}
else if (v0 != null)
{
modified = true;
break;
}
}
}
if (modified)
{
if (renderModelName != modelOverride)
{
renderModelName = modelOverride;
SetModel(modelOverride);
}
values = new Hashtable();
foreach (var f in fields)
values[f] = f.GetValue(this);
}
return; // Do not update transforms (below) when not playing in Editor (to avoid keeping OpenVR running all the time).
}
#endif
// Update component transforms dynamically.
if (updateDynamically)
UpdateComponents();
}
public void UpdateComponents()
{
var t = transform;
if (t.childCount == 0)
return;
using (var holder = new RenderModelInterfaceHolder())
{
var controllerState = (index != SteamVR_TrackedObject.EIndex.None) ?
SteamVR_Controller.Input((int)index).GetState() : new VRControllerState_t();
for (int i = 0; i < t.childCount; i++)
{
var child = t.GetChild(i);
var renderModels = holder.instance;
if (renderModels == null)
break;
var componentState = new RenderModel_ComponentState_t();
if (!renderModels.GetComponentState(renderModelName, child.name, ref controllerState, ref controllerModeState, ref componentState))
continue;
var componentTransform = new SteamVR_Utils.RigidTransform(componentState.mTrackingToComponentRenderModel);
child.localPosition = componentTransform.pos;
child.localRotation = componentTransform.rot;
var attach = child.FindChild(k_localTransformName);
if (attach != null)
{
var attachTransform = new SteamVR_Utils.RigidTransform(componentState.mTrackingToComponentLocal);
attach.position = t.TransformPoint(attachTransform.pos);
attach.rotation = t.rotation * attachTransform.rot;
}
bool visible = (componentState.uProperties & (uint)EVRComponentProperty.IsVisible) != 0;
if (visible != child.gameObject.activeSelf)
{
child.gameObject.SetActive(visible);
}
}
}
}
public void SetDeviceIndex(int index)
{
this.index = (SteamVR_TrackedObject.EIndex)index;
modelOverride = "";
if (enabled)
{
UpdateModel();
}
}
}
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5890e3cad70bea64d91aef9145ba3454
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
+116
View File
@@ -0,0 +1,116 @@
//========= Copyright 2015, Valve Corporation, All rights reserved. ===========
//
// Purpose: Sets cubemap to use in the compositor.
//
//=============================================================================
using UnityEngine;
using Valve.VR;
public class SteamVR_Skybox : MonoBehaviour
{
// Note: Unity's Left and Right Skybox shader variables are switched.
public Texture front, back, left, right, top, bottom;
public enum CellSize
{
x1024, x64, x32, x16, x8
}
public CellSize StereoCellSize = CellSize.x32;
public float StereoIpdMm = 64.0f;
public void SetTextureByIndex(int i, Texture t)
{
switch (i)
{
case 0:
front = t;
break;
case 1:
back = t;
break;
case 2:
left = t;
break;
case 3:
right = t;
break;
case 4:
top = t;
break;
case 5:
bottom = t;
break;
}
}
public Texture GetTextureByIndex(int i)
{
switch (i)
{
case 0:
return front;
case 1:
return back;
case 2:
return left;
case 3:
return right;
case 4:
return top;
case 5:
return bottom;
}
return null;
}
static public void SetOverride(
Texture front = null,
Texture back = null,
Texture left = null,
Texture right = null,
Texture top = null,
Texture bottom = null )
{
var compositor = OpenVR.Compositor;
if (compositor != null)
{
var handles = new Texture[] { front, back, left, right, top, bottom };
var textures = new Texture_t[6];
for (int i = 0; i < 6; i++)
{
textures[i].handle = (handles[i] != null) ? handles[i].GetNativeTexturePtr() : System.IntPtr.Zero;
textures[i].eType = SteamVR.instance.graphicsAPI;
textures[i].eColorSpace = EColorSpace.Auto;
}
var error = compositor.SetSkyboxOverride(textures);
if (error != EVRCompositorError.None)
{
Debug.LogError("Failed to set skybox override with error: " + error);
if (error == EVRCompositorError.TextureIsOnWrongDevice)
Debug.Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity.");
else if (error == EVRCompositorError.TextureUsesUnsupportedFormat)
Debug.Log("Ensure skybox textures are not compressed and have no mipmaps.");
}
}
}
static public void ClearOverride()
{
var compositor = OpenVR.Compositor;
if (compositor != null)
compositor.ClearSkyboxOverride();
}
void OnEnable()
{
SetOverride(front, back, left, right, top, bottom);
}
void OnDisable()
{
ClearOverride();
}
}
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 13a43e992568b8e48b4bd489b9d96f40
timeCreated: 1439344311
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+40
View File
@@ -0,0 +1,40 @@
//========= Copyright 2016, Valve Corporation, All rights reserved. ===========
//
// Purpose: Applies spherical projection to output.
//
//=============================================================================
using UnityEngine;
[ExecuteInEditMode]
public class SteamVR_SphericalProjection : MonoBehaviour
{
static Material material;
public void Set(Vector3 N,
float phi0, float phi1, float theta0, float theta1, // in degrees
Vector3 uAxis, Vector3 uOrigin, float uScale,
Vector3 vAxis, Vector3 vOrigin, float vScale)
{
if (material == null)
material = new Material(Shader.Find("Custom/SteamVR_SphericalProjection"));
material.SetVector("_N", new Vector4(N.x, N.y, N.z));
material.SetFloat("_Phi0", phi0 * Mathf.Deg2Rad);
material.SetFloat("_Phi1", phi1 * Mathf.Deg2Rad);
material.SetFloat("_Theta0", theta0 * Mathf.Deg2Rad + Mathf.PI / 2);
material.SetFloat("_Theta1", theta1 * Mathf.Deg2Rad + Mathf.PI / 2);
material.SetVector("_UAxis", uAxis);
material.SetVector("_VAxis", vAxis);
material.SetVector("_UOrigin", uOrigin);
material.SetVector("_VOrigin", vOrigin);
material.SetFloat("_UScale", uScale);
material.SetFloat("_VScale", vScale);
}
void OnRenderImage(RenderTexture src, RenderTexture dest)
{
Graphics.Blit(src, dest, material);
}
}

Some files were not shown because too many files have changed in this diff Show More