├── .gitignore ├── Assets ├── Prefabs.meta ├── Prefabs │ ├── InternetManager.prefab │ ├── InternetManager.prefab.meta │ ├── LocalNetworkManager.prefab │ ├── LocalNetworkManager.prefab.meta │ ├── VRPawn.prefab │ └── VRPawn.prefab.meta ├── Scenes.meta ├── Scenes │ ├── Internet.unity │ ├── Internet.unity.meta │ ├── LocalNetwork.unity │ └── LocalNetwork.unity.meta ├── Scripts.meta ├── Scripts │ ├── CustomNetworkDiscovery.cs │ ├── CustomNetworkDiscovery.cs.meta │ ├── InternetManager.cs │ ├── InternetManager.cs.meta │ ├── LocalNetworkManager.cs │ ├── LocalNetworkManager.cs.meta │ ├── VRPawn.cs │ └── VRPawn.cs.meta ├── SteamVR.meta └── SteamVR │ ├── Editor.meta │ ├── Editor │ ├── SteamVR_Editor.cs │ ├── SteamVR_Editor.cs.meta │ ├── SteamVR_Preferences.cs │ ├── SteamVR_Preferences.cs.meta │ ├── SteamVR_RenderModelEditor.cs │ ├── SteamVR_RenderModelEditor.cs.meta │ ├── SteamVR_Settings.cs │ ├── SteamVR_Settings.cs.meta │ ├── SteamVR_SkyboxEditor.cs │ ├── SteamVR_SkyboxEditor.cs.meta │ ├── SteamVR_Update.cs │ └── SteamVR_Update.cs.meta │ ├── Materials.meta │ ├── Materials │ ├── workshop.mat │ └── workshop.mat.meta │ ├── Plugins.meta │ ├── Plugins │ ├── openvr_api.cs │ └── openvr_api.cs.meta │ ├── Prefabs.meta │ ├── Prefabs │ ├── [CameraRig].prefab │ ├── [CameraRig].prefab.meta │ ├── [Status].prefab │ ├── [Status].prefab.meta │ ├── [SteamVR].prefab │ └── [SteamVR].prefab.meta │ ├── Resources.meta │ ├── Resources │ ├── SteamVR_AlphaOut.shader │ ├── SteamVR_AlphaOut.shader.meta │ ├── SteamVR_ClearAll.shader │ ├── SteamVR_ClearAll.shader.meta │ ├── SteamVR_ColorOut.shader │ ├── SteamVR_ColorOut.shader.meta │ ├── SteamVR_ExternalCamera.prefab │ ├── SteamVR_ExternalCamera.prefab.meta │ ├── SteamVR_Fade.shader │ ├── SteamVR_Fade.shader.meta │ ├── SteamVR_SphericalProjection.shader │ └── SteamVR_SphericalProjection.shader.meta │ ├── Scripts.meta │ ├── Scripts │ ├── SteamVR.cs │ ├── SteamVR.cs.meta │ ├── SteamVR_Camera.cs │ ├── SteamVR_Camera.cs.meta │ ├── SteamVR_CameraFlip.cs │ ├── SteamVR_CameraFlip.cs.meta │ ├── SteamVR_CameraMask.cs │ ├── SteamVR_CameraMask.cs.meta │ ├── SteamVR_Controller.cs │ ├── SteamVR_Controller.cs.meta │ ├── SteamVR_ControllerManager.cs │ ├── SteamVR_ControllerManager.cs.meta │ ├── SteamVR_Ears.cs │ ├── SteamVR_Ears.cs.meta │ ├── SteamVR_Events.cs │ ├── SteamVR_Events.cs.meta │ ├── SteamVR_ExternalCamera.cs │ ├── SteamVR_ExternalCamera.cs.meta │ ├── SteamVR_Fade.cs │ ├── SteamVR_Fade.cs.meta │ ├── SteamVR_Frustum.cs │ ├── SteamVR_Frustum.cs.meta │ ├── SteamVR_GameView.cs │ ├── SteamVR_GameView.cs.meta │ ├── SteamVR_IK.cs │ ├── SteamVR_IK.cs.meta │ ├── SteamVR_LoadLevel.cs │ ├── SteamVR_LoadLevel.cs.meta │ ├── SteamVR_Menu.cs │ ├── SteamVR_Menu.cs.meta │ ├── SteamVR_Overlay.cs │ ├── SteamVR_Overlay.cs.meta │ ├── SteamVR_PlayArea.cs │ ├── SteamVR_PlayArea.cs.meta │ ├── SteamVR_Render.cs │ ├── SteamVR_Render.cs.meta │ ├── SteamVR_RenderModel.cs │ ├── SteamVR_RenderModel.cs.meta │ ├── SteamVR_Skybox.cs │ ├── SteamVR_Skybox.cs.meta │ ├── SteamVR_SphericalProjection.cs │ ├── SteamVR_SphericalProjection.cs.meta │ ├── SteamVR_Stats.cs │ ├── SteamVR_Stats.cs.meta │ ├── SteamVR_TestController.cs │ ├── SteamVR_TestController.cs.meta │ ├── SteamVR_TrackedCamera.cs │ ├── SteamVR_TrackedCamera.cs.meta │ ├── SteamVR_TrackedObject.cs │ ├── SteamVR_TrackedObject.cs.meta │ ├── SteamVR_UpdatePoses.cs │ ├── SteamVR_UpdatePoses.cs.meta │ ├── SteamVR_Utils.cs │ └── SteamVR_Utils.cs.meta │ ├── Textures.meta │ ├── Textures │ ├── arrow.png │ ├── arrow.png.meta │ ├── background.png │ ├── background.png.meta │ ├── logo.png │ ├── logo.png.meta │ ├── overlay.renderTexture │ ├── overlay.renderTexture.meta │ ├── workshop.png │ └── workshop.png.meta │ ├── quickstart.pdf │ ├── quickstart.pdf.meta │ ├── readme.txt │ └── readme.txt.meta ├── LICENCE.txt ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | Temp/ 5 | Obj/ 6 | UnityGenerated/ 7 | Library/ 8 | 9 | # ===================================== # 10 | # Visual Studio / MonoDevelop generated # 11 | # ===================================== # 12 | ExportedObj/ 13 | *.svd 14 | *.userprefs 15 | *.csproj 16 | *.pidb 17 | *.suo 18 | *.sln 19 | *.user 20 | *.unityproj 21 | *.booproj 22 | 23 | # ============ # 24 | # OS generated # 25 | # ============ # 26 | .DS_Store 27 | .DS_Store? 28 | ._* 29 | .Spotlight-V100 30 | .Trashes 31 | Icon? 32 | ehthumbs.db 33 | Thumbs.db\ 34 | 35 | 36 | -------------------------------------------------------------------------------- /Assets/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5205557634cf01e4698b03ef81817ef6 3 | folderAsset: yes 4 | timeCreated: 1456787163 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Prefabs/InternetManager.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &124848 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 439066} 11 | - 114: {fileID: 11420786} 12 | m_Layer: 0 13 | m_Name: InternetManager 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!4 &439066 20 | Transform: 21 | m_ObjectHideFlags: 1 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | m_GameObject: {fileID: 124848} 25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 26 | m_LocalPosition: {x: 0, y: 0, z: 0} 27 | m_LocalScale: {x: 1, y: 1, z: 1} 28 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 29 | m_Children: [] 30 | m_Father: {fileID: 0} 31 | m_RootOrder: 0 32 | --- !u!114 &11420786 33 | MonoBehaviour: 34 | m_ObjectHideFlags: 1 35 | m_PrefabParentObject: {fileID: 0} 36 | m_PrefabInternal: {fileID: 100100000} 37 | m_GameObject: {fileID: 124848} 38 | m_Enabled: 1 39 | m_EditorHideFlags: 0 40 | m_Script: {fileID: 11500000, guid: 44ab48e658675c445ae25aace257926d, type: 3} 41 | m_Name: 42 | m_EditorClassIdentifier: 43 | m_NetworkPort: 7777 44 | m_ServerBindToIP: 0 45 | m_ServerBindAddress: 46 | m_NetworkAddress: localhost 47 | m_DontDestroyOnLoad: 1 48 | m_RunInBackground: 1 49 | m_ScriptCRCCheck: 1 50 | m_MaxDelay: 0.01 51 | m_LogLevel: 2 52 | m_PlayerPrefab: {fileID: 102416, guid: fb2bfd38b7b2afd428c39252593456e9, type: 2} 53 | m_AutoCreatePlayer: 1 54 | m_PlayerSpawnMethod: 0 55 | m_OfflineScene: 56 | m_OnlineScene: 57 | m_SpawnPrefabs: [] 58 | m_CustomConfig: 0 59 | m_MaxConnections: 4 60 | m_ConnectionConfig: 61 | m_PacketSize: 1500 62 | m_FragmentSize: 500 63 | m_ResendTimeout: 1200 64 | m_DisconnectTimeout: 2000 65 | m_ConnectTimeout: 2000 66 | m_MinUpdateTimeout: 10 67 | m_PingTimeout: 500 68 | m_ReducedPingTimeout: 100 69 | m_AllCostTimeout: 20 70 | m_NetworkDropThreshold: 5 71 | m_OverflowDropThreshold: 5 72 | m_MaxConnectionAttempt: 10 73 | m_AckDelay: 33 74 | m_MaxCombinedReliableMessageSize: 100 75 | m_MaxCombinedReliableMessageCount: 10 76 | m_MaxSentMessageQueueSize: 128 77 | m_IsAcksLong: 0 78 | m_UsePlatformSpecificProtocols: 0 79 | m_WebSocketReceiveBufferMaxSize: 0 80 | m_Channels: [] 81 | m_GlobalConfig: 82 | m_ThreadAwakeTimeout: 1 83 | m_ReactorModel: 0 84 | m_ReactorMaximumReceivedMessages: 1024 85 | m_ReactorMaximumSentMessages: 1024 86 | m_MaxPacketSize: 2000 87 | m_Channels: 0500000000000000 88 | m_UseWebSockets: 0 89 | m_UseSimulator: 0 90 | m_SimulatedLatency: 1 91 | m_PacketLossPercentage: 0 92 | m_MaxBufferedPackets: 16 93 | m_AllowFragmentation: 1 94 | m_MatchHost: mm.unet.unity3d.com 95 | m_MatchPort: 443 96 | matchName: default 97 | matchSize: 4 98 | isNetworkActive: 0 99 | matchMaker: {fileID: 0} 100 | CreateRoom: 0 101 | RoomName: room1 102 | --- !u!1001 &100100000 103 | Prefab: 104 | m_ObjectHideFlags: 1 105 | serializedVersion: 2 106 | m_Modification: 107 | m_TransformParent: {fileID: 0} 108 | m_Modifications: [] 109 | m_RemovedComponents: [] 110 | m_ParentPrefab: {fileID: 0} 111 | m_RootGameObject: {fileID: 124848} 112 | m_IsPrefabParent: 1 113 | -------------------------------------------------------------------------------- /Assets/Prefabs/InternetManager.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 101de9bf5b2f7394a9af421e496a4e25 3 | timeCreated: 1459176008 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Prefabs/LocalNetworkManager.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &193614 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 477486} 11 | - 114: {fileID: 11418718} 12 | - 114: {fileID: 11434398} 13 | m_Layer: 0 14 | m_Name: LocalNetworkManager 15 | m_TagString: Untagged 16 | m_Icon: {fileID: 0} 17 | m_NavMeshLayer: 0 18 | m_StaticEditorFlags: 0 19 | m_IsActive: 1 20 | --- !u!4 &477486 21 | Transform: 22 | m_ObjectHideFlags: 1 23 | m_PrefabParentObject: {fileID: 0} 24 | m_PrefabInternal: {fileID: 100100000} 25 | m_GameObject: {fileID: 193614} 26 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 27 | m_LocalPosition: {x: 0, y: 0, z: 0} 28 | m_LocalScale: {x: 1, y: 1, z: 1} 29 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 30 | m_Children: [] 31 | m_Father: {fileID: 0} 32 | m_RootOrder: 0 33 | --- !u!114 &11418718 34 | MonoBehaviour: 35 | m_ObjectHideFlags: 1 36 | m_PrefabParentObject: {fileID: 0} 37 | m_PrefabInternal: {fileID: 100100000} 38 | m_GameObject: {fileID: 193614} 39 | m_Enabled: 1 40 | m_EditorHideFlags: 0 41 | m_Script: {fileID: 11500000, guid: 2b4d769fe6bf89945958710579d005a3, type: 3} 42 | m_Name: 43 | m_EditorClassIdentifier: 44 | m_NetworkPort: 7777 45 | m_ServerBindToIP: 0 46 | m_ServerBindAddress: 47 | m_NetworkAddress: localhost 48 | m_DontDestroyOnLoad: 1 49 | m_RunInBackground: 1 50 | m_ScriptCRCCheck: 1 51 | m_MaxDelay: 0.01 52 | m_LogLevel: 2 53 | m_PlayerPrefab: {fileID: 102416, guid: fb2bfd38b7b2afd428c39252593456e9, type: 2} 54 | m_AutoCreatePlayer: 1 55 | m_PlayerSpawnMethod: 0 56 | m_OfflineScene: 57 | m_OnlineScene: 58 | m_SpawnPrefabs: [] 59 | m_CustomConfig: 0 60 | m_MaxConnections: 4 61 | m_ConnectionConfig: 62 | m_PacketSize: 1500 63 | m_FragmentSize: 500 64 | m_ResendTimeout: 1200 65 | m_DisconnectTimeout: 2000 66 | m_ConnectTimeout: 2000 67 | m_MinUpdateTimeout: 10 68 | m_PingTimeout: 500 69 | m_ReducedPingTimeout: 100 70 | m_AllCostTimeout: 20 71 | m_NetworkDropThreshold: 5 72 | m_OverflowDropThreshold: 5 73 | m_MaxConnectionAttempt: 10 74 | m_AckDelay: 33 75 | m_MaxCombinedReliableMessageSize: 100 76 | m_MaxCombinedReliableMessageCount: 10 77 | m_MaxSentMessageQueueSize: 128 78 | m_IsAcksLong: 0 79 | m_UsePlatformSpecificProtocols: 0 80 | m_WebSocketReceiveBufferMaxSize: 0 81 | m_Channels: [] 82 | m_GlobalConfig: 83 | m_ThreadAwakeTimeout: 1 84 | m_ReactorModel: 0 85 | m_ReactorMaximumReceivedMessages: 1024 86 | m_ReactorMaximumSentMessages: 1024 87 | m_MaxPacketSize: 2000 88 | m_Channels: 89 | m_UseWebSockets: 0 90 | m_UseSimulator: 0 91 | m_SimulatedLatency: 1 92 | m_PacketLossPercentage: 0 93 | m_MaxBufferedPackets: 16 94 | m_AllowFragmentation: 1 95 | m_MatchHost: mm.unet.unity3d.com 96 | m_MatchPort: 443 97 | matchName: default 98 | matchSize: 4 99 | isNetworkActive: 0 100 | matchMaker: {fileID: 0} 101 | runAsServer: 0 102 | --- !u!114 &11434398 103 | MonoBehaviour: 104 | m_ObjectHideFlags: 1 105 | m_PrefabParentObject: {fileID: 0} 106 | m_PrefabInternal: {fileID: 100100000} 107 | m_GameObject: {fileID: 193614} 108 | m_Enabled: 1 109 | m_EditorHideFlags: 0 110 | m_Script: {fileID: 11500000, guid: 24a31f5f19229444b99baad298d62475, type: 3} 111 | m_Name: 112 | m_EditorClassIdentifier: 113 | m_BroadcastPort: 47777 114 | m_BroadcastKey: 2222 115 | m_BroadcastVersion: 1 116 | m_BroadcastSubVersion: 1 117 | m_BroadcastInterval: 1000 118 | m_UseNetworkManager: 1 119 | m_BroadcastData: HELLO 120 | m_ShowGUI: 0 121 | m_OffsetX: 0 122 | m_OffsetY: 0 123 | --- !u!1001 &100100000 124 | Prefab: 125 | m_ObjectHideFlags: 1 126 | serializedVersion: 2 127 | m_Modification: 128 | m_TransformParent: {fileID: 0} 129 | m_Modifications: [] 130 | m_RemovedComponents: [] 131 | m_ParentPrefab: {fileID: 0} 132 | m_RootGameObject: {fileID: 193614} 133 | m_IsPrefabParent: 1 134 | -------------------------------------------------------------------------------- /Assets/Prefabs/LocalNetworkManager.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdd03d2b1d937894da576570fded8115 3 | timeCreated: 1459167904 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Prefabs/VRPawn.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb2bfd38b7b2afd428c39252593456e9 3 | timeCreated: 1456787170 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28fb757423b0ee345a18250287adea1d 3 | folderAsset: yes 4 | timeCreated: 1456786060 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scenes/Internet.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0cd1ce38a0229a548bceab33ad3d1358 3 | timeCreated: 1459167991 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/LocalNetwork.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2a210a1f1708de42aad84bc8fb1038a 3 | timeCreated: 1459167936 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7a11811e939a3e40b1f1794056ce23e 3 | folderAsset: yes 4 | timeCreated: 1456787914 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scripts/CustomNetworkDiscovery.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Networking; 3 | using System.Collections; 4 | 5 | public class CustomNetworkDiscovery : NetworkDiscovery { 6 | 7 | public delegate void BroadcastEvent(string fromAddress, string data); 8 | 9 | public event BroadcastEvent OnReceivedNetworkBroadcast = delegate { }; 10 | 11 | override public void OnReceivedBroadcast(string fromAddress, string data) 12 | { 13 | OnReceivedNetworkBroadcast(fromAddress, data); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Scripts/CustomNetworkDiscovery.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24a31f5f19229444b99baad298d62475 3 | timeCreated: 1456788003 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/InternetManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine.Networking; 5 | using UnityEngine.Networking.Match; 6 | 7 | public class InternetManager : NetworkManager 8 | { 9 | public bool CreateRoom = false; 10 | public string RoomName = "room1"; 11 | 12 | public void Start () { 13 | 14 | StartMatchMaker(); 15 | 16 | if (CreateRoom) 17 | { 18 | CreateMatch(RoomName); 19 | } else 20 | { 21 | matchMaker.ListMatches(0, 20, "", true, 0, 0, OnMatchList); 22 | } 23 | 24 | } 25 | 26 | void CreateMatch(string newMatchName) 27 | { 28 | matchName = newMatchName; 29 | matchMaker.CreateMatch(matchName, 2, true, "", "", "", 0, 0, OnMatchCreate); 30 | } 31 | 32 | void JoinMatch(MatchInfoSnapshot match) 33 | { 34 | matchName = match.name; 35 | matchSize = (uint)match.currentSize; 36 | matchMaker.JoinMatch(match.networkId, "", "","", 0, 0, OnMatchJoined); 37 | } 38 | 39 | override public void OnMatchList(bool success, string extendedInfo, List matchList) { 40 | 41 | base.OnMatchList(success, extendedInfo, matchList); 42 | 43 | // auto join room if found 44 | foreach (MatchInfoSnapshot match in matchList) 45 | { 46 | if (match.name == RoomName) 47 | { 48 | JoinMatch(match); 49 | return; 50 | } 51 | } 52 | 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Assets/Scripts/InternetManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44ab48e658675c445ae25aace257926d 3 | timeCreated: 1459171529 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/LocalNetworkManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Networking; 3 | using System.Collections; 4 | 5 | public class LocalNetworkManager : NetworkManager { 6 | 7 | public bool runAsServer = true; 8 | 9 | private CustomNetworkDiscovery netDiscovery; 10 | 11 | void Start () { 12 | 13 | netDiscovery = GetComponent(); 14 | netDiscovery.Initialize(); 15 | 16 | if (runAsServer) { 17 | SetupServer(); 18 | } else { 19 | SetupClient(); 20 | } 21 | } 22 | 23 | void netDiscovery_OnReceivedNetworkBroadcast(string fromAddress, string data) 24 | { 25 | Debug.Log("Received fromAddress:" + fromAddress); 26 | Debug.Log("Received data:" + data); 27 | 28 | networkAddress = fromAddress; 29 | StartClient(); 30 | netDiscovery.StopBroadcast(); 31 | } 32 | 33 | void SetupServer(){ 34 | 35 | networkAddress = "localhost"; 36 | StartHost(); 37 | 38 | netDiscovery.StartAsServer(); 39 | 40 | } 41 | 42 | void SetupClient(){ 43 | 44 | netDiscovery.OnReceivedNetworkBroadcast += netDiscovery_OnReceivedNetworkBroadcast; 45 | netDiscovery.StartAsClient(); 46 | } 47 | 48 | override public void OnClientDisconnect(NetworkConnection conn) 49 | { 50 | base.OnClientConnect(conn); 51 | 52 | StopClient(); 53 | enabled = false; 54 | netDiscovery.enabled = false; 55 | Invoke("ProcessDisconnect", 0.5f); 56 | } 57 | 58 | void ProcessDisconnect() 59 | { 60 | enabled = true; 61 | 62 | netDiscovery.enabled = true; 63 | netDiscovery.Initialize(); 64 | netDiscovery.StartAsClient(); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /Assets/Scripts/LocalNetworkManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b4d769fe6bf89945958710579d005a3 3 | timeCreated: 1456788003 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scripts/VRPawn.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Networking; 3 | using System.Collections; 4 | using System.Linq; 5 | 6 | public class VRPawn : NetworkBehaviour { 7 | 8 | public Transform Head; 9 | public Transform LeftController; 10 | public Transform RightController; 11 | 12 | 13 | void Start () { 14 | if (isLocalPlayer) { 15 | GetComponentInChildren().enabled = true; 16 | GetComponentsInChildren(true).ToList().ForEach(x => x.enabled = true); 17 | Head.GetComponentsInChildren(true).ToList().ForEach(x => x.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly); 18 | gameObject.name = "VRPawn (LocalPlayer)"; 19 | } else 20 | { 21 | gameObject.name = "VRPawn (RemotePlayer)"; 22 | } 23 | } 24 | 25 | void OnDestroy() 26 | { 27 | GetComponentInChildren().enabled = false; 28 | GetComponentsInChildren(true).ToList().ForEach(x => x.enabled = false); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Assets/Scripts/VRPawn.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 979158f32cf50434c906f0950a37d2d2 3 | timeCreated: 1456787914 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db4e9f1300d5d90479debdbec231eef7 3 | folderAsset: yes 4 | timeCreated: 1498163145 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c33af0785775d7548b22541da37936fe 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_Editor.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Custom inspector display for SteamVR_Camera 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using UnityEditor; 9 | using System.IO; 10 | 11 | [CustomEditor(typeof(SteamVR_Camera)), CanEditMultipleObjects] 12 | public class SteamVR_Editor : Editor 13 | { 14 | int bannerHeight = 150; 15 | Texture logo; 16 | 17 | SerializedProperty script, wireframe; 18 | 19 | string GetResourcePath() 20 | { 21 | var ms = MonoScript.FromScriptableObject(this); 22 | var path = AssetDatabase.GetAssetPath(ms); 23 | path = Path.GetDirectoryName(path); 24 | return path.Substring(0, path.Length - "Editor".Length) + "Textures/"; 25 | } 26 | 27 | void OnEnable() 28 | { 29 | var resourcePath = GetResourcePath(); 30 | 31 | logo = AssetDatabase.LoadAssetAtPath(resourcePath + "logo.png"); 32 | 33 | script = serializedObject.FindProperty("m_Script"); 34 | 35 | wireframe = serializedObject.FindProperty("wireframe"); 36 | 37 | foreach (SteamVR_Camera target in targets) 38 | target.ForceLast(); 39 | } 40 | 41 | public override void OnInspectorGUI() 42 | { 43 | serializedObject.Update(); 44 | 45 | var rect = GUILayoutUtility.GetRect(Screen.width - 38, bannerHeight, GUI.skin.box); 46 | if (logo) 47 | GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit); 48 | 49 | if (!Application.isPlaying) 50 | { 51 | var expand = false; 52 | var collapse = false; 53 | foreach (SteamVR_Camera target in targets) 54 | { 55 | if (AssetDatabase.Contains(target)) 56 | continue; 57 | if (target.isExpanded) 58 | collapse = true; 59 | else 60 | expand = true; 61 | } 62 | 63 | if (expand) 64 | { 65 | GUILayout.BeginHorizontal(); 66 | if (GUILayout.Button("Expand")) 67 | { 68 | foreach (SteamVR_Camera target in targets) 69 | { 70 | if (AssetDatabase.Contains(target)) 71 | continue; 72 | if (!target.isExpanded) 73 | { 74 | target.Expand(); 75 | EditorUtility.SetDirty(target); 76 | } 77 | } 78 | } 79 | GUILayout.Space(18); 80 | GUILayout.EndHorizontal(); 81 | } 82 | 83 | if (collapse) 84 | { 85 | GUILayout.BeginHorizontal(); 86 | if (GUILayout.Button("Collapse")) 87 | { 88 | foreach (SteamVR_Camera target in targets) 89 | { 90 | if (AssetDatabase.Contains(target)) 91 | continue; 92 | if (target.isExpanded) 93 | { 94 | target.Collapse(); 95 | EditorUtility.SetDirty(target); 96 | } 97 | } 98 | } 99 | GUILayout.Space(18); 100 | GUILayout.EndHorizontal(); 101 | } 102 | } 103 | 104 | EditorGUILayout.PropertyField(script); 105 | EditorGUILayout.PropertyField(wireframe); 106 | 107 | serializedObject.ApplyModifiedProperties(); 108 | } 109 | 110 | public static void ExportPackage() 111 | { 112 | AssetDatabase.ExportPackage(new string[] { 113 | "Assets/SteamVR", 114 | "Assets/Plugins/openvr_api.cs", 115 | "Assets/Plugins/openvr_api.bundle", 116 | "Assets/Plugins/x86/openvr_api.dll", 117 | "Assets/Plugins/x86/steam_api.dll", 118 | "Assets/Plugins/x86/libsteam_api.so", 119 | "Assets/Plugins/x86_64/openvr_api.dll", 120 | "Assets/Plugins/x86_64/steam_api.dll", 121 | "Assets/Plugins/x86_64/libsteam_api.so", 122 | "Assets/Plugins/x86_64/libopenvr_api.so", 123 | }, "steamvr.unitypackage", ExportPackageOptions.Recurse); 124 | EditorApplication.Exit(0); 125 | } 126 | } 127 | 128 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_Editor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ba22c80948c94e44a82b9fd1b3abd0d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_Preferences.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Preferences pane for how SteamVR plugin behaves. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using UnityEditor; 9 | 10 | public class SteamVR_Preferences 11 | { 12 | /// 13 | /// Should SteamVR automatically enable VR when opening Unity or pressing play. 14 | /// 15 | public static bool AutoEnableVR 16 | { 17 | get 18 | { 19 | return EditorPrefs.GetBool("SteamVR_AutoEnableVR", true); 20 | } 21 | set 22 | { 23 | EditorPrefs.SetBool("SteamVR_AutoEnableVR", value); 24 | } 25 | } 26 | 27 | [PreferenceItem("SteamVR")] 28 | static void PreferencesGUI() 29 | { 30 | EditorGUILayout.BeginVertical(); 31 | EditorGUILayout.Space(); 32 | 33 | // Automatically Enable VR 34 | { 35 | string title = "Automatically Enable VR"; 36 | string tooltip = "Should SteamVR automatically enable VR on launch and play?"; 37 | AutoEnableVR = EditorGUILayout.Toggle(new GUIContent(title, tooltip), AutoEnableVR); 38 | string helpMessage = "To enable VR manually:\n"; 39 | helpMessage += "- go to Edit -> Project Settings -> Player,\n"; 40 | helpMessage += "- tick 'Virtual Reality Supported',\n"; 41 | helpMessage += "- make sure OpenVR is in the 'Virtual Reality SDKs' list."; 42 | EditorGUILayout.HelpBox(helpMessage, MessageType.Info); 43 | } 44 | 45 | EditorGUILayout.EndVertical(); 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_Preferences.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29abf75f7265ccb45b799eac4ab0ca94 3 | timeCreated: 1487968203 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_RenderModelEditor.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Custom inspector display for SteamVR_RenderModel 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using UnityEditor; 9 | using System.Text; 10 | using System.Collections.Generic; 11 | using Valve.VR; 12 | 13 | [CustomEditor(typeof(SteamVR_RenderModel)), CanEditMultipleObjects] 14 | public class SteamVR_RenderModelEditor : Editor 15 | { 16 | SerializedProperty script, index, modelOverride, shader, verbose, createComponents, updateDynamically; 17 | 18 | static string[] renderModelNames; 19 | int renderModelIndex; 20 | 21 | void OnEnable() 22 | { 23 | script = serializedObject.FindProperty("m_Script"); 24 | index = serializedObject.FindProperty("index"); 25 | modelOverride = serializedObject.FindProperty("modelOverride"); 26 | shader = serializedObject.FindProperty("shader"); 27 | verbose = serializedObject.FindProperty("verbose"); 28 | createComponents = serializedObject.FindProperty("createComponents"); 29 | updateDynamically = serializedObject.FindProperty("updateDynamically"); 30 | 31 | // Load render model names if necessary. 32 | if (renderModelNames == null) 33 | { 34 | renderModelNames = LoadRenderModelNames(); 35 | } 36 | 37 | // Update renderModelIndex based on current modelOverride value. 38 | if (modelOverride.stringValue != "") 39 | { 40 | for (int i = 0; i < renderModelNames.Length; i++) 41 | { 42 | if (modelOverride.stringValue == renderModelNames[i]) 43 | { 44 | renderModelIndex = i; 45 | break; 46 | } 47 | } 48 | } 49 | } 50 | 51 | static string[] LoadRenderModelNames() 52 | { 53 | var results = new List(); 54 | results.Add("None"); 55 | 56 | using (var holder = new SteamVR_RenderModel.RenderModelInterfaceHolder()) 57 | { 58 | var renderModels = holder.instance; 59 | if (renderModels != null) 60 | { 61 | uint count = renderModels.GetRenderModelCount(); 62 | for (uint i = 0; i < count; i++) 63 | { 64 | var buffer = new StringBuilder(); 65 | var requiredSize = renderModels.GetRenderModelName(i, buffer, 0); 66 | if (requiredSize == 0) 67 | continue; 68 | 69 | buffer.EnsureCapacity((int)requiredSize); 70 | renderModels.GetRenderModelName(i, buffer, requiredSize); 71 | results.Add(buffer.ToString()); 72 | } 73 | } 74 | } 75 | 76 | return results.ToArray(); 77 | } 78 | 79 | public override void OnInspectorGUI() 80 | { 81 | serializedObject.Update(); 82 | 83 | EditorGUILayout.PropertyField(script); 84 | EditorGUILayout.PropertyField(index); 85 | //EditorGUILayout.PropertyField(modelOverride); 86 | 87 | GUILayout.BeginHorizontal(); 88 | GUILayout.Label("Model Override"); 89 | var selected = EditorGUILayout.Popup(renderModelIndex, renderModelNames); 90 | if (selected != renderModelIndex) 91 | { 92 | renderModelIndex = selected; 93 | modelOverride.stringValue = (selected > 0) ? renderModelNames[selected] : ""; 94 | } 95 | GUILayout.EndHorizontal(); 96 | 97 | EditorGUILayout.PropertyField(shader); 98 | EditorGUILayout.PropertyField(verbose); 99 | EditorGUILayout.PropertyField(createComponents); 100 | EditorGUILayout.PropertyField(updateDynamically); 101 | 102 | serializedObject.ApplyModifiedProperties(); 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_RenderModelEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67867a20919f7db45a2e7034fda1c28e 3 | timeCreated: 1433373945 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_Settings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2244eee8a3a4784fb40d1123ff69301 3 | timeCreated: 1438809573 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_SkyboxEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80087fbbf7bf93a46bb4aea276b19568 3 | timeCreated: 1446765449 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_Update.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Notify developers when a new version of the plugin is available. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using UnityEditor; 9 | using System.IO; 10 | using System.Text.RegularExpressions; 11 | 12 | [InitializeOnLoad] 13 | public class SteamVR_Update : EditorWindow 14 | { 15 | const string currentVersion = "1.2.1"; 16 | const string versionUrl = "http://media.steampowered.com/apps/steamvr/unitypluginversion.txt"; 17 | const string notesUrl = "http://media.steampowered.com/apps/steamvr/unityplugin-v{0}.txt"; 18 | const string pluginUrl = "http://u3d.as/content/valve-corporation/steam-vr-plugin"; 19 | const string doNotShowKey = "SteamVR.DoNotShow.v{0}"; 20 | 21 | static bool gotVersion = false; 22 | static WWW wwwVersion, wwwNotes; 23 | static string version, notes; 24 | static SteamVR_Update window; 25 | 26 | static SteamVR_Update() 27 | { 28 | EditorApplication.update += Update; 29 | } 30 | 31 | static void Update() 32 | { 33 | if (!gotVersion) 34 | { 35 | if (wwwVersion == null) 36 | wwwVersion = new WWW(versionUrl); 37 | 38 | if (!wwwVersion.isDone) 39 | return; 40 | 41 | if (UrlSuccess(wwwVersion)) 42 | version = wwwVersion.text; 43 | 44 | wwwVersion = null; 45 | gotVersion = true; 46 | 47 | if (ShouldDisplay()) 48 | { 49 | var url = string.Format(notesUrl, version); 50 | wwwNotes = new WWW(url); 51 | 52 | window = GetWindow(true); 53 | window.minSize = new Vector2(320, 440); 54 | //window.title = "SteamVR"; 55 | } 56 | } 57 | 58 | if (wwwNotes != null) 59 | { 60 | if (!wwwNotes.isDone) 61 | return; 62 | 63 | if (UrlSuccess(wwwNotes)) 64 | notes = wwwNotes.text; 65 | 66 | wwwNotes = null; 67 | 68 | if (notes != "") 69 | window.Repaint(); 70 | } 71 | 72 | EditorApplication.update -= Update; 73 | } 74 | 75 | static bool UrlSuccess(WWW www) 76 | { 77 | if (!string.IsNullOrEmpty(www.error)) 78 | return false; 79 | if (Regex.IsMatch(www.text, "404 not found", RegexOptions.IgnoreCase)) 80 | return false; 81 | return true; 82 | } 83 | 84 | static bool ShouldDisplay() 85 | { 86 | if (string.IsNullOrEmpty(version)) 87 | return false; 88 | if (version == currentVersion) 89 | return false; 90 | if (EditorPrefs.HasKey(string.Format(doNotShowKey, version))) 91 | return false; 92 | 93 | // parse to see if newer (e.g. 1.0.4 vs 1.0.3) 94 | var versionSplit = version.Split('.'); 95 | var currentVersionSplit = currentVersion.Split('.'); 96 | for (int i = 0; i < versionSplit.Length && i < currentVersionSplit.Length; i++) 97 | { 98 | int versionValue, currentVersionValue; 99 | if (int.TryParse(versionSplit[i], out versionValue) && 100 | int.TryParse(currentVersionSplit[i], out currentVersionValue)) 101 | { 102 | if (versionValue > currentVersionValue) 103 | return true; 104 | if (versionValue < currentVersionValue) 105 | return false; 106 | } 107 | } 108 | 109 | // same up to this point, now differentiate based on number of sub values (e.g. 1.0.4.1 vs 1.0.4) 110 | if (versionSplit.Length <= currentVersionSplit.Length) 111 | return false; 112 | 113 | return true; 114 | } 115 | 116 | Vector2 scrollPosition; 117 | bool toggleState; 118 | 119 | string GetResourcePath() 120 | { 121 | var ms = MonoScript.FromScriptableObject(this); 122 | var path = AssetDatabase.GetAssetPath(ms); 123 | path = Path.GetDirectoryName(path); 124 | return path.Substring(0, path.Length - "Editor".Length) + "Textures/"; 125 | } 126 | 127 | public void OnGUI() 128 | { 129 | EditorGUILayout.HelpBox("A new version of the SteamVR plugin is available!", MessageType.Warning); 130 | 131 | var resourcePath = GetResourcePath(); 132 | var logo = AssetDatabase.LoadAssetAtPath(resourcePath + "logo.png"); 133 | var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box); 134 | if (logo) 135 | GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit); 136 | 137 | scrollPosition = GUILayout.BeginScrollView(scrollPosition); 138 | 139 | GUILayout.Label("Current version: " + currentVersion); 140 | GUILayout.Label("New version: " + version); 141 | 142 | if (notes != "") 143 | { 144 | GUILayout.Label("Release notes:"); 145 | EditorGUILayout.HelpBox(notes, MessageType.Info); 146 | } 147 | 148 | GUILayout.EndScrollView(); 149 | 150 | GUILayout.FlexibleSpace(); 151 | 152 | if (GUILayout.Button("Get Latest Version")) 153 | { 154 | Application.OpenURL(pluginUrl); 155 | } 156 | 157 | EditorGUI.BeginChangeCheck(); 158 | var doNotShow = GUILayout.Toggle(toggleState, "Do not prompt for this version again."); 159 | if (EditorGUI.EndChangeCheck()) 160 | { 161 | toggleState = doNotShow; 162 | var key = string.Format(doNotShowKey, version); 163 | if (doNotShow) 164 | EditorPrefs.SetBool(key, true); 165 | else 166 | EditorPrefs.DeleteKey(key); 167 | } 168 | } 169 | } 170 | 171 | -------------------------------------------------------------------------------- /Assets/SteamVR/Editor/SteamVR_Update.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73a0556bda803bf4e898751dcfcf21a8 3 | timeCreated: 1433880062 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1459d94e0a5b7af4a8a3fa067ae575e9 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/SteamVR/Materials/workshop.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 5 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: workshop 10 | m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_CustomRenderQueue: -1 14 | m_SavedProperties: 15 | serializedVersion: 2 16 | m_TexEnvs: 17 | data: 18 | first: 19 | name: _MainTex 20 | second: 21 | m_Texture: {fileID: 2800000, guid: a57cd5c56c9d75c4ba0ee9fbc6e1d8df, type: 3} 22 | m_Scale: {x: 1, y: 1} 23 | m_Offset: {x: 0, y: 0} 24 | m_Floats: {} 25 | m_Colors: {} 26 | -------------------------------------------------------------------------------- /Assets/SteamVR/Materials/workshop.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 712cd3a70a5a1da41a6594aac6a97abe 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/SteamVR/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2a747d8f314a8449a70c1fb1807f8dd 3 | folderAsset: yes 4 | timeCreated: 1462480362 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Plugins/openvr_api.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d26b9eddedb33d48be044bb268a57c7 3 | timeCreated: 1429123043 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e2543c4beea3eb4e9ea1e02a4bc2df2 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/SteamVR/Prefabs/[CameraRig].prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d293c8e162f3874b982baadd71153d2 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/SteamVR/Prefabs/[Status].prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &100002 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 400002} 11 | - 20: {fileID: 2000000} 12 | - 92: {fileID: 9200000} 13 | - 132: {fileID: 13200002} 14 | - 114: {fileID: 11400002} 15 | - 114: {fileID: 11400004} 16 | m_Layer: 8 17 | m_Name: _Stats 18 | m_TagString: Untagged 19 | m_Icon: {fileID: 0} 20 | m_NavMeshLayer: 0 21 | m_StaticEditorFlags: 0 22 | m_IsActive: 1 23 | --- !u!1 &100008 24 | GameObject: 25 | m_ObjectHideFlags: 0 26 | m_PrefabParentObject: {fileID: 0} 27 | m_PrefabInternal: {fileID: 100100000} 28 | serializedVersion: 4 29 | m_Component: 30 | - 4: {fileID: 400008} 31 | m_Layer: 8 32 | m_Name: '[Status]' 33 | m_TagString: Untagged 34 | m_Icon: {fileID: 0} 35 | m_NavMeshLayer: 0 36 | m_StaticEditorFlags: 0 37 | m_IsActive: 1 38 | --- !u!1 &110680 39 | GameObject: 40 | m_ObjectHideFlags: 0 41 | m_PrefabParentObject: {fileID: 0} 42 | m_PrefabInternal: {fileID: 100100000} 43 | serializedVersion: 4 44 | m_Component: 45 | - 4: {fileID: 426596} 46 | - 114: {fileID: 11412486} 47 | m_Layer: 8 48 | m_Name: Overlay 49 | m_TagString: Untagged 50 | m_Icon: {fileID: 0} 51 | m_NavMeshLayer: 0 52 | m_StaticEditorFlags: 0 53 | m_IsActive: 1 54 | --- !u!4 &400002 55 | Transform: 56 | m_ObjectHideFlags: 1 57 | m_PrefabParentObject: {fileID: 0} 58 | m_PrefabInternal: {fileID: 100100000} 59 | m_GameObject: {fileID: 100002} 60 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 61 | m_LocalPosition: {x: 0.1, y: 0.75, z: 0} 62 | m_LocalScale: {x: 1, y: 1, z: 1} 63 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 64 | m_Children: [] 65 | m_Father: {fileID: 400008} 66 | m_RootOrder: 0 67 | --- !u!4 &400008 68 | Transform: 69 | m_ObjectHideFlags: 1 70 | m_PrefabParentObject: {fileID: 0} 71 | m_PrefabInternal: {fileID: 100100000} 72 | m_GameObject: {fileID: 100008} 73 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 74 | m_LocalPosition: {x: 0, y: 0, z: 0} 75 | m_LocalScale: {x: 1, y: 1, z: 1} 76 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 77 | m_Children: 78 | - {fileID: 400002} 79 | - {fileID: 426596} 80 | m_Father: {fileID: 0} 81 | m_RootOrder: 0 82 | --- !u!4 &426596 83 | Transform: 84 | m_ObjectHideFlags: 1 85 | m_PrefabParentObject: {fileID: 0} 86 | m_PrefabInternal: {fileID: 100100000} 87 | m_GameObject: {fileID: 110680} 88 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 89 | m_LocalPosition: {x: 0, y: 0, z: 0} 90 | m_LocalScale: {x: 1, y: 1, z: 1} 91 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 92 | m_Children: [] 93 | m_Father: {fileID: 400008} 94 | m_RootOrder: 1 95 | --- !u!20 &2000000 96 | Camera: 97 | m_ObjectHideFlags: 1 98 | m_PrefabParentObject: {fileID: 0} 99 | m_PrefabInternal: {fileID: 100100000} 100 | m_GameObject: {fileID: 100002} 101 | m_Enabled: 1 102 | serializedVersion: 2 103 | m_ClearFlags: 2 104 | m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} 105 | m_NormalizedViewPortRect: 106 | serializedVersion: 2 107 | x: 0 108 | y: 0 109 | width: 1 110 | height: 1 111 | near clip plane: 0.3 112 | far clip plane: 1000 113 | field of view: 60 114 | orthographic: 0 115 | orthographic size: 5 116 | m_Depth: -1 117 | m_CullingMask: 118 | serializedVersion: 2 119 | m_Bits: 256 120 | m_RenderingPath: -1 121 | m_TargetTexture: {fileID: 8400000, guid: 005ed5a6df2f5ff468efd6497d37fefa, type: 2} 122 | m_TargetDisplay: 0 123 | m_TargetEye: 3 124 | m_HDR: 0 125 | m_OcclusionCulling: 0 126 | m_StereoConvergence: 10 127 | m_StereoSeparation: 0.022 128 | m_StereoMirrorMode: 0 129 | --- !u!92 &9200000 130 | Behaviour: 131 | m_ObjectHideFlags: 1 132 | m_PrefabParentObject: {fileID: 0} 133 | m_PrefabInternal: {fileID: 100100000} 134 | m_GameObject: {fileID: 100002} 135 | m_Enabled: 1 136 | --- !u!114 &11400002 137 | MonoBehaviour: 138 | m_ObjectHideFlags: 1 139 | m_PrefabParentObject: {fileID: 0} 140 | m_PrefabInternal: {fileID: 100100000} 141 | m_GameObject: {fileID: 100002} 142 | m_Enabled: 1 143 | m_EditorHideFlags: 0 144 | m_Script: {fileID: 11500000, guid: 8c3faa610c019764a81eb8497109e2d4, type: 3} 145 | m_Name: 146 | m_EditorClassIdentifier: 147 | text: {fileID: 0} 148 | fadeColor: {r: 0, g: 0, b: 0, a: 1} 149 | fadeDuration: 1 150 | --- !u!114 &11400004 151 | MonoBehaviour: 152 | m_ObjectHideFlags: 1 153 | m_PrefabParentObject: {fileID: 0} 154 | m_PrefabInternal: {fileID: 100100000} 155 | m_GameObject: {fileID: 100002} 156 | m_Enabled: 1 157 | m_EditorHideFlags: 0 158 | m_Script: {fileID: 11500000, guid: e7afc8c74d1f73b458705e0b946292a0, type: 3} 159 | m_Name: 160 | m_EditorClassIdentifier: 161 | cursor: {fileID: 2800000, guid: 2db89a771043d7b4eb9d26622f6b97c7, type: 3} 162 | background: {fileID: 2800000, guid: bb00cc87e146a414fbf2c4d3c0d31151, type: 3} 163 | logo: {fileID: 2800000, guid: 09db43b3b77bf744287ba587fea02f8b, type: 3} 164 | logoHeight: 340 165 | menuOffset: 40 166 | scaleLimits: {x: 0.1, y: 5} 167 | scaleRate: 0.5 168 | --- !u!114 &11412486 169 | MonoBehaviour: 170 | m_ObjectHideFlags: 1 171 | m_PrefabParentObject: {fileID: 0} 172 | m_PrefabInternal: {fileID: 100100000} 173 | m_GameObject: {fileID: 110680} 174 | m_Enabled: 1 175 | m_EditorHideFlags: 0 176 | m_Script: {fileID: 11500000, guid: 46fe9e0b23166454c8cb73040321d78c, type: 3} 177 | m_Name: 178 | m_EditorClassIdentifier: 179 | texture: {fileID: 8400000, guid: 005ed5a6df2f5ff468efd6497d37fefa, type: 2} 180 | curved: 1 181 | antialias: 1 182 | highquality: 1 183 | scale: 3 184 | distance: 1.25 185 | alpha: 1 186 | uvOffset: {x: 0, y: 0, z: 1, w: 1} 187 | mouseScale: {x: 1, y: 1} 188 | curvedRange: {x: 1, y: 2} 189 | inputMethod: 0 190 | --- !u!132 &13200002 191 | GUIText: 192 | m_ObjectHideFlags: 1 193 | m_PrefabParentObject: {fileID: 0} 194 | m_PrefabInternal: {fileID: 100100000} 195 | m_GameObject: {fileID: 100002} 196 | m_Enabled: 1 197 | serializedVersion: 3 198 | m_Text: 199 | m_Anchor: 0 200 | m_Alignment: 0 201 | m_PixelOffset: {x: 0, y: 0} 202 | m_LineSpacing: 1 203 | m_TabSize: 4 204 | m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} 205 | m_Material: {fileID: 0} 206 | m_FontSize: 32 207 | m_FontStyle: 1 208 | m_Color: 209 | serializedVersion: 2 210 | rgba: 4278221311 211 | m_PixelCorrect: 1 212 | m_RichText: 1 213 | --- !u!1001 &100100000 214 | Prefab: 215 | m_ObjectHideFlags: 1 216 | serializedVersion: 2 217 | m_Modification: 218 | m_TransformParent: {fileID: 0} 219 | m_Modifications: [] 220 | m_RemovedComponents: [] 221 | m_ParentPrefab: {fileID: 0} 222 | m_RootGameObject: {fileID: 100008} 223 | m_IsPrefabParent: 1 224 | -------------------------------------------------------------------------------- /Assets/SteamVR/Prefabs/[Status].prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 255333d57084e4e46b3d948279746a47 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/SteamVR/Prefabs/[SteamVR].prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &132594 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 458990} 11 | - 114: {fileID: 11432822} 12 | m_Layer: 0 13 | m_Name: '[SteamVR]' 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!4 &458990 20 | Transform: 21 | m_ObjectHideFlags: 1 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | m_GameObject: {fileID: 132594} 25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 26 | m_LocalPosition: {x: 0, y: 0, z: 0} 27 | m_LocalScale: {x: 1, y: 1, z: 1} 28 | m_Children: [] 29 | m_Father: {fileID: 0} 30 | m_RootOrder: 0 31 | --- !u!114 &11432822 32 | MonoBehaviour: 33 | m_ObjectHideFlags: 1 34 | m_PrefabParentObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 132594} 37 | m_Enabled: 1 38 | m_EditorHideFlags: 0 39 | m_Script: {fileID: 11500000, guid: e979227f3384fac4b8ca0b3550bf005c, type: 3} 40 | m_Name: 41 | m_EditorClassIdentifier: 42 | helpSeconds: 10 43 | helpText: You may now put on your headset. 44 | helpStyle: 45 | m_Name: 46 | m_Normal: 47 | m_Background: {fileID: 0} 48 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 49 | m_Hover: 50 | m_Background: {fileID: 0} 51 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 52 | m_Active: 53 | m_Background: {fileID: 0} 54 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 55 | m_Focused: 56 | m_Background: {fileID: 0} 57 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 58 | m_OnNormal: 59 | m_Background: {fileID: 0} 60 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 61 | m_OnHover: 62 | m_Background: {fileID: 0} 63 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 64 | m_OnActive: 65 | m_Background: {fileID: 0} 66 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 67 | m_OnFocused: 68 | m_Background: {fileID: 0} 69 | m_TextColor: {r: 0, g: 0, b: 0, a: 1} 70 | m_Border: 71 | m_Left: 0 72 | m_Right: 0 73 | m_Top: 0 74 | m_Bottom: 0 75 | m_Margin: 76 | m_Left: 0 77 | m_Right: 0 78 | m_Top: 0 79 | m_Bottom: 0 80 | m_Padding: 81 | m_Left: 0 82 | m_Right: 0 83 | m_Top: 0 84 | m_Bottom: 0 85 | m_Overflow: 86 | m_Left: 0 87 | m_Right: 0 88 | m_Top: 0 89 | m_Bottom: 0 90 | m_Font: {fileID: 0} 91 | m_FontSize: 0 92 | m_FontStyle: 0 93 | m_Alignment: 0 94 | m_WordWrap: 0 95 | m_RichText: 1 96 | m_TextClipping: 0 97 | m_ImagePosition: 0 98 | m_ContentOffset: {x: 0, y: 0} 99 | m_FixedWidth: 0 100 | m_FixedHeight: 0 101 | m_StretchWidth: 1 102 | m_StretchHeight: 0 103 | leftMask: 104 | serializedVersion: 2 105 | m_Bits: 0 106 | rightMask: 107 | serializedVersion: 2 108 | m_Bits: 0 109 | trackingSpace: 1 110 | --- !u!1001 &100100000 111 | Prefab: 112 | m_ObjectHideFlags: 1 113 | serializedVersion: 2 114 | m_Modification: 115 | m_TransformParent: {fileID: 0} 116 | m_Modifications: [] 117 | m_RemovedComponents: [] 118 | m_ParentPrefab: {fileID: 0} 119 | m_RootGameObject: {fileID: 132594} 120 | m_IsPrefabParent: 1 121 | -------------------------------------------------------------------------------- /Assets/SteamVR/Prefabs/[SteamVR].prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f35fa249b5008c44ac2998be6f82d4d 3 | timeCreated: 1429757514 4 | licenseType: Store 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 40af2f692be87864ba388a27fcac9ed8 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_AlphaOut.shader: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // UNITY_SHADER_NO_UPGRADE 3 | Shader "Custom/SteamVR_AlphaOut" { 4 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | sampler2D _MainTex; 11 | 12 | struct v2f { 13 | float4 pos : SV_POSITION; 14 | float2 tex : TEXCOORD0; 15 | }; 16 | 17 | v2f vert(appdata_base v) { 18 | v2f o; 19 | #if UNITY_VERSION >= 540 20 | o.pos = UnityObjectToClipPos(v.vertex); 21 | #else 22 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 23 | #endif 24 | o.tex = v.texcoord; 25 | return o; 26 | } 27 | 28 | float luminance(float3 color) 29 | { 30 | return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; 31 | } 32 | 33 | float4 frag(v2f i) : COLOR { 34 | float4 color = tex2D(_MainTex, i.tex); 35 | float a = saturate(color.a + luminance(color.rgb)); 36 | return float4(a, a, a, a); 37 | } 38 | 39 | ENDCG 40 | 41 | SubShader { 42 | Pass { 43 | ZTest Always Cull Off ZWrite Off 44 | Fog { Mode Off } 45 | 46 | CGPROGRAM 47 | #pragma vertex vert 48 | #pragma fragment frag 49 | ENDCG 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_AlphaOut.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da25bb0dccfd3894181fc5e84714cd17 3 | timeCreated: 1456189850 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_ClearAll.shader: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // UNITY_SHADER_NO_UPGRADE 3 | Shader "Custom/SteamVR_ClearAll" { 4 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | sampler2D _MainTex; 11 | 12 | struct v2f { 13 | float4 pos : SV_POSITION; 14 | float2 tex : TEXCOORD0; 15 | }; 16 | 17 | v2f vert(appdata_base v) { 18 | v2f o; 19 | #if UNITY_VERSION >= 540 20 | o.pos = UnityObjectToClipPos(v.vertex); 21 | #else 22 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 23 | #endif 24 | o.tex = v.texcoord; 25 | return o; 26 | } 27 | 28 | float4 frag(v2f i) : COLOR { 29 | return float4(0, 0, 0, 0); 30 | } 31 | 32 | ENDCG 33 | 34 | SubShader { 35 | Tags{ "Queue" = "Background" } 36 | Pass { 37 | ZTest Always Cull Off ZWrite On 38 | Fog { Mode Off } 39 | 40 | CGPROGRAM 41 | #pragma vertex vert 42 | #pragma fragment frag 43 | ENDCG 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_ClearAll.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1eded52540dd0a4988d5d4d76382da9 3 | timeCreated: 1457042024 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_ColorOut.shader: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // UNITY_SHADER_NO_UPGRADE 3 | Shader "Custom/SteamVR_ColorOut" { 4 | Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | sampler2D _MainTex; 11 | 12 | struct v2f { 13 | float4 pos : SV_POSITION; 14 | float2 tex : TEXCOORD0; 15 | }; 16 | 17 | v2f vert(appdata_base v) { 18 | v2f o; 19 | #if UNITY_VERSION >= 540 20 | o.pos = UnityObjectToClipPos(v.vertex); 21 | #else 22 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 23 | #endif 24 | o.tex = v.texcoord; 25 | return o; 26 | } 27 | 28 | float luminance(float3 color) 29 | { 30 | return 0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b; 31 | } 32 | 33 | float4 frag(v2f i) : COLOR { 34 | float4 color = tex2D(_MainTex, i.tex); 35 | return float4(color.rgb, 1); 36 | } 37 | 38 | ENDCG 39 | 40 | SubShader { 41 | Pass { 42 | ZTest Always Cull Off ZWrite Off 43 | Fog { Mode Off } 44 | 45 | CGPROGRAM 46 | #pragma vertex vert 47 | #pragma fragment frag 48 | ENDCG 49 | } 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_ColorOut.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04d03a6e2ff64bf47911d08912140c31 3 | timeCreated: 1456866489 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_ExternalCamera.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &128450 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 417074} 11 | - 114: {fileID: 11479102} 12 | m_Layer: 0 13 | m_Name: SteamVR_ExternalCamera 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!1 &129796 20 | GameObject: 21 | m_ObjectHideFlags: 0 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | serializedVersion: 4 25 | m_Component: 26 | - 4: {fileID: 444732} 27 | - 114: {fileID: 11487396} 28 | - 114: {fileID: 11472986} 29 | m_Layer: 0 30 | m_Name: Controller (third) 31 | m_TagString: Untagged 32 | m_Icon: {fileID: 0} 33 | m_NavMeshLayer: 0 34 | m_StaticEditorFlags: 0 35 | m_IsActive: 1 36 | --- !u!4 &417074 37 | Transform: 38 | m_ObjectHideFlags: 1 39 | m_PrefabParentObject: {fileID: 0} 40 | m_PrefabInternal: {fileID: 100100000} 41 | m_GameObject: {fileID: 128450} 42 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 43 | m_LocalPosition: {x: 0, y: 0, z: 0} 44 | m_LocalScale: {x: 1, y: 1, z: 1} 45 | m_Children: 46 | - {fileID: 444732} 47 | m_Father: {fileID: 0} 48 | m_RootOrder: 0 49 | --- !u!4 &444732 50 | Transform: 51 | m_ObjectHideFlags: 1 52 | m_PrefabParentObject: {fileID: 0} 53 | m_PrefabInternal: {fileID: 100100000} 54 | m_GameObject: {fileID: 129796} 55 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 56 | m_LocalPosition: {x: 0, y: 0, z: 0} 57 | m_LocalScale: {x: 1, y: 1, z: 1} 58 | m_Children: [] 59 | m_Father: {fileID: 417074} 60 | m_RootOrder: 0 61 | --- !u!114 &11472986 62 | MonoBehaviour: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 129796} 67 | m_Enabled: 1 68 | m_EditorHideFlags: 0 69 | m_Script: {fileID: 11500000, guid: d37c2cf88f7c59f4c8cf5d3812568143, type: 3} 70 | m_Name: 71 | m_EditorClassIdentifier: 72 | index: -1 73 | origin: {fileID: 0} 74 | isValid: 0 75 | --- !u!114 &11479102 76 | MonoBehaviour: 77 | m_ObjectHideFlags: 1 78 | m_PrefabParentObject: {fileID: 0} 79 | m_PrefabInternal: {fileID: 100100000} 80 | m_GameObject: {fileID: 128450} 81 | m_Enabled: 1 82 | m_EditorHideFlags: 0 83 | m_Script: {fileID: 11500000, guid: e3b47c2980b93bc48844a54641dab5b8, type: 3} 84 | m_Name: 85 | m_EditorClassIdentifier: 86 | left: {fileID: 0} 87 | right: {fileID: 0} 88 | objects: 89 | - {fileID: 129796} 90 | --- !u!114 &11487396 91 | MonoBehaviour: 92 | m_ObjectHideFlags: 1 93 | m_PrefabParentObject: {fileID: 0} 94 | m_PrefabInternal: {fileID: 100100000} 95 | m_GameObject: {fileID: 129796} 96 | m_Enabled: 1 97 | m_EditorHideFlags: 0 98 | m_Script: {fileID: 11500000, guid: c9da270df5147d24597cc106058c1fa7, type: 3} 99 | m_Name: 100 | m_EditorClassIdentifier: 101 | offset: {fileID: 0} 102 | frontCam: {fileID: 0} 103 | backCam: {fileID: 0} 104 | --- !u!1001 &100100000 105 | Prefab: 106 | m_ObjectHideFlags: 1 107 | serializedVersion: 2 108 | m_Modification: 109 | m_TransformParent: {fileID: 0} 110 | m_Modifications: [] 111 | m_RemovedComponents: [] 112 | m_ParentPrefab: {fileID: 0} 113 | m_RootGameObject: {fileID: 128450} 114 | m_IsPrefabParent: 1 115 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_ExternalCamera.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b259143c09ffc447ad059e5b8d8cf89 3 | timeCreated: 1456288801 4 | licenseType: Store 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_Fade.shader: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // UNITY_SHADER_NO_UPGRADE 3 | Shader "Custom/SteamVR_Fade" 4 | { 5 | SubShader 6 | { 7 | Pass 8 | { 9 | Blend SrcAlpha OneMinusSrcAlpha 10 | ZTest Always 11 | Cull Off 12 | ZWrite Off 13 | 14 | CGPROGRAM 15 | #pragma vertex MainVS 16 | #pragma fragment MainPS 17 | 18 | float4 fadeColor; 19 | 20 | float4 MainVS( float4 vertex : POSITION ) : SV_POSITION 21 | { 22 | return vertex.xyzw; 23 | } 24 | 25 | float4 MainPS() : SV_Target 26 | { 27 | return fadeColor.rgba; 28 | } 29 | ENDCG 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_Fade.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f884441bea153347be721454dc13716 3 | timeCreated: 1433284862 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_SphericalProjection.shader: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // UNITY_SHADER_NO_UPGRADE 3 | Shader "Custom/SteamVR_SphericalProjection" { 4 | Properties { 5 | _MainTex ("Base (RGB)", 2D) = "white" {} 6 | _N ("N (normal of plane)", Vector) = (0,0,0,0) 7 | _Phi0 ("Phi0", Float) = 0 8 | _Phi1 ("Phi1", Float) = 1 9 | _Theta0 ("Theta0", Float) = 0 10 | _Theta1 ("Theta1", Float) = 1 11 | _UAxis ("uAxis", Vector) = (0,0,0,0) 12 | _VAxis ("vAxis", Vector) = (0,0,0,0) 13 | _UOrigin ("uOrigin", Vector) = (0,0,0,0) 14 | _VOrigin ("vOrigin", Vector) = (0,0,0,0) 15 | _UScale ("uScale", Float) = 1 16 | _VScale ("vScale", Float) = 1 17 | } 18 | 19 | CGINCLUDE 20 | 21 | #include "UnityCG.cginc" 22 | 23 | sampler2D _MainTex; 24 | float4 _N; 25 | float _Phi0, _Phi1, _Theta0, _Theta1; 26 | float4 _UAxis, _VAxis; 27 | float4 _UOrigin, _VOrigin; 28 | float _UScale, _VScale; 29 | 30 | struct v2f { 31 | float4 pos : SV_POSITION; 32 | float2 tex : TEXCOORD0; 33 | }; 34 | 35 | v2f vert(appdata_base v) { 36 | v2f o; 37 | #if UNITY_VERSION >= 540 38 | o.pos = UnityObjectToClipPos(v.vertex); 39 | #else 40 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 41 | #endif 42 | o.tex = float2( 43 | lerp(_Phi0, _Phi1, v.texcoord.x), 44 | lerp(_Theta0, _Theta1, v.texcoord.y)); 45 | return o; 46 | } 47 | 48 | float3 cartesian(float phi, float theta) 49 | { 50 | float sinTheta = sin(theta); 51 | return float3( 52 | sinTheta * sin(phi), 53 | cos(theta), 54 | sinTheta * cos(phi)); 55 | } 56 | 57 | float4 frag(v2f i) : COLOR { 58 | float3 V = cartesian(i.tex.x, i.tex.y); 59 | float3 P = V / dot(V, _N.xyz); // intersection point on plane 60 | float2 uv = float2( 61 | dot(P - _UOrigin.xyz, _UAxis.xyz) * _UScale, 62 | dot(P - _VOrigin.xyz, _VAxis.xyz) * _VScale); 63 | return tex2D(_MainTex, uv); 64 | } 65 | 66 | ENDCG 67 | 68 | SubShader { 69 | Pass { 70 | ZTest Always Cull Off ZWrite Off 71 | Fog { Mode Off } 72 | 73 | CGPROGRAM 74 | #pragma vertex vert 75 | #pragma fragment frag 76 | ENDCG 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Assets/SteamVR/Resources/SteamVR_SphericalProjection.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43b10deca54ca524c8cd9a0fcb622325 3 | timeCreated: 1462380123 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d88af1b1098a33a42bc43c910c864102 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fae0ddab09ac324c85494471274d6a4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Camera.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Adds SteamVR render support to existing camera objects 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using System.Reflection; 10 | using Valve.VR; 11 | 12 | [RequireComponent(typeof(Camera))] 13 | public class SteamVR_Camera : MonoBehaviour 14 | { 15 | [SerializeField] 16 | private Transform _head; 17 | public Transform head { get { return _head; } } 18 | public Transform offset { get { return _head; } } // legacy 19 | public Transform origin { get { return _head.parent; } } 20 | 21 | public new Camera camera { get; private set; } 22 | 23 | [SerializeField] 24 | private Transform _ears; 25 | public Transform ears { get { return _ears; } } 26 | 27 | public Ray GetRay() 28 | { 29 | return new Ray(_head.position, _head.forward); 30 | } 31 | 32 | public bool wireframe = false; 33 | 34 | static public float sceneResolutionScale 35 | { 36 | get { return UnityEngine.VR.VRSettings.renderScale; } 37 | set { UnityEngine.VR.VRSettings.renderScale = value; } 38 | } 39 | 40 | #region Enable / Disable 41 | 42 | void OnDisable() 43 | { 44 | SteamVR_Render.Remove(this); 45 | } 46 | 47 | void OnEnable() 48 | { 49 | // Bail if no hmd is connected 50 | var vr = SteamVR.instance; 51 | if (vr == null) 52 | { 53 | if (head != null) 54 | { 55 | head.GetComponent().enabled = false; 56 | } 57 | 58 | enabled = false; 59 | return; 60 | } 61 | 62 | // Convert camera rig for native OpenVR integration. 63 | var t = transform; 64 | if (head != t) 65 | { 66 | Expand(); 67 | 68 | t.parent = origin; 69 | 70 | while (head.childCount > 0) 71 | head.GetChild(0).parent = t; 72 | 73 | // Keep the head around, but parent to the camera now since it moves with the hmd 74 | // but existing content may still have references to this object. 75 | head.parent = t; 76 | head.localPosition = Vector3.zero; 77 | head.localRotation = Quaternion.identity; 78 | head.localScale = Vector3.one; 79 | head.gameObject.SetActive(false); 80 | 81 | _head = t; 82 | } 83 | 84 | if (ears == null) 85 | { 86 | var e = transform.GetComponentInChildren(); 87 | if (e != null) 88 | _ears = e.transform; 89 | } 90 | 91 | if (ears != null) 92 | ears.GetComponent().vrcam = this; 93 | 94 | SteamVR_Render.Add(this); 95 | } 96 | 97 | #endregion 98 | 99 | #region Functionality to ensure SteamVR_Camera component is always the last component on an object 100 | 101 | void Awake() 102 | { 103 | camera = GetComponent(); // cached to avoid runtime lookup 104 | ForceLast(); 105 | } 106 | 107 | static Hashtable values; 108 | 109 | public void ForceLast() 110 | { 111 | if (values != null) 112 | { 113 | // Restore values on new instance 114 | foreach (DictionaryEntry entry in values) 115 | { 116 | var f = entry.Key as FieldInfo; 117 | f.SetValue(this, entry.Value); 118 | } 119 | values = null; 120 | } 121 | else 122 | { 123 | // Make sure it's the last component 124 | var components = GetComponents(); 125 | 126 | // But first make sure there aren't any other SteamVR_Cameras on this object. 127 | for (int i = 0; i < components.Length; i++) 128 | { 129 | var c = components[i] as SteamVR_Camera; 130 | if (c != null && c != this) 131 | { 132 | DestroyImmediate(c); 133 | } 134 | } 135 | 136 | components = GetComponents(); 137 | 138 | if (this != components[components.Length - 1]) 139 | { 140 | // Store off values to be restored on new instance 141 | values = new Hashtable(); 142 | var fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); 143 | foreach (var f in fields) 144 | if (f.IsPublic || f.IsDefined(typeof(SerializeField), true)) 145 | values[f] = f.GetValue(this); 146 | 147 | var go = gameObject; 148 | DestroyImmediate(this); 149 | go.AddComponent().ForceLast(); 150 | } 151 | } 152 | } 153 | 154 | #endregion 155 | 156 | #region Expand / Collapse object hierarchy 157 | 158 | #if UNITY_EDITOR 159 | public bool isExpanded { get { return head != null && transform.parent == head; } } 160 | #endif 161 | const string eyeSuffix = " (eye)"; 162 | const string earsSuffix = " (ears)"; 163 | const string headSuffix = " (head)"; 164 | const string originSuffix = " (origin)"; 165 | public string baseName { get { return name.EndsWith(eyeSuffix) ? name.Substring(0, name.Length - eyeSuffix.Length) : name; } } 166 | 167 | // Object hierarchy creation to make it easy to parent other objects appropriately, 168 | // otherwise this gets called on demand at runtime. Remaining initialization is 169 | // performed at startup, once the hmd has been identified. 170 | public void Expand() 171 | { 172 | var _origin = transform.parent; 173 | if (_origin == null) 174 | { 175 | _origin = new GameObject(name + originSuffix).transform; 176 | _origin.localPosition = transform.localPosition; 177 | _origin.localRotation = transform.localRotation; 178 | _origin.localScale = transform.localScale; 179 | } 180 | 181 | if (head == null) 182 | { 183 | _head = new GameObject(name + headSuffix, typeof(SteamVR_TrackedObject)).transform; 184 | head.parent = _origin; 185 | head.position = transform.position; 186 | head.rotation = transform.rotation; 187 | head.localScale = Vector3.one; 188 | head.tag = tag; 189 | } 190 | 191 | if (transform.parent != head) 192 | { 193 | transform.parent = head; 194 | transform.localPosition = Vector3.zero; 195 | transform.localRotation = Quaternion.identity; 196 | transform.localScale = Vector3.one; 197 | 198 | while (transform.childCount > 0) 199 | transform.GetChild(0).parent = head; 200 | 201 | var guiLayer = GetComponent(); 202 | if (guiLayer != null) 203 | { 204 | DestroyImmediate(guiLayer); 205 | head.gameObject.AddComponent(); 206 | } 207 | 208 | var audioListener = GetComponent(); 209 | if (audioListener != null) 210 | { 211 | DestroyImmediate(audioListener); 212 | _ears = new GameObject(name + earsSuffix, typeof(SteamVR_Ears)).transform; 213 | ears.parent = _head; 214 | ears.localPosition = Vector3.zero; 215 | ears.localRotation = Quaternion.identity; 216 | ears.localScale = Vector3.one; 217 | } 218 | } 219 | 220 | if (!name.EndsWith(eyeSuffix)) 221 | name += eyeSuffix; 222 | } 223 | 224 | public void Collapse() 225 | { 226 | transform.parent = null; 227 | 228 | // Move children and components from head back to camera. 229 | while (head.childCount > 0) 230 | head.GetChild(0).parent = transform; 231 | 232 | var guiLayer = head.GetComponent(); 233 | if (guiLayer != null) 234 | { 235 | DestroyImmediate(guiLayer); 236 | gameObject.AddComponent(); 237 | } 238 | 239 | if (ears != null) 240 | { 241 | while (ears.childCount > 0) 242 | ears.GetChild(0).parent = transform; 243 | 244 | DestroyImmediate(ears.gameObject); 245 | _ears = null; 246 | 247 | gameObject.AddComponent(typeof(AudioListener)); 248 | } 249 | 250 | if (origin != null) 251 | { 252 | // If we created the origin originally, destroy it now. 253 | if (origin.name.EndsWith(originSuffix)) 254 | { 255 | // Reparent any children so we don't accidentally delete them. 256 | var _origin = origin; 257 | while (_origin.childCount > 0) 258 | _origin.GetChild(0).parent = _origin.parent; 259 | 260 | DestroyImmediate(_origin.gameObject); 261 | } 262 | else 263 | { 264 | transform.parent = origin; 265 | } 266 | } 267 | 268 | DestroyImmediate(head.gameObject); 269 | _head = null; 270 | 271 | if (name.EndsWith(eyeSuffix)) 272 | name = name.Substring(0, name.Length - eyeSuffix.Length); 273 | } 274 | 275 | #endregion 276 | } 277 | 278 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Camera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bca9ccf900ccc84c887d783321d27e2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_CameraFlip.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Flips the camera output back to normal for D3D. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [ExecuteInEditMode] 10 | public class SteamVR_CameraFlip : MonoBehaviour 11 | { 12 | void Awake() 13 | { 14 | Debug.Log("SteamVR_CameraFlip is deprecated in Unity 5.4 - REMOVING"); 15 | DestroyImmediate(this); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_CameraFlip.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f5be45115742b07478e21c85fcc233ec 3 | timeCreated: 1430851231 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_CameraMask.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Masks out pixels that cannot be seen through the connected hmd. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [ExecuteInEditMode] 10 | public class SteamVR_CameraMask : MonoBehaviour 11 | { 12 | void Awake() 13 | { 14 | Debug.Log("SteamVR_CameraMask is deprecated in Unity 5.4 - REMOVING"); 15 | DestroyImmediate(this); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_CameraMask.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5828f252c3c228f4b931f66c21e525c4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Controller.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Wrapper for working with SteamVR controller input 4 | // 5 | // Example usage: 6 | // 7 | // var deviceIndex = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost); 8 | // if (deviceIndex != -1 && SteamVR_Controller.Input(deviceIndex).GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) 9 | // SteamVR_Controller.Input(deviceIndex).TriggerHapticPulse(1000); 10 | // 11 | //============================================================================= 12 | 13 | using UnityEngine; 14 | using Valve.VR; 15 | 16 | public class SteamVR_Controller 17 | { 18 | public class ButtonMask 19 | { 20 | public const ulong System = (1ul << (int)EVRButtonId.k_EButton_System); // reserved 21 | public const ulong ApplicationMenu = (1ul << (int)EVRButtonId.k_EButton_ApplicationMenu); 22 | public const ulong Grip = (1ul << (int)EVRButtonId.k_EButton_Grip); 23 | public const ulong Axis0 = (1ul << (int)EVRButtonId.k_EButton_Axis0); 24 | public const ulong Axis1 = (1ul << (int)EVRButtonId.k_EButton_Axis1); 25 | public const ulong Axis2 = (1ul << (int)EVRButtonId.k_EButton_Axis2); 26 | public const ulong Axis3 = (1ul << (int)EVRButtonId.k_EButton_Axis3); 27 | public const ulong Axis4 = (1ul << (int)EVRButtonId.k_EButton_Axis4); 28 | public const ulong Touchpad = (1ul << (int)EVRButtonId.k_EButton_SteamVR_Touchpad); 29 | public const ulong Trigger = (1ul << (int)EVRButtonId.k_EButton_SteamVR_Trigger); 30 | } 31 | 32 | public class Device 33 | { 34 | public Device(uint i) { index = i; } 35 | public uint index { get; private set; } 36 | 37 | public bool valid { get; private set; } 38 | public bool connected { get { Update(); return pose.bDeviceIsConnected; } } 39 | public bool hasTracking { get { Update(); return pose.bPoseIsValid; } } 40 | 41 | public bool outOfRange { get { Update(); return pose.eTrackingResult == ETrackingResult.Running_OutOfRange || pose.eTrackingResult == ETrackingResult.Calibrating_OutOfRange; } } 42 | public bool calibrating { get { Update(); return pose.eTrackingResult == ETrackingResult.Calibrating_InProgress || pose.eTrackingResult == ETrackingResult.Calibrating_OutOfRange; } } 43 | public bool uninitialized { get { Update(); return pose.eTrackingResult == ETrackingResult.Uninitialized; } } 44 | 45 | // These values are only accurate for the last controller state change (e.g. trigger release), and by definition, will always lag behind 46 | // the predicted visual poses that drive SteamVR_TrackedObjects since they are sync'd to the input timestamp that caused them to update. 47 | public SteamVR_Utils.RigidTransform transform { get { Update(); return new SteamVR_Utils.RigidTransform(pose.mDeviceToAbsoluteTracking); } } 48 | public Vector3 velocity { get { Update(); return new Vector3(pose.vVelocity.v0, pose.vVelocity.v1, -pose.vVelocity.v2); } } 49 | public Vector3 angularVelocity { get { Update(); return new Vector3(-pose.vAngularVelocity.v0, -pose.vAngularVelocity.v1, pose.vAngularVelocity.v2); } } 50 | 51 | public VRControllerState_t GetState() { Update(); return state; } 52 | public VRControllerState_t GetPrevState() { Update(); return prevState; } 53 | public TrackedDevicePose_t GetPose() { Update(); return pose; } 54 | 55 | VRControllerState_t state, prevState; 56 | TrackedDevicePose_t pose; 57 | int prevFrameCount = -1; 58 | public void Update() 59 | { 60 | if (Time.frameCount != prevFrameCount) 61 | { 62 | prevFrameCount = Time.frameCount; 63 | prevState = state; 64 | 65 | var system = OpenVR.System; 66 | if (system != null) 67 | { 68 | valid = system.GetControllerStateWithPose(SteamVR_Render.instance.trackingSpace, index, ref state, (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(VRControllerState_t)), ref pose); 69 | UpdateHairTrigger(); 70 | } 71 | } 72 | } 73 | 74 | public bool GetPress(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) != 0; } 75 | public bool GetPressDown(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) != 0 && (prevState.ulButtonPressed & buttonMask) == 0; } 76 | public bool GetPressUp(ulong buttonMask) { Update(); return (state.ulButtonPressed & buttonMask) == 0 && (prevState.ulButtonPressed & buttonMask) != 0; } 77 | 78 | public bool GetPress(EVRButtonId buttonId) { return GetPress(1ul << (int)buttonId); } 79 | public bool GetPressDown(EVRButtonId buttonId) { return GetPressDown(1ul << (int)buttonId); } 80 | public bool GetPressUp(EVRButtonId buttonId) { return GetPressUp(1ul << (int)buttonId); } 81 | 82 | public bool GetTouch(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) != 0; } 83 | public bool GetTouchDown(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) != 0 && (prevState.ulButtonTouched & buttonMask) == 0; } 84 | public bool GetTouchUp(ulong buttonMask) { Update(); return (state.ulButtonTouched & buttonMask) == 0 && (prevState.ulButtonTouched & buttonMask) != 0; } 85 | 86 | public bool GetTouch(EVRButtonId buttonId) { return GetTouch(1ul << (int)buttonId); } 87 | public bool GetTouchDown(EVRButtonId buttonId) { return GetTouchDown(1ul << (int)buttonId); } 88 | public bool GetTouchUp(EVRButtonId buttonId) { return GetTouchUp(1ul << (int)buttonId); } 89 | 90 | public Vector2 GetAxis(EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad) 91 | { 92 | Update(); 93 | var axisId = (uint)buttonId - (uint)EVRButtonId.k_EButton_Axis0; 94 | switch (axisId) 95 | { 96 | case 0: return new Vector2(state.rAxis0.x, state.rAxis0.y); 97 | case 1: return new Vector2(state.rAxis1.x, state.rAxis1.y); 98 | case 2: return new Vector2(state.rAxis2.x, state.rAxis2.y); 99 | case 3: return new Vector2(state.rAxis3.x, state.rAxis3.y); 100 | case 4: return new Vector2(state.rAxis4.x, state.rAxis4.y); 101 | } 102 | return Vector2.zero; 103 | } 104 | 105 | public void TriggerHapticPulse(ushort durationMicroSec = 500, EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad) 106 | { 107 | var system = OpenVR.System; 108 | if (system != null) 109 | { 110 | var axisId = (uint)buttonId - (uint)EVRButtonId.k_EButton_Axis0; 111 | system.TriggerHapticPulse(index, axisId, (char)durationMicroSec); 112 | } 113 | } 114 | 115 | public float hairTriggerDelta = 0.1f; // amount trigger must be pulled or released to change state 116 | float hairTriggerLimit; 117 | bool hairTriggerState, hairTriggerPrevState; 118 | void UpdateHairTrigger() 119 | { 120 | hairTriggerPrevState = hairTriggerState; 121 | var value = state.rAxis1.x; // trigger 122 | if (hairTriggerState) 123 | { 124 | if (value < hairTriggerLimit - hairTriggerDelta || value <= 0.0f) 125 | hairTriggerState = false; 126 | } 127 | else 128 | { 129 | if (value > hairTriggerLimit + hairTriggerDelta || value >= 1.0f) 130 | hairTriggerState = true; 131 | } 132 | hairTriggerLimit = hairTriggerState ? Mathf.Max(hairTriggerLimit, value) : Mathf.Min(hairTriggerLimit, value); 133 | } 134 | 135 | public bool GetHairTrigger() { Update(); return hairTriggerState; } 136 | public bool GetHairTriggerDown() { Update(); return hairTriggerState && !hairTriggerPrevState; } 137 | public bool GetHairTriggerUp() { Update(); return !hairTriggerState && hairTriggerPrevState; } 138 | } 139 | 140 | private static Device[] devices; 141 | 142 | public static Device Input(int deviceIndex) 143 | { 144 | if (devices == null) 145 | { 146 | devices = new Device[OpenVR.k_unMaxTrackedDeviceCount]; 147 | for (uint i = 0; i < devices.Length; i++) 148 | devices[i] = new Device(i); 149 | } 150 | 151 | return devices[deviceIndex]; 152 | } 153 | 154 | public static void Update() 155 | { 156 | for (int i = 0; i < OpenVR.k_unMaxTrackedDeviceCount; i++) 157 | Input(i).Update(); 158 | } 159 | 160 | // This helper can be used in a variety of ways. Beware that indices may change 161 | // as new devices are dynamically added or removed, controllers are physically 162 | // swapped between hands, arms crossed, etc. 163 | public enum DeviceRelation 164 | { 165 | First, 166 | // radially 167 | Leftmost, 168 | Rightmost, 169 | // distance - also see vr.hmd.GetSortedTrackedDeviceIndicesOfClass 170 | FarthestLeft, 171 | FarthestRight, 172 | } 173 | public static int GetDeviceIndex(DeviceRelation relation, 174 | ETrackedDeviceClass deviceClass = ETrackedDeviceClass.Controller, 175 | int relativeTo = (int)OpenVR.k_unTrackedDeviceIndex_Hmd) // use -1 for absolute tracking space 176 | { 177 | var result = -1; 178 | 179 | var invXform = ((uint)relativeTo < OpenVR.k_unMaxTrackedDeviceCount) ? 180 | Input(relativeTo).transform.GetInverse() : SteamVR_Utils.RigidTransform.identity; 181 | 182 | var system = OpenVR.System; 183 | if (system == null) 184 | return result; 185 | 186 | var best = -float.MaxValue; 187 | for (int i = 0; i < OpenVR.k_unMaxTrackedDeviceCount; i++) 188 | { 189 | if (i == relativeTo || system.GetTrackedDeviceClass((uint)i) != deviceClass) 190 | continue; 191 | 192 | var device = Input(i); 193 | if (!device.connected) 194 | continue; 195 | 196 | if (relation == DeviceRelation.First) 197 | return i; 198 | 199 | float score; 200 | 201 | var pos = invXform * device.transform.pos; 202 | if (relation == DeviceRelation.FarthestRight) 203 | { 204 | score = pos.x; 205 | } 206 | else if (relation == DeviceRelation.FarthestLeft) 207 | { 208 | score = -pos.x; 209 | } 210 | else 211 | { 212 | var dir = new Vector3(pos.x, 0.0f, pos.z).normalized; 213 | var dot = Vector3.Dot(dir, Vector3.forward); 214 | var cross = Vector3.Cross(dir, Vector3.forward); 215 | if (relation == DeviceRelation.Leftmost) 216 | { 217 | score = (cross.y > 0.0f) ? 2.0f - dot : dot; 218 | } 219 | else 220 | { 221 | score = (cross.y < 0.0f) ? 2.0f - dot : dot; 222 | } 223 | } 224 | 225 | if (score > best) 226 | { 227 | result = i; 228 | best = score; 229 | } 230 | } 231 | 232 | return result; 233 | } 234 | } 235 | 236 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Controller.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9c6e0c408020c341b3c329ec30355a1 3 | timeCreated: 1429900414 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_ControllerManager.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Enables/disables objects based on connectivity and assigned roles. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections.Generic; 9 | using Valve.VR; 10 | 11 | public class SteamVR_ControllerManager : MonoBehaviour 12 | { 13 | public GameObject left, right; 14 | public GameObject[] objects; // populate with objects you want to assign to additional controllers 15 | 16 | public bool assignAllBeforeIdentified; // set to true if you want objects arbitrarily assigned to controllers before their role (left vs right) is identified 17 | 18 | uint[] indices; // assigned 19 | bool[] connected = new bool[OpenVR.k_unMaxTrackedDeviceCount]; // controllers only 20 | 21 | // cached roles - may or may not be connected 22 | uint leftIndex = OpenVR.k_unTrackedDeviceIndexInvalid; 23 | uint rightIndex = OpenVR.k_unTrackedDeviceIndexInvalid; 24 | 25 | // This needs to be called if you update left, right or objects at runtime (e.g. when dyanmically spawned). 26 | public void UpdateTargets() 27 | { 28 | // Add left and right entries to the head of the list so we only have to operate on the list itself. 29 | var additional = (this.objects != null) ? this.objects.Length : 0; 30 | var objects = new GameObject[2 + additional]; 31 | indices = new uint[2 + additional]; 32 | objects[0] = right; 33 | indices[0] = OpenVR.k_unTrackedDeviceIndexInvalid; 34 | objects[1] = left; 35 | indices[1] = OpenVR.k_unTrackedDeviceIndexInvalid; 36 | for (int i = 0; i < additional; i++) 37 | { 38 | objects[2 + i] = this.objects[i]; 39 | indices[2 + i] = OpenVR.k_unTrackedDeviceIndexInvalid; 40 | } 41 | this.objects = objects; 42 | } 43 | 44 | SteamVR_Events.Action inputFocusAction, deviceConnectedAction, trackedDeviceRoleChangedAction; 45 | 46 | void Awake() 47 | { 48 | UpdateTargets(); 49 | inputFocusAction = SteamVR_Events.InputFocusAction(OnInputFocus); 50 | deviceConnectedAction = SteamVR_Events.DeviceConnectedAction(OnDeviceConnected); 51 | trackedDeviceRoleChangedAction = SteamVR_Events.SystemAction(EVREventType.VREvent_TrackedDeviceRoleChanged, OnTrackedDeviceRoleChanged); 52 | } 53 | 54 | void OnEnable() 55 | { 56 | for (int i = 0; i < objects.Length; i++) 57 | { 58 | var obj = objects[i]; 59 | if (obj != null) 60 | obj.SetActive(false); 61 | } 62 | 63 | Refresh(); 64 | 65 | for (int i = 0; i < SteamVR.connected.Length; i++) 66 | if (SteamVR.connected[i]) 67 | OnDeviceConnected(i, true); 68 | 69 | inputFocusAction.enabled = true; 70 | deviceConnectedAction.enabled = true; 71 | trackedDeviceRoleChangedAction.enabled = true; 72 | } 73 | 74 | void OnDisable() 75 | { 76 | inputFocusAction.enabled = false; 77 | deviceConnectedAction.enabled = false; 78 | trackedDeviceRoleChangedAction.enabled = false; 79 | } 80 | 81 | static string[] labels = { "left", "right" }; 82 | 83 | // Hide controllers when the dashboard is up. 84 | private void OnInputFocus(bool hasFocus) 85 | { 86 | if (hasFocus) 87 | { 88 | for (int i = 0; i < objects.Length; i++) 89 | { 90 | var obj = objects[i]; 91 | if (obj != null) 92 | { 93 | var label = (i < 2) ? labels[i] : (i - 1).ToString(); 94 | ShowObject(obj.transform, "hidden (" + label + ")"); 95 | } 96 | } 97 | } 98 | else 99 | { 100 | for (int i = 0; i < objects.Length; i++) 101 | { 102 | var obj = objects[i]; 103 | if (obj != null) 104 | { 105 | var label = (i < 2) ? labels[i] : (i - 1).ToString(); 106 | HideObject(obj.transform, "hidden (" + label + ")"); 107 | } 108 | } 109 | } 110 | } 111 | 112 | // Reparents to a new object and deactivates that object (this allows 113 | // us to call SetActive in OnDeviceConnected independently. 114 | private void HideObject(Transform t, string name) 115 | { 116 | var hidden = new GameObject(name).transform; 117 | hidden.parent = t.parent; 118 | t.parent = hidden; 119 | hidden.gameObject.SetActive(false); 120 | } 121 | private void ShowObject(Transform t, string name) 122 | { 123 | var hidden = t.parent; 124 | if (hidden.gameObject.name != name) 125 | return; 126 | t.parent = hidden.parent; 127 | Destroy(hidden.gameObject); 128 | } 129 | 130 | private void SetTrackedDeviceIndex(int objectIndex, uint trackedDeviceIndex) 131 | { 132 | // First make sure no one else is already using this index. 133 | if (trackedDeviceIndex != OpenVR.k_unTrackedDeviceIndexInvalid) 134 | { 135 | for (int i = 0; i < objects.Length; i++) 136 | { 137 | if (i != objectIndex && indices[i] == trackedDeviceIndex) 138 | { 139 | var obj = objects[i]; 140 | if (obj != null) 141 | obj.SetActive(false); 142 | 143 | indices[i] = OpenVR.k_unTrackedDeviceIndexInvalid; 144 | } 145 | } 146 | } 147 | 148 | // Only set when changed. 149 | if (trackedDeviceIndex != indices[objectIndex]) 150 | { 151 | indices[objectIndex] = trackedDeviceIndex; 152 | 153 | var obj = objects[objectIndex]; 154 | if (obj != null) 155 | { 156 | if (trackedDeviceIndex == OpenVR.k_unTrackedDeviceIndexInvalid) 157 | obj.SetActive(false); 158 | else 159 | { 160 | obj.SetActive(true); 161 | obj.BroadcastMessage("SetDeviceIndex", (int)trackedDeviceIndex, SendMessageOptions.DontRequireReceiver); 162 | } 163 | } 164 | } 165 | } 166 | 167 | // Keep track of assigned roles. 168 | private void OnTrackedDeviceRoleChanged(VREvent_t vrEvent) 169 | { 170 | Refresh(); 171 | } 172 | 173 | // Keep track of connected controller indices. 174 | private void OnDeviceConnected(int index, bool connected) 175 | { 176 | bool changed = this.connected[index]; 177 | this.connected[index] = false; 178 | 179 | if (connected) 180 | { 181 | var system = OpenVR.System; 182 | if (system != null) 183 | { 184 | var deviceClass = system.GetTrackedDeviceClass((uint)index); 185 | if (deviceClass == ETrackedDeviceClass.Controller || 186 | deviceClass == ETrackedDeviceClass.GenericTracker) 187 | { 188 | this.connected[index] = true; 189 | changed = !changed; // if we clear and set the same index, nothing has changed 190 | } 191 | } 192 | } 193 | 194 | if (changed) 195 | Refresh(); 196 | } 197 | 198 | public void Refresh() 199 | { 200 | int objectIndex = 0; 201 | 202 | var system = OpenVR.System; 203 | if (system != null) 204 | { 205 | leftIndex = system.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand); 206 | rightIndex = system.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.RightHand); 207 | } 208 | 209 | // If neither role has been assigned yet, try hooking up at least the right controller. 210 | if (leftIndex == OpenVR.k_unTrackedDeviceIndexInvalid && rightIndex == OpenVR.k_unTrackedDeviceIndexInvalid) 211 | { 212 | for (uint deviceIndex = 0; deviceIndex < connected.Length; deviceIndex++) 213 | { 214 | if (objectIndex >= objects.Length) 215 | break; 216 | 217 | if (!connected[deviceIndex]) 218 | continue; 219 | 220 | SetTrackedDeviceIndex(objectIndex++, deviceIndex); 221 | 222 | if (!assignAllBeforeIdentified) 223 | break; 224 | } 225 | } 226 | else 227 | { 228 | SetTrackedDeviceIndex(objectIndex++, (rightIndex < connected.Length && connected[rightIndex]) ? rightIndex : OpenVR.k_unTrackedDeviceIndexInvalid); 229 | SetTrackedDeviceIndex(objectIndex++, (leftIndex < connected.Length && connected[leftIndex]) ? leftIndex : OpenVR.k_unTrackedDeviceIndexInvalid); 230 | 231 | // Assign out any additional controllers only after both left and right have been assigned. 232 | if (leftIndex != OpenVR.k_unTrackedDeviceIndexInvalid && rightIndex != OpenVR.k_unTrackedDeviceIndexInvalid) 233 | { 234 | for (uint deviceIndex = 0; deviceIndex < connected.Length; deviceIndex++) 235 | { 236 | if (objectIndex >= objects.Length) 237 | break; 238 | 239 | if (!connected[deviceIndex]) 240 | continue; 241 | 242 | if (deviceIndex != leftIndex && deviceIndex != rightIndex) 243 | { 244 | SetTrackedDeviceIndex(objectIndex++, deviceIndex); 245 | } 246 | } 247 | } 248 | } 249 | 250 | // Reset the rest. 251 | while (objectIndex < objects.Length) 252 | { 253 | SetTrackedDeviceIndex(objectIndex++, OpenVR.k_unTrackedDeviceIndexInvalid); 254 | } 255 | } 256 | } 257 | 258 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_ControllerManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3b47c2980b93bc48844a54641dab5b8 3 | timeCreated: 1437430318 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Ears.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Handles aligning audio listener when using speakers. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | [RequireComponent(typeof(AudioListener))] 11 | public class SteamVR_Ears : MonoBehaviour 12 | { 13 | public SteamVR_Camera vrcam; 14 | 15 | bool usingSpeakers; 16 | Quaternion offset; 17 | 18 | private void OnNewPosesApplied() 19 | { 20 | var origin = vrcam.origin; 21 | var baseRotation = origin != null ? origin.rotation : Quaternion.identity; 22 | transform.rotation = baseRotation * offset; 23 | } 24 | 25 | void OnEnable() 26 | { 27 | usingSpeakers = false; 28 | 29 | var settings = OpenVR.Settings; 30 | if (settings != null) 31 | { 32 | var error = EVRSettingsError.None; 33 | if (settings.GetBool(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_UsingSpeakers_Bool, ref error)) 34 | { 35 | usingSpeakers = true; 36 | 37 | var yawOffset = settings.GetFloat(OpenVR.k_pch_SteamVR_Section, OpenVR.k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float, ref error); 38 | offset = Quaternion.Euler(0.0f, yawOffset, 0.0f); 39 | } 40 | } 41 | 42 | if (usingSpeakers) 43 | SteamVR_Events.NewPosesApplied.Listen(OnNewPosesApplied); 44 | } 45 | 46 | void OnDisable() 47 | { 48 | if (usingSpeakers) 49 | SteamVR_Events.NewPosesApplied.Remove(OnNewPosesApplied); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Ears.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49a86c1078ce4314b9c4224560e031b9 3 | timeCreated: 1457243016 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Events.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Simple event system for SteamVR. 4 | // 5 | // Example usage: 6 | // 7 | // void OnDeviceConnected(int i, bool connected) { ... } 8 | // SteamVR_Events.DeviceConnected.Listen(OnDeviceConnected); // Usually in OnEnable 9 | // SteamVR_Events.DeviceConnected.Remove(OnDeviceConnected); // Usually in OnDisable 10 | // 11 | // Alternatively, if Listening/Removing often these can be cached as follows: 12 | // 13 | // SteamVR_Event.Action deviceConnectedAction; 14 | // void OnAwake() { deviceConnectedAction = SteamVR_Event.DeviceConnectedAction(OnDeviceConnected); } 15 | // void OnEnable() { deviceConnectedAction.enabled = true; } 16 | // void OnDisable() { deviceConnectedAction.enabled = false; } 17 | // 18 | //============================================================================= 19 | 20 | using UnityEngine; 21 | using UnityEngine.Events; 22 | using Valve.VR; 23 | 24 | public static class SteamVR_Events 25 | { 26 | public abstract class Action 27 | { 28 | public abstract void Enable(bool enabled); 29 | public bool enabled { set { Enable(value); } } 30 | } 31 | 32 | [System.Serializable] 33 | public class ActionNoArgs : Action 34 | { 35 | public ActionNoArgs(Event _event, UnityAction action) 36 | { 37 | this._event = _event; 38 | this.action = action; 39 | } 40 | 41 | public override void Enable(bool enabled) 42 | { 43 | if (enabled) 44 | _event.Listen(action); 45 | else 46 | _event.Remove(action); 47 | } 48 | 49 | Event _event; 50 | UnityAction action; 51 | } 52 | 53 | [System.Serializable] 54 | public class Action : Action 55 | { 56 | public Action(Event _event, UnityAction action) 57 | { 58 | this._event = _event; 59 | this.action = action; 60 | } 61 | 62 | public override void Enable(bool enabled) 63 | { 64 | if (enabled) 65 | _event.Listen(action); 66 | else 67 | _event.Remove(action); 68 | } 69 | 70 | Event _event; 71 | UnityAction action; 72 | } 73 | 74 | [System.Serializable] 75 | public class Action : Action 76 | { 77 | public Action(Event _event, UnityAction action) 78 | { 79 | this._event = _event; 80 | this.action = action; 81 | } 82 | 83 | public override void Enable(bool enabled) 84 | { 85 | if (enabled) 86 | _event.Listen(action); 87 | else 88 | _event.Remove(action); 89 | } 90 | 91 | Event _event; 92 | UnityAction action; 93 | } 94 | 95 | [System.Serializable] 96 | public class Action : Action 97 | { 98 | public Action(Event _event, UnityAction action) 99 | { 100 | this._event = _event; 101 | this.action = action; 102 | } 103 | 104 | public override void Enable(bool enabled) 105 | { 106 | if (enabled) 107 | _event.Listen(action); 108 | else 109 | _event.Remove(action); 110 | } 111 | 112 | Event _event; 113 | UnityAction action; 114 | } 115 | 116 | public class Event : UnityEvent 117 | { 118 | public void Listen(UnityAction action) { this.AddListener(action); } 119 | public void Remove(UnityAction action) { this.RemoveListener(action); } 120 | public void Send() { this.Invoke(); } 121 | } 122 | 123 | public class Event : UnityEvent 124 | { 125 | public void Listen(UnityAction action) { this.AddListener(action); } 126 | public void Remove(UnityAction action) { this.RemoveListener(action); } 127 | public void Send(T arg0) { this.Invoke(arg0); } 128 | } 129 | 130 | public class Event : UnityEvent 131 | { 132 | public void Listen(UnityAction action) { this.AddListener(action); } 133 | public void Remove(UnityAction action) { this.RemoveListener(action); } 134 | public void Send(T0 arg0, T1 arg1) { this.Invoke(arg0, arg1); } 135 | } 136 | 137 | public class Event : UnityEvent 138 | { 139 | public void Listen(UnityAction action) { this.AddListener(action); } 140 | public void Remove(UnityAction action) { this.RemoveListener(action); } 141 | public void Send(T0 arg0, T1 arg1, T2 arg2) { this.Invoke(arg0, arg1, arg2); } 142 | } 143 | 144 | public static Event Calibrating = new Event(); 145 | public static Action CalibratingAction(UnityAction action) { return new Action(Calibrating, action); } 146 | 147 | public static Event DeviceConnected = new Event(); 148 | public static Action DeviceConnectedAction(UnityAction action) { return new Action(DeviceConnected, action); } 149 | 150 | public static Event Fade = new Event(); 151 | public static Action FadeAction(UnityAction action) { return new Action(Fade, action); } 152 | 153 | public static Event FadeReady = new Event(); 154 | public static Action FadeReadyAction(UnityAction action) { return new ActionNoArgs(FadeReady, action); } 155 | 156 | public static Event HideRenderModels = new Event(); 157 | public static Action HideRenderModelsAction(UnityAction action) { return new Action(HideRenderModels, action); } 158 | 159 | public static Event Initializing = new Event(); 160 | public static Action InitializingAction(UnityAction action) { return new Action(Initializing, action); } 161 | 162 | public static Event InputFocus = new Event(); 163 | public static Action InputFocusAction(UnityAction action) { return new Action(InputFocus, action); } 164 | 165 | public static Event Loading = new Event(); 166 | public static Action LoadingAction(UnityAction action) { return new Action(Loading, action); } 167 | 168 | public static Event LoadingFadeIn = new Event(); 169 | public static Action LoadingFadeInAction(UnityAction action) { return new Action(LoadingFadeIn, action); } 170 | 171 | public static Event LoadingFadeOut = new Event(); 172 | public static Action LoadingFadeOutAction(UnityAction action) { return new Action(LoadingFadeOut, action); } 173 | 174 | public static Event NewPoses = new Event(); 175 | public static Action NewPosesAction(UnityAction action) { return new Action(NewPoses, action); } 176 | 177 | public static Event NewPosesApplied = new Event(); 178 | public static Action NewPosesAppliedAction(UnityAction action) { return new ActionNoArgs(NewPosesApplied, action); } 179 | 180 | public static Event OutOfRange = new Event(); 181 | public static Action OutOfRangeAction(UnityAction action) { return new Action(OutOfRange, action); } 182 | 183 | public static Event RenderModelLoaded = new Event(); 184 | public static Action RenderModelLoadedAction(UnityAction action) { return new Action(RenderModelLoaded, action); } 185 | 186 | static System.Collections.Generic.Dictionary> systemEvents = new System.Collections.Generic.Dictionary>(); 187 | public static Event System(EVREventType eventType) 188 | { 189 | Event e; 190 | if (!systemEvents.TryGetValue(eventType, out e)) 191 | { 192 | e = new Event(); 193 | systemEvents.Add(eventType, e); 194 | } 195 | return e; 196 | } 197 | 198 | public static Action SystemAction(EVREventType eventType, UnityAction action) 199 | { 200 | return new Action(System(eventType), action); 201 | } 202 | } 203 | 204 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Events.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44cb57742f235524189e5d8af1c4f3cc 3 | timeCreated: 1483744463 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_ExternalCamera.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Used to render an external camera of vr player (split front/back). 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using UnityEngine.Rendering; 9 | using Valve.VR; 10 | 11 | public class SteamVR_ExternalCamera : MonoBehaviour 12 | { 13 | public struct Config 14 | { 15 | public float x, y, z; 16 | public float rx, ry, rz; 17 | public float fov; 18 | public float near, far; 19 | public float sceneResolutionScale; 20 | public float frameSkip; 21 | public float nearOffset, farOffset; 22 | public float hmdOffset; 23 | public bool disableStandardAssets; 24 | } 25 | 26 | public Config config; 27 | public string configPath; 28 | 29 | public void ReadConfig() 30 | { 31 | try 32 | { 33 | var mCam = new HmdMatrix34_t(); 34 | var readCamMatrix = false; 35 | 36 | object c = config; // box 37 | var lines = System.IO.File.ReadAllLines(configPath); 38 | foreach (var line in lines) 39 | { 40 | var split = line.Split('='); 41 | if (split.Length == 2) 42 | { 43 | var key = split[0]; 44 | if (key == "m") 45 | { 46 | var values = split[1].Split(','); 47 | if (values.Length == 12) 48 | { 49 | mCam.m0 = float.Parse(values[0]); 50 | mCam.m1 = float.Parse(values[1]); 51 | mCam.m2 = float.Parse(values[2]); 52 | mCam.m3 = float.Parse(values[3]); 53 | mCam.m4 = float.Parse(values[4]); 54 | mCam.m5 = float.Parse(values[5]); 55 | mCam.m6 = float.Parse(values[6]); 56 | mCam.m7 = float.Parse(values[7]); 57 | mCam.m8 = float.Parse(values[8]); 58 | mCam.m9 = float.Parse(values[9]); 59 | mCam.m10 = float.Parse(values[10]); 60 | mCam.m11 = float.Parse(values[11]); 61 | readCamMatrix = true; 62 | } 63 | } 64 | else if (key == "disableStandardAssets") 65 | { 66 | var field = c.GetType().GetField(key); 67 | if (field != null) 68 | field.SetValue(c, bool.Parse(split[1])); 69 | } 70 | else 71 | { 72 | var field = c.GetType().GetField(key); 73 | if (field != null) 74 | field.SetValue(c, float.Parse(split[1])); 75 | } 76 | } 77 | } 78 | config = (Config)c; //unbox 79 | 80 | // Convert calibrated camera matrix settings. 81 | if (readCamMatrix) 82 | { 83 | var t = new SteamVR_Utils.RigidTransform(mCam); 84 | config.x = t.pos.x; 85 | config.y = t.pos.y; 86 | config.z = t.pos.z; 87 | var angles = t.rot.eulerAngles; 88 | config.rx = angles.x; 89 | config.ry = angles.y; 90 | config.rz = angles.z; 91 | } 92 | } 93 | catch { } 94 | } 95 | 96 | Camera cam; 97 | Transform target; 98 | GameObject clipQuad; 99 | Material clipMaterial; 100 | 101 | public void AttachToCamera(SteamVR_Camera vrcam) 102 | { 103 | if (target == vrcam.head) 104 | return; 105 | 106 | target = vrcam.head; 107 | 108 | var root = transform.parent; 109 | var origin = vrcam.head.parent; 110 | root.parent = origin; 111 | root.localPosition = Vector3.zero; 112 | root.localRotation = Quaternion.identity; 113 | root.localScale = Vector3.one; 114 | 115 | // Make a copy of the eye camera to pick up any camera fx. 116 | vrcam.enabled = false; 117 | var go = Instantiate(vrcam.gameObject); 118 | vrcam.enabled = true; 119 | go.name = "camera"; 120 | 121 | DestroyImmediate(go.GetComponent()); 122 | 123 | cam = go.GetComponent(); 124 | cam.fieldOfView = config.fov; 125 | cam.useOcclusionCulling = false; 126 | cam.enabled = false; // manually rendered 127 | 128 | colorMat = new Material(Shader.Find("Custom/SteamVR_ColorOut")); 129 | alphaMat = new Material(Shader.Find("Custom/SteamVR_AlphaOut")); 130 | clipMaterial = new Material(Shader.Find("Custom/SteamVR_ClearAll")); 131 | 132 | var offset = go.transform; 133 | offset.parent = transform; 134 | offset.localPosition = new Vector3(config.x, config.y, config.z); 135 | offset.localRotation = Quaternion.Euler(config.rx, config.ry, config.rz); 136 | offset.localScale = Vector3.one; 137 | 138 | // Strip children of cloned object (AudioListener in particular). 139 | while (offset.childCount > 0) 140 | DestroyImmediate(offset.GetChild(0).gameObject); 141 | 142 | // Setup clipping quad (using camera clip causes problems with shadows). 143 | clipQuad = GameObject.CreatePrimitive(PrimitiveType.Quad); 144 | clipQuad.name = "ClipQuad"; 145 | DestroyImmediate(clipQuad.GetComponent()); 146 | 147 | var clipRenderer = clipQuad.GetComponent(); 148 | clipRenderer.material = clipMaterial; 149 | clipRenderer.shadowCastingMode = ShadowCastingMode.Off; 150 | clipRenderer.receiveShadows = false; 151 | clipRenderer.lightProbeUsage = LightProbeUsage.Off; 152 | clipRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; 153 | 154 | var clipTransform = clipQuad.transform; 155 | clipTransform.parent = offset; 156 | clipTransform.localScale = new Vector3(1000.0f, 1000.0f, 1.0f); 157 | clipTransform.localRotation = Quaternion.identity; 158 | 159 | clipQuad.SetActive(false); 160 | } 161 | 162 | public float GetTargetDistance() 163 | { 164 | if (target == null) 165 | return config.near + 0.01f; 166 | 167 | var offset = cam.transform; 168 | var forward = new Vector3(offset.forward.x, 0.0f, offset.forward.z).normalized; 169 | var targetPos = target.position + new Vector3(target.forward.x, 0.0f, target.forward.z).normalized * config.hmdOffset; 170 | 171 | var distance = -(new Plane(forward, targetPos)).GetDistanceToPoint(offset.position); 172 | return Mathf.Clamp(distance, config.near + 0.01f, config.far - 0.01f); 173 | } 174 | 175 | Material colorMat, alphaMat; 176 | 177 | public void RenderNear() 178 | { 179 | var w = Screen.width / 2; 180 | var h = Screen.height / 2; 181 | 182 | if (cam.targetTexture == null || cam.targetTexture.width != w || cam.targetTexture.height != h) 183 | { 184 | cam.targetTexture = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32); 185 | cam.targetTexture.antiAliasing = QualitySettings.antiAliasing == 0 ? 1 : QualitySettings.antiAliasing; 186 | } 187 | 188 | cam.nearClipPlane = config.near; 189 | cam.farClipPlane = config.far; 190 | 191 | var clearFlags = cam.clearFlags; 192 | var backgroundColor = cam.backgroundColor; 193 | 194 | cam.clearFlags = CameraClearFlags.Color; 195 | cam.backgroundColor = Color.clear; 196 | 197 | float dist = Mathf.Clamp(GetTargetDistance() + config.nearOffset, config.near, config.far); 198 | var clipParent = clipQuad.transform.parent; 199 | clipQuad.transform.position = clipParent.position + clipParent.forward * dist; 200 | 201 | MonoBehaviour[] behaviours = null; 202 | bool[] wasEnabled = null; 203 | if (config.disableStandardAssets) 204 | { 205 | behaviours = cam.gameObject.GetComponents(); 206 | wasEnabled = new bool[behaviours.Length]; 207 | for (int i = 0; i < behaviours.Length; i++) 208 | { 209 | var behaviour = behaviours[i]; 210 | if (behaviour.enabled && behaviour.GetType().ToString().StartsWith("UnityStandardAssets.")) 211 | { 212 | behaviour.enabled = false; 213 | wasEnabled[i] = true; 214 | } 215 | } 216 | } 217 | 218 | clipQuad.SetActive(true); 219 | cam.Render(); 220 | clipQuad.SetActive(false); 221 | 222 | if (behaviours != null) 223 | { 224 | for (int i = 0; i < behaviours.Length; i++) 225 | { 226 | if (wasEnabled[i]) 227 | { 228 | behaviours[i].enabled = true; 229 | } 230 | } 231 | } 232 | 233 | cam.clearFlags = clearFlags; 234 | cam.backgroundColor = backgroundColor; 235 | 236 | Graphics.DrawTexture(new Rect(0, 0, w, h), cam.targetTexture, colorMat); 237 | Graphics.DrawTexture(new Rect(w, 0, w, h), cam.targetTexture, alphaMat); 238 | } 239 | 240 | public void RenderFar() 241 | { 242 | cam.nearClipPlane = config.near; 243 | cam.farClipPlane = config.far; 244 | cam.Render(); 245 | 246 | var w = Screen.width / 2; 247 | var h = Screen.height / 2; 248 | Graphics.DrawTexture(new Rect(0, h, w, h), cam.targetTexture, colorMat); 249 | } 250 | 251 | void OnGUI() 252 | { 253 | // Necessary for Graphics.DrawTexture to work even though we don't do anything here. 254 | } 255 | 256 | Camera[] cameras; 257 | Rect[] cameraRects; 258 | float sceneResolutionScale; 259 | 260 | void OnEnable() 261 | { 262 | // Move game view cameras to lower-right quadrant. 263 | cameras = FindObjectsOfType() as Camera[]; 264 | if (cameras != null) 265 | { 266 | var numCameras = cameras.Length; 267 | cameraRects = new Rect[numCameras]; 268 | for (int i = 0; i < numCameras; i++) 269 | { 270 | var cam = cameras[i]; 271 | cameraRects[i] = cam.rect; 272 | 273 | if (cam == this.cam) 274 | continue; 275 | 276 | if (cam.targetTexture != null) 277 | continue; 278 | 279 | if (cam.GetComponent() != null) 280 | continue; 281 | 282 | cam.rect = new Rect(0.5f, 0.0f, 0.5f, 0.5f); 283 | } 284 | } 285 | 286 | if (config.sceneResolutionScale > 0.0f) 287 | { 288 | sceneResolutionScale = SteamVR_Camera.sceneResolutionScale; 289 | SteamVR_Camera.sceneResolutionScale = config.sceneResolutionScale; 290 | } 291 | } 292 | 293 | void OnDisable() 294 | { 295 | // Restore game view cameras. 296 | if (cameras != null) 297 | { 298 | var numCameras = cameras.Length; 299 | for (int i = 0; i < numCameras; i++) 300 | { 301 | var cam = cameras[i]; 302 | if (cam != null) 303 | cam.rect = cameraRects[i]; 304 | } 305 | cameras = null; 306 | cameraRects = null; 307 | } 308 | 309 | if (config.sceneResolutionScale > 0.0f) 310 | { 311 | SteamVR_Camera.sceneResolutionScale = sceneResolutionScale; 312 | } 313 | } 314 | } 315 | 316 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_ExternalCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c9da270df5147d24597cc106058c1fa7 3 | timeCreated: 1455761349 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Fade.cs: -------------------------------------------------------------------------------- 1 | //#define TEST_FADE_VIEW 2 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 3 | // 4 | // Purpose: CameraFade script adapted to work with SteamVR. 5 | // 6 | // Usage: Add to your top level SteamVR_Camera (the one with ApplyDistoration 7 | // checked) and drag a reference to this component into SteamVR_Camera 8 | // RenderComponents list. Then call the static helper function 9 | // SteamVR_Fade.Start with the desired color and duration. 10 | // Use a duration of zero to set the start color. 11 | // 12 | // Example: Fade down from black over one second. 13 | // SteamVR_Fade.Start(Color.black, 0); 14 | // SteamVR_Fade.Start(Color.clear, 1); 15 | // 16 | // Note: This component is provided to fade out a single camera layer's 17 | // scene view. If instead you want to fade the entire view, use: 18 | // SteamVR_Fade.View(Color.black, 1); 19 | // (Does not affect the game view, however.) 20 | // 21 | //============================================================================= 22 | 23 | using UnityEngine; 24 | using Valve.VR; 25 | 26 | public class SteamVR_Fade : MonoBehaviour 27 | { 28 | private Color currentColor = new Color(0, 0, 0, 0); // default starting color: black and fully transparent 29 | private Color targetColor = new Color(0, 0, 0, 0); // default target color: black and fully transparent 30 | private Color deltaColor = new Color(0, 0, 0, 0); // the delta-color is basically the "speed / second" at which the current color should change 31 | private bool fadeOverlay = false; 32 | 33 | static public void Start(Color newColor, float duration, bool fadeOverlay = false) 34 | { 35 | SteamVR_Events.Fade.Send(newColor, duration, fadeOverlay); 36 | } 37 | 38 | static public void View(Color newColor, float duration) 39 | { 40 | var compositor = OpenVR.Compositor; 41 | if (compositor != null) 42 | compositor.FadeToColor(duration, newColor.r, newColor.g, newColor.b, newColor.a, false); 43 | } 44 | 45 | #if TEST_FADE_VIEW 46 | void Update() 47 | { 48 | if (Input.GetKeyDown(KeyCode.Space)) 49 | { 50 | SteamVR_Fade.View(Color.black, 0); 51 | SteamVR_Fade.View(Color.clear, 1); 52 | } 53 | } 54 | #endif 55 | 56 | public void OnStartFade(Color newColor, float duration, bool fadeOverlay) 57 | { 58 | if (duration > 0.0f) 59 | { 60 | targetColor = newColor; 61 | deltaColor = (targetColor - currentColor) / duration; 62 | } 63 | else 64 | { 65 | currentColor = newColor; 66 | } 67 | } 68 | 69 | static Material fadeMaterial = null; 70 | static int fadeMaterialColorID = -1; 71 | 72 | void OnEnable() 73 | { 74 | if (fadeMaterial == null) 75 | { 76 | fadeMaterial = new Material(Shader.Find("Custom/SteamVR_Fade")); 77 | fadeMaterialColorID = Shader.PropertyToID("fadeColor"); 78 | } 79 | 80 | SteamVR_Events.Fade.Listen(OnStartFade); 81 | SteamVR_Events.FadeReady.Send(); 82 | } 83 | 84 | void OnDisable() 85 | { 86 | SteamVR_Events.Fade.Remove(OnStartFade); 87 | } 88 | 89 | void OnPostRender() 90 | { 91 | if (currentColor != targetColor) 92 | { 93 | // if the difference between the current alpha and the desired alpha is smaller than delta-alpha * deltaTime, then we're pretty much done fading: 94 | if (Mathf.Abs(currentColor.a - targetColor.a) < Mathf.Abs(deltaColor.a) * Time.deltaTime) 95 | { 96 | currentColor = targetColor; 97 | deltaColor = new Color(0, 0, 0, 0); 98 | } 99 | else 100 | { 101 | currentColor += deltaColor * Time.deltaTime; 102 | } 103 | 104 | if (fadeOverlay) 105 | { 106 | var overlay = SteamVR_Overlay.instance; 107 | if (overlay != null) 108 | { 109 | overlay.alpha = 1.0f - currentColor.a; 110 | } 111 | } 112 | } 113 | 114 | if (currentColor.a > 0 && fadeMaterial) 115 | { 116 | fadeMaterial.SetColor(fadeMaterialColorID, currentColor); 117 | fadeMaterial.SetPass(0); 118 | GL.Begin(GL.QUADS); 119 | 120 | GL.Vertex3(-1, -1, 0); 121 | GL.Vertex3( 1, -1, 0); 122 | GL.Vertex3(1, 1, 0); 123 | GL.Vertex3(-1, 1, 0); 124 | GL.End(); 125 | } 126 | } 127 | } 128 | 129 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Fade.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2ad1e469d4e3e04489f9a36419f1a4f8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Frustum.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Generates a mesh based on field of view. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | [ExecuteInEditMode, RequireComponent(typeof(MeshRenderer), typeof(MeshFilter))] 11 | public class SteamVR_Frustum : MonoBehaviour 12 | { 13 | public SteamVR_TrackedObject.EIndex index; 14 | 15 | public float fovLeft = 45, fovRight = 45, fovTop = 45, fovBottom = 45, nearZ = 0.5f, farZ = 2.5f; 16 | 17 | public void UpdateModel() 18 | { 19 | fovLeft = Mathf.Clamp(fovLeft, 1, 89); 20 | fovRight = Mathf.Clamp(fovRight, 1, 89); 21 | fovTop = Mathf.Clamp(fovTop, 1, 89); 22 | fovBottom = Mathf.Clamp(fovBottom, 1, 89); 23 | farZ = Mathf.Max(farZ, nearZ + 0.01f); 24 | nearZ = Mathf.Clamp(nearZ, 0.01f, farZ - 0.01f); 25 | 26 | var lsin = Mathf.Sin(-fovLeft * Mathf.Deg2Rad); 27 | var rsin = Mathf.Sin(fovRight * Mathf.Deg2Rad); 28 | var tsin = Mathf.Sin(fovTop * Mathf.Deg2Rad); 29 | var bsin = Mathf.Sin(-fovBottom * Mathf.Deg2Rad); 30 | 31 | var lcos = Mathf.Cos(-fovLeft * Mathf.Deg2Rad); 32 | var rcos = Mathf.Cos(fovRight * Mathf.Deg2Rad); 33 | var tcos = Mathf.Cos(fovTop * Mathf.Deg2Rad); 34 | var bcos = Mathf.Cos(-fovBottom * Mathf.Deg2Rad); 35 | 36 | var corners = new Vector3[] { 37 | new Vector3(lsin * nearZ / lcos, tsin * nearZ / tcos, nearZ), //tln 38 | new Vector3(rsin * nearZ / rcos, tsin * nearZ / tcos, nearZ), //trn 39 | new Vector3(rsin * nearZ / rcos, bsin * nearZ / bcos, nearZ), //brn 40 | new Vector3(lsin * nearZ / lcos, bsin * nearZ / bcos, nearZ), //bln 41 | new Vector3(lsin * farZ / lcos, tsin * farZ / tcos, farZ ), //tlf 42 | new Vector3(rsin * farZ / rcos, tsin * farZ / tcos, farZ ), //trf 43 | new Vector3(rsin * farZ / rcos, bsin * farZ / bcos, farZ ), //brf 44 | new Vector3(lsin * farZ / lcos, bsin * farZ / bcos, farZ ), //blf 45 | }; 46 | 47 | var triangles = new int[] { 48 | // 0, 1, 2, 0, 2, 3, // near 49 | // 0, 2, 1, 0, 3, 2, // near 50 | // 4, 5, 6, 4, 6, 7, // far 51 | // 4, 6, 5, 4, 7, 6, // far 52 | 0, 4, 7, 0, 7, 3, // left 53 | 0, 7, 4, 0, 3, 7, // left 54 | 1, 5, 6, 1, 6, 2, // right 55 | 1, 6, 5, 1, 2, 6, // right 56 | 0, 4, 5, 0, 5, 1, // top 57 | 0, 5, 4, 0, 1, 5, // top 58 | 2, 3, 7, 2, 7, 6, // bottom 59 | 2, 7, 3, 2, 6, 7, // bottom 60 | }; 61 | 62 | int j = 0; 63 | var vertices = new Vector3[triangles.Length]; 64 | var normals = new Vector3[triangles.Length]; 65 | for (int i = 0; i < triangles.Length / 3; i++) 66 | { 67 | var a = corners[triangles[i * 3 + 0]]; 68 | var b = corners[triangles[i * 3 + 1]]; 69 | var c = corners[triangles[i * 3 + 2]]; 70 | var n = Vector3.Cross(b - a, c - a).normalized; 71 | normals[i * 3 + 0] = n; 72 | normals[i * 3 + 1] = n; 73 | normals[i * 3 + 2] = n; 74 | vertices[i * 3 + 0] = a; 75 | vertices[i * 3 + 1] = b; 76 | vertices[i * 3 + 2] = c; 77 | triangles[i * 3 + 0] = j++; 78 | triangles[i * 3 + 1] = j++; 79 | triangles[i * 3 + 2] = j++; 80 | } 81 | 82 | var mesh = new Mesh(); 83 | mesh.vertices = vertices; 84 | mesh.normals = normals; 85 | mesh.triangles = triangles; 86 | 87 | GetComponent().mesh = mesh; 88 | } 89 | 90 | private void OnDeviceConnected(int i, bool connected) 91 | { 92 | if (i != (int)index) 93 | return; 94 | 95 | GetComponent().mesh = null; 96 | 97 | if (connected) 98 | { 99 | var system = OpenVR.System; 100 | if (system != null && system.GetTrackedDeviceClass((uint)i) == ETrackedDeviceClass.TrackingReference) 101 | { 102 | var error = ETrackedPropertyError.TrackedProp_Success; 103 | var result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewLeftDegrees_Float, ref error); 104 | if (error == ETrackedPropertyError.TrackedProp_Success) 105 | fovLeft = result; 106 | 107 | result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewRightDegrees_Float, ref error); 108 | if (error == ETrackedPropertyError.TrackedProp_Success) 109 | fovRight = result; 110 | 111 | result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewTopDegrees_Float, ref error); 112 | if (error == ETrackedPropertyError.TrackedProp_Success) 113 | fovTop = result; 114 | 115 | result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_FieldOfViewBottomDegrees_Float, ref error); 116 | if (error == ETrackedPropertyError.TrackedProp_Success) 117 | fovBottom = result; 118 | 119 | result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_TrackingRangeMinimumMeters_Float, ref error); 120 | if (error == ETrackedPropertyError.TrackedProp_Success) 121 | nearZ = result; 122 | 123 | result = system.GetFloatTrackedDeviceProperty((uint)i, ETrackedDeviceProperty.Prop_TrackingRangeMaximumMeters_Float, ref error); 124 | if (error == ETrackedPropertyError.TrackedProp_Success) 125 | farZ = result; 126 | 127 | UpdateModel(); 128 | } 129 | } 130 | } 131 | 132 | void OnEnable() 133 | { 134 | GetComponent().mesh = null; 135 | SteamVR_Events.DeviceConnected.Listen(OnDeviceConnected); 136 | } 137 | 138 | void OnDisable() 139 | { 140 | SteamVR_Events.DeviceConnected.Remove(OnDeviceConnected); 141 | GetComponent().mesh = null; 142 | } 143 | 144 | #if UNITY_EDITOR 145 | void Update() 146 | { 147 | if (!Application.isPlaying) 148 | UpdateModel(); 149 | } 150 | #endif 151 | } 152 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Frustum.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2d1785fa0c551e408b6c94398847b76 3 | timeCreated: 1427400484 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_GameView.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Handles rendering to the game view window 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [ExecuteInEditMode] 10 | public class SteamVR_GameView : MonoBehaviour 11 | { 12 | void Awake() 13 | { 14 | Debug.Log("SteamVR_GameView is deprecated in Unity 5.4 - REMOVING"); 15 | DestroyImmediate(this); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_GameView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be96d45fe21847a4a805d408a8015c84 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_IK.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Simple two bone ik solver. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | public class SteamVR_IK : MonoBehaviour 10 | { 11 | public Transform target; 12 | public Transform start, joint, end; 13 | public Transform poleVector, upVector; 14 | 15 | public float blendPct = 1.0f; 16 | 17 | [HideInInspector] 18 | public Transform startXform, jointXform, endXform; 19 | 20 | void LateUpdate() 21 | { 22 | const float epsilon = 0.001f; 23 | if (blendPct < epsilon) 24 | return; 25 | 26 | var preUp = upVector ? upVector.up : Vector3.Cross(end.position - start.position, joint.position - start.position).normalized; 27 | 28 | var targetPosition = target.position; 29 | var targetRotation = target.rotation; 30 | 31 | Vector3 forward, up, result = joint.position; 32 | Solve(start.position, targetPosition, poleVector.position, 33 | (joint.position - start.position).magnitude, 34 | (end.position - joint.position).magnitude, 35 | ref result, out forward, out up); 36 | 37 | if (up == Vector3.zero) 38 | return; 39 | 40 | var startPosition = start.position; 41 | var jointPosition = joint.position; 42 | var endPosition = end.position; 43 | 44 | var startRotationLocal = start.localRotation; 45 | var jointRotationLocal = joint.localRotation; 46 | var endRotationLocal = end.localRotation; 47 | 48 | var startParent = start.parent; 49 | var jointParent = joint.parent; 50 | var endParent = end.parent; 51 | 52 | var startScale = start.localScale; 53 | var jointScale = joint.localScale; 54 | var endScale = end.localScale; 55 | 56 | if (startXform == null) 57 | { 58 | startXform = new GameObject("startXform").transform; 59 | startXform.parent = transform; 60 | } 61 | 62 | startXform.position = startPosition; 63 | startXform.LookAt(joint, preUp); 64 | start.parent = startXform; 65 | 66 | if (jointXform == null) 67 | { 68 | jointXform = new GameObject("jointXform").transform; 69 | jointXform.parent = startXform; 70 | } 71 | 72 | jointXform.position = jointPosition; 73 | jointXform.LookAt(end, preUp); 74 | joint.parent = jointXform; 75 | 76 | if (endXform == null) 77 | { 78 | endXform = new GameObject("endXform").transform; 79 | endXform.parent = jointXform; 80 | } 81 | 82 | endXform.position = endPosition; 83 | end.parent = endXform; 84 | 85 | startXform.LookAt(result, up); 86 | jointXform.LookAt(targetPosition, up); 87 | endXform.rotation = targetRotation; 88 | 89 | start.parent = startParent; 90 | joint.parent = jointParent; 91 | end.parent = endParent; 92 | 93 | end.rotation = targetRotation; // optionally blend? 94 | 95 | // handle blending in/out 96 | if (blendPct < 1.0f) 97 | { 98 | start.localRotation = Quaternion.Slerp(startRotationLocal, start.localRotation, blendPct); 99 | joint.localRotation = Quaternion.Slerp(jointRotationLocal, joint.localRotation, blendPct); 100 | end.localRotation = Quaternion.Slerp(endRotationLocal, end.localRotation, blendPct); 101 | } 102 | 103 | // restore scale so it doesn't blow out 104 | start.localScale = startScale; 105 | joint.localScale = jointScale; 106 | end.localScale = endScale; 107 | } 108 | 109 | public static bool Solve( 110 | Vector3 start, // shoulder / hip 111 | Vector3 end, // desired hand / foot position 112 | Vector3 poleVector, // point to aim elbow / knee toward 113 | float jointDist, // distance from start to elbow / knee 114 | float targetDist, // distance from joint to hand / ankle 115 | ref Vector3 result, // original and output elbow / knee position 116 | out Vector3 forward, out Vector3 up) // plane formed by root, joint and target 117 | { 118 | var totalDist = jointDist + targetDist; 119 | var start2end = end - start; 120 | var poleVectorDir = (poleVector - start).normalized; 121 | var baseDist = start2end.magnitude; 122 | 123 | result = start; 124 | 125 | const float epsilon = 0.001f; 126 | if (baseDist < epsilon) 127 | { 128 | // move jointDist toward jointTarget 129 | result += poleVectorDir * jointDist; 130 | 131 | forward = Vector3.Cross(poleVectorDir, Vector3.up); 132 | up = Vector3.Cross(forward, poleVectorDir).normalized; 133 | } 134 | else 135 | { 136 | forward = start2end * (1.0f / baseDist); 137 | up = Vector3.Cross(forward, poleVectorDir).normalized; 138 | 139 | if (baseDist + epsilon < totalDist) 140 | { 141 | // calculate the area of the triangle to determine its height 142 | var p = (totalDist + baseDist) * 0.5f; // half perimeter 143 | if (p > jointDist + epsilon && p > targetDist + epsilon) 144 | { 145 | var A = Mathf.Sqrt(p * (p - jointDist) * (p - targetDist) * (p - baseDist)); 146 | var height = 2.0f * A / baseDist; // distance of joint from line between root and target 147 | 148 | var dist = Mathf.Sqrt((jointDist * jointDist) - (height * height)); 149 | var right = Vector3.Cross(up, forward); // no need to normalized - already orthonormal 150 | 151 | result += (forward * dist) + (right * height); 152 | return true; // in range 153 | } 154 | else 155 | { 156 | // move jointDist toward jointTarget 157 | result += poleVectorDir * jointDist; 158 | } 159 | } 160 | else 161 | { 162 | // move elboDist toward target 163 | result += forward * jointDist; 164 | } 165 | } 166 | 167 | return false; // edge cases 168 | } 169 | } 170 | 171 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_IK.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea22dba3baf2ecc4d886bf2444444228 3 | timeCreated: 1437502789 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_LoadLevel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5a6a70209b6e6345bfe18b02314a54e 3 | timeCreated: 1446783318 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Menu.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Example menu using OnGUI with SteamVR_Camera's overlay support 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_Menu : MonoBehaviour 11 | { 12 | public Texture cursor, background, logo; 13 | public float logoHeight, menuOffset; 14 | 15 | public Vector2 scaleLimits = new Vector2(0.1f, 5.0f); 16 | public float scaleRate = 0.5f; 17 | 18 | SteamVR_Overlay overlay; 19 | Camera overlayCam; 20 | Vector4 uvOffset; 21 | float distance; 22 | 23 | public RenderTexture texture { get { return overlay ? overlay.texture as RenderTexture : null; } } 24 | public float scale { get; private set; } 25 | 26 | string scaleLimitX, scaleLimitY, scaleRateText; 27 | 28 | CursorLockMode savedCursorLockState; 29 | bool savedCursorVisible; 30 | 31 | void Awake() 32 | { 33 | scaleLimitX = string.Format("{0:N1}", scaleLimits.x); 34 | scaleLimitY = string.Format("{0:N1}", scaleLimits.y); 35 | scaleRateText = string.Format("{0:N1}", scaleRate); 36 | 37 | var overlay = SteamVR_Overlay.instance; 38 | if (overlay != null) 39 | { 40 | uvOffset = overlay.uvOffset; 41 | distance = overlay.distance; 42 | } 43 | } 44 | 45 | void OnGUI() 46 | { 47 | if (overlay == null) 48 | return; 49 | 50 | var texture = overlay.texture as RenderTexture; 51 | 52 | var prevActive = RenderTexture.active; 53 | RenderTexture.active = texture; 54 | 55 | if (Event.current.type == EventType.Repaint) 56 | GL.Clear(false, true, Color.clear); 57 | 58 | var area = new Rect(0, 0, texture.width, texture.height); 59 | 60 | // Account for screen smaller than texture (since mouse position gets clamped) 61 | if (Screen.width < texture.width) 62 | { 63 | area.width = Screen.width; 64 | overlay.uvOffset.x = -(float)(texture.width - Screen.width) / (2 * texture.width); 65 | } 66 | if (Screen.height < texture.height) 67 | { 68 | area.height = Screen.height; 69 | overlay.uvOffset.y = (float)(texture.height - Screen.height) / (2 * texture.height); 70 | } 71 | 72 | GUILayout.BeginArea(area); 73 | 74 | if (background != null) 75 | { 76 | GUI.DrawTexture(new Rect( 77 | (area.width - background.width) / 2, 78 | (area.height - background.height) / 2, 79 | background.width, background.height), background); 80 | } 81 | 82 | GUILayout.BeginHorizontal(); 83 | GUILayout.FlexibleSpace(); 84 | GUILayout.BeginVertical(); 85 | 86 | if (logo != null) 87 | { 88 | GUILayout.Space(area.height / 2 - logoHeight); 89 | GUILayout.Box(logo); 90 | } 91 | 92 | GUILayout.Space(menuOffset); 93 | 94 | bool bHideMenu = GUILayout.Button("[Esc] - Close menu"); 95 | 96 | GUILayout.BeginHorizontal(); 97 | GUILayout.Label(string.Format("Scale: {0:N4}", scale)); 98 | { 99 | var result = GUILayout.HorizontalSlider(scale, scaleLimits.x, scaleLimits.y); 100 | if (result != scale) 101 | { 102 | SetScale(result); 103 | } 104 | } 105 | GUILayout.EndHorizontal(); 106 | 107 | GUILayout.BeginHorizontal(); 108 | GUILayout.Label(string.Format("Scale limits:")); 109 | { 110 | var result = GUILayout.TextField(scaleLimitX); 111 | if (result != scaleLimitX) 112 | { 113 | if (float.TryParse(result, out scaleLimits.x)) 114 | scaleLimitX = result; 115 | } 116 | } 117 | { 118 | var result = GUILayout.TextField(scaleLimitY); 119 | if (result != scaleLimitY) 120 | { 121 | if (float.TryParse(result, out scaleLimits.y)) 122 | scaleLimitY = result; 123 | } 124 | } 125 | GUILayout.EndHorizontal(); 126 | 127 | GUILayout.BeginHorizontal(); 128 | GUILayout.Label(string.Format("Scale rate:")); 129 | { 130 | var result = GUILayout.TextField(scaleRateText); 131 | if (result != scaleRateText) 132 | { 133 | if (float.TryParse(result, out scaleRate)) 134 | scaleRateText = result; 135 | } 136 | } 137 | GUILayout.EndHorizontal(); 138 | 139 | if (SteamVR.active) 140 | { 141 | var vr = SteamVR.instance; 142 | 143 | GUILayout.BeginHorizontal(); 144 | { 145 | var t = SteamVR_Camera.sceneResolutionScale; 146 | int w = (int)(vr.sceneWidth * t); 147 | int h = (int)(vr.sceneHeight * t); 148 | int pct = (int)(100.0f * t); 149 | GUILayout.Label(string.Format("Scene quality: {0}x{1} ({2}%)", w, h, pct)); 150 | var result = Mathf.RoundToInt(GUILayout.HorizontalSlider(pct, 50, 200)); 151 | if (result != pct) 152 | { 153 | SteamVR_Camera.sceneResolutionScale = (float)result / 100.0f; 154 | } 155 | } 156 | GUILayout.EndHorizontal(); 157 | } 158 | 159 | overlay.highquality = GUILayout.Toggle(overlay.highquality, "High quality"); 160 | 161 | if (overlay.highquality) 162 | { 163 | overlay.curved = GUILayout.Toggle(overlay.curved, "Curved overlay"); 164 | overlay.antialias = GUILayout.Toggle(overlay.antialias, "Overlay RGSS(2x2)"); 165 | } 166 | else 167 | { 168 | overlay.curved = false; 169 | overlay.antialias = false; 170 | } 171 | 172 | var tracker = SteamVR_Render.Top(); 173 | if (tracker != null) 174 | { 175 | tracker.wireframe = GUILayout.Toggle(tracker.wireframe, "Wireframe"); 176 | 177 | var render = SteamVR_Render.instance; 178 | if (render.trackingSpace == ETrackingUniverseOrigin.TrackingUniverseSeated) 179 | { 180 | if (GUILayout.Button("Switch to Standing")) 181 | render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseStanding; 182 | if (GUILayout.Button("Center View")) 183 | { 184 | var system = OpenVR.System; 185 | if (system != null) 186 | system.ResetSeatedZeroPose(); 187 | } 188 | } 189 | else 190 | { 191 | if (GUILayout.Button("Switch to Seated")) 192 | render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseSeated; 193 | } 194 | } 195 | 196 | #if !UNITY_EDITOR 197 | if (GUILayout.Button("Exit")) 198 | Application.Quit(); 199 | #endif 200 | GUILayout.Space(menuOffset); 201 | 202 | var env = System.Environment.GetEnvironmentVariable("VR_OVERRIDE"); 203 | if (env != null) 204 | { 205 | GUILayout.Label("VR_OVERRIDE=" + env); 206 | } 207 | 208 | GUILayout.Label("Graphics device: " + SystemInfo.graphicsDeviceVersion); 209 | 210 | GUILayout.EndVertical(); 211 | GUILayout.FlexibleSpace(); 212 | GUILayout.EndHorizontal(); 213 | 214 | GUILayout.EndArea(); 215 | 216 | if (cursor != null) 217 | { 218 | float x = Input.mousePosition.x, y = Screen.height - Input.mousePosition.y; 219 | float w = cursor.width, h = cursor.height; 220 | GUI.DrawTexture(new Rect(x, y, w, h), cursor); 221 | } 222 | 223 | RenderTexture.active = prevActive; 224 | 225 | if (bHideMenu) 226 | HideMenu(); 227 | } 228 | 229 | public void ShowMenu() 230 | { 231 | var overlay = SteamVR_Overlay.instance; 232 | if (overlay == null) 233 | return; 234 | 235 | var texture = overlay.texture as RenderTexture; 236 | if (texture == null) 237 | { 238 | Debug.LogError("Menu requires overlay texture to be a render texture."); 239 | return; 240 | } 241 | 242 | SaveCursorState(); 243 | 244 | Cursor.visible = true; 245 | Cursor.lockState = CursorLockMode.None; 246 | 247 | this.overlay = overlay; 248 | uvOffset = overlay.uvOffset; 249 | distance = overlay.distance; 250 | 251 | // If an existing camera is rendering into the overlay texture, we need 252 | // to temporarily disable it to keep it from clearing the texture on us. 253 | var cameras = Object.FindObjectsOfType(typeof(Camera)) as Camera[]; 254 | foreach (var cam in cameras) 255 | { 256 | if (cam.enabled && cam.targetTexture == texture) 257 | { 258 | overlayCam = cam; 259 | overlayCam.enabled = false; 260 | break; 261 | } 262 | } 263 | 264 | var tracker = SteamVR_Render.Top(); 265 | if (tracker != null) 266 | scale = tracker.origin.localScale.x; 267 | } 268 | 269 | public void HideMenu() 270 | { 271 | RestoreCursorState(); 272 | 273 | if (overlayCam != null) 274 | overlayCam.enabled = true; 275 | 276 | if (overlay != null) 277 | { 278 | overlay.uvOffset = uvOffset; 279 | overlay.distance = distance; 280 | overlay = null; 281 | } 282 | } 283 | 284 | void Update() 285 | { 286 | if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Joystick1Button7)) 287 | { 288 | if (overlay == null) 289 | { 290 | ShowMenu(); 291 | } 292 | else 293 | { 294 | HideMenu(); 295 | } 296 | } 297 | else if (Input.GetKeyDown(KeyCode.Home)) 298 | { 299 | SetScale(1.0f); 300 | } 301 | else if (Input.GetKey(KeyCode.PageUp)) 302 | { 303 | SetScale(Mathf.Clamp(scale + scaleRate * Time.deltaTime, scaleLimits.x, scaleLimits.y)); 304 | } 305 | else if (Input.GetKey(KeyCode.PageDown)) 306 | { 307 | SetScale(Mathf.Clamp(scale - scaleRate * Time.deltaTime, scaleLimits.x, scaleLimits.y)); 308 | } 309 | } 310 | 311 | void SetScale(float scale) 312 | { 313 | this.scale = scale; 314 | 315 | var tracker = SteamVR_Render.Top(); 316 | if (tracker != null) 317 | tracker.origin.localScale = new Vector3(scale, scale, scale); 318 | } 319 | 320 | void SaveCursorState() 321 | { 322 | savedCursorVisible = Cursor.visible; 323 | savedCursorLockState = Cursor.lockState; 324 | } 325 | 326 | void RestoreCursorState() 327 | { 328 | Cursor.visible = savedCursorVisible; 329 | Cursor.lockState = savedCursorLockState; 330 | } 331 | } 332 | 333 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Menu.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7afc8c74d1f73b458705e0b946292a0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Overlay.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Displays 2d content on a large virtual screen. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | using Valve.VR; 10 | 11 | public class SteamVR_Overlay : MonoBehaviour 12 | { 13 | public Texture texture; 14 | public bool curved = true; 15 | public bool antialias = true; 16 | public bool highquality = true; 17 | public float scale = 3.0f; // size of overlay view 18 | public float distance = 1.25f; // distance from surface 19 | public float alpha = 1.0f; // opacity 0..1 20 | 21 | public Vector4 uvOffset = new Vector4(0, 0, 1, 1); 22 | public Vector2 mouseScale = new Vector2(1, 1); 23 | public Vector2 curvedRange = new Vector2(1, 2); 24 | 25 | public VROverlayInputMethod inputMethod = VROverlayInputMethod.None; 26 | 27 | static public SteamVR_Overlay instance { get; private set; } 28 | 29 | static public string key { get { return "unity:" + Application.companyName + "." + Application.productName; } } 30 | 31 | private ulong handle = OpenVR.k_ulOverlayHandleInvalid; 32 | 33 | void OnEnable() 34 | { 35 | var overlay = OpenVR.Overlay; 36 | if (overlay != null) 37 | { 38 | var error = overlay.CreateOverlay(key, gameObject.name, ref handle); 39 | if (error != EVROverlayError.None) 40 | { 41 | Debug.Log(overlay.GetOverlayErrorNameFromEnum(error)); 42 | enabled = false; 43 | return; 44 | } 45 | } 46 | 47 | SteamVR_Overlay.instance = this; 48 | } 49 | 50 | void OnDisable() 51 | { 52 | if (handle != OpenVR.k_ulOverlayHandleInvalid) 53 | { 54 | var overlay = OpenVR.Overlay; 55 | if (overlay != null) 56 | { 57 | overlay.DestroyOverlay(handle); 58 | } 59 | 60 | handle = OpenVR.k_ulOverlayHandleInvalid; 61 | } 62 | 63 | SteamVR_Overlay.instance = null; 64 | } 65 | 66 | public void UpdateOverlay() 67 | { 68 | var overlay = OpenVR.Overlay; 69 | if (overlay == null) 70 | return; 71 | 72 | if (texture != null) 73 | { 74 | var error = overlay.ShowOverlay(handle); 75 | if (error == EVROverlayError.InvalidHandle || error == EVROverlayError.UnknownOverlay) 76 | { 77 | if (overlay.FindOverlay(key, ref handle) != EVROverlayError.None) 78 | return; 79 | } 80 | 81 | var tex = new Texture_t(); 82 | tex.handle = texture.GetNativeTexturePtr(); 83 | tex.eType = SteamVR.instance.textureType; 84 | tex.eColorSpace = EColorSpace.Auto; 85 | overlay.SetOverlayTexture(handle, ref tex); 86 | 87 | overlay.SetOverlayAlpha(handle, alpha); 88 | overlay.SetOverlayWidthInMeters(handle, scale); 89 | overlay.SetOverlayAutoCurveDistanceRangeInMeters(handle, curvedRange.x, curvedRange.y); 90 | 91 | var textureBounds = new VRTextureBounds_t(); 92 | textureBounds.uMin = (0 + uvOffset.x) * uvOffset.z; 93 | textureBounds.vMin = (1 + uvOffset.y) * uvOffset.w; 94 | textureBounds.uMax = (1 + uvOffset.x) * uvOffset.z; 95 | textureBounds.vMax = (0 + uvOffset.y) * uvOffset.w; 96 | overlay.SetOverlayTextureBounds(handle, ref textureBounds); 97 | 98 | var vecMouseScale = new HmdVector2_t(); 99 | vecMouseScale.v0 = mouseScale.x; 100 | vecMouseScale.v1 = mouseScale.y; 101 | overlay.SetOverlayMouseScale(handle, ref vecMouseScale); 102 | 103 | var vrcam = SteamVR_Render.Top(); 104 | if (vrcam != null && vrcam.origin != null) 105 | { 106 | var offset = new SteamVR_Utils.RigidTransform(vrcam.origin, transform); 107 | offset.pos.x /= vrcam.origin.localScale.x; 108 | offset.pos.y /= vrcam.origin.localScale.y; 109 | offset.pos.z /= vrcam.origin.localScale.z; 110 | 111 | offset.pos.z += distance; 112 | 113 | var t = offset.ToHmdMatrix34(); 114 | overlay.SetOverlayTransformAbsolute(handle, SteamVR_Render.instance.trackingSpace, ref t); 115 | } 116 | 117 | overlay.SetOverlayInputMethod(handle, inputMethod); 118 | 119 | if (curved || antialias) 120 | highquality = true; 121 | 122 | if (highquality) 123 | { 124 | overlay.SetHighQualityOverlay(handle); 125 | overlay.SetOverlayFlag(handle, VROverlayFlags.Curved, curved); 126 | overlay.SetOverlayFlag(handle, VROverlayFlags.RGSS4X, antialias); 127 | } 128 | else if (overlay.GetHighQualityOverlay() == handle) 129 | { 130 | overlay.SetHighQualityOverlay(OpenVR.k_ulOverlayHandleInvalid); 131 | } 132 | } 133 | else 134 | { 135 | overlay.HideOverlay(handle); 136 | } 137 | } 138 | 139 | public bool PollNextEvent(ref VREvent_t pEvent) 140 | { 141 | var overlay = OpenVR.Overlay; 142 | if (overlay == null) 143 | return false; 144 | 145 | var size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Valve.VR.VREvent_t)); 146 | return overlay.PollNextOverlayEvent(handle, ref pEvent, size); 147 | } 148 | 149 | public struct IntersectionResults 150 | { 151 | public Vector3 point; 152 | public Vector3 normal; 153 | public Vector2 UVs; 154 | public float distance; 155 | } 156 | 157 | public bool ComputeIntersection(Vector3 source, Vector3 direction, ref IntersectionResults results) 158 | { 159 | var overlay = OpenVR.Overlay; 160 | if (overlay == null) 161 | return false; 162 | 163 | var input = new VROverlayIntersectionParams_t(); 164 | input.eOrigin = SteamVR_Render.instance.trackingSpace; 165 | input.vSource.v0 = source.x; 166 | input.vSource.v1 = source.y; 167 | input.vSource.v2 = -source.z; 168 | input.vDirection.v0 = direction.x; 169 | input.vDirection.v1 = direction.y; 170 | input.vDirection.v2 = -direction.z; 171 | 172 | var output = new VROverlayIntersectionResults_t(); 173 | if (!overlay.ComputeOverlayIntersection(handle, ref input, ref output)) 174 | return false; 175 | 176 | results.point = new Vector3(output.vPoint.v0, output.vPoint.v1, -output.vPoint.v2); 177 | results.normal = new Vector3(output.vNormal.v0, output.vNormal.v1, -output.vNormal.v2); 178 | results.UVs = new Vector2(output.vUVs.v0, output.vUVs.v1); 179 | results.distance = output.fDistance; 180 | return true; 181 | } 182 | } 183 | 184 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Overlay.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46fe9e0b23166454c8cb73040321d78c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_PlayArea.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Draws different sized room-scale play areas for targeting content 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using UnityEngine.Rendering; 9 | using System.Collections; 10 | using Valve.VR; 11 | 12 | [ExecuteInEditMode, RequireComponent(typeof(MeshRenderer), typeof(MeshFilter))] 13 | public class SteamVR_PlayArea : MonoBehaviour 14 | { 15 | public float borderThickness = 0.15f; 16 | public float wireframeHeight = 2.0f; 17 | public bool drawWireframeWhenSelectedOnly = false; 18 | public bool drawInGame = true; 19 | 20 | public enum Size 21 | { 22 | Calibrated, 23 | _400x300, 24 | _300x225, 25 | _200x150 26 | } 27 | 28 | public Size size; 29 | public Color color = Color.cyan; 30 | 31 | [HideInInspector] 32 | public Vector3[] vertices; 33 | 34 | public static bool GetBounds( Size size, ref HmdQuad_t pRect ) 35 | { 36 | if (size == Size.Calibrated) 37 | { 38 | var initOpenVR = (!SteamVR.active && !SteamVR.usingNativeSupport); 39 | if (initOpenVR) 40 | { 41 | var error = EVRInitError.None; 42 | OpenVR.Init(ref error, EVRApplicationType.VRApplication_Other); 43 | } 44 | 45 | var chaperone = OpenVR.Chaperone; 46 | bool success = (chaperone != null) && chaperone.GetPlayAreaRect(ref pRect); 47 | if (!success) 48 | Debug.LogWarning("Failed to get Calibrated Play Area bounds! Make sure you have tracking first, and that your space is calibrated."); 49 | 50 | if (initOpenVR) 51 | OpenVR.Shutdown(); 52 | 53 | return success; 54 | } 55 | else 56 | { 57 | try 58 | { 59 | var str = size.ToString().Substring(1); 60 | var arr = str.Split(new char[] {'x'}, 2); 61 | 62 | // convert to half size in meters (from cm) 63 | var x = float.Parse(arr[0]) / 200; 64 | var z = float.Parse(arr[1]) / 200; 65 | 66 | pRect.vCorners0.v0 = x; 67 | pRect.vCorners0.v1 = 0; 68 | pRect.vCorners0.v2 = z; 69 | 70 | pRect.vCorners1.v0 = x; 71 | pRect.vCorners1.v1 = 0; 72 | pRect.vCorners1.v2 = -z; 73 | 74 | pRect.vCorners2.v0 = -x; 75 | pRect.vCorners2.v1 = 0; 76 | pRect.vCorners2.v2 = -z; 77 | 78 | pRect.vCorners3.v0 = -x; 79 | pRect.vCorners3.v1 = 0; 80 | pRect.vCorners3.v2 = z; 81 | 82 | return true; 83 | } 84 | catch {} 85 | } 86 | 87 | return false; 88 | } 89 | 90 | public void BuildMesh() 91 | { 92 | var rect = new HmdQuad_t(); 93 | if ( !GetBounds( size, ref rect ) ) 94 | return; 95 | 96 | var corners = new HmdVector3_t[] { rect.vCorners0, rect.vCorners1, rect.vCorners2, rect.vCorners3 }; 97 | 98 | vertices = new Vector3[corners.Length * 2]; 99 | for (int i = 0; i < corners.Length; i++) 100 | { 101 | var c = corners[i]; 102 | vertices[i] = new Vector3(c.v0, 0.01f, c.v2); 103 | } 104 | 105 | if (borderThickness == 0.0f) 106 | { 107 | GetComponent().mesh = null; 108 | return; 109 | } 110 | 111 | for (int i = 0; i < corners.Length; i++) 112 | { 113 | int next = (i + 1) % corners.Length; 114 | int prev = (i + corners.Length - 1) % corners.Length; 115 | 116 | var nextSegment = (vertices[next] - vertices[i]).normalized; 117 | var prevSegment = (vertices[prev] - vertices[i]).normalized; 118 | 119 | var vert = vertices[i]; 120 | vert += Vector3.Cross(nextSegment, Vector3.up) * borderThickness; 121 | vert += Vector3.Cross(prevSegment, Vector3.down) * borderThickness; 122 | 123 | vertices[corners.Length + i] = vert; 124 | } 125 | 126 | var triangles = new int[] 127 | { 128 | 0, 4, 1, 129 | 1, 4, 5, 130 | 1, 5, 2, 131 | 2, 5, 6, 132 | 2, 6, 3, 133 | 3, 6, 7, 134 | 3, 7, 0, 135 | 0, 7, 4 136 | }; 137 | 138 | var uv = new Vector2[] 139 | { 140 | new Vector2(0.0f, 0.0f), 141 | new Vector2(1.0f, 0.0f), 142 | new Vector2(0.0f, 0.0f), 143 | new Vector2(1.0f, 0.0f), 144 | new Vector2(0.0f, 1.0f), 145 | new Vector2(1.0f, 1.0f), 146 | new Vector2(0.0f, 1.0f), 147 | new Vector2(1.0f, 1.0f) 148 | }; 149 | 150 | var colors = new Color[] 151 | { 152 | color, 153 | color, 154 | color, 155 | color, 156 | new Color(color.r, color.g, color.b, 0.0f), 157 | new Color(color.r, color.g, color.b, 0.0f), 158 | new Color(color.r, color.g, color.b, 0.0f), 159 | new Color(color.r, color.g, color.b, 0.0f) 160 | }; 161 | 162 | var mesh = new Mesh(); 163 | GetComponent().mesh = mesh; 164 | mesh.vertices = vertices; 165 | mesh.uv = uv; 166 | mesh.colors = colors; 167 | mesh.triangles = triangles; 168 | 169 | var renderer = GetComponent(); 170 | renderer.material = new Material(Shader.Find("Sprites/Default")); 171 | renderer.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; 172 | renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; 173 | renderer.receiveShadows = false; 174 | renderer.lightProbeUsage = LightProbeUsage.Off; 175 | } 176 | 177 | #if UNITY_EDITOR 178 | Hashtable values; 179 | void Update() 180 | { 181 | if (!Application.isPlaying) 182 | { 183 | var fields = GetType().GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); 184 | 185 | bool rebuild = false; 186 | 187 | if (values == null || (borderThickness != 0.0f && GetComponent().sharedMesh == null)) 188 | { 189 | rebuild = true; 190 | } 191 | else 192 | { 193 | foreach (var f in fields) 194 | { 195 | if (!values.Contains(f) || !f.GetValue(this).Equals(values[f])) 196 | { 197 | rebuild = true; 198 | break; 199 | } 200 | } 201 | } 202 | 203 | if (rebuild) 204 | { 205 | BuildMesh(); 206 | 207 | values = new Hashtable(); 208 | foreach (var f in fields) 209 | values[f] = f.GetValue(this); 210 | } 211 | } 212 | } 213 | #endif 214 | 215 | void OnDrawGizmos() 216 | { 217 | if (!drawWireframeWhenSelectedOnly) 218 | DrawWireframe(); 219 | } 220 | 221 | void OnDrawGizmosSelected() 222 | { 223 | if (drawWireframeWhenSelectedOnly) 224 | DrawWireframe(); 225 | } 226 | 227 | public void DrawWireframe() 228 | { 229 | if (vertices == null || vertices.Length == 0) 230 | return; 231 | 232 | var offset = transform.TransformVector(Vector3.up * wireframeHeight); 233 | for (int i = 0; i < 4; i++) 234 | { 235 | int next = (i + 1) % 4; 236 | 237 | var a = transform.TransformPoint(vertices[i]); 238 | var b = a + offset; 239 | var c = transform.TransformPoint(vertices[next]); 240 | var d = c + offset; 241 | Gizmos.DrawLine(a, b); 242 | Gizmos.DrawLine(a, c); 243 | Gizmos.DrawLine(b, d); 244 | } 245 | } 246 | 247 | public void OnEnable() 248 | { 249 | if (Application.isPlaying) 250 | { 251 | GetComponent().enabled = drawInGame; 252 | 253 | // No need to remain enabled at runtime. 254 | // Anyone that wants to change properties at runtime 255 | // should call BuildMesh themselves. 256 | enabled = false; 257 | 258 | // If we want the configured bounds of the user, 259 | // we need to wait for tracking. 260 | if (drawInGame && size == Size.Calibrated) 261 | StartCoroutine("UpdateBounds"); 262 | } 263 | } 264 | 265 | IEnumerator UpdateBounds() 266 | { 267 | GetComponent().mesh = null; // clear existing 268 | 269 | var chaperone = OpenVR.Chaperone; 270 | if (chaperone == null) 271 | yield break; 272 | 273 | while (chaperone.GetCalibrationState() != ChaperoneCalibrationState.OK) 274 | yield return null; 275 | 276 | BuildMesh(); 277 | } 278 | } 279 | 280 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_PlayArea.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f0522eaef74d984591c060d05a095c8 3 | timeCreated: 1438043592 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Render.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e979227f3384fac4b8ca0b3550bf005c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: -32000 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_RenderModel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5890e3cad70bea64d91aef9145ba3454 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Skybox.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Sets cubemap to use in the compositor. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_Skybox : MonoBehaviour 11 | { 12 | // Note: Unity's Left and Right Skybox shader variables are switched. 13 | public Texture front, back, left, right, top, bottom; 14 | 15 | public enum CellSize 16 | { 17 | x1024, x64, x32, x16, x8 18 | } 19 | public CellSize StereoCellSize = CellSize.x32; 20 | 21 | public float StereoIpdMm = 64.0f; 22 | 23 | public void SetTextureByIndex(int i, Texture t) 24 | { 25 | switch (i) 26 | { 27 | case 0: 28 | front = t; 29 | break; 30 | case 1: 31 | back = t; 32 | break; 33 | case 2: 34 | left = t; 35 | break; 36 | case 3: 37 | right = t; 38 | break; 39 | case 4: 40 | top = t; 41 | break; 42 | case 5: 43 | bottom = t; 44 | break; 45 | } 46 | } 47 | 48 | public Texture GetTextureByIndex(int i) 49 | { 50 | switch (i) 51 | { 52 | case 0: 53 | return front; 54 | case 1: 55 | return back; 56 | case 2: 57 | return left; 58 | case 3: 59 | return right; 60 | case 4: 61 | return top; 62 | case 5: 63 | return bottom; 64 | } 65 | return null; 66 | } 67 | 68 | static public void SetOverride( 69 | Texture front = null, 70 | Texture back = null, 71 | Texture left = null, 72 | Texture right = null, 73 | Texture top = null, 74 | Texture bottom = null ) 75 | { 76 | var compositor = OpenVR.Compositor; 77 | if (compositor != null) 78 | { 79 | var handles = new Texture[] { front, back, left, right, top, bottom }; 80 | var textures = new Texture_t[6]; 81 | for (int i = 0; i < 6; i++) 82 | { 83 | textures[i].handle = (handles[i] != null) ? handles[i].GetNativeTexturePtr() : System.IntPtr.Zero; 84 | textures[i].eType = SteamVR.instance.textureType; 85 | textures[i].eColorSpace = EColorSpace.Auto; 86 | } 87 | var error = compositor.SetSkyboxOverride(textures); 88 | if (error != EVRCompositorError.None) 89 | { 90 | Debug.LogError("Failed to set skybox override with error: " + error); 91 | if (error == EVRCompositorError.TextureIsOnWrongDevice) 92 | Debug.Log("Set your graphics driver to use the same video card as the headset is plugged into for Unity."); 93 | else if (error == EVRCompositorError.TextureUsesUnsupportedFormat) 94 | Debug.Log("Ensure skybox textures are not compressed and have no mipmaps."); 95 | } 96 | } 97 | } 98 | 99 | static public void ClearOverride() 100 | { 101 | var compositor = OpenVR.Compositor; 102 | if (compositor != null) 103 | compositor.ClearSkyboxOverride(); 104 | } 105 | 106 | void OnEnable() 107 | { 108 | SetOverride(front, back, left, right, top, bottom); 109 | } 110 | 111 | void OnDisable() 112 | { 113 | ClearOverride(); 114 | } 115 | } 116 | 117 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Skybox.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13a43e992568b8e48b4bd489b9d96f40 3 | timeCreated: 1439344311 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_SphericalProjection.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Applies spherical projection to output. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | 9 | [ExecuteInEditMode] 10 | public class SteamVR_SphericalProjection : MonoBehaviour 11 | { 12 | static Material material; 13 | 14 | public void Set(Vector3 N, 15 | float phi0, float phi1, float theta0, float theta1, // in degrees 16 | Vector3 uAxis, Vector3 uOrigin, float uScale, 17 | Vector3 vAxis, Vector3 vOrigin, float vScale) 18 | { 19 | if (material == null) 20 | material = new Material(Shader.Find("Custom/SteamVR_SphericalProjection")); 21 | 22 | material.SetVector("_N", new Vector4(N.x, N.y, N.z)); 23 | material.SetFloat("_Phi0", phi0 * Mathf.Deg2Rad); 24 | material.SetFloat("_Phi1", phi1 * Mathf.Deg2Rad); 25 | material.SetFloat("_Theta0", theta0 * Mathf.Deg2Rad + Mathf.PI / 2); 26 | material.SetFloat("_Theta1", theta1 * Mathf.Deg2Rad + Mathf.PI / 2); 27 | material.SetVector("_UAxis", uAxis); 28 | material.SetVector("_VAxis", vAxis); 29 | material.SetVector("_UOrigin", uOrigin); 30 | material.SetVector("_VOrigin", vOrigin); 31 | material.SetFloat("_UScale", uScale); 32 | material.SetFloat("_VScale", vScale); 33 | } 34 | 35 | void OnRenderImage(RenderTexture src, RenderTexture dest) 36 | { 37 | Graphics.Blit(src, dest, material); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_SphericalProjection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7f4097fabec5d2b4da2b861750319952 3 | timeCreated: 1462380202 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Stats.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Helper to display various hmd stats via GUIText 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_Stats : MonoBehaviour 11 | { 12 | public GUIText text; 13 | 14 | public Color fadeColor = Color.black; 15 | public float fadeDuration = 1.0f; 16 | 17 | void Awake() 18 | { 19 | if (text == null) 20 | { 21 | text = GetComponent(); 22 | text.enabled = false; 23 | } 24 | 25 | if (fadeDuration > 0) 26 | { 27 | SteamVR_Fade.Start(fadeColor, 0); 28 | SteamVR_Fade.Start(Color.clear, fadeDuration); 29 | } 30 | } 31 | 32 | double lastUpdate = 0.0f; 33 | 34 | void Update() 35 | { 36 | if (text != null) 37 | { 38 | if (Input.GetKeyDown(KeyCode.I)) 39 | { 40 | text.enabled = !text.enabled; 41 | } 42 | 43 | if (text.enabled) 44 | { 45 | var compositor = OpenVR.Compositor; 46 | if (compositor != null) 47 | { 48 | var timing = new Compositor_FrameTiming(); 49 | timing.m_nSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Compositor_FrameTiming)); 50 | compositor.GetFrameTiming(ref timing, 0); 51 | 52 | var update = timing.m_flSystemTimeInSeconds; 53 | if (update > lastUpdate) 54 | { 55 | var framerate = (lastUpdate > 0.0f) ? 1.0f / (update - lastUpdate) : 0.0f; 56 | lastUpdate = update; 57 | text.text = string.Format("framerate: {0:N0}\ndropped frames: {1}", framerate, (int)timing.m_nNumDroppedFrames); 58 | } 59 | else 60 | { 61 | lastUpdate = update; 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Stats.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c3faa610c019764a81eb8497109e2d4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_TestController.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Test SteamVR_Controller support. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using System.Collections.Generic; 9 | using Valve.VR; 10 | 11 | public class SteamVR_TestController : MonoBehaviour 12 | { 13 | List controllerIndices = new List(); 14 | 15 | private void OnDeviceConnected(int index, bool connected) 16 | { 17 | var system = OpenVR.System; 18 | if (system == null || system.GetTrackedDeviceClass((uint)index) != ETrackedDeviceClass.Controller) 19 | return; 20 | 21 | if (connected) 22 | { 23 | Debug.Log(string.Format("Controller {0} connected.", index)); 24 | PrintControllerStatus(index); 25 | controllerIndices.Add(index); 26 | } 27 | else 28 | { 29 | Debug.Log(string.Format("Controller {0} disconnected.", index)); 30 | PrintControllerStatus(index); 31 | controllerIndices.Remove(index); 32 | } 33 | } 34 | 35 | void OnEnable() 36 | { 37 | SteamVR_Events.DeviceConnected.Listen(OnDeviceConnected); 38 | } 39 | 40 | void OnDisable() 41 | { 42 | SteamVR_Events.DeviceConnected.Remove(OnDeviceConnected); 43 | } 44 | 45 | void PrintControllerStatus(int index) 46 | { 47 | var device = SteamVR_Controller.Input(index); 48 | Debug.Log("index: " + device.index); 49 | Debug.Log("connected: " + device.connected); 50 | Debug.Log("hasTracking: " + device.hasTracking); 51 | Debug.Log("outOfRange: " + device.outOfRange); 52 | Debug.Log("calibrating: " + device.calibrating); 53 | Debug.Log("uninitialized: " + device.uninitialized); 54 | Debug.Log("pos: " + device.transform.pos); 55 | Debug.Log("rot: " + device.transform.rot.eulerAngles); 56 | Debug.Log("velocity: " + device.velocity); 57 | Debug.Log("angularVelocity: " + device.angularVelocity); 58 | 59 | var l = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost); 60 | var r = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost); 61 | Debug.Log((l == r) ? "first" : (l == index) ? "left" : "right"); 62 | } 63 | 64 | EVRButtonId[] buttonIds = new EVRButtonId[] { 65 | EVRButtonId.k_EButton_ApplicationMenu, 66 | EVRButtonId.k_EButton_Grip, 67 | EVRButtonId.k_EButton_SteamVR_Touchpad, 68 | EVRButtonId.k_EButton_SteamVR_Trigger 69 | }; 70 | 71 | EVRButtonId[] axisIds = new EVRButtonId[] { 72 | EVRButtonId.k_EButton_SteamVR_Touchpad, 73 | EVRButtonId.k_EButton_SteamVR_Trigger 74 | }; 75 | 76 | public Transform point, pointer; 77 | 78 | void Update() 79 | { 80 | foreach (var index in controllerIndices) 81 | { 82 | var overlay = SteamVR_Overlay.instance; 83 | if (overlay && point && pointer) 84 | { 85 | var t = SteamVR_Controller.Input(index).transform; 86 | pointer.transform.localPosition = t.pos; 87 | pointer.transform.localRotation = t.rot; 88 | 89 | var results = new SteamVR_Overlay.IntersectionResults(); 90 | var hit = overlay.ComputeIntersection(t.pos, t.rot * Vector3.forward, ref results); 91 | if (hit) 92 | { 93 | point.transform.localPosition = results.point; 94 | point.transform.localRotation = Quaternion.LookRotation(results.normal); 95 | } 96 | 97 | continue; 98 | } 99 | 100 | foreach (var buttonId in buttonIds) 101 | { 102 | if (SteamVR_Controller.Input(index).GetPressDown(buttonId)) 103 | Debug.Log(buttonId + " press down"); 104 | if (SteamVR_Controller.Input(index).GetPressUp(buttonId)) 105 | { 106 | Debug.Log(buttonId + " press up"); 107 | if (buttonId == EVRButtonId.k_EButton_SteamVR_Trigger) 108 | { 109 | SteamVR_Controller.Input(index).TriggerHapticPulse(); 110 | PrintControllerStatus(index); 111 | } 112 | } 113 | if (SteamVR_Controller.Input(index).GetPress(buttonId)) 114 | Debug.Log(buttonId); 115 | } 116 | 117 | foreach (var buttonId in axisIds) 118 | { 119 | if (SteamVR_Controller.Input(index).GetTouchDown(buttonId)) 120 | Debug.Log(buttonId + " touch down"); 121 | if (SteamVR_Controller.Input(index).GetTouchUp(buttonId)) 122 | Debug.Log(buttonId + " touch up"); 123 | if (SteamVR_Controller.Input(index).GetTouch(buttonId)) 124 | { 125 | var axis = SteamVR_Controller.Input(index).GetAxis(buttonId); 126 | Debug.Log("axis: " + axis); 127 | } 128 | } 129 | } 130 | } 131 | } 132 | 133 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_TestController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0811e240274b8ea4a8469e82b86747b4 3 | timeCreated: 1432764931 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_TrackedCamera.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Provides access to video feed and poses of tracked cameras. 4 | // 5 | // Usage: 6 | // var source = SteamVR_TrackedCamera.Distorted(); 7 | // var source = SteamVR_TrackedCamera.Undistorted(); 8 | // or 9 | // var undistorted = true; // or false 10 | // var source = SteamVR_TrackedCamera.Source(undistorted); 11 | // 12 | // - Distorted feeds are the decoded images from the camera. 13 | // - Undistorted feeds correct for the camera lens distortion (a.k.a. fisheye) 14 | // to make straight lines straight. 15 | // 16 | // VideoStreamTexture objects must be symmetrically Acquired and Released to 17 | // ensure the video stream is activated, and shutdown properly once there are 18 | // no more consumers. You only need to Acquire once when starting to use a 19 | // stream, and Release when you are done using it (as opposed to every frame). 20 | // 21 | //============================================================================= 22 | 23 | using UnityEngine; 24 | using Valve.VR; 25 | 26 | public class SteamVR_TrackedCamera 27 | { 28 | public class VideoStreamTexture 29 | { 30 | public VideoStreamTexture(uint deviceIndex, bool undistorted) 31 | { 32 | this.undistorted = undistorted; 33 | videostream = Stream(deviceIndex); 34 | } 35 | public bool undistorted { get; private set; } 36 | public uint deviceIndex { get { return videostream.deviceIndex; } } 37 | public bool hasCamera { get { return videostream.hasCamera; } } 38 | public bool hasTracking { get { Update(); return header.standingTrackedDevicePose.bPoseIsValid; } } 39 | public uint frameId { get { Update(); return header.nFrameSequence; } } 40 | public VRTextureBounds_t frameBounds { get; private set; } 41 | public EVRTrackedCameraFrameType frameType { get { return undistorted ? EVRTrackedCameraFrameType.Undistorted : EVRTrackedCameraFrameType.Distorted; } } 42 | 43 | Texture2D _texture; 44 | public Texture2D texture { get { Update(); return _texture; } } 45 | 46 | public SteamVR_Utils.RigidTransform transform { get { Update(); return new SteamVR_Utils.RigidTransform(header.standingTrackedDevicePose.mDeviceToAbsoluteTracking); } } 47 | public Vector3 velocity { get { Update(); var pose = header.standingTrackedDevicePose; return new Vector3(pose.vVelocity.v0, pose.vVelocity.v1, -pose.vVelocity.v2); } } 48 | public Vector3 angularVelocity { get { Update(); var pose = header.standingTrackedDevicePose; return new Vector3(-pose.vAngularVelocity.v0, -pose.vAngularVelocity.v1, pose.vAngularVelocity.v2); } } 49 | 50 | public TrackedDevicePose_t GetPose() { Update(); return header.standingTrackedDevicePose; } 51 | 52 | public ulong Acquire() 53 | { 54 | return videostream.Acquire(); 55 | } 56 | public ulong Release() 57 | { 58 | var result = videostream.Release(); 59 | 60 | if (videostream.handle == 0) 61 | { 62 | Object.Destroy(_texture); 63 | _texture = null; 64 | } 65 | 66 | return result; 67 | } 68 | 69 | int prevFrameCount = -1; 70 | void Update() 71 | { 72 | if (Time.frameCount == prevFrameCount) 73 | return; 74 | 75 | prevFrameCount = Time.frameCount; 76 | 77 | if (videostream.handle == 0) 78 | return; 79 | 80 | var vr = SteamVR.instance; 81 | if (vr == null) 82 | return; 83 | 84 | var trackedCamera = OpenVR.TrackedCamera; 85 | if (trackedCamera == null) 86 | return; 87 | 88 | var nativeTex = System.IntPtr.Zero; 89 | var deviceTexture = (_texture != null) ? _texture : new Texture2D(2, 2); 90 | var headerSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(header.GetType()); 91 | 92 | if (vr.textureType == ETextureType.OpenGL) 93 | { 94 | if (glTextureId != 0) 95 | trackedCamera.ReleaseVideoStreamTextureGL(videostream.handle, glTextureId); 96 | 97 | if (trackedCamera.GetVideoStreamTextureGL(videostream.handle, frameType, ref glTextureId, ref header, headerSize) != EVRTrackedCameraError.None) 98 | return; 99 | 100 | nativeTex = (System.IntPtr)glTextureId; 101 | } 102 | else if (vr.textureType == ETextureType.DirectX) 103 | { 104 | if (trackedCamera.GetVideoStreamTextureD3D11(videostream.handle, frameType, deviceTexture.GetNativeTexturePtr(), ref nativeTex, ref header, headerSize) != EVRTrackedCameraError.None) 105 | return; 106 | } 107 | 108 | if (_texture == null) 109 | { 110 | _texture = Texture2D.CreateExternalTexture((int)header.nWidth, (int)header.nHeight, TextureFormat.RGBA32, false, false, nativeTex); 111 | 112 | uint width = 0, height = 0; 113 | var frameBounds = new VRTextureBounds_t(); 114 | if (trackedCamera.GetVideoStreamTextureSize(deviceIndex, frameType, ref frameBounds, ref width, ref height) == EVRTrackedCameraError.None) 115 | { 116 | // Account for textures being upside-down in Unity. 117 | frameBounds.vMin = 1.0f - frameBounds.vMin; 118 | frameBounds.vMax = 1.0f - frameBounds.vMax; 119 | this.frameBounds = frameBounds; 120 | } 121 | } 122 | else 123 | { 124 | _texture.UpdateExternalTexture(nativeTex); 125 | } 126 | } 127 | 128 | uint glTextureId; 129 | VideoStream videostream; 130 | CameraVideoStreamFrameHeader_t header; 131 | } 132 | 133 | #region Top level accessors. 134 | 135 | public static VideoStreamTexture Distorted(int deviceIndex = (int)OpenVR.k_unTrackedDeviceIndex_Hmd) 136 | { 137 | if (distorted == null) 138 | distorted = new VideoStreamTexture[OpenVR.k_unMaxTrackedDeviceCount]; 139 | if (distorted[deviceIndex] == null) 140 | distorted[deviceIndex] = new VideoStreamTexture((uint)deviceIndex, false); 141 | return distorted[deviceIndex]; 142 | } 143 | 144 | public static VideoStreamTexture Undistorted(int deviceIndex = (int)OpenVR.k_unTrackedDeviceIndex_Hmd) 145 | { 146 | if (undistorted == null) 147 | undistorted = new VideoStreamTexture[OpenVR.k_unMaxTrackedDeviceCount]; 148 | if (undistorted[deviceIndex] == null) 149 | undistorted[deviceIndex] = new VideoStreamTexture((uint)deviceIndex, true); 150 | return undistorted[deviceIndex]; 151 | } 152 | 153 | public static VideoStreamTexture Source(bool undistorted, int deviceIndex = (int)OpenVR.k_unTrackedDeviceIndex_Hmd) 154 | { 155 | return undistorted ? Undistorted(deviceIndex) : Distorted(deviceIndex); 156 | } 157 | 158 | private static VideoStreamTexture[] distorted, undistorted; 159 | 160 | #endregion 161 | 162 | #region Internal class to manage lifetime of video streams (per device). 163 | 164 | class VideoStream 165 | { 166 | public VideoStream(uint deviceIndex) 167 | { 168 | this.deviceIndex = deviceIndex; 169 | var trackedCamera = OpenVR.TrackedCamera; 170 | if (trackedCamera != null) 171 | trackedCamera.HasCamera(deviceIndex, ref _hasCamera); 172 | } 173 | public uint deviceIndex { get; private set; } 174 | 175 | ulong _handle; 176 | public ulong handle { get { return _handle; } } 177 | 178 | bool _hasCamera; 179 | public bool hasCamera { get { return _hasCamera; } } 180 | 181 | ulong refCount; 182 | public ulong Acquire() 183 | { 184 | if (_handle == 0 && hasCamera) 185 | { 186 | var trackedCamera = OpenVR.TrackedCamera; 187 | if (trackedCamera != null) 188 | trackedCamera.AcquireVideoStreamingService(deviceIndex, ref _handle); 189 | } 190 | return ++refCount; 191 | } 192 | public ulong Release() 193 | { 194 | if (refCount > 0 && --refCount == 0 && _handle != 0) 195 | { 196 | var trackedCamera = OpenVR.TrackedCamera; 197 | if (trackedCamera != null) 198 | trackedCamera.ReleaseVideoStreamingService(_handle); 199 | _handle = 0; 200 | } 201 | return refCount; 202 | } 203 | } 204 | 205 | static VideoStream Stream(uint deviceIndex) 206 | { 207 | if (videostreams == null) 208 | videostreams = new VideoStream[OpenVR.k_unMaxTrackedDeviceCount]; 209 | if (videostreams[deviceIndex] == null) 210 | videostreams[deviceIndex] = new VideoStream(deviceIndex); 211 | return videostreams[deviceIndex]; 212 | } 213 | 214 | static VideoStream[] videostreams; 215 | 216 | #endregion 217 | } 218 | 219 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_TrackedCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55da3adbb5d30254c97687991608dda0 3 | timeCreated: 1464217571 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_TrackedObject.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: For controlling in-game objects with tracked devices. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | public class SteamVR_TrackedObject : MonoBehaviour 11 | { 12 | public enum EIndex 13 | { 14 | None = -1, 15 | Hmd = (int)OpenVR.k_unTrackedDeviceIndex_Hmd, 16 | Device1, 17 | Device2, 18 | Device3, 19 | Device4, 20 | Device5, 21 | Device6, 22 | Device7, 23 | Device8, 24 | Device9, 25 | Device10, 26 | Device11, 27 | Device12, 28 | Device13, 29 | Device14, 30 | Device15 31 | } 32 | 33 | public EIndex index; 34 | public Transform origin; // if not set, relative to parent 35 | public bool isValid = false; 36 | 37 | private void OnNewPoses(TrackedDevicePose_t[] poses) 38 | { 39 | if (index == EIndex.None) 40 | return; 41 | 42 | var i = (int)index; 43 | 44 | isValid = false; 45 | if (poses.Length <= i) 46 | return; 47 | 48 | if (!poses[i].bDeviceIsConnected) 49 | return; 50 | 51 | if (!poses[i].bPoseIsValid) 52 | return; 53 | 54 | isValid = true; 55 | 56 | var pose = new SteamVR_Utils.RigidTransform(poses[i].mDeviceToAbsoluteTracking); 57 | 58 | if (origin != null) 59 | { 60 | transform.position = origin.transform.TransformPoint(pose.pos); 61 | transform.rotation = origin.rotation * pose.rot; 62 | } 63 | else 64 | { 65 | transform.localPosition = pose.pos; 66 | transform.localRotation = pose.rot; 67 | } 68 | } 69 | 70 | SteamVR_Events.Action newPosesAction; 71 | 72 | void Awake() 73 | { 74 | newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses); 75 | } 76 | 77 | void OnEnable() 78 | { 79 | var render = SteamVR_Render.instance; 80 | if (render == null) 81 | { 82 | enabled = false; 83 | return; 84 | } 85 | 86 | newPosesAction.enabled = true; 87 | } 88 | 89 | void OnDisable() 90 | { 91 | newPosesAction.enabled = false; 92 | isValid = false; 93 | } 94 | 95 | public void SetDeviceIndex(int index) 96 | { 97 | if (System.Enum.IsDefined(typeof(EIndex), index)) 98 | this.index = (EIndex)index; 99 | } 100 | } 101 | 102 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_TrackedObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d37c2cf88f7c59f4c8cf5d3812568143 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_UpdatePoses.cs: -------------------------------------------------------------------------------- 1 | //======= Copyright (c) Valve Corporation, All rights reserved. =============== 2 | // 3 | // Purpose: Helper to update poses when using native OpenVR integration. 4 | // 5 | //============================================================================= 6 | 7 | using UnityEngine; 8 | using Valve.VR; 9 | 10 | [RequireComponent(typeof(Camera))] 11 | public class SteamVR_UpdatePoses : MonoBehaviour 12 | { 13 | #if !(UNITY_5_6) 14 | void Awake() 15 | { 16 | var camera = GetComponent(); 17 | camera.stereoTargetEye = StereoTargetEyeMask.None; 18 | camera.clearFlags = CameraClearFlags.Nothing; 19 | camera.useOcclusionCulling = false; 20 | camera.cullingMask = 0; 21 | camera.depth = -9999; 22 | } 23 | #endif 24 | void OnPreCull() 25 | { 26 | var compositor = OpenVR.Compositor; 27 | if (compositor != null) 28 | { 29 | var render = SteamVR_Render.instance; 30 | compositor.GetLastPoses(render.poses, render.gamePoses); 31 | SteamVR_Events.NewPoses.Send(render.poses); 32 | SteamVR_Events.NewPosesApplied.Send(); 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_UpdatePoses.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b61cd59d8f02e454186a61a5f55c21b9 3 | timeCreated: 1457229804 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SteamVR/Scripts/SteamVR_Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be3c3a084f7b29b4880b42b4cfbf4d8f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/SteamVR/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: abfc00e0350ad744083849e2d7ae06ee 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pauberson/MultiuserVive/c0e71415dbc01aad8eb6158346fd0c867a421f4d/Assets/SteamVR/Textures/arrow.png -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/arrow.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2db89a771043d7b4eb9d26622f6b97c7 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 2 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pauberson/MultiuserVive/c0e71415dbc01aad8eb6158346fd0c867a421f4d/Assets/SteamVR/Textures/background.png -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/background.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb00cc87e146a414fbf2c4d3c0d31151 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 2 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pauberson/MultiuserVive/c0e71415dbc01aad8eb6158346fd0c867a421f4d/Assets/SteamVR/Textures/logo.png -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/logo.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09db43b3b77bf744287ba587fea02f8b 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -3 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 1 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 1 46 | textureType: 2 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | assetBundleVariant: 54 | -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/overlay.renderTexture: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!84 &8400000 4 | RenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 0} 8 | m_Name: overlay 9 | m_ImageContentsHash: 10 | serializedVersion: 2 11 | Hash: 00000000000000000000000000000000 12 | m_Width: 2048 13 | m_Height: 2048 14 | m_AntiAliasing: 8 15 | m_DepthFormat: 0 16 | m_ColorFormat: 0 17 | m_MipMap: 0 18 | m_GenerateMips: 1 19 | m_SRGB: 0 20 | m_TextureSettings: 21 | m_FilterMode: 2 22 | m_Aniso: 9 23 | m_MipBias: 0 24 | m_WrapMode: 1 25 | -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/overlay.renderTexture.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 005ed5a6df2f5ff468efd6497d37fefa 3 | NativeFormatImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/workshop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pauberson/MultiuserVive/c0e71415dbc01aad8eb6158346fd0c867a421f4d/Assets/SteamVR/Textures/workshop.png -------------------------------------------------------------------------------- /Assets/SteamVR/Textures/workshop.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a57cd5c56c9d75c4ba0ee9fbc6e1d8df 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 8 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -3 28 | maxTextureSize: 1024 29 | textureSettings: 30 | filterMode: 2 31 | aniso: 9 32 | mipBias: -1 33 | wrapMode: -1 34 | nPOTScale: 1 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | spriteMode: 0 39 | spriteExtrude: 1 40 | spriteMeshType: 1 41 | alignment: 0 42 | spritePivot: {x: .5, y: .5} 43 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 44 | spritePixelsToUnits: 100 45 | alphaIsTransparency: 0 46 | textureType: -1 47 | buildTargetSettings: [] 48 | spriteSheet: 49 | sprites: [] 50 | spritePackingTag: 51 | userData: 52 | assetBundleName: 53 | -------------------------------------------------------------------------------- /Assets/SteamVR/quickstart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pauberson/MultiuserVive/c0e71415dbc01aad8eb6158346fd0c867a421f4d/Assets/SteamVR/quickstart.pdf -------------------------------------------------------------------------------- /Assets/SteamVR/quickstart.pdf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e7e681076fb2fad47bed246936de90bf 3 | DefaultImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /Assets/SteamVR/readme.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a51c3dbd81ecb6741b7a2c5b06dbcb2e 3 | TextScriptImporter: 4 | userData: 5 | assetBundleName: 6 | -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Lumacode Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_DisableAudio: 0 16 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_SolverIterationCount: 6 13 | m_QueriesHitTriggers: 1 14 | m_EnableAdaptiveForce: 0 15 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 16 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 0 9 | path: Assets/Scenes/Main.unity 10 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Hidden Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 2 13 | m_SpritePackerPaddingPower: 1 14 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 15 | m_ProjectGenerationRootNamespace: 16 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 38 | m_PreloadedShaders: [] 39 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 40 | type: 0} 41 | m_ShaderSettings_Tier1: 42 | useCascadedShadowMaps: 1 43 | standardShaderQuality: 2 44 | useReflectionProbeBoxProjection: 1 45 | useReflectionProbeBlending: 1 46 | m_ShaderSettings_Tier2: 47 | useCascadedShadowMaps: 1 48 | standardShaderQuality: 2 49 | useReflectionProbeBoxProjection: 1 50 | useReflectionProbeBlending: 1 51 | m_ShaderSettings_Tier3: 52 | useCascadedShadowMaps: 1 53 | standardShaderQuality: 2 54 | useReflectionProbeBoxProjection: 1 55 | useReflectionProbeBlending: 1 56 | m_BuildTargetShaderSettings: [] 57 | m_LightmapStripping: 0 58 | m_FogStripping: 0 59 | m_LightmapKeepPlain: 1 60 | m_LightmapKeepDirCombined: 1 61 | m_LightmapKeepDirSeparate: 1 62 | m_LightmapKeepDynamicPlain: 1 63 | m_LightmapKeepDynamicDirCombined: 1 64 | m_LightmapKeepDynamicDirSeparate: 1 65 | m_FogKeepLinear: 1 66 | m_FogKeepExp: 1 67 | m_FogKeepExp2: 1 68 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshAreas: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_MinPenetrationForPenalty: 0.01 17 | m_BaumgarteScale: 0.2 18 | m_BaumgarteTimeOfImpactScale: 0.75 19 | m_TimeToSleep: 0.5 20 | m_LinearSleepTolerance: 0.01 21 | m_AngularSleepTolerance: 2 22 | m_QueriesHitTriggers: 1 23 | m_QueriesStartInColliders: 1 24 | m_ChangeStopsCallbacks: 0 25 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 26 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.6.1p3 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 2 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | blendWeights: 1 21 | textureQuality: 1 22 | anisotropicTextures: 0 23 | antiAliasing: 0 24 | softParticles: 0 25 | softVegetation: 0 26 | realtimeReflectionProbes: 0 27 | billboardsFaceCameraPosition: 0 28 | vSyncCount: 0 29 | lodBias: 0.3 30 | maximumLODLevel: 0 31 | particleRaycastBudget: 4 32 | asyncUploadTimeSlice: 2 33 | asyncUploadBufferSize: 4 34 | excludedTargetPlatforms: [] 35 | - serializedVersion: 2 36 | name: Fast 37 | pixelLightCount: 0 38 | shadows: 0 39 | shadowResolution: 0 40 | shadowProjection: 1 41 | shadowCascades: 1 42 | shadowDistance: 20 43 | shadowNearPlaneOffset: 2 44 | shadowCascade2Split: 0.33333334 45 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 46 | blendWeights: 2 47 | textureQuality: 0 48 | anisotropicTextures: 0 49 | antiAliasing: 0 50 | softParticles: 0 51 | softVegetation: 0 52 | realtimeReflectionProbes: 0 53 | billboardsFaceCameraPosition: 0 54 | vSyncCount: 0 55 | lodBias: 0.4 56 | maximumLODLevel: 0 57 | particleRaycastBudget: 16 58 | asyncUploadTimeSlice: 2 59 | asyncUploadBufferSize: 4 60 | excludedTargetPlatforms: [] 61 | - serializedVersion: 2 62 | name: Simple 63 | pixelLightCount: 1 64 | shadows: 1 65 | shadowResolution: 0 66 | shadowProjection: 1 67 | shadowCascades: 1 68 | shadowDistance: 20 69 | shadowNearPlaneOffset: 2 70 | shadowCascade2Split: 0.33333334 71 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 72 | blendWeights: 2 73 | textureQuality: 0 74 | anisotropicTextures: 1 75 | antiAliasing: 0 76 | softParticles: 0 77 | softVegetation: 0 78 | realtimeReflectionProbes: 0 79 | billboardsFaceCameraPosition: 0 80 | vSyncCount: 0 81 | lodBias: 0.7 82 | maximumLODLevel: 0 83 | particleRaycastBudget: 64 84 | asyncUploadTimeSlice: 2 85 | asyncUploadBufferSize: 4 86 | excludedTargetPlatforms: [] 87 | - serializedVersion: 2 88 | name: Good 89 | pixelLightCount: 2 90 | shadows: 2 91 | shadowResolution: 1 92 | shadowProjection: 1 93 | shadowCascades: 2 94 | shadowDistance: 40 95 | shadowNearPlaneOffset: 2 96 | shadowCascade2Split: 0.33333334 97 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 98 | blendWeights: 2 99 | textureQuality: 0 100 | anisotropicTextures: 1 101 | antiAliasing: 0 102 | softParticles: 0 103 | softVegetation: 1 104 | realtimeReflectionProbes: 1 105 | billboardsFaceCameraPosition: 1 106 | vSyncCount: 1 107 | lodBias: 1 108 | maximumLODLevel: 0 109 | particleRaycastBudget: 256 110 | asyncUploadTimeSlice: 2 111 | asyncUploadBufferSize: 4 112 | excludedTargetPlatforms: [] 113 | - serializedVersion: 2 114 | name: Beautiful 115 | pixelLightCount: 3 116 | shadows: 2 117 | shadowResolution: 2 118 | shadowProjection: 1 119 | shadowCascades: 2 120 | shadowDistance: 70 121 | shadowNearPlaneOffset: 2 122 | shadowCascade2Split: 0.33333334 123 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 124 | blendWeights: 4 125 | textureQuality: 0 126 | anisotropicTextures: 2 127 | antiAliasing: 2 128 | softParticles: 1 129 | softVegetation: 1 130 | realtimeReflectionProbes: 1 131 | billboardsFaceCameraPosition: 1 132 | vSyncCount: 1 133 | lodBias: 1.5 134 | maximumLODLevel: 0 135 | particleRaycastBudget: 1024 136 | asyncUploadTimeSlice: 2 137 | asyncUploadBufferSize: 4 138 | excludedTargetPlatforms: [] 139 | - serializedVersion: 2 140 | name: Fantastic 141 | pixelLightCount: 4 142 | shadows: 2 143 | shadowResolution: 3 144 | shadowProjection: 1 145 | shadowCascades: 4 146 | shadowDistance: 150 147 | shadowNearPlaneOffset: 2 148 | shadowCascade2Split: 0.33333334 149 | shadowCascade4Split: {x: 0.06666667, y: 0.19999999, z: 0.46666664} 150 | blendWeights: 4 151 | textureQuality: 0 152 | anisotropicTextures: 2 153 | antiAliasing: 2 154 | softParticles: 0 155 | softVegetation: 1 156 | realtimeReflectionProbes: 1 157 | billboardsFaceCameraPosition: 1 158 | vSyncCount: 1 159 | lodBias: 2 160 | maximumLODLevel: 0 161 | particleRaycastBudget: 4096 162 | asyncUploadTimeSlice: 2 163 | asyncUploadBufferSize: 4 164 | excludedTargetPlatforms: [] 165 | m_PerPlatformDefaultQuality: 166 | Android: 2 167 | BlackBerry: 2 168 | GLES Emulation: 5 169 | Nintendo 3DS: 5 170 | PS3: 5 171 | PS4: 5 172 | PSM: 5 173 | PSP2: 2 174 | Samsung TV: 2 175 | Standalone: 5 176 | Tizen: 2 177 | WP8: 5 178 | Web: 5 179 | WebGL: 3 180 | WiiU: 5 181 | Windows Store Apps: 5 182 | XBOX360: 5 183 | XboxOne: 5 184 | iPhone: 2 185 | tvOS: 5 186 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | m_Enabled: 0 7 | m_TestMode: 0 8 | m_TestEventUrl: 9 | m_TestConfigUrl: 10 | m_TestInitMode: 0 11 | CrashReportingSettings: 12 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 13 | m_Enabled: 0 14 | m_CaptureEditorExceptions: 1 15 | UnityPurchasingSettings: 16 | m_Enabled: 0 17 | m_TestMode: 0 18 | UnityAnalyticsSettings: 19 | m_Enabled: 0 20 | m_InitializeOnStartup: 1 21 | m_TestMode: 0 22 | m_TestEventUrl: 23 | m_TestConfigUrl: 24 | UnityAdsSettings: 25 | m_Enabled: 0 26 | m_InitializeOnStartup: 1 27 | m_TestMode: 0 28 | m_EnabledPlatforms: 4294967295 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | PerformanceReportingSettings: 32 | m_Enabled: 0 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Multiuser Vive 2 | 3 | Basic Unity project setup for multiplayer with HTC Vive. (Includes part of SteamVR v1.2.1) 4 | 5 | Updated for Unity 5.6.1p3. 6 | 7 | Seperate scenes for Local network or Internet version. 8 | 9 | ## Local network version 10 | Both PCs need to be on same subnet to find each other. 11 | 12 | Make sure "Run as server" on LocalNetworkManager is only checked on one of the PCs. 13 | 14 | ## Internet version 15 | Replace the project id with one of your own and enable multiplayer. 16 | 17 | Set "Create Room" on InternetManager on one of the PCs and start that one first. 18 | --------------------------------------------------------------------------------