Add SteamVR

This commit is contained in:
Jens Pitkänen 2020-04-29 20:40:05 +03:00
parent f7a4d1fbd1
commit 50b9e29197
769 changed files with 154269 additions and 3 deletions

25037
Assets/Scenes/VRScene.unity Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 877a6f99ade23364d85fbe5788f58091
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/SteamVR.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c476ae29a1e17304eafbda61b9565786
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
fileFormatVersion: 2
guid: c33af0785775d7548b22541da37936fe
folderAsset: yes
DefaultImporter:
userData:
assetBundleName:

View File

@ -0,0 +1,231 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Prompt developers to use settings most compatible with SteamVR.
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace Valve.VR
{
[InitializeOnLoad]
public class SteamVR_AutoEnableVR
{
static SteamVR_AutoEnableVR()
{
EditorApplication.update += Update;
}
protected const string openVRString = "OpenVR";
protected const string openVRPackageString = "com.unity.xr.openvr.standalone";
#if UNITY_2018_2_OR_NEWER
private enum PackageStates
{
None,
WaitingForList,
WaitingForAdd,
WaitingForAddConfirm,
Installed,
Failed,
}
private static UnityEditor.PackageManager.Requests.ListRequest listRequest;
private static UnityEditor.PackageManager.Requests.AddRequest addRequest;
private static PackageStates packageState = PackageStates.None;
private static System.Diagnostics.Stopwatch addingPackageTime = new System.Diagnostics.Stopwatch();
private static System.Diagnostics.Stopwatch addingPackageTimeTotal = new System.Diagnostics.Stopwatch();
private static float estimatedTimeToInstall = 80;
private static int addTryCount = 0;
#endif
public static void Update()
{
if (SteamVR_Settings.instance.autoEnableVR)
{
bool enabledVR = false;
if (UnityEditor.PlayerSettings.virtualRealitySupported == false)
{
UnityEditor.PlayerSettings.virtualRealitySupported = true;
enabledVR = true;
Debug.Log("<b>[SteamVR Setup]</b> Enabled virtual reality support in Player Settings. (you can disable this by unchecking Assets/SteamVR/SteamVR_Settings.autoEnableVR)");
}
UnityEditor.BuildTargetGroup currentTarget = UnityEditor.EditorUserBuildSettings.selectedBuildTargetGroup;
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(currentTarget);
#else
string[] devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(currentTarget);
#endif
bool hasOpenVR = devices.Any(device => string.Equals(device, openVRString, System.StringComparison.CurrentCultureIgnoreCase));
if (hasOpenVR == false || enabledVR)
{
string[] newDevices;
if (enabledVR && hasOpenVR == false)
{
newDevices = new string[] { openVRString }; //only list openvr if we enabled it
}
else
{
List<string> devicesList = new List<string>(devices); //list openvr as the first option if it wasn't in the list.
if (hasOpenVR)
devicesList.Remove(openVRString);
devicesList.Insert(0, openVRString);
newDevices = devicesList.ToArray();
}
#if (UNITY_5_6 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
UnityEditorInternal.VR.VREditor.SetVREnabledDevices(currentTarget, newDevices);
#else
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(currentTarget, newDevices);
#endif
Debug.Log("<b>[SteamVR Setup]</b> Added OpenVR to supported VR SDKs list.");
}
#if UNITY_2018_2_OR_NEWER
//2018+ requires us to manually add the OpenVR package
switch (packageState)
{
case PackageStates.None:
//see if we have the package
listRequest = UnityEditor.PackageManager.Client.List(true);
packageState = PackageStates.WaitingForList;
break;
case PackageStates.WaitingForList:
if (listRequest.IsCompleted)
{
if (listRequest.Error != null || listRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
{
packageState = PackageStates.Failed;
break;
}
bool hasPackage = listRequest.Result.Any(package => package.name == openVRPackageString);
if (hasPackage == false)
{
//if we don't have the package - then install it
addRequest = UnityEditor.PackageManager.Client.Add(openVRPackageString);
packageState = PackageStates.WaitingForAdd;
addTryCount++;
Debug.Log("<b>[SteamVR Setup]</b> Installing OpenVR package...");
addingPackageTime.Start();
addingPackageTimeTotal.Start();
}
else
{
//if we do have the package do nothing
packageState = PackageStates.Installed; //already installed
}
}
break;
case PackageStates.WaitingForAdd:
if (addRequest.IsCompleted)
{
if (addRequest.Error != null || addRequest.Status == UnityEditor.PackageManager.StatusCode.Failure)
{
packageState = PackageStates.Failed;
break;
}
else
{
//if the package manager says we added it then confirm that with the list
listRequest = UnityEditor.PackageManager.Client.List(true);
packageState = PackageStates.WaitingForAddConfirm;
}
}
else
{
if (addingPackageTimeTotal.Elapsed.TotalSeconds > estimatedTimeToInstall)
estimatedTimeToInstall *= 2; // :)
string dialogText;
if (addTryCount == 1)
dialogText = "Installing OpenVR from Unity Package Manager...";
else
dialogText = "Retrying OpenVR install from Unity Package Manager...";
bool cancel = UnityEditor.EditorUtility.DisplayCancelableProgressBar("SteamVR", dialogText, (float)addingPackageTimeTotal.Elapsed.TotalSeconds / estimatedTimeToInstall);
if (cancel)
packageState = PackageStates.Failed;
if (addingPackageTime.Elapsed.TotalSeconds > 10)
{
Debug.Log("<b>[SteamVR Setup]</b> Waiting for package manager to install OpenVR package...");
addingPackageTime.Stop();
addingPackageTime.Reset();
addingPackageTime.Start();
}
}
break;
case PackageStates.WaitingForAddConfirm:
if (listRequest.IsCompleted)
{
if (listRequest.Error != null)
{
packageState = PackageStates.Failed;
break;
}
bool hasPackage = listRequest.Result.Any(package => package.name == openVRPackageString);
if (hasPackage == false)
{
if (addTryCount == 1)
{
addRequest = UnityEditor.PackageManager.Client.Add(openVRPackageString);
packageState = PackageStates.WaitingForAdd;
addTryCount++;
Debug.Log("<b>[SteamVR Setup]</b> Retrying OpenVR package install...");
}
else
{
packageState = PackageStates.Failed;
}
}
else
{
packageState = PackageStates.Installed; //installed successfully
Debug.Log("<b>[SteamVR Setup]</b> Successfully installed OpenVR package.");
}
}
break;
}
if (packageState == PackageStates.Failed || packageState == PackageStates.Installed)
{
addingPackageTime.Stop();
addingPackageTimeTotal.Stop();
UnityEditor.EditorUtility.ClearProgressBar();
UnityEditor.EditorApplication.update -= Update; //we're done trying to auto-enable vr
if (packageState == PackageStates.Failed)
{
string failtext = "The Unity Package Manager failed to automatically install the OpenVR package. Please open the Package Manager Window and try to install it manually.";
UnityEditor.EditorUtility.DisplayDialog("SteamVR", failtext, "Ok");
Debug.Log("<b>[SteamVR Setup]</b> " + failtext);
}
}
#else
UnityEditor.EditorApplication.update -= Update;
#endif
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 359dfd8d7e3732240894f33b6f6d6e56
timeCreated: 1548371829
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,16 @@
{
"name": "SteamVR_Editor",
"references": [
"SteamVR"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9bac448de04a4f6448fee1acc220e5a1
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,127 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Custom inspector display for SteamVR_Camera
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.IO;
using Valve.VR;
[CustomEditor(typeof(SteamVR_Camera)), CanEditMultipleObjects]
public class SteamVR_Editor : Editor
{
int bannerHeight = 150;
Texture logo;
SerializedProperty script, wireframe;
string GetResourcePath()
{
var ms = MonoScript.FromScriptableObject(this);
var path = AssetDatabase.GetAssetPath(ms);
path = Path.GetDirectoryName(path);
return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
}
void OnEnable()
{
var resourcePath = GetResourcePath();
logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
script = serializedObject.FindProperty("m_Script");
wireframe = serializedObject.FindProperty("wireframe");
foreach (SteamVR_Camera target in targets)
target.ForceLast();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
var rect = GUILayoutUtility.GetRect(Screen.width - 38, bannerHeight, GUI.skin.box);
if (logo)
GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
if (!Application.isPlaying)
{
var expand = false;
var collapse = false;
foreach (SteamVR_Camera target in targets)
{
if (AssetDatabase.Contains(target))
continue;
if (target.isExpanded)
collapse = true;
else
expand = true;
}
if (expand)
{
GUILayout.BeginHorizontal();
if (GUILayout.Button("Expand"))
{
foreach (SteamVR_Camera target in targets)
{
if (AssetDatabase.Contains(target))
continue;
if (!target.isExpanded)
{
target.Expand();
EditorUtility.SetDirty(target);
}
}
}
GUILayout.Space(18);
GUILayout.EndHorizontal();
}
if (collapse)
{
GUILayout.BeginHorizontal();
if (GUILayout.Button("Collapse"))
{
foreach (SteamVR_Camera target in targets)
{
if (AssetDatabase.Contains(target))
continue;
if (target.isExpanded)
{
target.Collapse();
EditorUtility.SetDirty(target);
}
}
}
GUILayout.Space(18);
GUILayout.EndHorizontal();
}
}
EditorGUILayout.PropertyField(script);
EditorGUILayout.PropertyField(wireframe);
serializedObject.ApplyModifiedProperties();
}
public static void ExportPackage()
{
AssetDatabase.ExportPackage(new string[] {
"Assets/SteamVR",
"Assets/Plugins/openvr_api.cs",
"Assets/Plugins/openvr_api.bundle",
"Assets/Plugins/x86/openvr_api.dll",
"Assets/Plugins/x86/steam_api.dll",
"Assets/Plugins/x86/libsteam_api.so",
"Assets/Plugins/x86_64/openvr_api.dll",
"Assets/Plugins/x86_64/steam_api.dll",
"Assets/Plugins/x86_64/libsteam_api.so",
"Assets/Plugins/x86_64/libopenvr_api.so",
}, "steamvr.unitypackage", ExportPackageOptions.Recurse);
EditorApplication.Exit(0);
}
}

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5ba22c80948c94e44a82b9fd1b3abd0d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:

View File

@ -0,0 +1,2 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//removed and added to the SteamVR_Settings asset so it can be configured per project

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 29abf75f7265ccb45b799eac4ab0ca94
timeCreated: 1487968203
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,106 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Custom inspector display for SteamVR_RenderModel
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.Text;
using System.Collections.Generic;
namespace Valve.VR
{
[CustomEditor(typeof(SteamVR_RenderModel)), CanEditMultipleObjects]
public class SteamVR_RenderModelEditor : Editor
{
SerializedProperty script, index, modelOverride, shader, verbose, createComponents, updateDynamically;
static string[] renderModelNames;
int renderModelIndex;
void OnEnable()
{
script = serializedObject.FindProperty("m_Script");
index = serializedObject.FindProperty("index");
modelOverride = serializedObject.FindProperty("modelOverride");
shader = serializedObject.FindProperty("shader");
verbose = serializedObject.FindProperty("verbose");
createComponents = serializedObject.FindProperty("createComponents");
updateDynamically = serializedObject.FindProperty("updateDynamically");
// Load render model names if necessary.
if (renderModelNames == null)
{
renderModelNames = LoadRenderModelNames();
}
// Update renderModelIndex based on current modelOverride value.
if (modelOverride.stringValue != "")
{
for (int i = 0; i < renderModelNames.Length; i++)
{
if (modelOverride.stringValue == renderModelNames[i])
{
renderModelIndex = i;
break;
}
}
}
}
static string[] LoadRenderModelNames()
{
var results = new List<string>();
results.Add("None");
using (var holder = new SteamVR_RenderModel.RenderModelInterfaceHolder())
{
var renderModels = holder.instance;
if (renderModels != null)
{
uint count = renderModels.GetRenderModelCount();
for (uint i = 0; i < count; i++)
{
var buffer = new StringBuilder();
var requiredSize = renderModels.GetRenderModelName(i, buffer, 0);
if (requiredSize == 0)
continue;
buffer.EnsureCapacity((int)requiredSize);
renderModels.GetRenderModelName(i, buffer, requiredSize);
results.Add(buffer.ToString());
}
}
}
return results.ToArray();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(script);
EditorGUILayout.PropertyField(index);
//EditorGUILayout.PropertyField(modelOverride);
GUILayout.BeginHorizontal();
GUILayout.Label(new GUIContent("Model Override", SteamVR_RenderModel.modelOverrideWarning));
var selected = EditorGUILayout.Popup(renderModelIndex, renderModelNames);
if (selected != renderModelIndex)
{
renderModelIndex = selected;
modelOverride.stringValue = (selected > 0) ? renderModelNames[selected] : "";
}
GUILayout.EndHorizontal();
EditorGUILayout.PropertyField(shader);
EditorGUILayout.PropertyField(verbose);
EditorGUILayout.PropertyField(createComponents);
EditorGUILayout.PropertyField(updateDynamically);
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 67867a20919f7db45a2e7034fda1c28e
timeCreated: 1433373945
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,383 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Custom inspector display for SteamVR_Skybox
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.Text;
using System.Collections.Generic;
using Valve.VR;
using System.IO;
namespace Valve.VR
{
[CustomEditor(typeof(SteamVR_Skybox)), CanEditMultipleObjects]
public class SteamVR_SkyboxEditor : Editor
{
private const string nameFormat = "{0}/{1}-{2}.png";
private const string helpText = "Take snapshot will use the current " +
"position and rotation to capture six directional screenshots to use as this " +
"skybox's textures. Note: This skybox is only used to override what shows up " +
"in the compositor (e.g. when loading levels). Add a Camera component to this " +
"object to override default settings like which layers to render. Additionally, " +
"by specifying your own targetTexture, you can control the size of the textures " +
"and other properties like antialiasing. Don't forget to disable the camera.\n\n" +
"For stereo screenshots, a panorama is render for each eye using the specified " +
"ipd (in millimeters) broken up into segments cellSize pixels square to optimize " +
"generation.\n(32x32 takes about 10 seconds depending on scene complexity, 16x16 " +
"takes around a minute, while will 8x8 take several minutes.)\n\nTo test, hit " +
"play then pause - this will activate the skybox settings, and then drop you to " +
"the compositor where the skybox is rendered.";
public override void OnInspectorGUI()
{
DrawDefaultInspector();
EditorGUILayout.HelpBox(helpText, MessageType.Info);
if (GUILayout.Button("Take snapshot"))
{
var directions = new Quaternion[] {
Quaternion.LookRotation(Vector3.forward),
Quaternion.LookRotation(Vector3.back),
Quaternion.LookRotation(Vector3.left),
Quaternion.LookRotation(Vector3.right),
Quaternion.LookRotation(Vector3.up, Vector3.back),
Quaternion.LookRotation(Vector3.down, Vector3.forward)
};
Camera tempCamera = null;
foreach (SteamVR_Skybox target in targets)
{
var targetScene = target.gameObject.scene;
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
var scenePath = Path.GetDirectoryName(targetScene.path);
var assetPath = scenePath + "/" + sceneName;
if (!AssetDatabase.IsValidFolder(assetPath))
{
var guid = AssetDatabase.CreateFolder(scenePath, sceneName);
assetPath = AssetDatabase.GUIDToAssetPath(guid);
}
var camera = target.GetComponent<Camera>();
if (camera == null)
{
if (tempCamera == null)
tempCamera = new GameObject().AddComponent<Camera>();
camera = tempCamera;
}
var targetTexture = camera.targetTexture;
if (camera.targetTexture == null)
{
targetTexture = new RenderTexture(1024, 1024, 24);
targetTexture.antiAliasing = 8;
camera.targetTexture = targetTexture;
}
var oldPosition = target.transform.localPosition;
var oldRotation = target.transform.localRotation;
var baseRotation = target.transform.rotation;
var t = camera.transform;
t.position = target.transform.position;
camera.orthographic = false;
camera.fieldOfView = 90;
for (int i = 0; i < directions.Length; i++)
{
t.rotation = baseRotation * directions[i];
camera.Render();
// Copy to texture and save to disk.
RenderTexture.active = targetTexture;
var texture = new Texture2D(targetTexture.width, targetTexture.height, TextureFormat.ARGB32, false);
texture.ReadPixels(new Rect(0, 0, texture.width, texture.height), 0, 0);
texture.Apply();
RenderTexture.active = null;
var assetName = string.Format(nameFormat, assetPath, target.name, i);
System.IO.File.WriteAllBytes(assetName, texture.EncodeToPNG());
}
if (camera != tempCamera)
{
target.transform.localPosition = oldPosition;
target.transform.localRotation = oldRotation;
}
}
if (tempCamera != null)
{
Object.DestroyImmediate(tempCamera.gameObject);
}
// Now that everything has be written out, reload the associated assets and assign them.
AssetDatabase.Refresh();
foreach (SteamVR_Skybox target in targets)
{
var targetScene = target.gameObject.scene;
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
var scenePath = Path.GetDirectoryName(targetScene.path);
var assetPath = scenePath + "/" + sceneName;
for (int i = 0; i < directions.Length; i++)
{
var assetName = string.Format(nameFormat, assetPath, target.name, i);
var importer = AssetImporter.GetAtPath(assetName) as TextureImporter;
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
importer.textureFormat = TextureImporterFormat.RGB24;
#else
importer.textureCompression = TextureImporterCompression.Uncompressed;
#endif
importer.wrapMode = TextureWrapMode.Clamp;
importer.mipmapEnabled = false;
importer.SaveAndReimport();
var texture = AssetDatabase.LoadAssetAtPath<Texture>(assetName);
target.SetTextureByIndex(i, texture);
}
}
}
else if (GUILayout.Button("Take stereo snapshot"))
{
const int width = 4096;
const int height = width / 2;
const int halfHeight = height / 2;
var textures = new Texture2D[] {
new Texture2D(width, height, TextureFormat.ARGB32, false),
new Texture2D(width, height, TextureFormat.ARGB32, false) };
var timer = new System.Diagnostics.Stopwatch();
Camera tempCamera = null;
foreach (SteamVR_Skybox target in targets)
{
timer.Start();
var targetScene = target.gameObject.scene;
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
var scenePath = Path.GetDirectoryName(targetScene.path);
var assetPath = scenePath + "/" + sceneName;
if (!AssetDatabase.IsValidFolder(assetPath))
{
var guid = AssetDatabase.CreateFolder(scenePath, sceneName);
assetPath = AssetDatabase.GUIDToAssetPath(guid);
}
var camera = target.GetComponent<Camera>();
if (camera == null)
{
if (tempCamera == null)
tempCamera = new GameObject().AddComponent<Camera>();
camera = tempCamera;
}
var fx = camera.gameObject.AddComponent<SteamVR_SphericalProjection>();
var oldTargetTexture = camera.targetTexture;
var oldOrthographic = camera.orthographic;
var oldFieldOfView = camera.fieldOfView;
var oldAspect = camera.aspect;
var oldPosition = target.transform.localPosition;
var oldRotation = target.transform.localRotation;
var basePosition = target.transform.position;
var baseRotation = target.transform.rotation;
var transform = camera.transform;
int cellSize = int.Parse(target.StereoCellSize.ToString().Substring(1));
float ipd = target.StereoIpdMm / 1000.0f;
int vTotal = halfHeight / cellSize;
float dv = 90.0f / vTotal; // vertical degrees per segment
float dvHalf = dv / 2.0f;
var targetTexture = new RenderTexture(cellSize, cellSize, 24);
targetTexture.wrapMode = TextureWrapMode.Clamp;
targetTexture.antiAliasing = 8;
camera.fieldOfView = dv;
camera.orthographic = false;
camera.targetTexture = targetTexture;
// Render sections of a sphere using a rectilinear projection
// and resample using a sphereical projection into a single panorama
// texture per eye. We break into sections in order to keep the eye
// separation similar around the sphere. Rendering alternates between
// top and bottom sections, sweeping horizontally around the sphere,
// alternating left and right eyes.
for (int v = 0; v < vTotal; v++)
{
var pitch = 90.0f - (v * dv) - dvHalf;
var uTotal = width / targetTexture.width;
var du = 360.0f / uTotal; // horizontal degrees per segment
var duHalf = du / 2.0f;
var vTarget = v * halfHeight / vTotal;
for (int i = 0; i < 2; i++) // top, bottom
{
if (i == 1)
{
pitch = -pitch;
vTarget = height - vTarget - cellSize;
}
for (int u = 0; u < uTotal; u++)
{
var yaw = -180.0f + (u * du) + duHalf;
var uTarget = u * width / uTotal;
var xOffset = -ipd / 2 * Mathf.Cos(pitch * Mathf.Deg2Rad);
for (int j = 0; j < 2; j++) // left, right
{
var texture = textures[j];
if (j == 1)
{
xOffset = -xOffset;
}
var offset = baseRotation * Quaternion.Euler(0, yaw, 0) * new Vector3(xOffset, 0, 0);
transform.position = basePosition + offset;
var direction = Quaternion.Euler(pitch, yaw, 0.0f);
transform.rotation = baseRotation * direction;
// vector pointing to center of this section
var N = direction * Vector3.forward;
// horizontal span of this section in degrees
var phi0 = yaw - (du / 2);
var phi1 = phi0 + du;
// vertical span of this section in degrees
var theta0 = pitch + (dv / 2);
var theta1 = theta0 - dv;
var midPhi = (phi0 + phi1) / 2;
var baseTheta = Mathf.Abs(theta0) < Mathf.Abs(theta1) ? theta0 : theta1;
// vectors pointing to corners of image closes to the equator
var V00 = Quaternion.Euler(baseTheta, phi0, 0.0f) * Vector3.forward;
var V01 = Quaternion.Euler(baseTheta, phi1, 0.0f) * Vector3.forward;
// vectors pointing to top and bottom midsection of image
var V0M = Quaternion.Euler(theta0, midPhi, 0.0f) * Vector3.forward;
var V1M = Quaternion.Euler(theta1, midPhi, 0.0f) * Vector3.forward;
// intersection points for each of the above
var P00 = V00 / Vector3.Dot(V00, N);
var P01 = V01 / Vector3.Dot(V01, N);
var P0M = V0M / Vector3.Dot(V0M, N);
var P1M = V1M / Vector3.Dot(V1M, N);
// calculate basis vectors for plane
var P00_P01 = P01 - P00;
var P0M_P1M = P1M - P0M;
var uMag = P00_P01.magnitude;
var vMag = P0M_P1M.magnitude;
var uScale = 1.0f / uMag;
var vScale = 1.0f / vMag;
var uAxis = P00_P01 * uScale;
var vAxis = P0M_P1M * vScale;
// update material constant buffer
fx.Set(N, phi0, phi1, theta0, theta1,
uAxis, P00, uScale,
vAxis, P0M, vScale);
camera.aspect = uMag / vMag;
camera.Render();
RenderTexture.active = targetTexture;
texture.ReadPixels(new Rect(0, 0, targetTexture.width, targetTexture.height), uTarget, vTarget);
RenderTexture.active = null;
}
}
}
}
// Save textures to disk.
for (int i = 0; i < 2; i++)
{
var texture = textures[i];
texture.Apply();
var assetName = string.Format(nameFormat, assetPath, target.name, i);
File.WriteAllBytes(assetName, texture.EncodeToPNG());
}
// Cleanup.
if (camera != tempCamera)
{
camera.targetTexture = oldTargetTexture;
camera.orthographic = oldOrthographic;
camera.fieldOfView = oldFieldOfView;
camera.aspect = oldAspect;
target.transform.localPosition = oldPosition;
target.transform.localRotation = oldRotation;
}
else
{
tempCamera.targetTexture = null;
}
DestroyImmediate(targetTexture);
DestroyImmediate(fx);
timer.Stop();
Debug.Log(string.Format("<b>[SteamVR]</b> Screenshot took {0} seconds.", timer.Elapsed));
}
if (tempCamera != null)
{
DestroyImmediate(tempCamera.gameObject);
}
DestroyImmediate(textures[0]);
DestroyImmediate(textures[1]);
// Now that everything has be written out, reload the associated assets and assign them.
AssetDatabase.Refresh();
foreach (SteamVR_Skybox target in targets)
{
var targetScene = target.gameObject.scene;
var sceneName = Path.GetFileNameWithoutExtension(targetScene.path);
var scenePath = Path.GetDirectoryName(targetScene.path);
var assetPath = scenePath + "/" + sceneName;
for (int i = 0; i < 2; i++)
{
var assetName = string.Format(nameFormat, assetPath, target.name, i);
var importer = AssetImporter.GetAtPath(assetName) as TextureImporter;
importer.mipmapEnabled = false;
importer.wrapMode = TextureWrapMode.Repeat;
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
importer.SetPlatformTextureSettings("Standalone", width, TextureImporterFormat.RGB24);
#else
var settings = importer.GetPlatformTextureSettings("Standalone");
settings.textureCompression = TextureImporterCompression.Uncompressed;
settings.maxTextureSize = width;
importer.SetPlatformTextureSettings(settings);
#endif
importer.SaveAndReimport();
var texture = AssetDatabase.LoadAssetAtPath<Texture2D>(assetName);
target.SetTextureByIndex(i, texture);
}
}
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 80087fbbf7bf93a46bb4aea276b19568
timeCreated: 1446765449
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,692 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Prompt developers to use settings most compatible with SteamVR.
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.IO;
namespace Valve.VR
{
[InitializeOnLoad]
public class SteamVR_UnitySettingsWindow : EditorWindow
{
const bool forceShow = false; // Set to true to get the dialog to show back up in the case you clicked Ignore All.
const string ignore = "ignore.";
const string useRecommended = "Use recommended ({0})";
const string currentValue = " (current = {0})";
const string buildTarget = "Build Target";
const string showUnitySplashScreen = "Show Unity Splashscreen";
const string defaultIsFullScreen = "Default is Fullscreen";
const string defaultScreenSize = "Default Screen Size";
const string runInBackground = "Run In Background";
const string displayResolutionDialog = "Display Resolution Dialog";
const string resizableWindow = "Resizable Window";
const string fullscreenMode = "D3D11 Fullscreen Mode";
const string visibleInBackground = "Visible In Background";
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
const string renderingPath = "Rendering Path";
#endif
const string colorSpace = "Color Space";
const string gpuSkinning = "GPU Skinning";
#if false // skyboxes are currently broken
const string singlePassStereoRendering = "Single-Pass Stereo Rendering";
#endif
const BuildTarget recommended_BuildTarget = BuildTarget.StandaloneWindows64;
const bool recommended_ShowUnitySplashScreen = false;
const bool recommended_DefaultIsFullScreen = false;
const int recommended_DefaultScreenWidth = 1024;
const int recommended_DefaultScreenHeight = 768;
const bool recommended_RunInBackground = true;
#if !UNITY_2019_1_OR_NEWER
const ResolutionDialogSetting recommended_DisplayResolutionDialog = ResolutionDialogSetting.HiddenByDefault;
#endif
const bool recommended_ResizableWindow = true;
const D3D11FullscreenMode recommended_FullscreenMode = D3D11FullscreenMode.FullscreenWindow;
const bool recommended_VisibleInBackground = true;
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
const RenderingPath recommended_RenderPath = RenderingPath.Forward;
#endif
const ColorSpace recommended_ColorSpace = ColorSpace.Linear;
const bool recommended_GpuSkinning = true;
#if false
const bool recommended_SinglePassStereoRendering = true;
#endif
#if UNITY_2018_1_OR_NEWER
const FullScreenMode recommended_FullScreenMode = FullScreenMode.FullScreenWindow;
#endif
static SteamVR_UnitySettingsWindow window;
static SteamVR_UnitySettingsWindow()
{
EditorApplication.update += Update;
}
static void Update()
{
bool show =
(!EditorPrefs.HasKey(ignore + buildTarget) &&
EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) ||
(!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) ||
#else
PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) ||
#endif
#if UNITY_2018_1_OR_NEWER
(!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
PlayerSettings.fullScreenMode != recommended_FullScreenMode) ||
#else
(!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) ||
(!EditorPrefs.HasKey(ignore + fullscreenMode) &&
PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) ||
#endif
(!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
(PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) ||
(!EditorPrefs.HasKey(ignore + runInBackground) &&
PlayerSettings.runInBackground != recommended_RunInBackground) ||
#if !UNITY_2019_1_OR_NEWER
(!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) ||
#endif
(!EditorPrefs.HasKey(ignore + resizableWindow) &&
PlayerSettings.resizableWindow != recommended_ResizableWindow) ||
(!EditorPrefs.HasKey(ignore + visibleInBackground) &&
PlayerSettings.visibleInBackground != recommended_VisibleInBackground) ||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
(!EditorPrefs.HasKey(ignore + renderingPath) &&
PlayerSettings.renderingPath != recommended_RenderPath) ||
#endif
(!EditorPrefs.HasKey(ignore + colorSpace) &&
PlayerSettings.colorSpace != recommended_ColorSpace) ||
(!EditorPrefs.HasKey(ignore + gpuSkinning) &&
PlayerSettings.gpuSkinning != recommended_GpuSkinning) ||
#if false
(!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) ||
#endif
forceShow;
if (show)
{
window = GetWindow<SteamVR_UnitySettingsWindow>(true);
window.minSize = new Vector2(320, 440);
//window.title = "SteamVR";
}
string[] dlls = new string[]
{
"Plugins/x86/openvr_api.dll",
"Plugins/x86_64/openvr_api.dll"
};
foreach (string path in dlls)
{
if (!File.Exists(Application.dataPath + "/" + path))
continue;
if (AssetDatabase.DeleteAsset("Assets/" + path))
Debug.Log("<b>[SteamVR Setup]</b> Deleting " + path);
else
{
Debug.Log("<b>[SteamVR Setup]</b> " + path + " in use; cannot delete. Please restart Unity to complete upgrade.");
}
}
EditorApplication.update -= Update;
}
Vector2 scrollPosition;
string GetResourcePath()
{
var ms = MonoScript.FromScriptableObject(this);
var path = AssetDatabase.GetAssetPath(ms);
path = Path.GetDirectoryName(path);
return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
}
public void OnGUI()
{
var resourcePath = GetResourcePath();
var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);
if (logo)
GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
EditorGUILayout.HelpBox("Recommended project settings for SteamVR:", MessageType.Warning);
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
int numItems = 0;
if (!EditorPrefs.HasKey(ignore + buildTarget) &&
EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
{
++numItems;
GUILayout.Label(buildTarget + string.Format(currentValue, EditorUserBuildSettings.activeBuildTarget));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_BuildTarget)))
{
#if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
#else
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget);
#endif
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + buildTarget, true);
}
GUILayout.EndHorizontal();
}
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
{
++numItems;
GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.showUnitySplashScreen));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen)))
{
PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
}
GUILayout.EndHorizontal();
}
#else
if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen)
{
++numItems;
GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen)))
{
PlayerSettings.SplashScreen.show = recommended_ShowUnitySplashScreen;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
}
GUILayout.EndHorizontal();
}
#endif
#if UNITY_2018_1_OR_NEWER
#else
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
{
++numItems;
GUILayout.Label(defaultIsFullScreen + string.Format(currentValue, PlayerSettings.defaultIsFullScreen));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_DefaultIsFullScreen)))
{
PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
}
GUILayout.EndHorizontal();
}
#endif
if (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
(PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight))
{
++numItems;
GUILayout.Label(defaultScreenSize + string.Format(" ({0}x{1})", PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format("Use recommended ({0}x{1})", recommended_DefaultScreenWidth, recommended_DefaultScreenHeight)))
{
PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth;
PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + defaultScreenSize, true);
}
GUILayout.EndHorizontal();
}
if (!EditorPrefs.HasKey(ignore + runInBackground) &&
PlayerSettings.runInBackground != recommended_RunInBackground)
{
++numItems;
GUILayout.Label(runInBackground + string.Format(currentValue, PlayerSettings.runInBackground));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_RunInBackground)))
{
PlayerSettings.runInBackground = recommended_RunInBackground;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + runInBackground, true);
}
GUILayout.EndHorizontal();
}
#if !UNITY_2019_1_OR_NEWER
if (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
{
++numItems;
GUILayout.Label(displayResolutionDialog + string.Format(currentValue, PlayerSettings.displayResolutionDialog));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_DisplayResolutionDialog)))
{
PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
}
GUILayout.EndHorizontal();
}
#endif
if (!EditorPrefs.HasKey(ignore + resizableWindow) &&
PlayerSettings.resizableWindow != recommended_ResizableWindow)
{
++numItems;
GUILayout.Label(resizableWindow + string.Format(currentValue, PlayerSettings.resizableWindow));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_ResizableWindow)))
{
PlayerSettings.resizableWindow = recommended_ResizableWindow;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + resizableWindow, true);
}
GUILayout.EndHorizontal();
}
#if UNITY_2018_1_OR_NEWER
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
PlayerSettings.fullScreenMode != recommended_FullScreenMode)
#else
if (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
#endif
{
++numItems;
#if UNITY_2018_1_OR_NEWER
GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.fullScreenMode));
#else
GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.d3d11FullscreenMode));
#endif
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_FullscreenMode)))
{
#if UNITY_2018_1_OR_NEWER
PlayerSettings.fullScreenMode = recommended_FullScreenMode;
#else
PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
#endif
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + fullscreenMode, true);
}
GUILayout.EndHorizontal();
}
if (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
{
++numItems;
GUILayout.Label(visibleInBackground + string.Format(currentValue, PlayerSettings.visibleInBackground));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_VisibleInBackground)))
{
PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + visibleInBackground, true);
}
GUILayout.EndHorizontal();
}
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (!EditorPrefs.HasKey(ignore + renderingPath) &&
PlayerSettings.renderingPath != recommended_RenderPath)
{
++numItems;
GUILayout.Label(renderingPath + string.Format(currentValue, PlayerSettings.renderingPath));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_RenderPath) + " - required for MSAA"))
{
PlayerSettings.renderingPath = recommended_RenderPath;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + renderingPath, true);
}
GUILayout.EndHorizontal();
}
#endif
if (!EditorPrefs.HasKey(ignore + colorSpace) &&
PlayerSettings.colorSpace != recommended_ColorSpace)
{
++numItems;
GUILayout.Label(colorSpace + string.Format(currentValue, PlayerSettings.colorSpace));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_ColorSpace) + " - requires reloading scene"))
{
PlayerSettings.colorSpace = recommended_ColorSpace;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + colorSpace, true);
}
GUILayout.EndHorizontal();
}
if (!EditorPrefs.HasKey(ignore + gpuSkinning) &&
PlayerSettings.gpuSkinning != recommended_GpuSkinning)
{
++numItems;
GUILayout.Label(gpuSkinning + string.Format(currentValue, PlayerSettings.gpuSkinning));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_GpuSkinning)))
{
PlayerSettings.gpuSkinning = recommended_GpuSkinning;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + gpuSkinning, true);
}
GUILayout.EndHorizontal();
}
#if false
if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
{
++numItems;
GUILayout.Label(singlePassStereoRendering + string.Format(currentValue, PlayerSettings.singlePassStereoRendering));
GUILayout.BeginHorizontal();
if (GUILayout.Button(string.Format(useRecommended, recommended_SinglePassStereoRendering)))
{
PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Ignore"))
{
EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
}
GUILayout.EndHorizontal();
}
#endif
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Clear All Ignores"))
{
EditorPrefs.DeleteKey(ignore + buildTarget);
EditorPrefs.DeleteKey(ignore + showUnitySplashScreen);
EditorPrefs.DeleteKey(ignore + defaultIsFullScreen);
EditorPrefs.DeleteKey(ignore + defaultScreenSize);
EditorPrefs.DeleteKey(ignore + runInBackground);
EditorPrefs.DeleteKey(ignore + displayResolutionDialog);
EditorPrefs.DeleteKey(ignore + resizableWindow);
EditorPrefs.DeleteKey(ignore + fullscreenMode);
EditorPrefs.DeleteKey(ignore + visibleInBackground);
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
EditorPrefs.DeleteKey(ignore + renderingPath);
#endif
EditorPrefs.DeleteKey(ignore + colorSpace);
EditorPrefs.DeleteKey(ignore + gpuSkinning);
#if false
EditorPrefs.DeleteKey(ignore + singlePassStereoRendering);
#endif
}
GUILayout.EndHorizontal();
GUILayout.EndScrollView();
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal();
if (numItems > 0)
{
if (GUILayout.Button("Accept All"))
{
// Only set those that have not been explicitly ignored.
if (!EditorPrefs.HasKey(ignore + buildTarget))
#if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
#else
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget);
#endif
if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen))
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
#else
PlayerSettings.SplashScreen.show = recommended_ShowUnitySplashScreen;
#endif
#if UNITY_2018_1_OR_NEWER
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen))
PlayerSettings.fullScreenMode = recommended_FullScreenMode;
#else
if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen))
PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
if (!EditorPrefs.HasKey(ignore + fullscreenMode))
PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
#endif
if (!EditorPrefs.HasKey(ignore + defaultScreenSize))
{
PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth;
PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
}
if (!EditorPrefs.HasKey(ignore + runInBackground))
PlayerSettings.runInBackground = recommended_RunInBackground;
#if !UNITY_2019_1_OR_NEWER
if (!EditorPrefs.HasKey(ignore + displayResolutionDialog))
PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
#endif
if (!EditorPrefs.HasKey(ignore + resizableWindow))
PlayerSettings.resizableWindow = recommended_ResizableWindow;
if (!EditorPrefs.HasKey(ignore + visibleInBackground))
PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (!EditorPrefs.HasKey(ignore + renderingPath))
PlayerSettings.renderingPath = recommended_RenderPath;
#endif
if (!EditorPrefs.HasKey(ignore + colorSpace))
PlayerSettings.colorSpace = recommended_ColorSpace;
if (!EditorPrefs.HasKey(ignore + gpuSkinning))
PlayerSettings.gpuSkinning = recommended_GpuSkinning;
#if false
if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering))
PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
#endif
EditorUtility.DisplayDialog("Accept All", "You made the right choice!", "Ok");
Close();
}
if (GUILayout.Button("Ignore All"))
{
if (EditorUtility.DisplayDialog("Ignore All", "Are you sure?", "Yes, Ignore All", "Cancel"))
{
// Only ignore those that do not currently match our recommended settings.
if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
EditorPrefs.SetBool(ignore + buildTarget, true);
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
#else
if (PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen)
#endif
EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
#if UNITY_2018_1_OR_NEWER
if (PlayerSettings.fullScreenMode != recommended_FullScreenMode)
{
EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
EditorPrefs.SetBool(ignore + fullscreenMode, true);
}
#else
if (PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
if (PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
EditorPrefs.SetBool(ignore + fullscreenMode, true);
#endif
if (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)
EditorPrefs.SetBool(ignore + defaultScreenSize, true);
if (PlayerSettings.runInBackground != recommended_RunInBackground)
EditorPrefs.SetBool(ignore + runInBackground, true);
#if !UNITY_2019_1_OR_NEWER
if (PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
#endif
if (PlayerSettings.resizableWindow != recommended_ResizableWindow)
EditorPrefs.SetBool(ignore + resizableWindow, true);
if (PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
EditorPrefs.SetBool(ignore + visibleInBackground, true);
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
if (PlayerSettings.renderingPath != recommended_RenderPath)
EditorPrefs.SetBool(ignore + renderingPath, true);
#endif
if (PlayerSettings.colorSpace != recommended_ColorSpace)
EditorPrefs.SetBool(ignore + colorSpace, true);
if (PlayerSettings.gpuSkinning != recommended_GpuSkinning)
EditorPrefs.SetBool(ignore + gpuSkinning, true);
#if false
if (PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
#endif
Close();
}
}
}
else if (GUILayout.Button("Close"))
{
Close();
}
GUILayout.EndHorizontal();
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d2244eee8a3a4784fb40d1123ff69301
timeCreated: 1438809573
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,180 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Notify developers when a new version of the plugin is available.
//
//=============================================================================
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Text.RegularExpressions;
#if UNITY_2018_3_OR_NEWER
#pragma warning disable CS0618
#endif
namespace Valve.VR
{
[InitializeOnLoad]
public class SteamVR_Update : EditorWindow
{
const string currentVersion = "2.1";
const string versionUrl = "http://media.steampowered.com/apps/steamvr/unitypluginversion.txt";
const string notesUrl = "http://media.steampowered.com/apps/steamvr/unityplugin-v{0}.txt";
const string pluginUrl = "http://u3d.as/content/valve-corporation/steam-vr-plugin";
const string doNotShowKey = "SteamVR.DoNotShow.v{0}";
static bool gotVersion = false;
static WWW wwwVersion, wwwNotes;
static string version, notes;
static SteamVR_Update window;
static SteamVR_Update()
{
EditorApplication.update += Update;
}
static void Update()
{
if (!gotVersion)
{
if (wwwVersion == null)
wwwVersion = new WWW(versionUrl);
if (!wwwVersion.isDone)
return;
if (UrlSuccess(wwwVersion))
version = wwwVersion.text;
wwwVersion = null;
gotVersion = true;
if (ShouldDisplay())
{
var url = string.Format(notesUrl, version);
wwwNotes = new WWW(url);
window = GetWindow<SteamVR_Update>(true);
window.minSize = new Vector2(320, 440);
//window.title = "SteamVR";
}
}
if (wwwNotes != null)
{
if (!wwwNotes.isDone)
return;
if (UrlSuccess(wwwNotes))
notes = wwwNotes.text;
wwwNotes = null;
if (notes != "")
window.Repaint();
}
EditorApplication.update -= Update;
}
static bool UrlSuccess(WWW www)
{
if (!string.IsNullOrEmpty(www.error))
return false;
if (Regex.IsMatch(www.text, "404 not found", RegexOptions.IgnoreCase))
return false;
return true;
}
static bool ShouldDisplay()
{
if (string.IsNullOrEmpty(version))
return false;
if (version == currentVersion)
return false;
if (EditorPrefs.HasKey(string.Format(doNotShowKey, version)))
return false;
// parse to see if newer (e.g. 1.0.4 vs 1.0.3)
var versionSplit = version.Split('.');
var currentVersionSplit = currentVersion.Split('.');
for (int i = 0; i < versionSplit.Length && i < currentVersionSplit.Length; i++)
{
int versionValue, currentVersionValue;
if (int.TryParse(versionSplit[i], out versionValue) &&
int.TryParse(currentVersionSplit[i], out currentVersionValue))
{
if (versionValue > currentVersionValue)
return true;
if (versionValue < currentVersionValue)
return false;
}
}
// same up to this point, now differentiate based on number of sub values (e.g. 1.0.4.1 vs 1.0.4)
if (versionSplit.Length <= currentVersionSplit.Length)
return false;
return true;
}
Vector2 scrollPosition;
bool toggleState;
string GetResourcePath()
{
var ms = MonoScript.FromScriptableObject(this);
var path = AssetDatabase.GetAssetPath(ms);
path = Path.GetDirectoryName(path);
return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
}
public void OnGUI()
{
EditorGUILayout.HelpBox("A new version of the SteamVR plugin is available!", MessageType.Warning);
var resourcePath = GetResourcePath();
var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);
if (logo)
GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
scrollPosition = GUILayout.BeginScrollView(scrollPosition);
GUILayout.Label("Current version: " + currentVersion);
GUILayout.Label("New version: " + version);
if (notes != "")
{
GUILayout.Label("Release notes:");
EditorGUILayout.HelpBox(notes, MessageType.Info);
}
GUILayout.EndScrollView();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Get Latest Version"))
{
Application.OpenURL(pluginUrl);
}
EditorGUI.BeginChangeCheck();
var doNotShow = GUILayout.Toggle(toggleState, "Do not prompt for this version again.");
if (EditorGUI.EndChangeCheck())
{
toggleState = doNotShow;
var key = string.Format(doNotShowKey, version);
if (doNotShow)
EditorPrefs.SetBool(key, true);
else
EditorPrefs.DeleteKey(key);
}
}
}
}
#if UNITY_2018_3_OR_NEWER
#pragma warning restore CS0618
#endif

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 73a0556bda803bf4e898751dcfcf21a8
timeCreated: 1433880062
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,26 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
[CustomPropertyDrawer(typeof(SteamVR_UpdateModes))]
public class SteamVR_UpdateModesEditor : PropertyDrawer
{
public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label)
{
_property.intValue = EditorGUI.MaskField(_position, _label, _property.intValue, _property.enumNames);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 656e3d05f0a289d4ab6f3d44f65c9b6d
timeCreated: 1521584981
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/SteamVR/Icon.meta Normal file
View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 37d1a399d1ea2d24c8f27e07036b83fb
folderAsset: yes
timeCreated: 1532646714
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: a9d04296988f9324d98f54789595e5bf
timeCreated: 1547854934
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 128
textureSettings:
filterMode: 2
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 200a36575873a1d40baa790e18dafe5d
timeCreated: 1532646733
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 034ad660702976d4da58a18ccae19443
folderAsset: yes
timeCreated: 1521243381
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 353612abd09de3a478236e679e220759
folderAsset: yes
timeCreated: 1548282626
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_BooleanEvent : UnityEvent<SteamVR_Behaviour_Boolean, SteamVR_Input_Sources, bool> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 59250d64a1ce9a44891e9bb0b3d71e6b
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_PoseEvent : UnityEvent<SteamVR_Behaviour_Pose, SteamVR_Input_Sources> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d77e49c3174e18045ab27a1029c6a977
timeCreated: 1548282627
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_Pose_ConnectedChangedEvent : UnityEvent<SteamVR_Behaviour_Pose, SteamVR_Input_Sources, bool> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f0abecbe8a5e4e04dab8f886e1d6d070
timeCreated: 1548282627
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_Pose_DeviceIndexChangedEvent : UnityEvent<SteamVR_Behaviour_Pose, SteamVR_Input_Sources, int> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bc42b626f4ef1264ebfc0393f40df5c9
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_Pose_TrackingChangedEvent : UnityEvent<SteamVR_Behaviour_Pose, SteamVR_Input_Sources, ETrackingResult> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 62c981c44fe9a6046bb0766cb96bdf65
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_SingleEvent : UnityEvent<SteamVR_Behaviour_Single, SteamVR_Input_Sources, float, float> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b8fd33c9d8ff2114a8b6a59629165318
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_SkeletonEvent : UnityEvent<SteamVR_Behaviour_Skeleton, SteamVR_Input_Sources> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c56ae57c82c46674ea85a60fd6ba9334
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_Skeleton_ConnectedChangedEvent : UnityEvent<SteamVR_Behaviour_Skeleton, SteamVR_Input_Sources, bool> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 431bf7eb5ceb24a448dc44a2ed8d8243
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_Skeleton_TrackingChangedEvent : UnityEvent<SteamVR_Behaviour_Skeleton, SteamVR_Input_Sources, ETrackingResult> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7461d65099840d840af0e25e6afda525
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_Vector2Event : UnityEvent<SteamVR_Behaviour_Vector2, SteamVR_Input_Sources, Vector2, Vector2> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 091545c123a858440b2e32a3f299a923
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,11 @@
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using System;
using UnityEngine;
using UnityEngine.Events;
namespace Valve.VR
{
[Serializable]
public class SteamVR_Behaviour_Vector3Event : UnityEvent<SteamVR_Behaviour_Vector3, SteamVR_Input_Sources, Vector3, Vector3> { }
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 99c31ec1b21aa424987b0162f9971dc6
timeCreated: 1548282626
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fed05885250fc2c4daab18c7df3717bf
folderAsset: yes
timeCreated: 1521243387
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7836f978f062019499564a455654e74a
timeCreated: 1521247191
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7d5e740d15d7ca249b884d30ff558bc1
folderAsset: yes
timeCreated: 1547747995
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 16f1e3ee1a373e34ea3a84a7afa0a259
folderAsset: yes
timeCreated: 1547747995
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: aa701b1f3ae438e469d0ad4f122a0633
timeCreated: 1547747996
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 2f8721c3878282b44bd0c8a689d4788c
timeCreated: 1547747995
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 426d721c1fc5bfa418c79dc808856464
timeCreated: 1547747995
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 1e898a11a01f33d4a80b04e98158023a
timeCreated: 1547857461
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 985915d4db439114797fb72a46387d71
timeCreated: 1547857461
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: d1f34261d4655bc4cb5413868ae9bee2
timeCreated: 1547765671
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 2c4294febb4dfe54d98c37083da7a639
timeCreated: 1547765602
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 0f57642ec96c82446a79c525bb70b018
timeCreated: 1547765602
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: e0a60ab44553a7f4ca994dec64351d08
timeCreated: 1547765602
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 4fb892aabe590ec4fb65a57a048a093f
timeCreated: 1547765602
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: c3b3083cc66322049822d98fa4c15fd6
timeCreated: 1547765602
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -0,0 +1,59 @@
fileFormatVersion: 2
guid: 764dada5864e19440bb07e24e684e950
timeCreated: 1547765602
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 2
mipmaps:
mipMapMode: 0
enableMipMap: 0
linearTexture: 1
correctGamma: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 0
cubemapConvolution: 0
cubemapConvolutionSteps: 7
cubemapConvolutionExponent: 1.5
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: 1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
rGBM: 0
compressionQuality: 50
allowsAlphaSplitting: 0
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
buildTargetSettings: []
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,62 @@
using UnityEngine;
using System.Collections;
using UnityEditor;
using System;
using System.Linq;
using System.IO;
namespace Valve.VR
{
public class SteamVR_CopyExampleInputFiles : Editor
{
public const string steamVRInputExampleJSONCopiedKey = "SteamVR_Input_CopiedExamples";
public const string exampleJSONFolderParent = "Input";
public const string exampleJSONFolderName = "ExampleJSON";
[UnityEditor.Callbacks.DidReloadScripts]
private static void OnReloadScripts()
{
SteamVR_Input.CheckOldLocation();
CopyFiles();
}
public static void CopyFiles(bool force = false)
{
bool hasCopied = EditorPrefs.GetBool(steamVRInputExampleJSONCopiedKey, false);
if (hasCopied == false || force == true)
{
string actionsFilePath = SteamVR_Input.GetActionsFilePath();
bool exists = File.Exists(actionsFilePath);
if (exists == false)
{
string steamVRFolder = SteamVR.GetSteamVRFolderPath();
string exampleLocation = Path.Combine(steamVRFolder, exampleJSONFolderParent);
string exampleFolderPath = Path.Combine(exampleLocation, exampleJSONFolderName);
string streamingAssetsPath = SteamVR_Input.GetActionsFileFolder();
string[] files = Directory.GetFiles(exampleFolderPath, "*.json");
foreach (string file in files)
{
string filename = Path.GetFileName(file);
string newPath = Path.Combine(streamingAssetsPath, filename);
try
{
File.Copy(file, newPath, false);
Debug.Log("<b>[SteamVR]</b> Copied example input JSON to path: " + newPath);
}
catch
{
Debug.LogError("<b>[SteamVR]</b> Could not copy file: " + file + " to path: " + newPath);
}
}
EditorPrefs.SetBool(steamVRInputExampleJSONCopiedKey, true);
}
}
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 806facaa17de95d4794b0acbbad1268d
timeCreated: 1528159292
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,879 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
using Valve.Newtonsoft.Json;
namespace Valve.VR
{
public class SteamVR_Input_ActionManifest_Manager : AssetPostprocessor
{
private static bool importing = false;
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
if (importing)
return;
importing = true;
Dictionary<string, List<SteamVR_PartialInputBindings>> partials = ScanForPartials();
if (partials != null)
{
foreach (var element in partials)
{
if (element.Value != null && element.Value.Count > 0 && element.Value[0].imported == false)
ConfirmImport(element.Value);
}
}
importing = false;
}
public const string partialManifestFilename = "steamvr_partial_manifest.json";
public static void CreatePartial(string name, int version, bool overwriteOld, bool removeUnused)
{
if (SteamVR_Input.actionFile.action_sets.Any(set => set.name == "default"))
{
bool confirm = EditorUtility.DisplayDialog("Confirmation", "We don't recommend you create a partial binding manifest with an action set named 'default'. There will often be collisions with existing actions. Are you sure you want to continue creating this partial binding manifest?", "Create", "Cancel");
if (confirm == false)
return;
}
string folderName = "SteamVR_" + SteamVR_Input_ActionFile.GetCodeFriendlyName(name);
string directorySeparatorChar = System.IO.Path.DirectorySeparatorChar.ToString();
string mainFolderPath = string.Format("{0}", folderName);
string versionFolderPath = string.Format("{1}{0}{2}", directorySeparatorChar, folderName, version.ToString());
string manifestPath = string.Format("{1}{0}{2}{0}{3}", directorySeparatorChar, folderName, version.ToString(), partialManifestFilename);
if (Directory.Exists(mainFolderPath) == false)
{
Directory.CreateDirectory(mainFolderPath);
}
if (Directory.Exists(versionFolderPath) == false)
{
Directory.CreateDirectory(versionFolderPath);
}
SteamVR_PartialInputBindings partial = new SteamVR_PartialInputBindings();
partial.name = name;
partial.version = version;
partial.overwriteOld = overwriteOld;
partial.removeUnused = removeUnused;
string jsonText = JsonConvert.SerializeObject(partial, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
if (File.Exists(manifestPath))
{
FileInfo manifestFile = new FileInfo(manifestPath);
manifestFile.IsReadOnly = false;
}
File.WriteAllText(manifestPath, jsonText);
SteamVR_Input.actionFile.CopyFilesToPath(versionFolderPath, true);
EditorUtility.RevealInFinder(mainFolderPath);
}
protected static string FindLanguageInDictionary(Dictionary<string, string> dictionary)
{
foreach (var localizationMember in dictionary)
{
if (localizationMember.Key == SteamVR_Input_ActionFile_LocalizationItem.languageTagKeyName)
return localizationMember.Value;
}
return null;
}
protected static int ImportLocalization(SteamVR_Input_ActionFile currentActionsFile, SteamVR_Input_ActionFile newActionsFile, SteamVR_PartialInputBindings partialBinding)
{
int count = 0;
foreach (var newLocalDictionary in newActionsFile.localization)
{
string newLanguage = FindLanguageInDictionary(newLocalDictionary);
if (string.IsNullOrEmpty(newLanguage))
{
Debug.LogError("<b>[SteamVR Input]</b> Localization entry in partial actions file is missing a language tag: " + partialBinding.path);
continue;
}
int currentLanguage = -1;
for (int currentLanguageIndex = 0; currentLanguageIndex < currentActionsFile.localization.Count; currentLanguageIndex++)
{
string language = FindLanguageInDictionary(currentActionsFile.localization[currentLanguageIndex]);
if (newLanguage == language)
{
currentLanguage = currentLanguageIndex;
break;
}
}
if (currentLanguage == -1)
{
Dictionary<string, string> newDictionary = new Dictionary<string, string>();
foreach (var element in newLocalDictionary)
{
newDictionary.Add(element.Key, element.Value);
count++;
}
currentActionsFile.localization.Add(newDictionary);
}
else
{
foreach (var element in newLocalDictionary)
{
Dictionary<string, string> currentDictionary = currentActionsFile.localization[currentLanguage];
bool exists = currentDictionary.Any(inCurrent => inCurrent.Key == element.Key);
if (exists)
{
//todo: should we overwrite?
currentDictionary[element.Key] = element.Value;
}
else
{
currentDictionary.Add(element.Key, element.Value);
count++;
}
}
}
}
return count;
}
protected static int ImportActionSets(SteamVR_Input_ActionFile currentActionsFile, SteamVR_Input_ActionFile newActionsFile)
{
int count = 0;
foreach (var newSet in newActionsFile.action_sets)
{
if (currentActionsFile.action_sets.Any(setInCurrent => newSet.name == setInCurrent.name) == false)
{
currentActionsFile.action_sets.Add(newSet.GetCopy());
count++;
}
}
return count;
}
protected static int ImportActions(SteamVR_Input_ActionFile currentActionsFile, SteamVR_Input_ActionFile newActionsFile)
{
int count = 0;
foreach (var newAction in newActionsFile.actions)
{
if (currentActionsFile.actions.Any(actionInCurrent => newAction.name == actionInCurrent.name) == false)
{
currentActionsFile.actions.Add(newAction.GetCopy());
count++;
}
else
{
SteamVR_Input_ActionFile_Action existingAction = currentActionsFile.actions.First(actionInCurrent => newAction.name == actionInCurrent.name);
//todo: better merge? should we overwrite?
existingAction.type = newAction.type;
existingAction.scope = newAction.scope;
existingAction.skeleton = newAction.skeleton;
existingAction.requirement = newAction.requirement;
}
}
return count;
}
protected static SteamVR_Input_BindingFile GetBindingFileObject(string path)
{
if (File.Exists(path) == false)
{
Debug.LogError("<b>[SteamVR]</b> Could not access file at path: " + path);
return null;
}
string jsonText = File.ReadAllText(path);
SteamVR_Input_BindingFile importingBindingFile = JsonConvert.DeserializeObject<SteamVR_Input_BindingFile>(jsonText);
return importingBindingFile;
}
protected static void WriteBindingFileObject(SteamVR_Input_BindingFile currentBindingFile, string currentBindingPath)
{
if (File.Exists(currentBindingPath))
{
FileInfo fileInfo = new FileInfo(currentBindingPath);
fileInfo.IsReadOnly = false;
}
string newJSON = JsonConvert.SerializeObject(currentBindingFile, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
File.WriteAllText(currentBindingPath, newJSON);
Debug.Log("<b>[SteamVR]</b> Added action bindings to: " + currentBindingPath);
}
protected static void ImportBindings(SteamVR_Input_ActionFile currentActionsFile, SteamVR_Input_ActionFile newActionsFile, string directory)
{
foreach (var newDefaultPath in newActionsFile.default_bindings)
{
if (currentActionsFile.default_bindings.Any(currentDefaultPath => newDefaultPath.controller_type == currentDefaultPath.controller_type) == false)
{
currentActionsFile.default_bindings.Add(newDefaultPath.GetCopy());
string bindingPath = Path.Combine(directory, newDefaultPath.binding_url);
File.Copy(bindingPath, newDefaultPath.binding_url);
}
else
{
string currentBindingDirectory = SteamVR_Input.GetActionsFileFolder();
string currentBindingPath = currentActionsFile.default_bindings.First(binding => binding.controller_type == newDefaultPath.controller_type).binding_url;
currentBindingPath = Path.Combine(currentBindingDirectory, currentBindingPath);
SteamVR_Input_BindingFile currentBindingFile = GetBindingFileObject(currentBindingPath);
if (currentBindingFile == null)
{
Debug.LogError("<b>[SteamVR]</b> There was an error deserializing the binding at path: " + currentBindingPath);
continue;
}
SteamVR_Input_BindingFile importingBindingFile = GetBindingFileObject(Path.Combine(directory, newDefaultPath.binding_url));
if (importingBindingFile == null)
{
Debug.LogError("<b>[SteamVR]</b> There was an error deserializing the binding at path: " + Path.Combine(directory, newDefaultPath.binding_url));
continue;
}
bool changed = false;
foreach (var importingActionList in importingBindingFile.bindings)
{
if (currentBindingFile.bindings.Any(binding => binding.Key == importingActionList.Key))
{
var currentSetBinding = currentBindingFile.bindings.FirstOrDefault(binding => binding.Key == importingActionList.Key);
//todo: better merge? if we don't have an exact copy of the item then we add a new one
foreach (var importingChord in importingActionList.Value.chords)
{
if (currentSetBinding.Value.chords.Any(currentChord => importingChord.Equals(currentChord)) == false)
{
changed = true;
currentSetBinding.Value.chords.Add(importingChord);
}
}
foreach (var importingHaptic in importingActionList.Value.haptics)
{
if (currentSetBinding.Value.haptics.Any(currentHaptic => importingHaptic.Equals(currentHaptic)) == false)
{
changed = true;
currentSetBinding.Value.haptics.Add(importingHaptic);
}
}
foreach (var importingPose in importingActionList.Value.poses)
{
if (currentSetBinding.Value.poses.Any(currentPose => importingPose.Equals(currentPose)) == false)
{
changed = true;
currentSetBinding.Value.poses.Add(importingPose);
}
}
foreach (var importingSkeleton in importingActionList.Value.skeleton)
{
if (currentSetBinding.Value.skeleton.Any(currentSkeleton => importingSkeleton.Equals(currentSkeleton)) == false)
{
changed = true;
currentSetBinding.Value.skeleton.Add(importingSkeleton);
}
}
foreach (var importingSource in importingActionList.Value.sources)
{
if (currentSetBinding.Value.sources.Any(currentSource => importingSource.Equals(currentSource)) == false)
{
changed = true;
currentSetBinding.Value.sources.Add(importingSource);
}
}
}
else
{
changed = true;
currentBindingFile.bindings.Add(importingActionList.Key, importingActionList.Value);
}
}
if (changed)
{
WriteBindingFileObject(currentBindingFile, currentBindingPath);
}
}
}
}
public static void CleanBindings(bool verbose = false)
{
SteamVR_Input.InitializeFile(true);
SteamVR_Input_ActionFile currentActionsFile = SteamVR_Input.actionFile;
for (int localizationIndex = 0; localizationIndex < currentActionsFile.localization.Count; localizationIndex++)
{
Dictionary<string, string> dictionary = currentActionsFile.localization[localizationIndex];
bool removed;
do
{
removed = false;
string missingAction = null;
foreach (string key in dictionary.Keys)
{
if (key == SteamVR_Input_ActionFile_LocalizationItem.languageTagKeyName)
continue;
if (currentActionsFile.actions.Any(action => string.Equals(action.name, key, StringComparison.CurrentCultureIgnoreCase)) == false)
{
missingAction = key;
}
}
if (missingAction != null)
{
removed = true;
dictionary.Remove(missingAction);
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> Removing localization entry for: " + missingAction);
}
} while (removed);
}
for (int bindingIndex = 0; bindingIndex < currentActionsFile.default_bindings.Count; bindingIndex++)
{
SteamVR_Input_ActionFile_DefaultBinding currentBinding = currentActionsFile.default_bindings[bindingIndex];
string bindingPath = Path.Combine(SteamVR_Input.GetActionsFileFolder(), currentBinding.binding_url);
if (File.Exists(bindingPath) == false)
{
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> Removing binding entry for missing file: '" + currentBinding.controller_type + "' at: " + bindingPath);
currentActionsFile.default_bindings.RemoveAt(bindingIndex);
bindingIndex--;
continue;
}
SteamVR_Input_BindingFile bindingFile = GetBindingFileObject(bindingPath);
if (bindingFile == null)
{
Debug.LogError("<b>[SteamVR Input]</b> Error parsing binding file for: '" + currentBinding.controller_type + "' at: " + bindingPath);
continue;
}
int changed = 0;
foreach (var actionList in bindingFile.bindings)
{
for (int itemIndex = 0; itemIndex < actionList.Value.chords.Count; itemIndex++)
{
string outputActionPath = actionList.Value.chords[itemIndex].output;
if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
{
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing chord binding for action: " + outputActionPath);
actionList.Value.chords.RemoveAt(itemIndex);
itemIndex--;
changed++;
}
}
for (int itemIndex = 0; itemIndex < actionList.Value.haptics.Count; itemIndex++)
{
string outputActionPath = actionList.Value.haptics[itemIndex].output;
if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
{
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing haptics binding for action: " + outputActionPath);
actionList.Value.haptics.RemoveAt(itemIndex);
itemIndex--;
changed++;
}
}
for (int itemIndex = 0; itemIndex < actionList.Value.poses.Count; itemIndex++)
{
string outputActionPath = actionList.Value.poses[itemIndex].output;
if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
{
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing pose binding for action: " + outputActionPath);
actionList.Value.poses.RemoveAt(itemIndex);
itemIndex--;
changed++;
}
}
for (int itemIndex = 0; itemIndex < actionList.Value.skeleton.Count; itemIndex++)
{
string outputActionPath = actionList.Value.skeleton[itemIndex].output;
if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
{
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing skeleton binding for action: " + outputActionPath);
actionList.Value.skeleton.RemoveAt(itemIndex);
itemIndex--;
changed++;
}
}
for (int itemIndex = 0; itemIndex < actionList.Value.sources.Count; itemIndex++)
{
string outputActionPath = actionList.Value.sources[itemIndex].GetOutput();
if (currentActionsFile.actions.Any(action => string.Equals(action.name, outputActionPath, StringComparison.CurrentCultureIgnoreCase)) == false)
{
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> " + currentBinding.controller_type + ": Removing source binding for action: " + outputActionPath);
actionList.Value.sources.RemoveAt(itemIndex);
itemIndex--;
changed++;
}
}
}
if (changed > 0)
{
WriteBindingFileObject(bindingFile, bindingPath);
}
}
if (SteamVR_Input.HasFileInMemoryBeenModified())
{
SteamVR_Input.actionFile.Save(SteamVR_Input.GetActionsFilePath());
if (verbose)
Debug.Log("<b>[SteamVR Input]</b> Saved new actions file: " + SteamVR_Input.GetActionsFilePath());
}
}
protected static void ImportPartialBinding(SteamVR_PartialInputBindings partialBinding)
{
SteamVR_Input.InitializeFile();
SteamVR_Input_ActionFile currentActionsFile = SteamVR_Input.actionFile;
SteamVR_Input_ActionFile newActionsFile = ReadJson<SteamVR_Input_ActionFile>(partialBinding.GetActionsPath());
/*
int sets = ImportActionSets(currentActionsFile, newActionsFile);
int locs = ImportLocalization(currentActionsFile, newActionsFile, partialBinding);
int actions = ImportActions(currentActionsFile, newActionsFile);
*/
ImportActionSets(currentActionsFile, newActionsFile);
ImportLocalization(currentActionsFile, newActionsFile, partialBinding);
ImportActions(currentActionsFile, newActionsFile);
if (SteamVR_Input.HasFileInMemoryBeenModified())
{
SteamVR_Input.actionFile.Save(SteamVR_Input.GetActionsFilePath());
Debug.Log("<b>[SteamVR]</b> Saved new actions file: " + SteamVR_Input.GetActionsFilePath());
}
ImportBindings(currentActionsFile, newActionsFile, partialBinding.GetDirectory());
partialBinding.imported = true;
partialBinding.Save();
SteamVR_Input.InitializeFile(true);
SteamVR_Input_EditorWindow.ReopenWindow();
//todo: ask first?
/*string dialogText = string.Format("{0} new action sets, {1} new actions, and {2} new localization strings have been added. Would you like to regenerate SteamVR Input code files?", sets, actions, locs);
bool confirm = EditorUtility.DisplayDialog("SteamVR Input", dialogText, "Generate", "Cancel");
if (confirm)
SteamVR_Input_Generator.BeginGeneration();
*/
SteamVR_Input_Generator.BeginGeneration();
Debug.Log("<b>[SteamVR]</b> Reloaded actions file with additional actions from " + partialBinding.name);
}
protected static void ReplaceBinding(SteamVR_PartialInputBindings partialBinding)
{
SteamVR_Input.DeleteManifestAndBindings();
string newActionsFilePath = partialBinding.GetActionsPath();
if (File.Exists(newActionsFilePath))
{
File.Copy(newActionsFilePath, SteamVR_Input.GetActionsFilePath());
}
string bindingsFolder = SteamVR_Input.GetActionsFileFolder();
SteamVR_Input_ActionFile newActionsFile = ReadJson<SteamVR_Input_ActionFile>(SteamVR_Input.GetActionsFilePath());
string partialBindingDirectory = partialBinding.GetDirectory();
foreach (var newDefaultPath in newActionsFile.default_bindings)
{
string bindingPath = Path.Combine(partialBindingDirectory, newDefaultPath.binding_url);
string newBindingPath = Path.Combine(bindingsFolder, newDefaultPath.binding_url);
File.Copy(bindingPath, newBindingPath, true);
}
partialBinding.imported = true;
partialBinding.Save();
SteamVR_Input.InitializeFile(true);
SteamVR_Input_EditorWindow.ReopenWindow();
//todo: ask first?
/*string dialogText = string.Format("{0} new action sets, {1} new actions, and {2} new localization strings have been added. Would you like to regenerate SteamVR Input code files?", sets, actions, locs);
bool confirm = EditorUtility.DisplayDialog("SteamVR Input", dialogText, "Generate", "Cancel");
if (confirm)
SteamVR_Input_Generator.BeginGeneration();
*/
SteamVR_Input_Generator.BeginGeneration();
Debug.Log("<b>[SteamVR Input]</b> Reloaded with new actions from " + partialBinding.name);
}
protected static T ReadJson<T>(string path)
{
if (File.Exists(path))
{
string jsonText = File.ReadAllText(path);
return JsonConvert.DeserializeObject<T>(jsonText);
}
return default(T);
}
protected static List<SteamVR_Input_ActionFile_Action> RemoveOldActions(List<SteamVR_PartialInputBindings> partialBindingList)
{
List<SteamVR_Input_ActionFile_Action> toRemove = new List<SteamVR_Input_ActionFile_Action>();
SteamVR_Input_ActionFile newestActionsFile = ReadJson<SteamVR_Input_ActionFile>(partialBindingList[0].GetActionsPath());
for (int partialBindingIndex = 1; partialBindingIndex < partialBindingList.Count; partialBindingIndex++)
{
SteamVR_Input_ActionFile oldActionsFile = ReadJson<SteamVR_Input_ActionFile>(partialBindingList[partialBindingIndex].GetActionsPath());
for (int oldActionIndex = 0; oldActionIndex < oldActionsFile.actions.Count; oldActionIndex++)
{
var oldAction = oldActionsFile.actions[oldActionIndex];
if (newestActionsFile.actions.Any(newAction => oldAction.Equals(newAction)) == false)
{
var existing = SteamVR_Input.actionFile.actions.FirstOrDefault(action => oldAction.Equals(action));
if (existing != null)
{
SteamVR_Input.actionFile.actions.Remove(existing);
toRemove.Add(oldAction);
}
}
}
}
return toRemove;
}
protected static List<SteamVR_Input_ActionFile_ActionSet> RemoveOldActionSets(List<SteamVR_PartialInputBindings> partialBindingList)
{
List<SteamVR_Input_ActionFile_ActionSet> toRemove = new List<SteamVR_Input_ActionFile_ActionSet>();
SteamVR_Input_ActionFile newestActionsFile = ReadJson<SteamVR_Input_ActionFile>(partialBindingList[0].GetActionsPath());
for (int partialBindingIndex = 1; partialBindingIndex < partialBindingList.Count; partialBindingIndex++)
{
SteamVR_Input_ActionFile oldActionsFile = ReadJson<SteamVR_Input_ActionFile>(partialBindingList[0].GetActionsPath());
for (int oldActionIndex = 0; oldActionIndex < oldActionsFile.action_sets.Count; oldActionIndex++)
{
var oldActionSet = oldActionsFile.action_sets[oldActionIndex];
if (newestActionsFile.action_sets.Any(newAction => oldActionSet.Equals(newAction)) == false)
{
var existing = SteamVR_Input.actionFile.action_sets.FirstOrDefault(actionSet => oldActionSet.Equals(actionSet));
if (existing != null)
{
SteamVR_Input.actionFile.action_sets.Remove(existing);
toRemove.Add(oldActionSet);
}
}
}
}
return toRemove;
}
protected static int RemoveOldLocalizations(List<SteamVR_Input_ActionFile_Action> removedActionList)
{
int count = 0;
foreach (var action in removedActionList)
{
foreach (var locDictionary in SteamVR_Input.actionFile.localization)
{
bool removed = locDictionary.Remove(action.name);
if (removed)
count++;
}
}
return count;
}
protected static void RemoveOldActionsAndSetsFromBindings(List<SteamVR_Input_ActionFile_ActionSet> setsToRemove, List<SteamVR_Input_ActionFile_Action> actionsToRemove)
{
foreach (var defaultBindingItem in SteamVR_Input.actionFile.default_bindings)
{
string currentBindingPath = defaultBindingItem.binding_url;
SteamVR_Input_BindingFile currentBindingFile = GetBindingFileObject(currentBindingPath);
if (currentBindingFile == null)
{
Debug.LogError("<b>[SteamVR]</b> There was an error deserializing the binding at path: " + currentBindingPath);
continue;
}
bool changed = false;
List<string> bindingListsToRemove = new List<string>();
foreach (var actionList in currentBindingFile.bindings)
{
if (setsToRemove.Any(set => set.name == actionList.Key))
{
bindingListsToRemove.Add(actionList.Key);
changed = true;
continue;
}
for (int chordIndex = 0; chordIndex < actionList.Value.chords.Count; chordIndex++)
{
var existingChord = actionList.Value.chords[chordIndex];
if (actionsToRemove.Any(action => action.name == existingChord.output))
{
actionList.Value.chords.Remove(existingChord);
chordIndex--;
changed = true;
}
}
for (int hapticIndex = 0; hapticIndex < actionList.Value.haptics.Count; hapticIndex++)
{
var existingHaptic = actionList.Value.haptics[hapticIndex];
if (actionsToRemove.Any(action => action.name == existingHaptic.output))
{
actionList.Value.haptics.Remove(existingHaptic);
hapticIndex--;
changed = true;
}
}
for (int poseIndex = 0; poseIndex < actionList.Value.poses.Count; poseIndex++)
{
var existingPose = actionList.Value.poses[poseIndex];
if (actionsToRemove.Any(action => action.name == existingPose.output))
{
actionList.Value.poses.Remove(existingPose);
poseIndex--;
changed = true;
}
}
for (int skeletonIndex = 0; skeletonIndex < actionList.Value.skeleton.Count; skeletonIndex++)
{
var existingSkeleton = actionList.Value.skeleton[skeletonIndex];
if (actionsToRemove.Any(action => action.name == existingSkeleton.output))
{
actionList.Value.skeleton.Remove(existingSkeleton);
skeletonIndex--;
changed = true;
}
}
for (int sourceIndex = 0; sourceIndex < actionList.Value.sources.Count; sourceIndex++)
{
var existingSource = actionList.Value.sources[sourceIndex];
if (actionsToRemove.Any(action => action.name == existingSource.GetOutput()))
{
actionList.Value.sources.Remove(existingSource);
sourceIndex--;
changed = true;
}
}
}
for (int bindingListToRemoveIndex = 0; bindingListToRemoveIndex < bindingListsToRemove.Count; bindingListToRemoveIndex++)
{
currentBindingFile.bindings.Remove(bindingListsToRemove[bindingListToRemoveIndex]);
}
if (changed)
{
WriteBindingFileObject(currentBindingFile, currentBindingPath);
}
}
}
protected static void RemoveOldPartialBindings(List<SteamVR_PartialInputBindings> partialBindingList)
{
List<SteamVR_Input_ActionFile_Action> actionsToRemove = RemoveOldActions(partialBindingList);
List<SteamVR_Input_ActionFile_ActionSet> setsToRemove = RemoveOldActionSets(partialBindingList);
int sets = setsToRemove.Count;
int actions = actionsToRemove.Count;
int locs = RemoveOldLocalizations(actionsToRemove);
string dialogText = string.Format("We've found a old {0} action sets, {1} actions, and {2} localization entries from old versions of this partial binding. Would you like to remove them from the actions file and default bindings?", sets, actions, locs);
bool confirm = EditorUtility.DisplayDialog("SteamVR Input", dialogText, "Import", "Cancel");
if (confirm)
{
RemoveOldActionsAndSetsFromBindings(setsToRemove, actionsToRemove);
SteamVR_Input.actionFile.Save(SteamVR_Input.GetActionsFilePath());
SteamVR_Input.InitializeFile(true); // reload after the save
}
else
{
SteamVR_Input.InitializeFile(true); // reload since we actually removed the actions / sets to display this message
}
}
protected const string dontAskAgainTemplate = "{0}_{1}_DontAskAgain";
protected static void ConfirmImport(List<SteamVR_PartialInputBindings> partialBindingList)
{
SteamVR_PartialInputBindings partial = partialBindingList.First();
//bool dontAskAgain = EditorPrefs.GetBool(dontAskAgainTemplate, false);
//todo: implement 'do not ask again'
string dialogText = string.Format("We've found a partial SteamVR Input binding for '{0}' version '{1}'. Would you like to import it?", partial.name, partial.version);
bool confirm = EditorUtility.DisplayDialog("SteamVR Input", dialogText, "Import", "Cancel");
if (confirm)
{
bool actionsExists = SteamVR_Input.DoesActionsFileExist();
if (actionsExists)
{
string mergeDialogText = "You have two options for importing this binding:\n Replace your current action file (delete all your actions)\n Merge the partial action file with your existing actions";
bool shouldMerge = EditorUtility.DisplayDialog("SteamVR Input", mergeDialogText, "Merge", "Replace");
if (shouldMerge)
{
ImportPartialBinding(partial);
}
else
{
ReplaceBinding(partial);
}
}
else
{
ReplaceBinding(partial);
}
if (partialBindingList.Count > 1)
{
RemoveOldPartialBindings(partialBindingList);
}
}
}
public static Dictionary<string, List<SteamVR_PartialInputBindings>> ScanForPartials()
{
string[] partialManifestPaths = Directory.GetFiles(Application.dataPath, partialManifestFilename, SearchOption.AllDirectories);
Dictionary<string, List<SteamVR_PartialInputBindings>> partialBindings = new Dictionary<string, List<SteamVR_PartialInputBindings>>();
for (int partialIndex = 0; partialIndex < partialManifestPaths.Length; partialIndex++)
{
string path = partialManifestPaths[partialIndex];
string jsonText = File.ReadAllText(path);
SteamVR_PartialInputBindings partialBinding = JsonConvert.DeserializeObject<SteamVR_PartialInputBindings>(jsonText);
partialBinding.path = path;
if (partialBindings.ContainsKey(partialBinding.name))
{
for (int versionIndex = 0; versionIndex < partialBindings[partialBinding.name].Count; versionIndex++)
{
if (partialBinding.version < partialBindings[partialBinding.name][versionIndex].version)
partialBindings[partialBinding.name].Insert(versionIndex, partialBinding);
}
}
else
{
partialBindings.Add(partialBinding.name, new List<SteamVR_PartialInputBindings>() { partialBinding });
}
}
return partialBindings;
}
}
public class SteamVR_PartialInputBindings
{
public string name;
public int version;
public bool overwriteOld;
public bool removeUnused;
public bool imported;
[JsonIgnore]
public string path { get; set; }
public string GetActionsPath()
{
return Path.Combine(GetDirectory(), "actions.json");
}
public string GetDirectory()
{
return new FileInfo(path).Directory.FullName;
}
public void Save()
{
FileInfo existingActionsFile = new FileInfo(path);
if (existingActionsFile.Exists)
{
existingActionsFile.IsReadOnly = false;
}
//SanitizeActionFile(); //todo: shouldn't we be doing this?
string json = JsonConvert.SerializeObject(this, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
File.WriteAllText(path, json);
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8c0dec2678a8ce94dbdd749500441172
timeCreated: 1540850400
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,177 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
[CustomPropertyDrawer(typeof(SteamVR_ActionSet))]
public class SteamVR_Input_ActionSetPropertyEditor : PropertyDrawer
{
protected SteamVR_ActionSet[] actionSets;
protected string[] enumItems;
public int selectedIndex = notInitializedIndex;
protected const int notInitializedIndex = -1;
protected const int noneIndex = 0;
protected int addIndex = 1;
protected const string defaultPathTemplate = " \u26A0 Missing action set: {0}";
protected string defaultPathLabel = null;
protected void Awake()
{
actionSets = SteamVR_Input.GetActionSets();
if (actionSets != null && actionSets.Length > 0)
{
List<string> enumList = actionSets.Select(actionSet => actionSet.fullPath).ToList();
enumList.Insert(noneIndex, "None");
//replace forward slashes with backslack instead
for (int index = 0; index < enumList.Count; index++)
enumList[index] = enumList[index].Replace('/', '\\');
enumList.Add("Add...");
enumItems = enumList.ToArray();
}
else
{
enumItems = new string[] { "None", "Add..." };
}
addIndex = enumItems.Length - 1;
/*
//keep sub menus:
for (int index = 0; index < enumItems.Length; index++)
if (enumItems[index][0] == '/')
enumItems[index] = enumItems[index].Substring(1);
*/
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = base.GetPropertyHeight(property, label);
SerializedProperty actionPathProperty = property.FindPropertyRelative("actionSetPath");
if (string.IsNullOrEmpty(actionPathProperty.stringValue) == false)
{
if (selectedIndex == 0)
return height * 2;
}
return height;
}
// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (SteamVR_Input.actions == null || SteamVR_Input.actions.Length == 0)
{
EditorGUI.BeginProperty(position, label, property);
EditorGUI.LabelField(position, "Please generate SteamVR Input actions");
EditorGUI.EndProperty();
return;
}
if (enumItems == null || enumItems.Length == 0)
{
Awake();
}
// Using BeginProperty / EndProperty on the parent property means that
// prefab override logic works on the entire property.
EditorGUI.BeginProperty(position, label, property);
SerializedProperty actionPathProperty = property.FindPropertyRelative("actionSetPath");
string currentPath = null;
if (actionPathProperty != null)
{
currentPath = actionPathProperty.stringValue;
if (string.IsNullOrEmpty(currentPath) == false)
{
for (int actionSetIndex = 0; actionSetIndex < actionSets.Length; actionSetIndex++)
{
if (actionSets[actionSetIndex].fullPath == currentPath)
{
selectedIndex = actionSetIndex + 1; // account for none option
break;
}
}
}
}
if (selectedIndex == notInitializedIndex)
selectedIndex = 0;
Rect labelPosition = position;
labelPosition.width = EditorGUIUtility.labelWidth;
EditorGUI.LabelField(labelPosition, label);
Rect fieldPosition = position;
fieldPosition.x = (labelPosition.x + labelPosition.width);
fieldPosition.width = EditorGUIUtility.currentViewWidth - (labelPosition.x + labelPosition.width) - 5 - 16;
if (selectedIndex == 0 && string.IsNullOrEmpty(currentPath) == false)
{
if (defaultPathLabel == null)
defaultPathLabel = string.Format(defaultPathTemplate, currentPath);
Rect defaultLabelPosition = position;
defaultLabelPosition.y = position.y + fieldPosition.height / 2f;
EditorGUI.LabelField(defaultLabelPosition, defaultPathLabel);
}
Rect objectRect = position;
objectRect.x = fieldPosition.x + fieldPosition.width + 15;
objectRect.width = 10;
bool showInputWindow = false;
int wasSelected = selectedIndex;
selectedIndex = EditorGUI.Popup(fieldPosition, selectedIndex, enumItems);
if (selectedIndex != wasSelected)
{
if (selectedIndex == noneIndex || selectedIndex == notInitializedIndex)
{
selectedIndex = noneIndex;
actionPathProperty.stringValue = null;
}
else if (selectedIndex == addIndex)
{
selectedIndex = wasSelected; // don't change the index
showInputWindow = true;
}
else
{
int actionIndex = selectedIndex - 1; // account for none option
actionPathProperty.stringValue = actionSets[actionIndex].GetPath();
//property.objectReferenceValue = actions[actionIndex];
}
property.serializedObject.ApplyModifiedProperties();
}
EditorGUI.EndProperty();
if (showInputWindow)
SteamVR_Input_EditorWindow.ShowWindow(); //show the input window so they can add a new actionset
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 074d66e09af4e46429424ca09a9c3402
timeCreated: 1521655060
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
[CustomPropertyDrawer(typeof(SteamVR_Action_Boolean))]
public class SteamVR_Input_Action_Boolean_PropertyEditor : SteamVR_Input_Action_GenericPropertyEditor<SteamVR_Action_Boolean>
{
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 779685f855764aa449874336c160b4d0
timeCreated: 1521130773
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,187 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
public class SteamVR_Input_Action_GenericPropertyEditor<T> : PropertyDrawer where T : SteamVR_Action, new()
{
protected T[] actions;
protected string[] enumItems;
public int selectedIndex = notInitializedIndex;
protected const int notInitializedIndex = -1;
protected const int noneIndex = 0;
protected int addIndex = 1;
protected const string defaultPathTemplate = " \u26A0 Missing action: {0}";
protected string defaultPathLabel = null;
protected void Awake()
{
actions = SteamVR_Input.GetActions<T>();
if (actions != null && actions.Length > 0)
{
List<string> enumList = actions.Select(action => action.fullPath).ToList();
enumList.Insert(noneIndex, "None");
//replace forward slashes with backslack instead
for (int index = 0; index < enumList.Count; index++)
enumList[index] = enumList[index].Replace('/', '\\');
enumList.Add("Add...");
enumItems = enumList.ToArray();
}
else
{
enumItems = new string[] { "None", "Add..." };
}
addIndex = enumItems.Length - 1;
/*
//keep sub menus:
for (int index = 0; index < enumItems.Length; index++)
if (enumItems[index][0] == '/')
enumItems[index] = enumItems[index].Substring(1);
*/
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = base.GetPropertyHeight(property, label);
SerializedProperty actionPathProperty = property.FindPropertyRelative("actionPath");
if (string.IsNullOrEmpty(actionPathProperty.stringValue) == false)
{
if (selectedIndex == 0)
return height * 2;
}
return height;
}
// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (SteamVR_Input.actions == null || SteamVR_Input.actions.Length == 0)
{
EditorGUI.BeginProperty(position, label, property);
EditorGUI.LabelField(position, "Please generate SteamVR Input actions");
EditorGUI.EndProperty();
return;
}
if (enumItems == null || enumItems.Length == 0)
{
Awake();
}
// Using BeginProperty / EndProperty on the parent property means that
// prefab override logic works on the entire property.
EditorGUI.BeginProperty(position, label, property);
SerializedProperty actionPathProperty = property.FindPropertyRelative("actionPath");
string currentPath = null;
if (actionPathProperty != null)
{
currentPath = actionPathProperty.stringValue;
if (string.IsNullOrEmpty(currentPath) == false)
{
SteamVR_Action existingAction = SteamVR_Action.FindExistingActionForPartialPath(currentPath);
if (existingAction != null)
{
if (currentPath != existingAction.GetPath())
{
actionPathProperty.stringValue = existingAction.GetPath();
property.serializedObject.ApplyModifiedProperties();
}
currentPath = existingAction.GetPath();
}
for (int actionsIndex = 0; actionsIndex < actions.Length; actionsIndex++)
{
if (actions[actionsIndex].fullPath == currentPath)
{
selectedIndex = actionsIndex + 1; // account for none option
break;
}
}
}
}
if (selectedIndex == notInitializedIndex)
selectedIndex = 0;
Rect labelPosition = position;
labelPosition.width = EditorGUIUtility.labelWidth;
EditorGUI.LabelField(labelPosition, label);
Rect fieldPosition = position;
fieldPosition.x = (labelPosition.x + labelPosition.width);
fieldPosition.width = EditorGUIUtility.currentViewWidth - (labelPosition.x + labelPosition.width) - 5;
if (selectedIndex == 0 && string.IsNullOrEmpty(currentPath) == false)
{
if (defaultPathLabel == null)
defaultPathLabel = string.Format(defaultPathTemplate, currentPath);
Rect defaultLabelPosition = position;
defaultLabelPosition.y = position.y + fieldPosition.height / 2f;
EditorGUI.LabelField(defaultLabelPosition, defaultPathLabel);
}
bool showInputWindow = false;
int wasSelected = selectedIndex;
selectedIndex = EditorGUI.Popup(fieldPosition, selectedIndex, enumItems);
if (selectedIndex != wasSelected)
{
if (selectedIndex == noneIndex || selectedIndex == notInitializedIndex)
{
selectedIndex = noneIndex;
actionPathProperty.stringValue = null;
}
else if (selectedIndex == addIndex)
{
selectedIndex = wasSelected; // don't change the index
showInputWindow = true;
}
else
{
int actionIndex = selectedIndex - 1; // account for none option
actionPathProperty.stringValue = actions[actionIndex].GetPath();
//property.objectReferenceValue = actions[actionIndex];
}
property.serializedObject.ApplyModifiedProperties();
}
EditorGUI.EndProperty();
if (showInputWindow)
SteamVR_Input_EditorWindow.ShowWindow(); //show the input window so they can add a new action
}
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2800414421e3d124486646cbf8206a64
timeCreated: 1520474969
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7f01bda1d81aff44b8832e1779ef392f
timeCreated: 1521130773
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bc5014b5bd4c9254885346ccb2479e34
timeCreated: 1521130774
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
[CustomPropertyDrawer(typeof(SteamVR_Action_Pose))]
public class SteamVR_Input_Action_Pose_PropertyEditor : SteamVR_Input_Action_GenericPropertyEditor<SteamVR_Action_Pose>
{
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6c580c8ee65b2064b9cecf9c8a56b126
timeCreated: 1521130773
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1 @@
// removed

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ef30f8b815c7563459f9bb661516015e
timeCreated: 1521130774
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
using UnityEditor;
using UnityEngine;
using System.CodeDom;
using Microsoft.CSharp;
using System.IO;
using System.CodeDom.Compiler;
using System.Linq;
using System.Collections.Generic;
using System.Reflection;
using System.Linq.Expressions;
using System;
namespace Valve.VR
{
[CustomPropertyDrawer(typeof(SteamVR_Action_Single))]
public class SteamVR_Input_Action_Single_PropertyEditor : SteamVR_Input_Action_GenericPropertyEditor<SteamVR_Action_Single>
{
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4830402dc20240e4ea78925fdf5cb924
timeCreated: 1521652403
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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