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: 35f24737e2be3254294c49e1f383a8c2
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+17
View File
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: ea4b2adf1264c404281aff8c04b269eb
folderAsset: yes
timeCreated: 1463532356
licenseType: Free
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a810837989e35734b968e2f09f53a163
folderAsset: yes
timeCreated: 1463532356
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+42
View File
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>13F1077</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>openvr_api</string>
<key>CFBundleIdentifier</key>
<string>com.valvesoftware.openvr-api</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>openvr_api</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>6A1052d</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>14A382</string>
<key>DTSDKName</key>
<string>macosx10.10</string>
<key>DTXcode</key>
<string>0610</string>
<key>DTXcodeBuild</key>
<string>6A1052d</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Valve Corporation. All rights reserved.</string>
</dict>
</plist>
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7312850033767144bb8b56eac9e62164
timeCreated: 1438824914
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 90d343df4ddf4d3468418f0e523e6c29
folderAsset: yes
timeCreated: 1463532356
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4336b0f89b9f24808bfc781a1e52b6f0
timeCreated: 1438825138
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+3744
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8d26b9eddedb33d48be044bb268a57c7
timeCreated: 1429123043
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a5c3b129d3d9a0742ad5e46a72c14422
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+53
View File
@@ -0,0 +1,53 @@
fileFormatVersion: 2
guid: 64b48e8bdcc9e0541aa902936def9faa
timeCreated: 1463158122
licenseType: Store
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 1
settings: {}
Editor:
enabled: 0
settings:
CPU: x86
DefaultValueInitialized: true
Linux:
enabled: 1
settings:
CPU: x86
Linux64:
enabled: 0
settings:
CPU: None
LinuxUniversal:
enabled: 0
settings:
CPU: x86
OSXIntel:
enabled: 1
settings:
CPU: AnyCPU
OSXIntel64:
enabled: 0
settings:
CPU: None
OSXUniversal:
enabled: 0
settings:
CPU: x86
Win:
enabled: 1
settings:
CPU: AnyCPU
Win64:
enabled: 0
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:
BIN
View File
Binary file not shown.
+30
View File
@@ -0,0 +1,30 @@
fileFormatVersion: 2
guid: 73d5d79effb76f84491567f3c473b810
timeCreated: 1429123045
licenseType: Store
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: x86
DefaultValueInitialized: true
OS: Windows
Win:
enabled: 1
settings:
CPU: AnyCPU
Win64:
enabled: 1
settings:
CPU: None
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 773cb752a1b9ec1418ee0e93b926424a
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+76
View File
@@ -0,0 +1,76 @@
fileFormatVersion: 2
guid: d4aa343e31277cd45b2c3096d3318b90
timeCreated: 1457668425
licenseType: Store
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Android:
enabled: 0
settings:
CPU: AnyCPU
Any:
enabled: 0
settings: {}
Editor:
enabled: 0
settings:
CPU: x86_64
DefaultValueInitialized: true
OS: AnyOS
Linux:
enabled: 1
settings:
CPU: None
Linux64:
enabled: 1
settings:
CPU: x86_64
LinuxUniversal:
enabled: 1
settings:
CPU: x86_64
OSXIntel:
enabled: 1
settings:
CPU: None
OSXIntel64:
enabled: 1
settings:
CPU: None
OSXUniversal:
enabled: 1
settings:
CPU: None
WP8:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath:
Win:
enabled: 1
settings:
CPU: None
Win64:
enabled: 1
settings:
CPU: AnyCPU
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath:
SDK: AnySDK
iOS:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
+30
View File
@@ -0,0 +1,30 @@
fileFormatVersion: 2
guid: 9d42e4d46d897b648a1d6ed58a18e8a6
timeCreated: 1429123045
licenseType: Store
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
CPU: x86_64
DefaultValueInitialized: true
OS: Windows
Win:
enabled: 1
settings:
CPU: None
Win64:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+9
View File
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3a38812fdf982e049b19da282af16223
folderAsset: yes
timeCreated: 1463532355
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
+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:

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