From 62d1dc8dfff16a2c985ff9e5636c279f6b857548 Mon Sep 17 00:00:00 2001 From: yipinguo Date: Tue, 24 Jan 2017 11:16:12 -0800 Subject: [PATCH 001/457] Expose EditorVR's static instance, proxies and TwoHandedProxyBase's left hand and right hand transforms. --- Scripts/Core/EditorVR.Rays.cs | 6 +++++- Scripts/Core/EditorVR.cs | 6 +++++- Scripts/Proxies/TwoHandedProxyBase.cs | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 7bf1b3241..75d43331d 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -22,7 +22,11 @@ partial class EditorVR DefaultProxyRay m_ProxyRayPrefab; readonly Dictionary m_DefaultRays = new Dictionary(); - readonly List m_Proxies = new List(); + public List Proxies + { + get { return m_Proxies; } + } + readonly List m_Proxies = new List(); MultipleRayInputModule m_InputModule; diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index afeae71f9..451777ce8 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -357,7 +357,11 @@ void AddPlayerModel() } #if UNITY_EDITOR - static EditorVR s_Instance; + public static EditorVR Instance + { + get { return s_Instance; } + } + static EditorVR s_Instance; static InputManager s_InputManager; [MenuItem("Window/EditorVR %e", false)] diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index e3c90b79a..6d50bdcbb 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -19,8 +19,18 @@ public abstract class TwoHandedProxyBase : MonoBehaviour, IProxy [SerializeField] protected PlayerInput m_PlayerInput; - protected Transform m_LeftHand; - protected Transform m_RightHand; + public Transform LeftHand + { + get { return m_LeftHand; } + } + protected Transform m_LeftHand; + + + public Transform RightHand + { + get { return m_RightHand; } + } + protected Transform m_RightHand; readonly List m_Materials = new List(); protected Dictionary m_RayOrigins; From 530d745ad8ee2b0e0618d728db3d2ca352cfe571 Mon Sep 17 00:00:00 2001 From: yipinguo Date: Tue, 24 Jan 2017 12:54:21 -0800 Subject: [PATCH 002/457] Use tabs instead of spaces. --- Scripts/Core/EditorVR.Rays.cs | 10 +++++----- Scripts/Core/EditorVR.cs | 10 +++++----- Scripts/Proxies/TwoHandedProxyBase.cs | 23 +++++++++++------------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 75d43331d..39e069a61 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -22,11 +22,11 @@ partial class EditorVR DefaultProxyRay m_ProxyRayPrefab; readonly Dictionary m_DefaultRays = new Dictionary(); - public List Proxies - { - get { return m_Proxies; } - } - readonly List m_Proxies = new List(); + public List Proxies + { + get { return m_Proxies; } + } + readonly List m_Proxies = new List(); MultipleRayInputModule m_InputModule; diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index 451777ce8..81352777f 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -357,11 +357,11 @@ void AddPlayerModel() } #if UNITY_EDITOR - public static EditorVR Instance - { - get { return s_Instance; } - } - static EditorVR s_Instance; + public static EditorVR Instance + { + get { return s_Instance; } + } + static EditorVR s_Instance; static InputManager s_InputManager; [MenuItem("Window/EditorVR %e", false)] diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 6d50bdcbb..e6fe39c29 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -19,18 +19,17 @@ public abstract class TwoHandedProxyBase : MonoBehaviour, IProxy [SerializeField] protected PlayerInput m_PlayerInput; - public Transform LeftHand - { - get { return m_LeftHand; } - } - protected Transform m_LeftHand; - - - public Transform RightHand - { - get { return m_RightHand; } - } - protected Transform m_RightHand; + public Transform LeftHand + { + get { return m_LeftHand; } + } + protected Transform m_LeftHand; + + public Transform RightHand + { + get { return m_RightHand; } + } + protected Transform m_RightHand; readonly List m_Materials = new List(); protected Dictionary m_RayOrigins; From bf1ac0b147c713f4c0d212a1905122b234791576 Mon Sep 17 00:00:00 2001 From: yipinguo Date: Tue, 24 Jan 2017 14:48:50 -0800 Subject: [PATCH 003/457] Select newly created objects. --- Actions/Clone.cs | 4 ++++ Actions/Paste.cs | 8 ++++++++ Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs | 2 ++ 3 files changed, 14 insertions(+) diff --git a/Actions/Clone.cs b/Actions/Clone.cs index 20f9e78b3..a09122fc2 100644 --- a/Actions/Clone.cs +++ b/Actions/Clone.cs @@ -13,6 +13,8 @@ public class Clone : BaseAction, IUsesSpatialHash public override void ExecuteAction() { var selection = Selection.gameObjects; + GameObject[] clones = new GameObject[selection.Length]; + int index = 0; var bounds = U.Object.GetBounds(selection); foreach (var s in selection) { @@ -24,7 +26,9 @@ public override void ExecuteAction() cloneTransform.position = cameraTransform.TransformPoint(Vector3.forward * viewDirection.magnitude) + cloneTransform.position - bounds.center; addToSpatialHash(clone); + clones[index++] = clone; } + Selection.objects = clones; } } } diff --git a/Actions/Paste.cs b/Actions/Paste.cs index b8dce64bb..5764ecc3f 100644 --- a/Actions/Paste.cs +++ b/Actions/Paste.cs @@ -1,4 +1,5 @@ using System; +using UnityEditor; using UnityEngine.Experimental.EditorVR.Utilities; namespace UnityEngine.Experimental.EditorVR.Actions @@ -37,6 +38,8 @@ public override void ExecuteAction() if (buffer != null) { + GameObject[] pastedGameObjects = new GameObject[buffer.Length]; + int index = 0; var bounds = U.Object.GetBounds(buffer); foreach (var go in buffer) { @@ -48,6 +51,11 @@ public override void ExecuteAction() + pastedTransform.position - bounds.center; pasted.SetActive(true); addToSpatialHash(pasted); + pastedGameObjects[index++] = pasted; + } + if (pastedGameObjects.Length > 0) + { + Selection.objects = pastedGameObjects; } } } diff --git a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs index f185d0325..ff80fb348 100644 --- a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs +++ b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs @@ -1,4 +1,5 @@ using System; +using UnityEditor; using UnityEngine; using UnityEngine.InputNew; using UnityEngine.Experimental.EditorVR; @@ -101,6 +102,7 @@ void HandleStartPoint(Standard standardInput, Action consumeContro addToSpatialHash(m_CurrentGameObject); consumeControl(standardInput.action); + Selection.activeGameObject = m_CurrentGameObject; } } From 826086cd8dc716f9c3e554f0121a982b5f61050c Mon Sep 17 00:00:00 2001 From: yipinguo Date: Wed, 25 Jan 2017 16:33:53 -0800 Subject: [PATCH 004/457] Use lower case for the first letter of properties. --- Scripts/Core/EditorVR.Rays.cs | 2 +- Scripts/Core/EditorVR.cs | 2 +- Scripts/Proxies/TwoHandedProxyBase.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 39e069a61..19564fbf6 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -22,7 +22,7 @@ partial class EditorVR DefaultProxyRay m_ProxyRayPrefab; readonly Dictionary m_DefaultRays = new Dictionary(); - public List Proxies + public List proxies { get { return m_Proxies; } } diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index 81352777f..1618801c1 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -357,7 +357,7 @@ void AddPlayerModel() } #if UNITY_EDITOR - public static EditorVR Instance + public static EditorVR instance { get { return s_Instance; } } diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index e6fe39c29..cab935f7e 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -19,13 +19,13 @@ public abstract class TwoHandedProxyBase : MonoBehaviour, IProxy [SerializeField] protected PlayerInput m_PlayerInput; - public Transform LeftHand + public Transform leftHand { get { return m_LeftHand; } } protected Transform m_LeftHand; - public Transform RightHand + public Transform rightHand { get { return m_RightHand; } } From 204f747b8c45b2108ad59b8014f01cdacca61302 Mon Sep 17 00:00:00 2001 From: yipinguo Date: Tue, 31 Jan 2017 17:26:06 -0800 Subject: [PATCH 005/457] Use var instead of specific types. --- Actions/Clone.cs | 4 ++-- Actions/Paste.cs | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Actions/Clone.cs b/Actions/Clone.cs index a09122fc2..755486673 100644 --- a/Actions/Clone.cs +++ b/Actions/Clone.cs @@ -13,8 +13,8 @@ public class Clone : BaseAction, IUsesSpatialHash public override void ExecuteAction() { var selection = Selection.gameObjects; - GameObject[] clones = new GameObject[selection.Length]; - int index = 0; + var clones = new GameObject[selection.Length]; + var index = 0; var bounds = U.Object.GetBounds(selection); foreach (var s in selection) { diff --git a/Actions/Paste.cs b/Actions/Paste.cs index 5764ecc3f..3a86a420a 100644 --- a/Actions/Paste.cs +++ b/Actions/Paste.cs @@ -38,8 +38,8 @@ public override void ExecuteAction() if (buffer != null) { - GameObject[] pastedGameObjects = new GameObject[buffer.Length]; - int index = 0; + var pastedGameObjects = new GameObject[buffer.Length]; + var index = 0; var bounds = U.Object.GetBounds(buffer); foreach (var go in buffer) { @@ -53,10 +53,9 @@ public override void ExecuteAction() addToSpatialHash(pasted); pastedGameObjects[index++] = pasted; } + if (pastedGameObjects.Length > 0) - { - Selection.objects = pastedGameObjects; - } + Selection.objects = pastedGameObjects; } } } From a138593e220212124e271b02ff30a9278656ad56 Mon Sep 17 00:00:00 2001 From: yipinguo Date: Wed, 1 Feb 2017 09:53:54 -0800 Subject: [PATCH 006/457] Remove code to get EditorVR instance and proxies. --- Scripts/Core/EditorVR.Rays.cs | 4 ---- Scripts/Core/EditorVR.cs | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 19564fbf6..7bf1b3241 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -22,10 +22,6 @@ partial class EditorVR DefaultProxyRay m_ProxyRayPrefab; readonly Dictionary m_DefaultRays = new Dictionary(); - public List proxies - { - get { return m_Proxies; } - } readonly List m_Proxies = new List(); MultipleRayInputModule m_InputModule; diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index 1618801c1..afeae71f9 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -357,10 +357,6 @@ void AddPlayerModel() } #if UNITY_EDITOR - public static EditorVR instance - { - get { return s_Instance; } - } static EditorVR s_Instance; static InputManager s_InputManager; From 65e37cbc53aa7e127b4d4613739228196c2bcf81 Mon Sep 17 00:00:00 2001 From: Stella Cannefax Date: Wed, 26 Jul 2017 18:25:00 -0500 Subject: [PATCH 007/457] tests for contexts --- .../Core/Contexts/EditingContextManager.cs | 25 ++- Scripts/Core/Contexts/EditorVRContext.cs | 2 +- Tests/Editor/Unit/Core.meta | 9 + .../Unit/Core/EditingContextManagerTests.cs | 171 ++++++++++++++++++ .../Core/EditingContextManagerTests.cs.meta | 12 ++ Tests/Test Helpers/Editor.meta | 9 + .../Editor/EditorVRTestInitializer.cs | 28 +++ .../Editor/EditorVRTestInitializer.cs.meta | 12 ++ 8 files changed, 257 insertions(+), 11 deletions(-) create mode 100644 Tests/Editor/Unit/Core.meta create mode 100644 Tests/Editor/Unit/Core/EditingContextManagerTests.cs create mode 100644 Tests/Editor/Unit/Core/EditingContextManagerTests.cs.meta create mode 100644 Tests/Test Helpers/Editor.meta create mode 100644 Tests/Test Helpers/Editor/EditorVRTestInitializer.cs create mode 100644 Tests/Test Helpers/Editor/EditorVRTestInitializer.cs.meta diff --git a/Scripts/Core/Contexts/EditingContextManager.cs b/Scripts/Core/Contexts/EditingContextManager.cs index 231bad4fa..e2579806c 100644 --- a/Scripts/Core/Contexts/EditingContextManager.cs +++ b/Scripts/Core/Contexts/EditingContextManager.cs @@ -17,12 +17,12 @@ sealed class EditingContextManager : MonoBehaviour [SerializeField] UnityObject m_DefaultContext; - const string k_SettingsPath = "ProjectSettings/EditingContextManagerSettings.asset"; - const string k_UserSettingsPath = "Library/EditingContextManagerSettings.asset"; + internal const string k_SettingsPath = "ProjectSettings/EditingContextManagerSettings.asset"; + internal const string k_UserSettingsPath = "Library/EditingContextManagerSettings.asset"; const string k_LaunchOnExitPlaymode = "EditingContextManager.LaunchOnExitPlaymode"; - static EditingContextManager s_Instance; + internal static EditingContextManager s_Instance; static InputManager s_InputManager; EditingContextManagerSettings m_Settings; @@ -34,7 +34,7 @@ sealed class EditingContextManager : MonoBehaviour IEditingContext m_CurrentContext; readonly List m_PreviousContexts = new List(); - IEditingContext defaultContext + internal IEditingContext defaultContext { get { @@ -53,6 +53,11 @@ IEditingContext defaultContext set { m_Settings.defaultContextName = value.name; } } + internal IEditingContext currentContext + { + get { return m_CurrentContext; } + } + static EditingContextManager() { VRView.viewEnabled += OnVRViewEnabled; @@ -74,7 +79,7 @@ static void OnVRViewDisabled() } [MenuItem("Window/EditorVR %e", false)] - static void ShowEditorVR() + internal static void ShowEditorVR() { // Using a utility window improves performance by saving from the overhead of DockArea.OnGUI() EditorWindow.GetWindow(true, "EditorVR", true); @@ -186,7 +191,7 @@ internal static void DoGUI(string[] contextNames, ref int selectedContextIndex, } } - void SetEditingContext(IEditingContext context) + internal void SetEditingContext(IEditingContext context) { if (context == null) return; @@ -203,7 +208,7 @@ void SetEditingContext(IEditingContext context) m_SelectedContextIndex = m_AvailableContexts.IndexOf(context); } - void RestorePreviousContext() + internal void RestorePreviousContext() { if (m_PreviousContexts.Count > 0) SetEditingContext(m_PreviousContexts.First()); @@ -245,7 +250,7 @@ List GetPreviousEditingContexts() return m_PreviousContexts; } - static EditingContextManagerSettings LoadProjectSettings() + internal static EditingContextManagerSettings LoadProjectSettings() { EditingContextManagerSettings settings = ScriptableObject.CreateInstance(); if (File.Exists(k_SettingsPath)) @@ -254,7 +259,7 @@ static EditingContextManagerSettings LoadProjectSettings() return settings; } - static EditingContextManagerSettings LoadUserSettings() + internal static EditingContextManagerSettings LoadUserSettings() { EditingContextManagerSettings settings; if (File.Exists(k_UserSettingsPath) @@ -282,7 +287,7 @@ internal static void SaveProjectSettings(EditingContextManagerSettings settings) File.WriteAllText(k_SettingsPath, JsonUtility.ToJson(settings, true)); } - static void SaveUserSettings(EditingContextManagerSettings settings) + internal static void SaveUserSettings(EditingContextManagerSettings settings) { File.WriteAllText(k_UserSettingsPath, JsonUtility.ToJson(settings, true)); } diff --git a/Scripts/Core/Contexts/EditorVRContext.cs b/Scripts/Core/Contexts/EditorVRContext.cs index a95df2525..24ecf4cb5 100644 --- a/Scripts/Core/Contexts/EditorVRContext.cs +++ b/Scripts/Core/Contexts/EditorVRContext.cs @@ -10,7 +10,7 @@ namespace UnityEditor.Experimental.EditorVR.Core class EditorVRContext : ScriptableObject, IEditingContext { [SerializeField] - List m_DefaultToolStack; + internal List m_DefaultToolStack; EditorVR m_Instance; diff --git a/Tests/Editor/Unit/Core.meta b/Tests/Editor/Unit/Core.meta new file mode 100644 index 000000000..bf5ea2dc6 --- /dev/null +++ b/Tests/Editor/Unit/Core.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6935cbffab102b74e81da55598217ad4 +folderAsset: yes +timeCreated: 1500348068 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Editor/Unit/Core/EditingContextManagerTests.cs b/Tests/Editor/Unit/Core/EditingContextManagerTests.cs new file mode 100644 index 000000000..5d564febb --- /dev/null +++ b/Tests/Editor/Unit/Core/EditingContextManagerTests.cs @@ -0,0 +1,171 @@ +using System; +using System.IO; +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; +using NUnit.Framework; +using UnityEditor.Experimental.EditorVR.Core; +using UnityEditor.Experimental.EditorVR.Utilities; +using UnityEditor.Experimental.EditorVR.Tools; + +namespace UnityEditor.Experimental.EditorVR.Tests.Core +{ + [TestFixture] + public class EditingContextManagerTests + { + GameObject go; + EditorVRContext context, context2; + EditingContextManager manager; + EditingContextManagerSettings settings, newSettings; + SetEditingContextImplementor contextSetter; + + [OneTimeSetUp] + public void Setup() + { + manager = EditingContextManager.s_Instance; + go = new GameObject("context test object"); + var transformTool = go.AddComponent(); + var createPrimitiveTool = go.AddComponent(); + + context = ScriptableObject.CreateInstance(); + context.name = "Some Other Context"; + context.m_DefaultToolStack = new List(); + context.m_DefaultToolStack.Add(MonoScript.FromMonoBehaviour(transformTool)); + context.m_DefaultToolStack.Add(MonoScript.FromMonoBehaviour(createPrimitiveTool)); + + context2 = ScriptableObject.CreateInstance(); + context2.name = "Yet Another Context"; + context2.m_DefaultToolStack = context.m_DefaultToolStack; + + settings = ScriptableObject.CreateInstance(); + settings.defaultContextName = "Custom Default Context"; + newSettings = ScriptableObject.CreateInstance(); + newSettings.defaultContextName = "New Custom Default Context"; + } + + [Test] + public void Initializes_WithDefaultContext() + { + Assert.AreEqual(manager.defaultContext, manager.currentContext); + } + + [Test] + public void Initializes_ISetEditingContextMethods() + { + Assert.IsNotNull(ISetEditingContextMethods.getAvailableEditingContexts); + Assert.IsNotNull(ISetEditingContextMethods.getPreviousEditingContexts); + Assert.IsNotNull(ISetEditingContextMethods.setEditingContext); + Assert.IsNotNull(ISetEditingContextMethods.restorePreviousEditingContext); + } + + [Test] + public void SetEditingContext_DoesNothing_IfNull() + { + var beginningContext = manager.currentContext; + manager.SetEditingContext(null); + Assert.AreEqual(beginningContext, manager.currentContext); + } + + [Test] + public void SetEditingContext_SetsCurrentContext_IfNotNull() + { + manager.SetEditingContext(context); + Assert.AreEqual(context, manager.currentContext); + } + + [Test] + public void RestorePreviousContext_SetsPreviousContextToCurrent() + { + var beginningContext = manager.currentContext; + manager.SetEditingContext(context2); + Assert.AreNotEqual(beginningContext, manager.currentContext); + + manager.RestorePreviousContext(); + Assert.AreEqual(beginningContext, manager.currentContext); + } + + [Test] + public void LoadProjectSettings_IfAssetFound() + { + EditingContextManager.SaveProjectSettings(settings); + var loaded = EditingContextManager.LoadProjectSettings(); + Assert.AreEqual(settings.defaultContextName, loaded.defaultContextName); + } + + [Test] + public void LoadProjectSettings_IfAssetNotFound() + { + if (File.Exists(EditingContextManager.k_SettingsPath)) + File.Delete(EditingContextManager.k_SettingsPath); + + var loaded = EditingContextManager.LoadProjectSettings(); + Assert.IsInstanceOf(loaded); + Assert.IsNull(loaded.defaultContextName); + } + + [Test] + public void LoadUserSettings_NewerThanProjectSettings() + { + EditingContextManager.SaveUserSettings(newSettings); + var loaded = EditingContextManager.LoadUserSettings(); + Assert.AreEqual(newSettings.defaultContextName, loaded.defaultContextName); + } + + [Test] + public void LoadUserSettings_OlderThanProjectSettings() + { + EditingContextManager.SaveUserSettings(newSettings); + EditingContextManager.SaveProjectSettings(settings); + + var loaded = EditingContextManager.LoadUserSettings(); + Assert.AreEqual(settings.defaultContextName, loaded.defaultContextName); + } + + [Test] + public void LoadUserSettings_ProjectSettingsFallback() + { + if (File.Exists(EditingContextManager.k_UserSettingsPath)) + File.Delete(EditingContextManager.k_UserSettingsPath); + + var projectSettings = EditingContextManager.LoadProjectSettings(); + var userSettings = EditingContextManager.LoadUserSettings(); + + Assert.AreEqual(projectSettings.defaultContextName, userSettings.defaultContextName); + } + + [Test] + public void SaveProjectSettings_UpdatesProjectSettingsFile() + { + var path = EditingContextManager.k_SettingsPath; + var lastModTime = File.GetLastWriteTime(path); + EditingContextManager.SaveProjectSettings(settings); + + Assert.AreEqual(JsonUtility.ToJson(settings, true), File.ReadAllText(path)); + Assert.Greater(File.GetLastWriteTime(path), lastModTime); + } + + [Test] + public void SaveUserSettings_UpdatesUserSettingsFile() + { + var path = EditingContextManager.k_UserSettingsPath; + var lastModTime = File.GetLastWriteTime(path); + EditingContextManager.SaveUserSettings(newSettings); + + Assert.AreEqual(JsonUtility.ToJson(newSettings, true), File.ReadAllText(path)); + Assert.Greater(File.GetLastWriteTime(path), lastModTime); + } + + [OneTimeTearDown] + public void Cleanup() + { + ObjectUtils.Destroy(go); + manager.SetEditingContext(manager.defaultContext); + ObjectUtils.Destroy(context); + ObjectUtils.Destroy(context2); + } + } + + class SetEditingContextImplementor : ISetEditingContext {} +} + + diff --git a/Tests/Editor/Unit/Core/EditingContextManagerTests.cs.meta b/Tests/Editor/Unit/Core/EditingContextManagerTests.cs.meta new file mode 100644 index 000000000..f4c69a54e --- /dev/null +++ b/Tests/Editor/Unit/Core/EditingContextManagerTests.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6b889e94d831cfc4a8ef5346d4619bda +timeCreated: 1500348068 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Test Helpers/Editor.meta b/Tests/Test Helpers/Editor.meta new file mode 100644 index 000000000..e8c1c59f5 --- /dev/null +++ b/Tests/Test Helpers/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 876025908b2c3a34cb0787d0dac5c557 +folderAsset: yes +timeCreated: 1501087147 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs b/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs new file mode 100644 index 000000000..1987908d6 --- /dev/null +++ b/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs @@ -0,0 +1,28 @@ +using NUnit.Framework; +using UnityEditor.Experimental.EditorVR.Core; + +namespace UnityEditor.Experimental.EditorVR.Tests.Core +{ + [SetUpFixture] + public class EditorVRTestInitializer + { + [OneTimeSetUp] + public void SetupBeforeAllTests() + { + EditingContextManager.ShowEditorVR(); + } + + [OneTimeTearDown] + public void CleanupAfterAllTests() + { + EditorApplication.delayCall += CloseVRView; + } + + private void CloseVRView() + { + EditorWindow.GetWindow("EditorVR", false).Close(); + } + } +} + + diff --git a/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs.meta b/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs.meta new file mode 100644 index 000000000..751d70ee1 --- /dev/null +++ b/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cce7a1d2ae440a4468cf4de8939a7b1e +timeCreated: 1501084979 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 10aed642127afa84cf3a0705cfadf8c4dbab1e7d Mon Sep 17 00:00:00 2001 From: Stella Cannefax Date: Fri, 28 Jul 2017 14:12:36 -0500 Subject: [PATCH 008/457] add null check to TouchProxy init to allow cleaner tests --- Scripts/Proxies/TouchProxy.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Scripts/Proxies/TouchProxy.cs b/Scripts/Proxies/TouchProxy.cs index 42044753c..4bd55dcfa 100644 --- a/Scripts/Proxies/TouchProxy.cs +++ b/Scripts/Proxies/TouchProxy.cs @@ -21,7 +21,8 @@ public override IEnumerator Start() #if UNITY_EDITOR EditorApplication.delayCall += () => { - transform.localPosition = Vector3.zero; + if (this != null) + transform.localPosition = Vector3.zero; }; #else transform.localPosition = Vector3.zero; From 41ba57ad026f972ba8d02e9c6241926ff8410dbe Mon Sep 17 00:00:00 2001 From: Stella Cannefax Date: Fri, 28 Jul 2017 14:43:43 -0500 Subject: [PATCH 009/457] add settings backup to test harness --- .../Editor/EditorVRTestInitializer.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs b/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs index 1987908d6..0be761f65 100644 --- a/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs +++ b/Tests/Test Helpers/Editor/EditorVRTestInitializer.cs @@ -6,21 +6,28 @@ namespace UnityEditor.Experimental.EditorVR.Tests.Core [SetUpFixture] public class EditorVRTestInitializer { + EditingContextManagerSettings projectSettingsBackup; + EditingContextManagerSettings userSettingsBackup; + [OneTimeSetUp] public void SetupBeforeAllTests() { + projectSettingsBackup = EditingContextManager.LoadProjectSettings(); + userSettingsBackup = EditingContextManager.LoadUserSettings(); + EditingContextManager.ShowEditorVR(); } [OneTimeTearDown] public void CleanupAfterAllTests() { - EditorApplication.delayCall += CloseVRView; - } + EditingContextManager.SaveProjectSettings(projectSettingsBackup); + EditingContextManager.SaveUserSettings(userSettingsBackup); - private void CloseVRView() - { - EditorWindow.GetWindow("EditorVR", false).Close(); + EditorApplication.delayCall += () => + { + EditorWindow.GetWindow("EditorVR", false).Close(); + }; } } } From 5d3eec00e04e39c43340f740ebb24940f89d3fe9 Mon Sep 17 00:00:00 2001 From: Stella Cannefax Date: Fri, 28 Jul 2017 14:47:36 -0500 Subject: [PATCH 010/457] fix inconsistent line endings --- .../Unit/Core/EditingContextManagerTests.cs | 222 +++++++++--------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/Tests/Editor/Unit/Core/EditingContextManagerTests.cs b/Tests/Editor/Unit/Core/EditingContextManagerTests.cs index 5d564febb..29e6d70a5 100644 --- a/Tests/Editor/Unit/Core/EditingContextManagerTests.cs +++ b/Tests/Editor/Unit/Core/EditingContextManagerTests.cs @@ -17,8 +17,8 @@ public class EditingContextManagerTests EditorVRContext context, context2; EditingContextManager manager; EditingContextManagerSettings settings, newSettings; - SetEditingContextImplementor contextSetter; - + SetEditingContextImplementor contextSetter; + [OneTimeSetUp] public void Setup() { @@ -34,7 +34,7 @@ public void Setup() context.m_DefaultToolStack.Add(MonoScript.FromMonoBehaviour(createPrimitiveTool)); context2 = ScriptableObject.CreateInstance(); - context2.name = "Yet Another Context"; + context2.name = "Yet Another Context"; context2.m_DefaultToolStack = context.m_DefaultToolStack; settings = ScriptableObject.CreateInstance(); @@ -45,123 +45,123 @@ public void Setup() [Test] public void Initializes_WithDefaultContext() - { - Assert.AreEqual(manager.defaultContext, manager.currentContext); - } - - [Test] - public void Initializes_ISetEditingContextMethods() - { + { + Assert.AreEqual(manager.defaultContext, manager.currentContext); + } + + [Test] + public void Initializes_ISetEditingContextMethods() + { Assert.IsNotNull(ISetEditingContextMethods.getAvailableEditingContexts); Assert.IsNotNull(ISetEditingContextMethods.getPreviousEditingContexts); Assert.IsNotNull(ISetEditingContextMethods.setEditingContext); - Assert.IsNotNull(ISetEditingContextMethods.restorePreviousEditingContext); - } - - [Test] - public void SetEditingContext_DoesNothing_IfNull() - { - var beginningContext = manager.currentContext; - manager.SetEditingContext(null); - Assert.AreEqual(beginningContext, manager.currentContext); - } - - [Test] - public void SetEditingContext_SetsCurrentContext_IfNotNull() - { - manager.SetEditingContext(context); - Assert.AreEqual(context, manager.currentContext); - } - - [Test] - public void RestorePreviousContext_SetsPreviousContextToCurrent() - { - var beginningContext = manager.currentContext; - manager.SetEditingContext(context2); - Assert.AreNotEqual(beginningContext, manager.currentContext); - - manager.RestorePreviousContext(); - Assert.AreEqual(beginningContext, manager.currentContext); - } - - [Test] - public void LoadProjectSettings_IfAssetFound() - { - EditingContextManager.SaveProjectSettings(settings); - var loaded = EditingContextManager.LoadProjectSettings(); - Assert.AreEqual(settings.defaultContextName, loaded.defaultContextName); - } - - [Test] - public void LoadProjectSettings_IfAssetNotFound() - { - if (File.Exists(EditingContextManager.k_SettingsPath)) - File.Delete(EditingContextManager.k_SettingsPath); - - var loaded = EditingContextManager.LoadProjectSettings(); - Assert.IsInstanceOf(loaded); - Assert.IsNull(loaded.defaultContextName); - } - - [Test] - public void LoadUserSettings_NewerThanProjectSettings() - { - EditingContextManager.SaveUserSettings(newSettings); - var loaded = EditingContextManager.LoadUserSettings(); - Assert.AreEqual(newSettings.defaultContextName, loaded.defaultContextName); - } - - [Test] - public void LoadUserSettings_OlderThanProjectSettings() - { - EditingContextManager.SaveUserSettings(newSettings); - EditingContextManager.SaveProjectSettings(settings); - - var loaded = EditingContextManager.LoadUserSettings(); - Assert.AreEqual(settings.defaultContextName, loaded.defaultContextName); - } - - [Test] - public void LoadUserSettings_ProjectSettingsFallback() - { - if (File.Exists(EditingContextManager.k_UserSettingsPath)) - File.Delete(EditingContextManager.k_UserSettingsPath); - - var projectSettings = EditingContextManager.LoadProjectSettings(); - var userSettings = EditingContextManager.LoadUserSettings(); - - Assert.AreEqual(projectSettings.defaultContextName, userSettings.defaultContextName); - } - - [Test] - public void SaveProjectSettings_UpdatesProjectSettingsFile() - { - var path = EditingContextManager.k_SettingsPath; - var lastModTime = File.GetLastWriteTime(path); - EditingContextManager.SaveProjectSettings(settings); - - Assert.AreEqual(JsonUtility.ToJson(settings, true), File.ReadAllText(path)); - Assert.Greater(File.GetLastWriteTime(path), lastModTime); - } - - [Test] - public void SaveUserSettings_UpdatesUserSettingsFile() - { - var path = EditingContextManager.k_UserSettingsPath; - var lastModTime = File.GetLastWriteTime(path); - EditingContextManager.SaveUserSettings(newSettings); - - Assert.AreEqual(JsonUtility.ToJson(newSettings, true), File.ReadAllText(path)); - Assert.Greater(File.GetLastWriteTime(path), lastModTime); - } - + Assert.IsNotNull(ISetEditingContextMethods.restorePreviousEditingContext); + } + + [Test] + public void SetEditingContext_DoesNothing_IfNull() + { + var beginningContext = manager.currentContext; + manager.SetEditingContext(null); + Assert.AreEqual(beginningContext, manager.currentContext); + } + + [Test] + public void SetEditingContext_SetsCurrentContext_IfNotNull() + { + manager.SetEditingContext(context); + Assert.AreEqual(context, manager.currentContext); + } + + [Test] + public void RestorePreviousContext_SetsPreviousContextToCurrent() + { + var beginningContext = manager.currentContext; + manager.SetEditingContext(context2); + Assert.AreNotEqual(beginningContext, manager.currentContext); + + manager.RestorePreviousContext(); + Assert.AreEqual(beginningContext, manager.currentContext); + } + + [Test] + public void LoadProjectSettings_IfAssetFound() + { + EditingContextManager.SaveProjectSettings(settings); + var loaded = EditingContextManager.LoadProjectSettings(); + Assert.AreEqual(settings.defaultContextName, loaded.defaultContextName); + } + + [Test] + public void LoadProjectSettings_IfAssetNotFound() + { + if (File.Exists(EditingContextManager.k_SettingsPath)) + File.Delete(EditingContextManager.k_SettingsPath); + + var loaded = EditingContextManager.LoadProjectSettings(); + Assert.IsInstanceOf(loaded); + Assert.IsNull(loaded.defaultContextName); + } + + [Test] + public void LoadUserSettings_NewerThanProjectSettings() + { + EditingContextManager.SaveUserSettings(newSettings); + var loaded = EditingContextManager.LoadUserSettings(); + Assert.AreEqual(newSettings.defaultContextName, loaded.defaultContextName); + } + + [Test] + public void LoadUserSettings_OlderThanProjectSettings() + { + EditingContextManager.SaveUserSettings(newSettings); + EditingContextManager.SaveProjectSettings(settings); + + var loaded = EditingContextManager.LoadUserSettings(); + Assert.AreEqual(settings.defaultContextName, loaded.defaultContextName); + } + + [Test] + public void LoadUserSettings_ProjectSettingsFallback() + { + if (File.Exists(EditingContextManager.k_UserSettingsPath)) + File.Delete(EditingContextManager.k_UserSettingsPath); + + var projectSettings = EditingContextManager.LoadProjectSettings(); + var userSettings = EditingContextManager.LoadUserSettings(); + + Assert.AreEqual(projectSettings.defaultContextName, userSettings.defaultContextName); + } + + [Test] + public void SaveProjectSettings_UpdatesProjectSettingsFile() + { + var path = EditingContextManager.k_SettingsPath; + var lastModTime = File.GetLastWriteTime(path); + EditingContextManager.SaveProjectSettings(settings); + + Assert.AreEqual(JsonUtility.ToJson(settings, true), File.ReadAllText(path)); + Assert.Greater(File.GetLastWriteTime(path), lastModTime); + } + + [Test] + public void SaveUserSettings_UpdatesUserSettingsFile() + { + var path = EditingContextManager.k_UserSettingsPath; + var lastModTime = File.GetLastWriteTime(path); + EditingContextManager.SaveUserSettings(newSettings); + + Assert.AreEqual(JsonUtility.ToJson(newSettings, true), File.ReadAllText(path)); + Assert.Greater(File.GetLastWriteTime(path), lastModTime); + } + [OneTimeTearDown] public void Cleanup() { ObjectUtils.Destroy(go); manager.SetEditingContext(manager.defaultContext); ObjectUtils.Destroy(context); - ObjectUtils.Destroy(context2); + ObjectUtils.Destroy(context2); } } From 3936c3caddc1ecddfdfdbd968ba19d345ca5c525 Mon Sep 17 00:00:00 2001 From: andrewm Date: Fri, 25 Aug 2017 15:57:20 -0700 Subject: [PATCH 011/457] 2017.2 script updates --- Scripts/Core/EditorVR.Viewer.cs | 2 +- Scripts/Core/VRView.cs | 18 +++++++++--------- Scripts/Proxies/ViveProxy.cs | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index 743ae36e6..b60c93df5 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -143,7 +143,7 @@ internal void InitializeCamera() viewerCamera.gameObject.hideFlags = defaultHideFlags; m_OriginalNearClipPlane = viewerCamera.nearClipPlane; m_OriginalFarClipPlane = viewerCamera.farClipPlane; - if (VRSettings.loadedDeviceName == "OpenVR") + if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR") { // Steam's reference position should be at the feet and not at the head as we do with Oculus cameraRig.localPosition = Vector3.zero; diff --git a/Scripts/Core/VRView.cs b/Scripts/Core/VRView.cs index c44d617d1..faaf192b2 100644 --- a/Scripts/Core/VRView.cs +++ b/Scripts/Core/VRView.cs @@ -147,8 +147,8 @@ public void OnEnable() // VRSettings.enabled latches the reference pose for the current camera var currentCamera = Camera.current; Camera.SetupCurrent(m_Camera); - VRSettings.enabled = true; - InputTracking.Recenter(); + UnityEngine.XR.XRSettings.enabled = true; + UnityEngine.XR.InputTracking.Recenter(); Camera.SetupCurrent(currentCamera); if (viewEnabled != null) @@ -160,7 +160,7 @@ public void OnDisable() if (viewDisabled != null) viewDisabled(); - VRSettings.enabled = false; + UnityEngine.XR.XRSettings.enabled = false; EditorPrefs.SetBool(k_ShowDeviceView, m_ShowDeviceView); EditorPrefs.SetBool(k_UseCustomPreviewCamera, m_UseCustomPreviewCamera); @@ -177,8 +177,8 @@ public void OnDisable() void UpdateCameraTransform() { var cameraTransform = m_Camera.transform; - cameraTransform.localPosition = InputTracking.GetLocalPosition(VRNode.Head); - cameraTransform.localRotation = InputTracking.GetLocalRotation(VRNode.Head); + cameraTransform.localPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.Head); + cameraTransform.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.Head); } public void CreateCameraTargetTexture(ref RenderTexture renderTexture, Rect cameraRect, bool hdr) @@ -224,7 +224,7 @@ void PrepareCameraTargetTexture(Rect cameraRect) // Always render camera into a RT CreateCameraTargetTexture(ref m_TargetTexture, cameraRect, false); m_Camera.targetTexture = m_ShowDeviceView ? m_TargetTexture : null; - VRSettings.showDeviceView = !customPreviewCamera && m_ShowDeviceView; + UnityEngine.XR.XRSettings.showDeviceView = !customPreviewCamera && m_ShowDeviceView; } void OnGUI() @@ -286,7 +286,7 @@ void DoDrawCamera(Rect rect) if (!m_Camera.gameObject.activeInHierarchy) return; - if (!VRDevice.isPresent) + if (!UnityEngine.XR.XRDevice.isPresent) return; UnityEditor.Handles.DrawCamera(rect, m_Camera, m_RenderMode); @@ -308,7 +308,7 @@ private void Update() // Force the window to repaint every tick, since we need live updating // This also allows scripts with [ExecuteInEditMode] to run - EditorApplication.SetSceneRepaintDirty(); + EditorApplication.QueuePlayerLoopUpdate(); // Our camera is disabled, so it doesn't get automatically updated to HMD values until it renders UpdateCameraTransform(); @@ -334,7 +334,7 @@ void UpdateHMDStatus() static bool GetIsUserPresent() { #if ENABLE_OVR_INPUT - if (VRSettings.loadedDeviceName == "Oculus") + if (UnityEngine.XR.XRSettings.loadedDeviceName == "Oculus") return OVRPlugin.userPresent; #endif #if ENABLE_STEAMVR_INPUT diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 9580b2cb1..1af2a424d 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -23,7 +23,7 @@ sealed class ViveProxy : TwoHandedProxyBase public override void Awake() { - if (VRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0) + if (UnityEngine.XR.XRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0) { m_LeftHandProxyPrefab = m_LeftHandTouchProxyPrefab; m_RightHandProxyPrefab = m_RightHandTouchProxyPrefab; From a2296222a97e42749f27097b38ea2de2ce56167e Mon Sep 17 00:00:00 2001 From: andrewm Date: Wed, 6 Sep 2017 16:32:23 -0700 Subject: [PATCH 012/457] Converting the initial 2017 changes to the latest development updates --- Editor/EditingContextManagerEditor.cs | 2 +- .../Core/Contexts/EditingContextManager.cs | 16 ++++++++---- Scripts/Core/Contexts/EditorVRContext.cs | 2 +- Scripts/Core/EditorVR.DirectSelection.cs | 2 +- Scripts/Core/EditorVR.Interfaces.cs | 2 +- Scripts/Core/EditorVR.Menus.cs | 2 +- Scripts/Core/EditorVR.MiniWorlds.cs | 2 +- Scripts/Core/EditorVR.Rays.cs | 2 +- Scripts/Core/EditorVR.Tools.cs | 2 +- Scripts/Core/EditorVR.UI.cs | 2 +- Scripts/Core/EditorVR.Vacuumables.cs | 2 +- Scripts/Core/EditorVR.Viewer.cs | 2 +- Scripts/Core/EditorVR.cs | 4 +-- .../ActionsModuleConnector.cs | 2 +- .../DeviceInputModuleConnector.cs | 2 +- .../HapticsModuleConnector.cs | 2 +- .../HierarchyModuleConnector.cs | 2 +- .../HighlightModuleConnector.cs | 2 +- .../LockModuleConnector.cs | 2 +- .../MultipleRayInputModuleConnector.cs | 2 +- .../ProjectFolderModuleConnector.cs | 2 +- .../SceneObjectModuleConnector.cs | 2 +- .../SelectionModuleConnector.cs | 2 +- .../SnappingModuleConnector.cs | 2 +- .../SpatialHashModuleConnector.cs | 2 +- .../TooltipModuleConnector.cs | 2 +- .../WorkspaceModuleConnector.cs | 2 +- Scripts/Core/VRView.cs | 6 +---- Scripts/Helpers/VRSmoothCamera.cs | 2 +- Scripts/Input/SixenseInputToEvents.cs | 2 +- Scripts/Modules/ActionsModule.cs | 2 +- Scripts/Modules/DeviceInputModule.cs | 2 +- Scripts/Modules/SceneObjectModule.cs | 2 +- Scripts/UI/InputField.cs | 2 +- Scripts/Utilities/CameraUtils.cs | 4 +-- Scripts/Utilities/ObjectUtils.cs | 25 ++++++++++++++++--- Tests/Editor/CompilationTest.cs | 2 +- Tools/SelectionTool/SelectionTool.cs | 2 +- libs/input-prototype | 2 +- 39 files changed, 71 insertions(+), 52 deletions(-) diff --git a/Editor/EditingContextManagerEditor.cs b/Editor/EditingContextManagerEditor.cs index a54b5546f..308caf0dd 100644 --- a/Editor/EditingContextManagerEditor.cs +++ b/Editor/EditingContextManagerEditor.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITORVR +#if UNITY_2017_2_OR_NEWER using System; using UnityEngine; diff --git a/Scripts/Core/Contexts/EditingContextManager.cs b/Scripts/Core/Contexts/EditingContextManager.cs index 231bad4fa..a38200768 100644 --- a/Scripts/Core/Contexts/EditingContextManager.cs +++ b/Scripts/Core/Contexts/EditingContextManager.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using System.Linq; @@ -109,9 +109,9 @@ static void ReopenOnExitPlaymode() } } - private void OnPlaymodeStateChanged() + static void OnPlayModeStateChanged(PlayModeStateChange stateChange) { - if (EditorApplication.isPlayingOrWillChangePlaymode) + if (stateChange == PlayModeStateChange.ExitingEditMode) { EditorPrefs.SetBool(k_LaunchOnExitPlaymode, true); var view = VRView.activeView; @@ -137,12 +137,18 @@ void OnEnable() if (m_AvailableContexts.Count > 1) VRView.afterOnGUI += OnVRViewGUI; - EditorApplication.playmodeStateChanged += OnPlaymodeStateChanged; + // Force the window to repaint every tick, since we need live updating + // This also allows scripts with [ExecuteInEditMode] to run + EditorApplication.update += EditorApplication.QueuePlayerLoopUpdate; + + EditorApplication.playModeStateChanged += OnPlayModeStateChanged; } void OnDisable() { - EditorApplication.playmodeStateChanged -= OnPlaymodeStateChanged; + EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; + + EditorApplication.update -= EditorApplication.QueuePlayerLoopUpdate; VRView.afterOnGUI -= OnVRViewGUI; diff --git a/Scripts/Core/Contexts/EditorVRContext.cs b/Scripts/Core/Contexts/EditorVRContext.cs index a95df2525..a63c5177d 100644 --- a/Scripts/Core/Contexts/EditorVRContext.cs +++ b/Scripts/Core/Contexts/EditorVRContext.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Utilities; diff --git a/Scripts/Core/EditorVR.DirectSelection.cs b/Scripts/Core/EditorVR.DirectSelection.cs index 2a0cf3da3..a88c66d25 100644 --- a/Scripts/Core/EditorVR.DirectSelection.cs +++ b/Scripts/Core/EditorVR.DirectSelection.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Extensions; diff --git a/Scripts/Core/EditorVR.Interfaces.cs b/Scripts/Core/EditorVR.Interfaces.cs index 2ca6701d6..c9276e456 100644 --- a/Scripts/Core/EditorVR.Interfaces.cs +++ b/Scripts/Core/EditorVR.Interfaces.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Core/EditorVR.Menus.cs b/Scripts/Core/EditorVR.Menus.cs index f84804086..ec4b7f72c 100644 --- a/Scripts/Core/EditorVR.Menus.cs +++ b/Scripts/Core/EditorVR.Menus.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Core/EditorVR.MiniWorlds.cs b/Scripts/Core/EditorVR.MiniWorlds.cs index 02daf23c5..8cb04c1e6 100644 --- a/Scripts/Core/EditorVR.MiniWorlds.cs +++ b/Scripts/Core/EditorVR.MiniWorlds.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Extensions; diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 5af63e410..372991b6e 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Helpers; diff --git a/Scripts/Core/EditorVR.Tools.cs b/Scripts/Core/EditorVR.Tools.cs index 9f5ca37e8..6f1c10a51 100644 --- a/Scripts/Core/EditorVR.Tools.cs +++ b/Scripts/Core/EditorVR.Tools.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Core/EditorVR.UI.cs b/Scripts/Core/EditorVR.UI.cs index 2db62cff0..1d8862a5f 100644 --- a/Scripts/Core/EditorVR.UI.cs +++ b/Scripts/Core/EditorVR.UI.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Modules; diff --git a/Scripts/Core/EditorVR.Vacuumables.cs b/Scripts/Core/EditorVR.Vacuumables.cs index 040dcc52d..19f849643 100644 --- a/Scripts/Core/EditorVR.Vacuumables.cs +++ b/Scripts/Core/EditorVR.Vacuumables.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System.Collections.Generic; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index b60c93df5..6dabff772 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections; using UnityEditor.Experimental.EditorVR.Helpers; diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index 558746cf3..b0f8d76e5 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -14,7 +14,7 @@ namespace UnityEditor.Experimental.EditorVR.Core { [InitializeOnLoad] -#if UNITY_EDITORVR +#if UNITY_2017_2_OR_NEWER [RequiresTag(k_VRPlayerTag)] sealed partial class EditorVR : MonoBehaviour { @@ -299,7 +299,7 @@ static void ClearDeveloperConsoleIfNecessary() if (result) { - var logEntries = asm.GetType("UnityEditorInternal.LogEntries"); + var logEntries = asm.GetType("UnityEditor.LogEntries"); var clearMethod = logEntries.GetMethod("Clear", BindingFlags.Static | BindingFlags.Public); clearMethod.Invoke(null, null); } diff --git a/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs b/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs index d2e06d26b..28a750323 100644 --- a/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; diff --git a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs index 8c6f5a60d..c563a8355 100644 --- a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; diff --git a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs index b55dc3e66..fd7a0f9d1 100644 --- a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs index 9bae7284e..3d428c685 100644 --- a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; diff --git a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs index ba30ee83e..373a6e356 100644 --- a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; diff --git a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs index eba893c4b..db64e4243 100644 --- a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs index d1d5b6c5c..45d558768 100644 --- a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs index bc032ab6a..2a7fccdb1 100644 --- a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; diff --git a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs index 90d16a0e1..141ec514d 100644 --- a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs index a92581eec..77728ea16 100644 --- a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; diff --git a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs index bf754e19e..147ce6172 100644 --- a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs index 6845f7971..ba994e076 100644 --- a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs index 3221a284e..2cd24d38e 100644 --- a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs index c1119e043..525a05007 100644 --- a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; diff --git a/Scripts/Core/VRView.cs b/Scripts/Core/VRView.cs index faaf192b2..f4a6ee8b3 100644 --- a/Scripts/Core/VRView.cs +++ b/Scripts/Core/VRView.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using UnityEngine; using UnityEngine.Assertions; @@ -306,10 +306,6 @@ private void Update() return; } - // Force the window to repaint every tick, since we need live updating - // This also allows scripts with [ExecuteInEditMode] to run - EditorApplication.QueuePlayerLoopUpdate(); - // Our camera is disabled, so it doesn't get automatically updated to HMD values until it renders UpdateCameraTransform(); diff --git a/Scripts/Helpers/VRSmoothCamera.cs b/Scripts/Helpers/VRSmoothCamera.cs index 2a22a1240..bbd249157 100644 --- a/Scripts/Helpers/VRSmoothCamera.cs +++ b/Scripts/Helpers/VRSmoothCamera.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Core; using UnityEngine; diff --git a/Scripts/Input/SixenseInputToEvents.cs b/Scripts/Input/SixenseInputToEvents.cs index 99dece328..116c09076 100644 --- a/Scripts/Input/SixenseInputToEvents.cs +++ b/Scripts/Input/SixenseInputToEvents.cs @@ -182,7 +182,7 @@ private void SendTrackingEvents(int sixenseDeviceIndex, int deviceIndex) void CalibrateControllers() { -#if UNITY_EDITORVR +#if UNITY_2017_2_OR_NEWER // Assume controllers are on the side of the HMD and facing forward (aligned with base) var span = (SixenseInput.Controllers[1].Position * k_HydraUnits - SixenseInput.Controllers[0].Position * k_HydraUnits).magnitude; diff --git a/Scripts/Modules/ActionsModule.cs b/Scripts/Modules/ActionsModule.cs index 6e917a596..38bf231fc 100644 --- a/Scripts/Modules/ActionsModule.cs +++ b/Scripts/Modules/ActionsModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index c0effd0bd..17cb04a55 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Utilities; diff --git a/Scripts/Modules/SceneObjectModule.cs b/Scripts/Modules/SceneObjectModule.cs index 806d6251f..d8fb8eedf 100644 --- a/Scripts/Modules/SceneObjectModule.cs +++ b/Scripts/Modules/SceneObjectModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections; using UnityEditor.Experimental.EditorVR.Utilities; diff --git a/Scripts/UI/InputField.cs b/Scripts/UI/InputField.cs index 2558bd6cf..bfc02dda4 100644 --- a/Scripts/UI/InputField.cs +++ b/Scripts/UI/InputField.cs @@ -1,5 +1,5 @@ #if UNITY_EDITOR -#if !UNITY_EDITORVR +#if !UNITY_2017_2_OR_NEWER #pragma warning disable 649 // "never assigned to" warning #endif diff --git a/Scripts/Utilities/CameraUtils.cs b/Scripts/Utilities/CameraUtils.cs index 210978ad6..b42104918 100644 --- a/Scripts/Utilities/CameraUtils.cs +++ b/Scripts/Utilities/CameraUtils.cs @@ -36,7 +36,7 @@ public static Camera GetMainCamera() { var camera = Camera.main; -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER if (!Application.isPlaying && VRView.viewerCamera) { camera = VRView.viewerCamera; @@ -50,7 +50,7 @@ public static Transform GetCameraRig() { var rig = Camera.main ? Camera.main.transform.parent : null; -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER if (!Application.isPlaying) { if (VRView.cameraRig) diff --git a/Scripts/Utilities/ObjectUtils.cs b/Scripts/Utilities/ObjectUtils.cs index edf76bbec..75fb29d8c 100644 --- a/Scripts/Utilities/ObjectUtils.cs +++ b/Scripts/Utilities/ObjectUtils.cs @@ -239,7 +239,7 @@ public static void Destroy(UnityObject o, float t = 0f) { UnityObject.Destroy(o, t); } -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER else { if (Mathf.Approximately(t, 0f)) @@ -278,9 +278,26 @@ public static string NicifySerializedPropertyType(string type) /// Best guess System.Type public static Type TypeNameToType(string name) { - return AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(x => x.GetTypes()) - .FirstOrDefault(x => x.Name.Equals(name) && typeof(UnityObject).IsAssignableFrom(x)); + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + foreach (var assembly in assemblies) + { + try + { + foreach (var type in assembly.GetTypes()) + { + if (type.Name.Equals(name) && typeof(UnityObject).IsAssignableFrom(type)) + { + return type; + } + } + } + catch (ReflectionTypeLoadException) + { + // Skip any assemblies that don't load properly + } + } + + return typeof(UnityObject); } public static IEnumerator GetAssetPreview(UnityObject obj, Action callback) diff --git a/Tests/Editor/CompilationTest.cs b/Tests/Editor/CompilationTest.cs index 90dda517a..08292f0b5 100644 --- a/Tests/Editor/CompilationTest.cs +++ b/Tests/Editor/CompilationTest.cs @@ -30,7 +30,7 @@ public void NoCCUDefines() public void NoEditorVR() { var defines = EditorUserBuildSettings.activeScriptCompilationDefines.ToList(); - defines.Remove("UNITY_EDITORVR"); + defines.Remove("UNITY_2017_2_OR_NEWER"); TestCompile(defines.ToArray()); } diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index f1137aec8..44707e2c6 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using System.Linq; diff --git a/libs/input-prototype b/libs/input-prototype index b2316ef33..b671b868a 160000 --- a/libs/input-prototype +++ b/libs/input-prototype @@ -1 +1 @@ -Subproject commit b2316ef3354d9b548064faeb38f95f99f11a63e2 +Subproject commit b671b868a5c458f2ce194da5bd6808f401a914c5 From 665d4179da237b5d5ca8e25c422c028ad3fc2460 Mon Sep 17 00:00:00 2001 From: andrewm Date: Thu, 7 Sep 2017 13:39:32 -0700 Subject: [PATCH 013/457] A few protection tags got flipped back in the previous merge --- Scripts/Modules/HierarchyModule.cs | 2 +- Tools/LocomotionTool/LocomotionTool.cs | 2 +- Tools/SelectionTool/SelectionTool.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/Modules/HierarchyModule.cs b/Scripts/Modules/HierarchyModule.cs index 74fc61fdd..9c7cefd19 100644 --- a/Scripts/Modules/HierarchyModule.cs +++ b/Scripts/Modules/HierarchyModule.cs @@ -28,7 +28,7 @@ void Awake() m_IgnoreList.Add(manager.gameObject); } -#if UNITY_EDITORVR +#if UNITY_2017_2_OR_NEWER foreach (var manager in Resources.FindObjectsOfTypeAll()) { m_IgnoreList.Add(manager.gameObject); diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index dc58cf9f5..75f682796 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -485,7 +485,7 @@ bool DoTwoHandedScaling(ConsumeControlDelegate consumeControl) if (worldResetHeld && otherWorldResetHeld) { m_AllowScaling = false; -#if UNITY_EDITORVR +#if UNITY_2017_2_OR_NEWER cameraRig.position = Vector3.up * VRView.HeadHeight; #endif cameraRig.rotation = Quaternion.identity; diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index edf7bd911..839c4346d 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Collections.Generic; using System.Linq; From 6afe5690944a77604b0c536135a9a0cf8c8a50a2 Mon Sep 17 00:00:00 2001 From: Andrew Maneri Date: Thu, 7 Sep 2017 13:45:14 -0700 Subject: [PATCH 014/457] Script updater didn't run on vive path previously --- Scripts/Core/VRView.cs | 2 +- Scripts/Input/ViveInputToEvents.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/Core/VRView.cs b/Scripts/Core/VRView.cs index f4a6ee8b3..9e4e75e1c 100644 --- a/Scripts/Core/VRView.cs +++ b/Scripts/Core/VRView.cs @@ -334,7 +334,7 @@ static bool GetIsUserPresent() return OVRPlugin.userPresent; #endif #if ENABLE_STEAMVR_INPUT - if (VRSettings.loadedDeviceName == "OpenVR") + if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR") return OpenVR.System.GetTrackedDeviceActivityLevel(0) == EDeviceActivityLevel.k_EDeviceActivityLevel_UserInteraction; #endif return true; diff --git a/Scripts/Input/ViveInputToEvents.cs b/Scripts/Input/ViveInputToEvents.cs index c3a222e34..40fe05235 100644 --- a/Scripts/Input/ViveInputToEvents.cs +++ b/Scripts/Input/ViveInputToEvents.cs @@ -65,7 +65,7 @@ public void Update() return; // Oculus Touch on OpenVR should have fixed left/right hand device indices - if (VRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0 + if (UnityEngine.XR.XRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0 && leftSteamDeviceIndex > rightSteamDeviceIndex) { var swap = rightSteamDeviceIndex; From 793f522179e80c0b230a5c5d44a1e9bdd9eb2a49 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Mon, 18 Sep 2017 12:56:03 -0700 Subject: [PATCH 015/457] WIP commit experimenting with generics in functionality injection --- Scripts/Core/EditorVR.Rays.cs | 2 + Scripts/Core/EditorVR.cs | 2 + Scripts/Helpers/ProxyHelper.cs | 12 +++ .../Interfaces/Capability/IDropReceiver.cs | 5 +- .../Capability/IFeedbackReciever.cs | 23 ++++++ .../Capability/IFeedbackReciever.cs.meta | 12 +++ .../IRequestFeedback.cs | 33 ++++++++ .../IRequestFeedback.cs.meta | 12 +++ Scripts/Modules/FeedbackModule.meta | 9 +++ .../Modules/FeedbackModule/FeedbackModule.cs | 80 +++++++++++++++++++ .../FeedbackModule/FeedbackModule.cs.meta | 12 +++ .../Modules/TooltipModule/TooltipModule.cs | 14 +++- Scripts/Proxies/TwoHandedProxyBase.cs | 28 ++++++- Tools/LocomotionTool/LocomotionTool.cs | 18 ++++- 14 files changed, 253 insertions(+), 9 deletions(-) create mode 100644 Scripts/Interfaces/Capability/IFeedbackReciever.cs create mode 100644 Scripts/Interfaces/Capability/IFeedbackReciever.cs.meta create mode 100644 Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs create mode 100644 Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs.meta create mode 100644 Scripts/Modules/FeedbackModule.meta create mode 100644 Scripts/Modules/FeedbackModule/FeedbackModule.cs create mode 100644 Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 94a86c5f5..5a6db1d47 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -150,9 +150,11 @@ static bool OverrideSelectObject(GameObject hoveredObject) internal void CreateAllProxies() { var deviceInputModule = evr.GetModule(); + var interfaceModule = evr.GetNestedModule(); foreach (var proxyType in ObjectUtils.GetImplementationsOfInterface(typeof(IProxy))) { var proxy = (IProxy)ObjectUtils.CreateGameObjectWithComponent(proxyType, VRView.cameraRig, false); + interfaceModule.ConnectInterfaces(proxy); proxy.trackedObjectInput = deviceInputModule.trackedObjectInput; proxy.activeChanged += () => OnProxyActiveChanged(proxy); proxy.hidden = true; diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index 40de4a280..442971fdf 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -234,6 +234,8 @@ void Awake() AddModule(); + AddModule(); + viewer.AddPlayerModel(); GetNestedModule().CreateAllProxies(); diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index 4e935cd25..4bfd2fb8a 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -1,5 +1,7 @@ #if UNITY_EDITOR +using System; using UnityEngine; +using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR.Proxies { @@ -8,6 +10,13 @@ namespace UnityEditor.Experimental.EditorVR.Proxies /// sealed class ProxyHelper : MonoBehaviour { + [Serializable] + class ButtonObject + { + public VRInputDevice.VRControl control; + public Renderer renderer; + } + /// /// The transform that the device's ray contents (default ray, custom ray, etc) will be parented under /// @@ -73,6 +82,9 @@ public Transform meshRoot [SerializeField] private Transform m_MeshRoot; + + [SerializeField] + ButtonObject[] m_Buttons; } } #endif diff --git a/Scripts/Interfaces/Capability/IDropReceiver.cs b/Scripts/Interfaces/Capability/IDropReceiver.cs index 345b41caf..add3c9ce7 100644 --- a/Scripts/Interfaces/Capability/IDropReceiver.cs +++ b/Scripts/Interfaces/Capability/IDropReceiver.cs @@ -1,6 +1,4 @@ -using UnityEngine; - -#if UNITY_EDITOR +#if UNITY_EDITOR namespace UnityEditor.Experimental.EditorVR { /// @@ -11,7 +9,6 @@ public interface IDropReceiver /// /// Called when an object is hovering over the receiver /// - /// The GameObject with which the pointer is intersecting /// The object we are dropping /// Whether the drop can be accepted bool CanDrop(object dropObject); diff --git a/Scripts/Interfaces/Capability/IFeedbackReciever.cs b/Scripts/Interfaces/Capability/IFeedbackReciever.cs new file mode 100644 index 000000000..418f69947 --- /dev/null +++ b/Scripts/Interfaces/Capability/IFeedbackReciever.cs @@ -0,0 +1,23 @@ +#if UNITY_EDITOR +namespace UnityEditor.Experimental.EditorVR +{ + /// + /// Implementors can receive Feedback Requests + /// + public interface IFeedbackReciever + { + void ClearFeedbackRequests(object caller); + } + + /// + /// + /// Implementors can receive Feedback Requests that extend IFeedbackRequest + /// + /// + public interface IFeedbackReciever : IFeedbackReciever where TFeedbackRequest : FeedbackRequest + { + void AddFeedbackRequest(TFeedbackRequest request); + void RemoveFeedbackRequest(TFeedbackRequest request); + } +} +#endif diff --git a/Scripts/Interfaces/Capability/IFeedbackReciever.cs.meta b/Scripts/Interfaces/Capability/IFeedbackReciever.cs.meta new file mode 100644 index 000000000..1a3c0c906 --- /dev/null +++ b/Scripts/Interfaces/Capability/IFeedbackReciever.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 48ed0498a70591944962fe28fd0656d1 +timeCreated: 1505752857 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs new file mode 100644 index 000000000..ce877f635 --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs @@ -0,0 +1,33 @@ +using System; + +namespace UnityEditor.Experimental.EditorVR +{ + public interface IRequestFeedback + { + } + + public static class IRequestFeedbackMethods + { + public delegate void AddFeedbackRequestDelegate(FeedbackRequest request, object caller, int priority = 0); + public delegate void RemoveFeedbackRequestDelegate(FeedbackRequest request); + + public static AddFeedbackRequestDelegate addFeedbackRequest { private get; set; } + public static RemoveFeedbackRequestDelegate removeFeedbackRequest { private get; set; } + public static Action clearFeedbackRequests { private get; set; } + + public static void AddFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request, object caller, int priority = 0) where TFeedbackRequest : FeedbackRequest + { + addFeedbackRequest(request, caller, priority); + } + + public static void RemoveFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request) where TFeedbackRequest : FeedbackRequest + { + removeFeedbackRequest(request); + } + + public static void ClearFeedbackRequests(this IRequestFeedback obj, Type feedbackType, object caller) + { + clearFeedbackRequests(caller); + } + } +} diff --git a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs.meta b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs.meta new file mode 100644 index 000000000..584bdd347 --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 247ea31d44a420449ac1c10d8ba5f814 +timeCreated: 1505760144 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/FeedbackModule.meta b/Scripts/Modules/FeedbackModule.meta new file mode 100644 index 000000000..4fd9ada6d --- /dev/null +++ b/Scripts/Modules/FeedbackModule.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0fb0583bd44580a4a9b4b87cbe9dcd27 +folderAsset: yes +timeCreated: 1505752814 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs new file mode 100644 index 000000000..6c00c1e26 --- /dev/null +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -0,0 +1,80 @@ +#if UNITY_EDITOR +using System; +using System.Collections.Generic; +using UnityEditor.Experimental.EditorVR.Core; +using UnityEngine; + +namespace UnityEditor.Experimental.EditorVR +{ + public abstract class FeedbackRequest + { + internal object caller; + internal int priority; + } + + public class FeedbackModule : MonoBehaviour, IInterfaceConnector + { + readonly List m_FeedbackReceivers = new List(); + + void Awake() + { + IRequestFeedbackMethods.addFeedbackRequest = AddFeedbackRequest; + IRequestFeedbackMethods.removeFeedbackRequest = RemoveFeedbackRequest; + IRequestFeedbackMethods.clearFeedbackRequests = ClearFeedbackRequests; + } + + public void ConnectInterface(object obj, Transform rayOrigin = null) + { + var feedbackReceiver = obj as IFeedbackReciever; + if (feedbackReceiver != null) + m_FeedbackReceivers.Add(feedbackReceiver); + } + + public void DisconnectInterface(object obj, Transform rayOrigin = null) + { + var feedbackReceiver = obj as IFeedbackReciever; + if (feedbackReceiver != null) + m_FeedbackReceivers.Remove(feedbackReceiver); + } + + public void AddFeedbackRequest(TFeedbackRequest request, object caller, int priority = 0) where TFeedbackRequest : FeedbackRequest + { + Debug.Log("asdf"); + foreach (var obj in m_FeedbackReceivers) + { + Debug.Log(obj.GetType() + ", " + typeof(TFeedbackRequest) + ", " + typeof(IFeedbackReciever).IsAssignableFrom(obj.GetType())); + var reciever = obj as IFeedbackReciever; + Debug.Log(reciever); + if (reciever == null) + continue; + + Debug.Log(obj); + + request.caller = caller; + request.priority = priority; + reciever.AddFeedbackRequest(request); + } + } + + public void RemoveFeedbackRequest(TFeedbackRequest request) where TFeedbackRequest : FeedbackRequest + { + foreach (var obj in m_FeedbackReceivers) + { + var reciever = obj as IFeedbackReciever; + if (reciever == null) + continue; + + reciever.RemoveFeedbackRequest(request); + } + } + + public void ClearFeedbackRequests(object caller) + { + foreach (var obj in m_FeedbackReceivers) + { + obj.ClearFeedbackRequests(caller); + } + } + } +} +#endif diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta b/Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta new file mode 100644 index 000000000..0732e8780 --- /dev/null +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0c0af8559f906454db081815e6275f48 +timeCreated: 1505752823 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index e42cceac1..40a2763de 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -8,6 +8,14 @@ namespace UnityEditor.Experimental.EditorVR.Modules { sealed class TooltipModule : MonoBehaviour, IUsesViewerScale { + public class Tooltip : ITooltip, ITooltipPlacement + { + public string tooltipText { get; set; } + public Transform tooltipTarget { get; set; } + public Transform tooltipSource { get; set; } + public TextAlignment tooltipAlignment { get; set; } + } + const float k_Delay = 0; // In case we want to bring back a delay const float k_TransitionDuration = 0.1f; const float k_UVScale = 100f; @@ -102,10 +110,10 @@ void Update() static Transform GetTooltipTarget(ITooltip tooltip) { var placement = tooltip as ITooltipPlacement; - var target = ((MonoBehaviour)tooltip).transform; if (placement != null) - target = placement.tooltipTarget; - return target; + return placement.tooltipTarget; + + return ((MonoBehaviour)tooltip).transform; } void UpdateVisuals(ITooltip tooltip, TooltipUI tooltipUI, Transform target, float lerp) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 8790edc5f..5abf70774 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -9,7 +9,14 @@ namespace UnityEditor.Experimental.EditorVR.Proxies { - abstract class TwoHandedProxyBase : MonoBehaviour, IProxy + public class ProxyFeedbackRequest : FeedbackRequest + { + public VRInputDevice.VRControl control; + public Node node; + public ITooltip tooltip; + } + + abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility { const int k_RendererQueue = 9000; @@ -161,6 +168,25 @@ public virtual void Update() m_RightHand.localRotation = trackedObjectInput.rightRotation.quaternion; } } + + public void AddFeedbackRequest(ProxyFeedbackRequest request) + { + Debug.Log(request); + if (request.tooltip != null) + { + this.ShowTooltip(request.tooltip); + } + } + + public void RemoveFeedbackRequest(ProxyFeedbackRequest request) + { + Debug.Log(request); + } + + public void ClearFeedbackRequests(object caller) + { + Debug.Log(caller); + } } } #endif diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index cf60ca5b9..6c0afd3fb 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -3,6 +3,8 @@ using System.Collections; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Core; +using UnityEditor.Experimental.EditorVR.Modules; +using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -13,7 +15,7 @@ namespace UnityEditor.Experimental.EditorVR.Tools { sealed class LocomotionTool : MonoBehaviour, ITool, ILocomotor, IUsesRayOrigin, IRayVisibilitySettings, ICustomActionMap, ILinkedObject, IUsesViewerScale, ISettingsMenuItemProvider, ISerializePreferences, - IUsesProxyType, IGetVRPlayerObjects + IUsesProxyType, IGetVRPlayerObjects, IRequestFeedback, IUsesNode { const float k_FastMoveSpeed = 20f; const float k_SlowMoveSpeed = 1f; @@ -145,6 +147,8 @@ public GameObject settingsMenuItemInstance public Type proxyType { get; set; } + public Node? node { private get; set; } + void Start() { if (this.IsSharedUpdater(this) && m_Preferences == null) @@ -187,8 +191,20 @@ void OnDestroy() public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { + var firstFrame = m_LocomotionInput == null; m_LocomotionInput = (LocomotionInput)input; + if (firstFrame && m_LocomotionInput != null) + { + Debug.Log("asdf"); + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + node = node.Value, + control = VRInputDevice.VRControl.Trigger2, + tooltip = new TooltipModule.Tooltip { tooltipText = "text" } + }, this); + } + if (DoTwoHandedScaling(consumeControl)) return; From 9708bd7e1f9ca965612b4e63f9a480fc00c16856 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Mon, 18 Sep 2017 14:30:38 -0700 Subject: [PATCH 016/457] WIP second try on generic interfaces --- .../IRequestFeedback.cs | 2 +- .../Modules/FeedbackModule/FeedbackModule.cs | 85 +++++++++++++------ 2 files changed, 61 insertions(+), 26 deletions(-) diff --git a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs index ce877f635..595a9cf67 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs @@ -12,7 +12,7 @@ public static class IRequestFeedbackMethods public delegate void RemoveFeedbackRequestDelegate(FeedbackRequest request); public static AddFeedbackRequestDelegate addFeedbackRequest { private get; set; } - public static RemoveFeedbackRequestDelegate removeFeedbackRequest { private get; set; } + public static Action removeFeedbackRequest { private get; set; } public static Action clearFeedbackRequests { private get; set; } public static void AddFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request, object caller, int priority = 0) where TFeedbackRequest : FeedbackRequest diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index 6c00c1e26..760e6c99b 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -1,6 +1,7 @@ #if UNITY_EDITOR using System; using System.Collections.Generic; +using System.Linq; using UnityEditor.Experimental.EditorVR.Core; using UnityEngine; @@ -14,7 +15,7 @@ public abstract class FeedbackRequest public class FeedbackModule : MonoBehaviour, IInterfaceConnector { - readonly List m_FeedbackReceivers = new List(); + readonly Dictionary> m_FeedbackReceivers = new Dictionary>(); void Awake() { @@ -27,44 +28,75 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) { var feedbackReceiver = obj as IFeedbackReciever; if (feedbackReceiver != null) - m_FeedbackReceivers.Add(feedbackReceiver); + { + var requestType = obj.GetType().GetInterfaces() + .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IFeedbackReciever<>)) + .SelectMany(i => i.GetGenericArguments()) + .First(); + if (requestType != null) + { + List recievers; + if (!m_FeedbackReceivers.TryGetValue(requestType, out recievers)) + { + recievers = new List(); + m_FeedbackReceivers[requestType] = recievers; + } + + recievers.Add(feedbackReceiver); + } + } } public void DisconnectInterface(object obj, Transform rayOrigin = null) { var feedbackReceiver = obj as IFeedbackReciever; if (feedbackReceiver != null) - m_FeedbackReceivers.Remove(feedbackReceiver); + { + var requestType = obj.GetType().GetInterfaces() + .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IFeedbackReciever<>)) + .SelectMany(i => i.GetGenericArguments()) + .First(); + if (requestType != null) + { + List recievers; + if (m_FeedbackReceivers.TryGetValue(requestType, out recievers)) + { + recievers.Remove(feedbackReceiver); + + if (recievers.Count == 0) + m_FeedbackReceivers.Remove(requestType); + } + } + } } - public void AddFeedbackRequest(TFeedbackRequest request, object caller, int priority = 0) where TFeedbackRequest : FeedbackRequest + void AddFeedbackRequest(FeedbackRequest request, object caller, int priority = 0) { - Debug.Log("asdf"); - foreach (var obj in m_FeedbackReceivers) + var requestType = request.GetType(); + List recievers; + if (m_FeedbackReceivers.TryGetValue(requestType, out recievers)) { - Debug.Log(obj.GetType() + ", " + typeof(TFeedbackRequest) + ", " + typeof(IFeedbackReciever).IsAssignableFrom(obj.GetType())); - var reciever = obj as IFeedbackReciever; - Debug.Log(reciever); - if (reciever == null) - continue; - - Debug.Log(obj); - - request.caller = caller; - request.priority = priority; - reciever.AddFeedbackRequest(request); + foreach (var obj in recievers) + { + request.caller = caller; + request.priority = priority; + var receiver = (IFeedbackReciever)obj; + receiver.AddFeedbackRequest(request); + } } } - public void RemoveFeedbackRequest(TFeedbackRequest request) where TFeedbackRequest : FeedbackRequest + public void RemoveFeedbackRequest(FeedbackRequest request) { - foreach (var obj in m_FeedbackReceivers) + var requestType = request.GetType(); + List recievers; + if (m_FeedbackReceivers.TryGetValue(requestType, out recievers)) { - var reciever = obj as IFeedbackReciever; - if (reciever == null) - continue; - - reciever.RemoveFeedbackRequest(request); + foreach (var obj in recievers) + { + var receiver = (IFeedbackReciever)obj; + receiver.RemoveFeedbackRequest(request); + } } } @@ -72,7 +104,10 @@ public void ClearFeedbackRequests(object caller) { foreach (var obj in m_FeedbackReceivers) { - obj.ClearFeedbackRequests(caller); + foreach (var reciever in obj.Value) + { + reciever.ClearFeedbackRequests(caller); + } } } } From 2477546340cb6e793a9e1ecd12315d5c7e33c04b Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Mon, 18 Sep 2017 17:03:28 -0700 Subject: [PATCH 017/457] Finish MVP of feedback system --- Prefabs/Proxies/LeftTouch.prefab | 190 ++++++++++++++++-- Prefabs/Proxies/RightTouch.prefab | 149 ++++++++++++++ Scripts/Helpers/ProxyHelper.cs | 18 +- .../Capability/IFeedbackReciever.cs | 15 +- .../IRequestFeedback.cs | 17 +- .../Modules/FeedbackModule/FeedbackModule.cs | 76 ++----- .../HighlightModule/HighlightModule.cs | 25 ++- .../Modules/TooltipModule/TooltipModule.cs | 8 - Scripts/Proxies/TwoHandedProxyBase.cs | 112 +++++++++-- Scripts/Utilities/IntersectionUtils.cs | 5 + .../CreatePrimitiveTool.cs | 12 +- Tools/LocomotionTool/LocomotionTool.cs | 20 +- 12 files changed, 497 insertions(+), 150 deletions(-) diff --git a/Prefabs/Proxies/LeftTouch.prefab b/Prefabs/Proxies/LeftTouch.prefab index c92eabab1..ef3ade030 100644 --- a/Prefabs/Proxies/LeftTouch.prefab +++ b/Prefabs/Proxies/LeftTouch.prefab @@ -9,6 +9,7 @@ GameObject: m_Component: - component: {fileID: 461814} - component: {fileID: 13767942} + - component: {fileID: 65403493955253320} m_Layer: 0 m_Name: lctrl:side_trigger_PLY m_TagString: ShowInMiniWorld @@ -72,7 +73,7 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 447250} - m_Layer: 0 + m_Layer: 5 m_Name: lctrl:b_button02 m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} @@ -151,7 +152,7 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 498550} - m_Layer: 0 + m_Layer: 5 m_Name: lctrl:left_touch_controller_world m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} @@ -166,8 +167,8 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 499662} - m_Layer: 0 - m_Name: lctrl:b_trigger + m_Layer: 5 + m_Name: GripTarget m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -227,7 +228,7 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 442622} - m_Layer: 0 + m_Layer: 5 m_Name: lctrl:b_button01 m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} @@ -258,7 +259,10 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 450394} - m_Layer: 0 + - component: {fileID: 65524402868567802} + - component: {fileID: 114692086924928774} + - component: {fileID: 114126251981801024} + m_Layer: 5 m_Name: lctrl:b_hold m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} @@ -273,7 +277,7 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 425138} - m_Layer: 0 + m_Layer: 5 m_Name: lctrl:b_stick_IGNORE m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} @@ -288,7 +292,7 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 407362} - m_Layer: 0 + m_Layer: 5 m_Name: lctrl:b_stick m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} @@ -577,6 +581,8 @@ Transform: - {fileID: 447250} - {fileID: 450394} - {fileID: 407362} + - {fileID: 4023718469717780} + - {fileID: 4922541072726130} - {fileID: 499662} m_Father: {fileID: 485484} m_RootOrder: 1 @@ -587,13 +593,13 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 153432} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.0006312649, y: 0.023094632, z: -0.008431792} + m_LocalRotation: {x: -0.09117605, y: 0.99275935, z: 0.07810742, w: -0.0038822622} + m_LocalPosition: {x: -0.0536, y: -0.0241, z: -0.0261} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 498550} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: -8.8810005, y: -178.727, z: -370.594} --- !u!95 &9567726 Animator: serializedVersion: 3 @@ -875,9 +881,9 @@ SkinnedMeshRenderer: m_SkinnedMotionVectors: 1 m_Mesh: {fileID: 4300002, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} m_Bones: - - {fileID: 499662} + - {fileID: 4023718469717780} m_BlendShapeWeights: [] - m_RootBone: {fileID: 499662} + m_RootBone: {fileID: 4023718469717780} m_AABB: m_Center: {x: 0.00022322498, y: -0.004294172, z: -0.011436155} m_Extent: {x: 0.013697366, y: 0.0092213, z: 0.012605751} @@ -1066,6 +1072,39 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1365665863623068 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4922541072726130} + m_Layer: 5 + m_Name: TriggerTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1603997552537722 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4023718469717780} + - component: {fileID: 65318774059041546} + - component: {fileID: 114543264181638874} + - component: {fileID: 114015681421713280} + m_Layer: 5 + m_Name: lctrl:b_trigger + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!4 &4000010810114962 Transform: m_ObjectHideFlags: 1 @@ -1131,6 +1170,68 @@ Transform: m_Father: {fileID: 436998} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 90, y: 8, z: 0} +--- !u!4 &4023718469717780 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1603997552537722} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.0006312649, y: 0.023094632, z: -0.008431792} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 498550} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4922541072726130 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1365665863623068} + m_LocalRotation: {x: -0.000000009313225, y: -0.99875486, z: 0.00000008940696, w: -0.049887232} + m_LocalPosition: {x: -0.0127, y: 0.0597, z: 0.014} + m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005} + m_Children: [] + m_Father: {fileID: 498550} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: -185.719, z: 0} +--- !u!65 &65318774059041546 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1603997552537722} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.027765447, y: 0.016550489, z: 0.024621258} + m_Center: {x: 0.000057838857, y: -0.003146829, z: -0.011298977} +--- !u!65 &65403493955253320 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 117230} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.019283134, y: 0.028666984, z: 0.025938202} + m_Center: {x: 0.0006553563, y: 0.024918877, z: -0.02661042} +--- !u!65 &65524402868567802 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 172048} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0138321975, y: 0.023385666, z: 0.01187079} + m_Center: {x: -0.006514117, y: -0.0015480702, z: -0.00021664354} --- !u!114 &114000013861093962 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1148,3 +1249,64 @@ MonoBehaviour: m_PreviewOrigin: {fileID: 4000012123783760} m_FieldGrabOrigin: {fileID: 4000010810114962} m_MeshRoot: {fileID: 485484} + m_Buttons: + - m_Control: 2 + m_Transform: {fileID: 4023718469717780} + m_Renderer: {fileID: 13787692} + - m_Control: 3 + m_Transform: {fileID: 450394} + m_Renderer: {fileID: 13767942} +--- !u!114 &114015681421713280 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1603997552537722} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4922541072726130} + m_TooltipSource: {fileID: 4023718469717780} + m_TooltipAlignment: 1 +--- !u!114 &114126251981801024 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 172048} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 499662} + m_TooltipSource: {fileID: 450394} + m_TooltipAlignment: 1 +--- !u!114 &114543264181638874 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1603997552537722} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114692086924928774 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 172048} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 diff --git a/Prefabs/Proxies/RightTouch.prefab b/Prefabs/Proxies/RightTouch.prefab index bf21bca81..23d5e988c 100644 --- a/Prefabs/Proxies/RightTouch.prefab +++ b/Prefabs/Proxies/RightTouch.prefab @@ -24,6 +24,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 431526} + - component: {fileID: 65698481663436802} + - component: {fileID: 114713234785505344} + - component: {fileID: 114710602601813986} m_Layer: 0 m_Name: rctrl:b_hold m_TagString: ShowInMiniWorld @@ -195,6 +198,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 482366} + - component: {fileID: 65543380702871742} + - component: {fileID: 114643829396939542} + - component: {fileID: 114431176106213124} m_Layer: 0 m_Name: rctrl:b_trigger m_TagString: ShowInMiniWorld @@ -448,6 +454,8 @@ Transform: - {fileID: 431526} - {fileID: 451284} - {fileID: 482366} + - {fileID: 4512895743762768} + - {fileID: 4733308111900852} m_Father: {fileID: 484770} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1066,6 +1074,36 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1172441472411894 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4512895743762768} + m_Layer: 5 + m_Name: GripTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1339159515951860 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4733308111900852} + m_Layer: 5 + m_Name: TriggerTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!4 &4000010594257346 Transform: m_ObjectHideFlags: 1 @@ -1131,6 +1169,56 @@ Transform: m_Father: {fileID: 401760} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: -8, z: 0} +--- !u!4 &4512895743762768 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1172441472411894} + m_LocalRotation: {x: -0.016156727, y: 0.99761605, z: -0.059107296, w: -0.031740725} + m_LocalPosition: {x: 0.0536, y: -0.0241, z: -0.0261} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 449518} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 6.8320003, y: -176.453, z: -361.644} +--- !u!4 &4733308111900852 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1339159515951860} + m_LocalRotation: {x: -6.120436e-17, y: -0.9995429, z: 0.000000059604638, w: 0.030231994} + m_LocalPosition: {x: 0.0127, y: 0.05970001, z: 0.013999991} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 449518} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: -176.535, z: 0} +--- !u!65 &65543380702871742 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 161524} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.027765447, y: 0.016550489, z: 0.024621258} + m_Center: {x: 0.000057838857, y: -0.003146829, z: -0.011298977} +--- !u!65 &65698481663436802 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 118028} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0138321975, y: 0.023385666, z: 0.01187079} + m_Center: {x: 0.006514117, y: -0.0015480702, z: -0.00021664354} --- !u!114 &114000011379258124 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1148,3 +1236,64 @@ MonoBehaviour: m_PreviewOrigin: {fileID: 4000013824268610} m_FieldGrabOrigin: {fileID: 4000013218449236} m_MeshRoot: {fileID: 484770} + m_Buttons: + - m_Control: 2 + m_Transform: {fileID: 482366} + m_Renderer: {fileID: 13788364} + - m_Control: 3 + m_Transform: {fileID: 431526} + m_Renderer: {fileID: 13791512} +--- !u!114 &114431176106213124 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 161524} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4733308111900852} + m_TooltipSource: {fileID: 482366} + m_TooltipAlignment: 1 +--- !u!114 &114643829396939542 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 161524} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114710602601813986 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 118028} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4512895743762768} + m_TooltipSource: {fileID: 431526} + m_TooltipAlignment: 1 +--- !u!114 &114713234785505344 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 118028} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index 4bfd2fb8a..e92717fac 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -11,10 +11,20 @@ namespace UnityEditor.Experimental.EditorVR.Proxies sealed class ProxyHelper : MonoBehaviour { [Serializable] - class ButtonObject + public class ButtonObject { - public VRInputDevice.VRControl control; - public Renderer renderer; + [SerializeField] + VRInputDevice.VRControl m_Control; + + [SerializeField] + Transform m_Transform; + + [SerializeField] + Renderer m_Renderer; + + public VRInputDevice.VRControl control { get { return m_Control; } } + public Transform transform { get { return m_Transform; } } + public Renderer renderer { get { return m_Renderer; } } } /// @@ -85,6 +95,8 @@ public Transform meshRoot [SerializeField] ButtonObject[] m_Buttons; + + public ButtonObject[] buttons { get { return m_Buttons; } } } } #endif diff --git a/Scripts/Interfaces/Capability/IFeedbackReciever.cs b/Scripts/Interfaces/Capability/IFeedbackReciever.cs index 418f69947..27a1f544d 100644 --- a/Scripts/Interfaces/Capability/IFeedbackReciever.cs +++ b/Scripts/Interfaces/Capability/IFeedbackReciever.cs @@ -6,18 +6,9 @@ namespace UnityEditor.Experimental.EditorVR /// public interface IFeedbackReciever { - void ClearFeedbackRequests(object caller); - } - - /// - /// - /// Implementors can receive Feedback Requests that extend IFeedbackRequest - /// - /// - public interface IFeedbackReciever : IFeedbackReciever where TFeedbackRequest : FeedbackRequest - { - void AddFeedbackRequest(TFeedbackRequest request); - void RemoveFeedbackRequest(TFeedbackRequest request); + void AddFeedbackRequest(FeedbackRequest request); + void RemoveFeedbackRequest(FeedbackRequest request); + void ClearFeedbackRequests(IRequestFeedback caller); } } #endif diff --git a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs index 595a9cf67..7c2faa9b4 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs @@ -8,26 +8,25 @@ public interface IRequestFeedback public static class IRequestFeedbackMethods { - public delegate void AddFeedbackRequestDelegate(FeedbackRequest request, object caller, int priority = 0); - public delegate void RemoveFeedbackRequestDelegate(FeedbackRequest request); - - public static AddFeedbackRequestDelegate addFeedbackRequest { private get; set; } + public static Action addFeedbackRequest { private get; set; } public static Action removeFeedbackRequest { private get; set; } - public static Action clearFeedbackRequests { private get; set; } + public static Action clearFeedbackRequests { private get; set; } - public static void AddFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request, object caller, int priority = 0) where TFeedbackRequest : FeedbackRequest + public static void AddFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request) where TFeedbackRequest : FeedbackRequest { - addFeedbackRequest(request, caller, priority); + request.caller = obj; + addFeedbackRequest(request); } public static void RemoveFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request) where TFeedbackRequest : FeedbackRequest { + request.caller = obj; removeFeedbackRequest(request); } - public static void ClearFeedbackRequests(this IRequestFeedback obj, Type feedbackType, object caller) + public static void ClearFeedbackRequests(this IRequestFeedback obj) { - clearFeedbackRequests(caller); + clearFeedbackRequests(obj); } } } diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index 760e6c99b..faade8d1c 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -1,7 +1,5 @@ #if UNITY_EDITOR -using System; using System.Collections.Generic; -using System.Linq; using UnityEditor.Experimental.EditorVR.Core; using UnityEngine; @@ -9,13 +7,12 @@ namespace UnityEditor.Experimental.EditorVR { public abstract class FeedbackRequest { - internal object caller; - internal int priority; + public IRequestFeedback caller; } public class FeedbackModule : MonoBehaviour, IInterfaceConnector { - readonly Dictionary> m_FeedbackReceivers = new Dictionary>(); + readonly List m_FeedbackReceivers = new List(); void Awake() { @@ -28,86 +25,37 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) { var feedbackReceiver = obj as IFeedbackReciever; if (feedbackReceiver != null) - { - var requestType = obj.GetType().GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IFeedbackReciever<>)) - .SelectMany(i => i.GetGenericArguments()) - .First(); - if (requestType != null) - { - List recievers; - if (!m_FeedbackReceivers.TryGetValue(requestType, out recievers)) - { - recievers = new List(); - m_FeedbackReceivers[requestType] = recievers; - } - - recievers.Add(feedbackReceiver); - } - } + m_FeedbackReceivers.Add(feedbackReceiver); } public void DisconnectInterface(object obj, Transform rayOrigin = null) { var feedbackReceiver = obj as IFeedbackReciever; if (feedbackReceiver != null) - { - var requestType = obj.GetType().GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IFeedbackReciever<>)) - .SelectMany(i => i.GetGenericArguments()) - .First(); - if (requestType != null) - { - List recievers; - if (m_FeedbackReceivers.TryGetValue(requestType, out recievers)) - { - recievers.Remove(feedbackReceiver); - - if (recievers.Count == 0) - m_FeedbackReceivers.Remove(requestType); - } - } - } + m_FeedbackReceivers.Remove(feedbackReceiver); } - void AddFeedbackRequest(FeedbackRequest request, object caller, int priority = 0) + void AddFeedbackRequest(FeedbackRequest request) { - var requestType = request.GetType(); - List recievers; - if (m_FeedbackReceivers.TryGetValue(requestType, out recievers)) + foreach (var receiver in m_FeedbackReceivers) { - foreach (var obj in recievers) - { - request.caller = caller; - request.priority = priority; - var receiver = (IFeedbackReciever)obj; - receiver.AddFeedbackRequest(request); - } + receiver.AddFeedbackRequest(request); } } public void RemoveFeedbackRequest(FeedbackRequest request) { - var requestType = request.GetType(); - List recievers; - if (m_FeedbackReceivers.TryGetValue(requestType, out recievers)) + foreach (var receiver in m_FeedbackReceivers) { - foreach (var obj in recievers) - { - var receiver = (IFeedbackReciever)obj; - receiver.RemoveFeedbackRequest(request); - } + receiver.RemoveFeedbackRequest(request); } } - public void ClearFeedbackRequests(object caller) + public void ClearFeedbackRequests(IRequestFeedback caller) { - foreach (var obj in m_FeedbackReceivers) + foreach (var reciever in m_FeedbackReceivers) { - foreach (var reciever in obj.Value) - { - reciever.ClearFeedbackRequests(caller); - } + reciever.ClearFeedbackRequests(caller); } } } diff --git a/Scripts/Modules/HighlightModule/HighlightModule.cs b/Scripts/Modules/HighlightModule/HighlightModule.cs index f65d0c1fb..8d6193ff2 100644 --- a/Scripts/Modules/HighlightModule/HighlightModule.cs +++ b/Scripts/Modules/HighlightModule/HighlightModule.cs @@ -1,6 +1,7 @@ #if UNITY_EDITOR using System; using System.Collections.Generic; +using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -18,8 +19,7 @@ sealed class HighlightModule : MonoBehaviour, IUsesGameObjectLocking readonly Dictionary> m_Highlights = new Dictionary>(); readonly Dictionary> m_NodeMap = new Dictionary>(); - - static Mesh s_BakedMesh; + static readonly Dictionary m_BakedMeshes = new Dictionary(); public event Func customHighlight { @@ -36,8 +36,6 @@ public Color highlightColor void Awake() { - s_BakedMesh = new Mesh(); - m_RayHighlightMaterial = Instantiate(m_RayHighlightMaterial); if (EditorPrefs.HasKey(k_SelectionOutlinePrefsKey)) { @@ -93,13 +91,20 @@ static void HighlightObject(GameObject go, Material material) if (skinnedMeshRenderer.sharedMesh == null) continue; - skinnedMeshRenderer.BakeMesh(s_BakedMesh); + Mesh bakedMesh; + if (!m_BakedMeshes.TryGetValue(skinnedMeshRenderer, out bakedMesh)) + { + bakedMesh = new Mesh(); + m_BakedMeshes[skinnedMeshRenderer] = bakedMesh; + } + + skinnedMeshRenderer.BakeMesh(bakedMesh); - var localToWorldMatrix = skinnedMeshRenderer.transform.localToWorldMatrix; + var localToWorldMatrix = skinnedMeshRenderer.transform.localToWorldMatrix * Matrix4x4.Scale(skinnedMeshRenderer.transform.lossyScale.Inverse()); var layer = skinnedMeshRenderer.gameObject.layer; - for (var i = 0; i < s_BakedMesh.subMeshCount; i++) + for (var i = 0; i < bakedMesh.subMeshCount; i++) { - Graphics.DrawMesh(s_BakedMesh, localToWorldMatrix, material, layer, null, i); + Graphics.DrawMesh(bakedMesh, localToWorldMatrix, material, layer, null, i); } } } @@ -157,6 +162,10 @@ public void SetHighlight(GameObject go, bool active, Transform rayOrigin = null, gameObjects.Remove(go); } } + + var skinnedMeshRenderer = go.GetComponent(); + if (skinnedMeshRenderer) + m_BakedMeshes.Remove(skinnedMeshRenderer); } } } diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index 40a2763de..dcae4cc0b 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -8,14 +8,6 @@ namespace UnityEditor.Experimental.EditorVR.Modules { sealed class TooltipModule : MonoBehaviour, IUsesViewerScale { - public class Tooltip : ITooltip, ITooltipPlacement - { - public string tooltipText { get; set; } - public Transform tooltipTarget { get; set; } - public Transform tooltipSource { get; set; } - public TextAlignment tooltipAlignment { get; set; } - } - const float k_Delay = 0; // In case we want to bring back a delay const float k_TransitionDuration = 0.1f; const float k_UVScale = 100f; diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 5abf70774..b6806e04d 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -2,7 +2,10 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEditor.Experimental.EditorVR.Input; +using UnityEditor.Experimental.EditorVR.Modules; +using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; @@ -11,12 +14,13 @@ namespace UnityEditor.Experimental.EditorVR.Proxies { public class ProxyFeedbackRequest : FeedbackRequest { + public int priority; public VRInputDevice.VRControl control; public Node node; - public ITooltip tooltip; + public string tooltipText; } - abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility + abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility, ISetHighlight { const int k_RendererQueue = 9000; @@ -31,23 +35,20 @@ abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever m_Materials = new List(); + readonly List m_FeedbackRequests = new List(); protected Dictionary m_RayOrigins; List m_ProxyMeshRoots = new List(); + readonly Dictionary> m_Buttons = new Dictionary>(); + + public Transform leftHand { get { return m_LeftHand; } } + public Transform rightHand { get { return m_RightHand; } } + public virtual Dictionary rayOrigins { get { return m_RayOrigins; } } public virtual TrackedObject trackedObjectInput { protected get; set; } @@ -91,6 +92,23 @@ public virtual void Awake() m_ProxyMeshRoots.Add(leftProxyHelper.meshRoot); m_ProxyMeshRoots.Add(rightProxyHelper.meshRoot); + var leftButtons = new Dictionary(); + foreach (var button in leftProxyHelper.buttons) + { + leftButtons[button.control] = button; + } + m_Buttons[Node.LeftHand] = leftButtons; + + var rightButtons = new Dictionary(); + foreach (var button in rightProxyHelper.buttons) + { + rightButtons[button.control] = button; + } + m_Buttons[Node.RightHand] = rightButtons; + + //m_LeftButtons = leftProxyHelper.buttons; + //m_RightButtons = rightProxyHelper.buttons; + m_RayOrigins = new Dictionary { { Node.LeftHand, leftProxyHelper.rayOrigin }, @@ -169,23 +187,79 @@ public virtual void Update() } } - public void AddFeedbackRequest(ProxyFeedbackRequest request) + public void AddFeedbackRequest(FeedbackRequest request) { - Debug.Log(request); - if (request.tooltip != null) + var proxyRequest = request as ProxyFeedbackRequest; + if (proxyRequest != null) { - this.ShowTooltip(request.tooltip); + Dictionary buttons; + if (m_Buttons.TryGetValue(proxyRequest.node, out buttons)) + { + ProxyHelper.ButtonObject button; + if (buttons.TryGetValue(proxyRequest.control, out button)) + { + if (button.renderer) + this.SetHighlight(button.renderer.gameObject, true); + + if (button.transform) + { + var tooltip = button.transform.GetComponent(); + var tooltipText = proxyRequest.tooltipText; + if (!string.IsNullOrEmpty(tooltipText) && tooltip) + { + tooltip.tooltipText = tooltipText; + this.ShowTooltip(tooltip); + } + } + } + } + + m_FeedbackRequests.Add(proxyRequest); + } + } + + public void RemoveFeedbackRequest(FeedbackRequest request) + { + var proxyRequest = request as ProxyFeedbackRequest; + if (proxyRequest != null) + { + RemoveFeedbackRequest(proxyRequest); } } - public void RemoveFeedbackRequest(ProxyFeedbackRequest request) + void RemoveFeedbackRequest(ProxyFeedbackRequest request) { - Debug.Log(request); + Dictionary buttons; + if (m_Buttons.TryGetValue(request.node, out buttons)) + { + ProxyHelper.ButtonObject button; + if (buttons.TryGetValue(request.control, out button)) + { + if (button.renderer) + this.SetHighlight(button.renderer.gameObject, false); + + if (button.transform) + { + var tooltip = button.transform.GetComponent(); + if (tooltip) + { + tooltip.tooltipText = string.Empty; + this.HideTooltip(tooltip); + } + } + } + } + + m_FeedbackRequests.Remove(request); } - public void ClearFeedbackRequests(object caller) + public void ClearFeedbackRequests(IRequestFeedback caller) { - Debug.Log(caller); + var requests = m_FeedbackRequests.Where(feedbackRequest => feedbackRequest.caller == caller).ToList(); + foreach (var feedbackRequest in requests) + { + RemoveFeedbackRequest(feedbackRequest); + } } } } diff --git a/Scripts/Utilities/IntersectionUtils.cs b/Scripts/Utilities/IntersectionUtils.cs index f3056f69f..c4ea2116e 100644 --- a/Scripts/Utilities/IntersectionUtils.cs +++ b/Scripts/Utilities/IntersectionUtils.cs @@ -1,4 +1,5 @@ #if UNITY_EDITOR +using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; @@ -185,7 +186,10 @@ public static void SetupCollisionTester(MeshCollider collisionTester, Transform { var mf = obj.GetComponent(); if (mf) + { collisionTester.sharedMesh = mf.sharedMesh; + collisionTester.transform.localScale = Vector3.one; + } if (!mf) { @@ -194,6 +198,7 @@ public static void SetupCollisionTester(MeshCollider collisionTester, Transform { smr.BakeMesh(BakedMesh); collisionTester.sharedMesh = BakedMesh; + collisionTester.transform.localScale = obj.transform.lossyScale.Inverse(); } } } diff --git a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs index f38b6e8a8..921f12fd8 100644 --- a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs +++ b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs @@ -1,4 +1,5 @@ #if UNITY_EDITOR +using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; @@ -8,7 +9,7 @@ namespace UnityEditor.Experimental.EditorVR.Tools [MainMenuItem("Primitive", "Create", "Create primitives in the scene")] sealed class CreatePrimitiveTool : MonoBehaviour, ITool, IStandardActionMap, IConnectInterfaces, IInstantiateMenuUI, IUsesRayOrigin, IUsesSpatialHash, IUsesViewerScale, ISelectTool, IIsHoveringOverUI, IIsMainMenuVisible, - IRayVisibilitySettings + IRayVisibilitySettings, IRequestFeedback, IUsesNode { [SerializeField] CreatePrimitiveMenu m_MenuPrefab; @@ -28,6 +29,7 @@ sealed class CreatePrimitiveTool : MonoBehaviour, ITool, IStandardActionMap, ICo PrimitiveCreationStates m_State = PrimitiveCreationStates.StartPoint; public Transform rayOrigin { get; set; } + public Node? node { get; set; } enum PrimitiveCreationStates { @@ -43,6 +45,13 @@ void Start() this.ConnectInterfaces(createPrimitiveMenu, rayOrigin); createPrimitiveMenu.selectPrimitive = SetSelectedPrimitive; createPrimitiveMenu.close = Close; + + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + node = node.Value, + control = VRInputDevice.VRControl.Trigger1, + tooltipText = "Draw" + }); } public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) @@ -162,6 +171,7 @@ void OnDestroy() return; this.RemoveRayVisibilitySettings(rayOrigin, this); + this.ClearFeedbackRequests(); } } } diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 6c0afd3fb..cd4d9a4de 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -179,11 +179,19 @@ void Start() var viewerScaleObject = ObjectUtils.Instantiate(m_ViewerScaleVisualsPrefab, cameraRig, false); m_ViewerScaleVisuals = viewerScaleObject.GetComponent(); viewerScaleObject.SetActive(false); + + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + node = node.Value, + control = VRInputDevice.VRControl.Trigger2, + tooltipText = "Crawl" + }); } void OnDestroy() { this.RemoveRayVisibilitySettings(rayOrigin, this); + this.ClearFeedbackRequests(); if (m_ViewerScaleVisuals) ObjectUtils.Destroy(m_ViewerScaleVisuals.gameObject); @@ -191,20 +199,8 @@ void OnDestroy() public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { - var firstFrame = m_LocomotionInput == null; m_LocomotionInput = (LocomotionInput)input; - if (firstFrame && m_LocomotionInput != null) - { - Debug.Log("asdf"); - this.AddFeedbackRequest(new ProxyFeedbackRequest - { - node = node.Value, - control = VRInputDevice.VRControl.Trigger2, - tooltip = new TooltipModule.Tooltip { tooltipText = "text" } - }, this); - } - if (DoTwoHandedScaling(consumeControl)) return; From cd14ea937cbb12c24ef530f17f0c69c797613a02 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 19 Sep 2017 09:06:03 -0700 Subject: [PATCH 018/457] Add duration parameters to highlights and tooltips to auto-hide feedback 5 seconds after it is shown --- .../FunctionalityInjection/ISetHighlight.cs | 9 +-- .../ISetTooltipVisibility.cs | 20 ++++--- .../HighlightModule/HighlightModule.cs | 56 ++++++++++++++----- .../Modules/TooltipModule/TooltipModule.cs | 26 +++++++-- Scripts/Proxies/TwoHandedProxyBase.cs | 13 ++--- 5 files changed, 84 insertions(+), 40 deletions(-) diff --git a/Scripts/Interfaces/FunctionalityInjection/ISetHighlight.cs b/Scripts/Interfaces/FunctionalityInjection/ISetHighlight.cs index a195ab57d..ef9753ccb 100644 --- a/Scripts/Interfaces/FunctionalityInjection/ISetHighlight.cs +++ b/Scripts/Interfaces/FunctionalityInjection/ISetHighlight.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using UnityEngine; namespace UnityEditor.Experimental.EditorVR @@ -12,7 +12,7 @@ public interface ISetHighlight public static class ISetHighlightMethods { - internal delegate void SetHighlightDelegate(GameObject go, bool active, Transform rayOrigin = null, Material material = null, bool force = false); + internal delegate void SetHighlightDelegate(GameObject go, bool active, Transform rayOrigin = null, Material material = null, bool force = false, float duration = 0f); internal static SetHighlightDelegate setHighlight { get; set; } @@ -24,9 +24,10 @@ public static class ISetHighlightMethods /// RayOrigin that hovered over the object (optional) /// Custom material to use for this object /// Force the setting or unsetting of the highlight - public static void SetHighlight(this ISetHighlight obj, GameObject go, bool active, Transform rayOrigin = null, Material material = null, bool force = false) + /// The duration for which to show this highlight. Keep default value of 0 to show until explicitly hidden + public static void SetHighlight(this ISetHighlight obj, GameObject go, bool active, Transform rayOrigin = null, Material material = null, bool force = false, float duration = 0f) { - setHighlight(go, active, rayOrigin, material, force); + setHighlight(go, active, rayOrigin, material, force, duration); } } } diff --git a/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs b/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs index 086b7441b..c5c925d04 100644 --- a/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs +++ b/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; namespace UnityEditor.Experimental.EditorVR @@ -12,25 +12,31 @@ public interface ISetTooltipVisibility public static class ISetTooltipVisibilityMethods { - internal static Action showTooltip { get; set; } - internal static Action hideTooltip { get; set; } + public delegate void ShowTooltipDelegate(ITooltip tooltip, bool persistent = false, float duration = 0f); + public delegate void HideTooltipDelegate(ITooltip tooltip, bool persistent = false); + + internal static ShowTooltipDelegate showTooltip { get; set; } + internal static HideTooltipDelegate hideTooltip { get; set; } /// /// Show the given Tooltip /// /// The tooltip to show - public static void ShowTooltip(this ISetTooltipVisibility obj, ITooltip tooltip) + /// Whether the tooltip should stay visible regardless of raycasts + /// If the tooltip is shown persistently, and duration is > 0, hide after the duration, in seconds + public static void ShowTooltip(this ISetTooltipVisibility obj, ITooltip tooltip, bool persistent = false, float duration = 0f) { - showTooltip(tooltip); + showTooltip(tooltip, persistent, duration); } /// /// Hide the given Tooltip /// /// The tooltip to hide - public static void HideTooltip(this ISetTooltipVisibility obj, ITooltip tooltip) + /// Whether to hide the tooltip if it was shown with the persistent argument set to true + public static void HideTooltip(this ISetTooltipVisibility obj, ITooltip tooltip, bool persistent = false) { - hideTooltip(tooltip); + hideTooltip(tooltip, persistent); } } diff --git a/Scripts/Modules/HighlightModule/HighlightModule.cs b/Scripts/Modules/HighlightModule/HighlightModule.cs index 8d6193ff2..456f31387 100644 --- a/Scripts/Modules/HighlightModule/HighlightModule.cs +++ b/Scripts/Modules/HighlightModule/HighlightModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Extensions; @@ -9,17 +9,27 @@ namespace UnityEditor.Experimental.EditorVR.Modules { sealed class HighlightModule : MonoBehaviour, IUsesGameObjectLocking { + class HighlightData + { + public float startTime; + public float duration; + } + const string k_SelectionOutlinePrefsKey = "Scene/Selected Outline"; + static readonly Dictionary m_BakedMeshes = new Dictionary(); + [SerializeField] Material m_DefaultHighlightMaterial; [SerializeField] Material m_RayHighlightMaterial; - readonly Dictionary> m_Highlights = new Dictionary>(); + readonly Dictionary> m_Highlights = new Dictionary>(); readonly Dictionary> m_NodeMap = new Dictionary>(); - static readonly Dictionary m_BakedMeshes = new Dictionary(); + + // Local method use only -- created here to reduce garbage collection + readonly List> m_HighlightsToRemove = new List>(); public event Func customHighlight { @@ -47,15 +57,25 @@ void Awake() void LateUpdate() { + m_HighlightsToRemove.Clear(); foreach (var highlight in m_Highlights) { var material = highlight.Key; var highlights = highlight.Value; - foreach (var go in highlights) + foreach (var kvp in highlights) { + var go = kvp.Key; if (go == null) continue; + var highlightData = kvp.Value; + if (highlightData.duration > 0) + { + var visibleTime = Time.time - highlightData.startTime; + if (visibleTime > highlightData.duration) + m_HighlightsToRemove.Add(new KeyValuePair(material, go)); + } + var shouldHighlight = true; for (int i = 0; i < m_CustomHighlightFuncs.Count; i++) { @@ -68,6 +88,13 @@ void LateUpdate() HighlightObject(go, material); } } + + foreach (var kvp in m_HighlightsToRemove) + { + var highlights = m_Highlights[kvp.Key]; + if (highlights.Remove(kvp.Value) && highlights.Count == 0) + m_Highlights.Remove(kvp.Key); + } } static void HighlightObject(GameObject go, Material material) @@ -121,7 +148,7 @@ public void AddRayOriginForNode(Node node, Transform rayOrigin) set.Add(rayOrigin); } - public void SetHighlight(GameObject go, bool active, Transform rayOrigin = null, Material material = null, bool force = false) + public void SetHighlight(GameObject go, bool active, Transform rayOrigin = null, Material material = null, bool force = false, float duration = 0f) { if (go == null) return; @@ -136,13 +163,14 @@ public void SetHighlight(GameObject go, bool active, Transform rayOrigin = null, if (active) // Highlight { - HashSet gameObjects; - if (!m_Highlights.TryGetValue(material, out gameObjects)) + Dictionary highlights; + if (!m_Highlights.TryGetValue(material, out highlights)) { - gameObjects = new HashSet(); - m_Highlights[material] = gameObjects; + highlights = new Dictionary(); + m_Highlights[material] = highlights; } - gameObjects.Add(go); + + highlights[go] = new HighlightData { startTime = Time.time, duration = duration }; } else // Unhighlight { @@ -156,11 +184,9 @@ public void SetHighlight(GameObject go, bool active, Transform rayOrigin = null, } else { - HashSet gameObjects; - if (m_Highlights.TryGetValue(material, out gameObjects)) - { - gameObjects.Remove(go); - } + Dictionary highlights; + if (m_Highlights.TryGetValue(material, out highlights)) + highlights.Remove(go); } var skinnedMeshRenderer = go.GetComponent(); diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index dcae4cc0b..a19c765da 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System.Collections; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Utilities; @@ -30,6 +30,8 @@ class TooltipData { public float startTime; public TooltipUI tooltipUI; + public bool persistent; + public float duration; } readonly Dictionary m_Tooltips = new Dictionary(); @@ -58,7 +60,7 @@ void Update() { var tooltip = kvp.Key; var tooltipData = kvp.Value; - var hoverTime = Time.realtimeSinceStartup - tooltipData.startTime; + var hoverTime = Time.time - tooltipData.startTime; if (hoverTime > k_Delay) { var placement = tooltip as ITooltipPlacement; @@ -91,11 +93,18 @@ void Update() if (!IsValidTooltip(tooltip)) m_TooltipsToHide.Add(tooltip); + + if (tooltipData.persistent) + { + var duration = tooltipData.duration; + if (duration > 0 && hoverTime + k_Delay > duration) + m_TooltipsToHide.Add(tooltip); + } } foreach (var tooltip in m_TooltipsToHide) { - HideTooltip(tooltip); + HideTooltip(tooltip, true); } } @@ -216,7 +225,7 @@ public void OnRayExited(GameObject gameObject, RayEventData eventData) } } - public void ShowTooltip(ITooltip tooltip) + public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duration = 0f) { if (!IsValidTooltip(tooltip)) return; @@ -226,7 +235,9 @@ public void ShowTooltip(ITooltip tooltip) m_Tooltips[tooltip] = new TooltipData { - startTime = Time.realtimeSinceStartup + startTime = Time.time, + persistent = persistent, + duration = duration }; } @@ -235,11 +246,14 @@ static bool IsValidTooltip(ITooltip tooltip) return !string.IsNullOrEmpty(tooltip.tooltipText); } - public void HideTooltip(ITooltip tooltip) + public void HideTooltip(ITooltip tooltip, bool persistent = false) { TooltipData tooltipData; if (m_Tooltips.TryGetValue(tooltip, out tooltipData)) { + if (!persistent && tooltipData.persistent) + return; + m_Tooltips.Remove(tooltip); if (tooltipData.tooltipUI) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index b6806e04d..0230bd009 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -1,10 +1,9 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Input; -using UnityEditor.Experimental.EditorVR.Modules; using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -23,6 +22,7 @@ public class ProxyFeedbackRequest : FeedbackRequest abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility, ISetHighlight { const int k_RendererQueue = 9000; + const float k_FeedbackDuration = 5f; [SerializeField] protected GameObject m_LeftHandProxyPrefab; @@ -106,9 +106,6 @@ public virtual void Awake() } m_Buttons[Node.RightHand] = rightButtons; - //m_LeftButtons = leftProxyHelper.buttons; - //m_RightButtons = rightProxyHelper.buttons; - m_RayOrigins = new Dictionary { { Node.LeftHand, leftProxyHelper.rayOrigin }, @@ -199,7 +196,7 @@ public void AddFeedbackRequest(FeedbackRequest request) if (buttons.TryGetValue(proxyRequest.control, out button)) { if (button.renderer) - this.SetHighlight(button.renderer.gameObject, true); + this.SetHighlight(button.renderer.gameObject, true, duration: k_FeedbackDuration); if (button.transform) { @@ -208,7 +205,7 @@ public void AddFeedbackRequest(FeedbackRequest request) if (!string.IsNullOrEmpty(tooltipText) && tooltip) { tooltip.tooltipText = tooltipText; - this.ShowTooltip(tooltip); + this.ShowTooltip(tooltip, true, k_FeedbackDuration); } } } @@ -244,7 +241,7 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) if (tooltip) { tooltip.tooltipText = string.Empty; - this.HideTooltip(tooltip); + this.HideTooltip(tooltip, true); } } } From 55d68b6416799d7bf72194b18011c6548be174a9 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 19 Sep 2017 23:06:51 -0700 Subject: [PATCH 019/457] WIP commit fleshing out feedback --- Scripts/Proxies/TwoHandedProxyBase.cs | 22 +++- Tools/LocomotionTool/LocomotionTool.cs | 134 +++++++++++++++++++++++-- 2 files changed, 149 insertions(+), 7 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 0230bd009..2a53919cf 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -46,6 +46,9 @@ abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, IS readonly Dictionary> m_Buttons = new Dictionary>(); + // Local method use only -- created here to reduce garbage collection + readonly List m_FeedbackToRemove = new List(); + public Transform leftHand { get { return m_LeftHand; } } public Transform rightHand { get { return m_RightHand; } } @@ -61,7 +64,6 @@ public event Action activeChanged remove { m_InputToEvents.activeChanged -= value; } } - public virtual bool hidden { set @@ -189,6 +191,24 @@ public void AddFeedbackRequest(FeedbackRequest request) var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) { + m_FeedbackToRemove.Clear(); + foreach (var existingRequest in new List(m_FeedbackRequests)) + { + if (existingRequest.node == proxyRequest.node + && existingRequest.control == proxyRequest.control) + { + if (existingRequest.priority <= proxyRequest.priority) + RemoveFeedbackRequest(existingRequest); + else + return; + } + } + + foreach (var feedback in m_FeedbackToRemove) + { + RemoveFeedbackRequest(feedback); + } + Dictionary buttons; if (m_Buttons.TryGetValue(proxyRequest.node, out buttons)) { diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index cd4d9a4de..a7b5cc562 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -1,7 +1,8 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Modules; using UnityEditor.Experimental.EditorVR.Proxies; @@ -95,6 +96,8 @@ class Preferences Toggle m_BlinkToggle; bool m_BlockValueChangedListener; + readonly Dictionary> m_Controls = new Dictionary>(); + public ActionMap actionMap { get { return m_BlinkActionMap; } } public Transform rayOrigin { get; set; } @@ -180,12 +183,59 @@ void Start() m_ViewerScaleVisuals = viewerScaleObject.GetComponent(); viewerScaleObject.SetActive(false); - this.AddFeedbackRequest(new ProxyFeedbackRequest + var actions = m_BlinkActionMap.actions; + foreach (var scheme in m_BlinkActionMap.controlSchemes) { - node = node.Value, - control = VRInputDevice.VRControl.Trigger2, - tooltipText = "Crawl" - }); + var bindings = scheme.bindings; + for (var i = 0; i < bindings.Count; i++) + { + var binding = bindings[i]; + var action = actions[i].name; + List controls; + if (!m_Controls.TryGetValue(action, out controls)) + { + controls = new List(); + m_Controls[action] = controls; + } + + foreach (var source in binding.sources) + { + m_Controls[action].Add((VRInputDevice.VRControl)source.controlIndex); + } + } + } + + var defaultControls = new [] { "Crawl", "Blink", "Speed" }; + + foreach (var control in defaultControls) + { + List ids; + if (m_Controls.TryGetValue(control, out ids)) + { + foreach (var id in ids) + { + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + node = node.Value, + control = id, + tooltipText = TooltipForControl(control) + }); + } + } + } + } + + string TooltipForControl(string controlName) + { + switch (controlName.ToLower()) + { + case "blink": + return m_Preferences.blinkMode ? "Blink" : "Fly"; + case "speed": + return m_Preferences.blinkMode ? "Extra distace" : "Extra speed"; + default: + return controlName; + } } void OnDestroy() @@ -319,6 +369,9 @@ bool DoCrawl(ConsumeControlDelegate consumeControl) m_StartCrawling = true; m_ActualRayOriginStartPosition = m_RayOriginStartPosition; m_CrawlStartTime = Time.time; + + ShowScaleFeedback(); + ShowRotateFeedback(); } var localRayPosition = cameraRig.position - rayOrigin.position; @@ -348,6 +401,9 @@ bool DoCrawl(ConsumeControlDelegate consumeControl) bool DoBlink(ConsumeControlDelegate consumeControl) { + if (m_LocomotionInput.blink.wasJustPressed) + ShowRotateFeedback(); + if (m_LocomotionInput.blink.isHeld) { this.AddRayVisibilitySettings(rayOrigin, this, false, false); @@ -439,6 +495,8 @@ bool DoTwoHandedScaling(ConsumeControlDelegate consumeControl) m_ViewerScaleVisuals.leftHand = rayOrigin; m_ViewerScaleVisuals.rightHand = otherRayOrigin; m_ViewerScaleVisuals.gameObject.SetActive(true); + + ShowResetScaleFeedback(); } m_Scaling = true; @@ -582,6 +640,70 @@ IEnumerator MoveTowardTarget(Vector3 targetPosition) m_BlinkMoving = false; } + void ShowRotateFeedback() + { + List ids; + if (m_Controls.TryGetValue("Rotate", out ids)) + { + foreach (var id in ids) + { + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + control = id, + node = node.Value, + tooltipText = "Rotate" + }); + } + } + } + + void ShowScaleFeedback() + { + List ids; + if (m_Controls.TryGetValue("Crawl", out ids)) + { + foreach (var id in ids) + { + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + control = id, + node = node == Node.LeftHand ? Node.RightHand : Node.LeftHand, + tooltipText = "Scale" + }); + } + } + } + + void ShowResetScaleFeedback() + { + List ids; + if (m_Controls.TryGetValue("Scale Reset", out ids)) + { + foreach (var id in ids) + { + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + control = id, + node = node.Value, + tooltipText = "Reset scale" + }); + } + } + + if (m_Controls.TryGetValue("World Reset", out ids)) + { + foreach (var id in ids) + { + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + control = id, + node = node.Value, + tooltipText = "Reset position rotation and scale" + }); + } + } + } + public object OnSerializePreferences() { if (this.IsSharedUpdater(this)) From fd6e97d54e746f31d4eda7a85e86529e5ed97014 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 20 Sep 2017 01:20:58 -0700 Subject: [PATCH 020/457] Finish setting up touch proxy prefabs; Turn feedback on/off based on locomotion state (WIP) --- Prefabs/Proxies/LeftTouch.prefab | 316 ++++++++++++++++-- Prefabs/Proxies/RightTouch.prefab | 235 ++++++++++++- .../Modules/FeedbackModule/FeedbackModule.cs | 1 + .../Modules/TooltipModule/TooltipModule.cs | 2 + Scripts/Proxies/TwoHandedProxyBase.cs | 2 +- Tools/LocomotionTool/LocomotionTool.cs | 195 ++++++++--- 6 files changed, 668 insertions(+), 83 deletions(-) diff --git a/Prefabs/Proxies/LeftTouch.prefab b/Prefabs/Proxies/LeftTouch.prefab index ef3ade030..d33631efe 100644 --- a/Prefabs/Proxies/LeftTouch.prefab +++ b/Prefabs/Proxies/LeftTouch.prefab @@ -9,7 +9,6 @@ GameObject: m_Component: - component: {fileID: 461814} - component: {fileID: 13767942} - - component: {fileID: 65403493955253320} m_Layer: 0 m_Name: lctrl:side_trigger_PLY m_TagString: ShowInMiniWorld @@ -73,6 +72,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 447250} + - component: {fileID: 65047749595656640} + - component: {fileID: 114810234494472290} + - component: {fileID: 114626331710630820} m_Layer: 5 m_Name: lctrl:b_button02 m_TagString: ShowInMiniWorld @@ -89,6 +91,7 @@ GameObject: m_Component: - component: {fileID: 478002} - component: {fileID: 13758356} + - component: {fileID: 65442985896710628} m_Layer: 0 m_Name: lctrl:thumbstick_ball_PLY m_TagString: ShowInMiniWorld @@ -137,6 +140,7 @@ GameObject: m_Component: - component: {fileID: 430330} - component: {fileID: 13771122} + - component: {fileID: 65217700424197956} m_Layer: 0 m_Name: lctrl:x_button_PLY m_TagString: ShowInMiniWorld @@ -159,21 +163,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &153432 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 499662} - m_Layer: 5 - m_Name: GripTarget - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 --- !u!1 &158282 GameObject: m_ObjectHideFlags: 1 @@ -228,6 +217,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 442622} + - component: {fileID: 65675722717554818} + - component: {fileID: 114957305131514852} + - component: {fileID: 114720817646417354} m_Layer: 5 m_Name: lctrl:b_button01 m_TagString: ShowInMiniWorld @@ -292,6 +284,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 407362} + - component: {fileID: 136773898160763008} + - component: {fileID: 114687094704889498} + - component: {fileID: 114996085697448538} m_Layer: 5 m_Name: lctrl:b_stick m_TagString: ShowInMiniWorld @@ -346,14 +341,14 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 183382} - m_LocalRotation: {x: 0.002293064, y: 0.70780116, z: 0.0029638258, w: 0.7064019} + m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068} m_LocalPosition: {x: 0.0075226245, y: 0.0048274146, z: -0.011412583} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 425138} m_Father: {fileID: 498550} m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} --- !u!4 &425138 Transform: m_ObjectHideFlags: 1 @@ -583,23 +578,13 @@ Transform: - {fileID: 407362} - {fileID: 4023718469717780} - {fileID: 4922541072726130} - - {fileID: 499662} + - {fileID: 4032307745343326} + - {fileID: 4274270865372182} + - {fileID: 4442266189860376} + - {fileID: 4310256503251038} m_Father: {fileID: 485484} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &499662 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 153432} - m_LocalRotation: {x: -0.09117605, y: 0.99275935, z: 0.07810742, w: -0.0038822622} - m_LocalPosition: {x: -0.0536, y: -0.0241, z: -0.0261} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 498550} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: -8.8810005, y: -178.727, z: -370.594} --- !u!95 &9567726 Animator: serializedVersion: 3 @@ -1072,6 +1057,36 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1026636374437032 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4310256503251038} + m_Layer: 5 + m_Name: StickTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1109432372925108 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4274270865372182} + m_Layer: 5 + m_Name: YTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1365665863623068 GameObject: m_ObjectHideFlags: 1 @@ -1105,6 +1120,36 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1800859972846318 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4442266189860376} + m_Layer: 5 + m_Name: XTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1882268458449164 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4032307745343326} + m_Layer: 5 + m_Name: GripTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!4 &4000010810114962 Transform: m_ObjectHideFlags: 1 @@ -1183,6 +1228,58 @@ Transform: m_Father: {fileID: 498550} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4032307745343326 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1882268458449164} + m_LocalRotation: {x: -0.09117605, y: 0.99275935, z: 0.07810742, w: -0.0038822622} + m_LocalPosition: {x: -0.0536, y: -0.0241, z: -0.0261} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 498550} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: -8.8810005, y: -178.727, z: -370.594} +--- !u!4 &4274270865372182 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1109432372925108} + m_LocalRotation: {x: -0.47878605, y: 0.87015635, z: 0.11138897, w: -0.034416135} + m_LocalPosition: {x: -0.052, y: 0.0265, z: 0.0292} + m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1.0000006} + m_Children: [] + m_Father: {fileID: 498550} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -418.43} +--- !u!4 &4310256503251038 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1026636374437032} + m_LocalRotation: {x: 0.33000115, y: 0.91632354, z: 0.2230584, w: 0.041176602} + m_LocalPosition: {x: 0.042, y: 0.0306, z: 0.0413} + m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1.0000006} + m_Children: [] + m_Father: {fileID: 498550} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: -22.433, y: -193.93999, z: -317.611} +--- !u!4 &4442266189860376 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1800859972846318} + m_LocalRotation: {x: -0.47878605, y: 0.87015635, z: 0.11138897, w: -0.034416135} + m_LocalPosition: {x: -0.057, y: -0.0111, z: 0.0238} + m_LocalScale: {x: 1.0000007, y: 1.000001, z: 1.0000012} + m_Children: [] + m_Father: {fileID: 498550} + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -418.43} --- !u!4 &4922541072726130 Transform: m_ObjectHideFlags: 1 @@ -1196,6 +1293,30 @@ Transform: m_Father: {fileID: 498550} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: -185.719, z: 0} +--- !u!65 &65047749595656640 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134980} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} +--- !u!65 &65217700424197956 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 150630} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.009820405, y: 0.009820404, z: 0.004344657} + m_Center: {x: 0.009307315, y: 0.012594526, z: -0.000050143473} --- !u!65 &65318774059041546 BoxCollider: m_ObjectHideFlags: 1 @@ -1208,18 +1329,18 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 0.027765447, y: 0.016550489, z: 0.024621258} m_Center: {x: 0.000057838857, y: -0.003146829, z: -0.011298977} ---- !u!65 &65403493955253320 +--- !u!65 &65442985896710628 BoxCollider: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 117230} + m_GameObject: {fileID: 137646} m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 serializedVersion: 2 - m_Size: {x: 0.019283134, y: 0.028666984, z: 0.025938202} - m_Center: {x: 0.0006553563, y: 0.024918877, z: -0.02661042} + m_Size: {x: 0.017161056, y: 0.016454693, z: 0.008820649} + m_Center: {x: -0.0075670555, y: -0.004549614, z: 0.00416026} --- !u!65 &65524402868567802 BoxCollider: m_ObjectHideFlags: 1 @@ -1232,6 +1353,18 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 0.0138321975, y: 0.023385666, z: 0.01187079} m_Center: {x: -0.006514117, y: -0.0015480702, z: -0.00021664354} +--- !u!65 &65675722717554818 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 164520} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} --- !u!114 &114000013861093962 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1256,6 +1389,21 @@ MonoBehaviour: - m_Control: 3 m_Transform: {fileID: 450394} m_Renderer: {fileID: 13767942} + - m_Control: 17 + m_Transform: {fileID: 442622} + m_Renderer: {fileID: 13771122} + - m_Control: 18 + m_Transform: {fileID: 447250} + m_Renderer: {fileID: 13791068} + - m_Control: 22 + m_Transform: {fileID: 407362} + m_Renderer: {fileID: 13758356} + - m_Control: 0 + m_Transform: {fileID: 407362} + m_Renderer: {fileID: 13758356} + - m_Control: 1 + m_Transform: {fileID: 407362} + m_Renderer: {fileID: 13758356} --- !u!114 &114015681421713280 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1283,7 +1431,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_TooltipText: - m_TooltipTarget: {fileID: 499662} + m_TooltipTarget: {fileID: 4032307745343326} m_TooltipSource: {fileID: 450394} m_TooltipAlignment: 1 --- !u!114 &114543264181638874 @@ -1298,6 +1446,33 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_SelectionFlags: 3 +--- !u!114 &114626331710630820 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134980} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4274270865372182} + m_TooltipSource: {fileID: 447250} + m_TooltipAlignment: 1 +--- !u!114 &114687094704889498 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 183382} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 --- !u!114 &114692086924928774 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1310,3 +1485,70 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_SelectionFlags: 3 +--- !u!114 &114720817646417354 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 164520} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4442266189860376} + m_TooltipSource: {fileID: 442622} + m_TooltipAlignment: 1 +--- !u!114 &114810234494472290 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134980} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114957305131514852 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 164520} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114996085697448538 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 183382} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4310256503251038} + m_TooltipSource: {fileID: 407362} + m_TooltipAlignment: 1 +--- !u!136 &136773898160763008 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 183382} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.007829846 + m_Height: 0.020090805 + m_Direction: 0 + m_Center: {x: -0.013697198, y: 0.00020355526, z: -0.000012598241} diff --git a/Prefabs/Proxies/RightTouch.prefab b/Prefabs/Proxies/RightTouch.prefab index 23d5e988c..707da161a 100644 --- a/Prefabs/Proxies/RightTouch.prefab +++ b/Prefabs/Proxies/RightTouch.prefab @@ -74,6 +74,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 412818} + - component: {fileID: 65532786443924200} + - component: {fileID: 114099124700230328} + - component: {fileID: 114587196572306994} m_Layer: 0 m_Name: rctrl:b_button01 m_TagString: ShowInMiniWorld @@ -89,6 +92,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 451284} + - component: {fileID: 136939997479679710} + - component: {fileID: 114972585640418204} + - component: {fileID: 114564303215576146} m_Layer: 0 m_Name: rctrl:b_stick m_TagString: ShowInMiniWorld @@ -120,6 +126,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 437054} + - component: {fileID: 65185470389824374} + - component: {fileID: 114449939092263594} + - component: {fileID: 114526162600788140} m_Layer: 0 m_Name: rctrl:b_button02 m_TagString: ShowInMiniWorld @@ -454,8 +463,11 @@ Transform: - {fileID: 431526} - {fileID: 451284} - {fileID: 482366} - - {fileID: 4512895743762768} - {fileID: 4733308111900852} + - {fileID: 4512895743762768} + - {fileID: 4458782614489772} + - {fileID: 4088168330103002} + - {fileID: 4852355382428020} m_Father: {fileID: 484770} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -1089,6 +1101,21 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1253209964145740 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4852355382428020} + m_Layer: 5 + m_Name: StickTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1339159515951860 GameObject: m_ObjectHideFlags: 1 @@ -1104,6 +1131,36 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1787517956260218 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4088168330103002} + m_Layer: 5 + m_Name: 'ATarget ' + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1874640749952246 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4458782614489772} + m_Layer: 5 + m_Name: BTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!4 &4000010594257346 Transform: m_ObjectHideFlags: 1 @@ -1169,6 +1226,32 @@ Transform: m_Father: {fileID: 401760} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: -8, z: 0} +--- !u!4 &4088168330103002 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1787517956260218} + m_LocalRotation: {x: 0.25962713, y: 0.9586458, z: 0.056264184, w: -0.10210912} + m_LocalPosition: {x: 0.072, y: -0.0078, z: 0.0201} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 449518} + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -330.481} +--- !u!4 &4458782614489772 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1874640749952246} + m_LocalRotation: {x: 0.25962713, y: 0.9586459, z: 0.056264214, w: -0.10210911} + m_LocalPosition: {x: 0.05200003, y: 0.0265, z: 0.0292} + m_LocalScale: {x: 1.0000006, y: 1.0000006, z: 1.000001} + m_Children: [] + m_Father: {fileID: 449518} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -330.481} --- !u!4 &4512895743762768 Transform: m_ObjectHideFlags: 1 @@ -1180,7 +1263,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 449518} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 6.8320003, y: -176.453, z: -361.644} --- !u!4 &4733308111900852 Transform: @@ -1193,8 +1276,45 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 449518} - m_RootOrder: 6 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: -176.535, z: 0} +--- !u!4 &4852355382428020 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1253209964145740} + m_LocalRotation: {x: -0.4478652, y: 0.88833606, z: 0.085730694, w: -0.054093756} + m_LocalPosition: {x: -0.042, y: 0.0306, z: 0.0413} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 449518} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: -5.9620004, y: -169.98901, z: -414.034} +--- !u!65 &65185470389824374 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 145060} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} +--- !u!65 &65532786443924200 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134068} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} --- !u!65 &65543380702871742 BoxCollider: m_ObjectHideFlags: 1 @@ -1243,6 +1363,33 @@ MonoBehaviour: - m_Control: 3 m_Transform: {fileID: 431526} m_Renderer: {fileID: 13791512} + - m_Control: 17 + m_Transform: {fileID: 412818} + m_Renderer: {fileID: 13757144} + - m_Control: 18 + m_Transform: {fileID: 437054} + m_Renderer: {fileID: 13724278} + - m_Control: 22 + m_Transform: {fileID: 451284} + m_Renderer: {fileID: 13768278} + - m_Control: 0 + m_Transform: {fileID: 451284} + m_Renderer: {fileID: 13768278} + - m_Control: 1 + m_Transform: {fileID: 451284} + m_Renderer: {fileID: 13768278} +--- !u!114 &114099124700230328 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134068} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 --- !u!114 &114431176106213124 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1258,6 +1405,63 @@ MonoBehaviour: m_TooltipTarget: {fileID: 4733308111900852} m_TooltipSource: {fileID: 482366} m_TooltipAlignment: 1 +--- !u!114 &114449939092263594 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 145060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114526162600788140 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 145060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4458782614489772} + m_TooltipSource: {fileID: 437054} + m_TooltipAlignment: 1 +--- !u!114 &114564303215576146 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134988} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4852355382428020} + m_TooltipSource: {fileID: 451284} + m_TooltipAlignment: 1 +--- !u!114 &114587196572306994 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134068} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4088168330103002} + m_TooltipSource: {fileID: 412818} + m_TooltipAlignment: 1 --- !u!114 &114643829396939542 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1297,3 +1501,28 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_SelectionFlags: 3 +--- !u!114 &114972585640418204 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134988} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!136 &136939997479679710 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 134988} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.007829846 + m_Height: 0.020090805 + m_Direction: 0 + m_Center: {x: -0.013697198, y: 0.00020355526, z: -0.000012598241} diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index faade8d1c..3f6971eee 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -45,6 +45,7 @@ void AddFeedbackRequest(FeedbackRequest request) public void RemoveFeedbackRequest(FeedbackRequest request) { + //Debug.Log("add"); foreach (var receiver in m_FeedbackReceivers) { receiver.RemoveFeedbackRequest(request); diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index a19c765da..e293f3b41 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -233,6 +233,8 @@ public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duratio if (m_Tooltips.ContainsKey(tooltip)) return; + Debug.Log(tooltip.tooltipText); + m_Tooltips[tooltip] = new TooltipData { startTime = Time.time, diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 2a53919cf..5bd56892e 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -22,7 +22,7 @@ public class ProxyFeedbackRequest : FeedbackRequest abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility, ISetHighlight { const int k_RendererQueue = 9000; - const float k_FeedbackDuration = 5f; + const float k_FeedbackDuration = 50f; [SerializeField] protected GameObject m_LeftHandProxyPrefab; diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index a7b5cc562..33d902503 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -97,6 +97,13 @@ class Preferences bool m_BlockValueChangedListener; readonly Dictionary> m_Controls = new Dictionary>(); + readonly List m_MainButtonFeedback = new List(); + readonly List m_SpeedFeedback = new List(); + readonly List m_CrawlFeedback = new List(); + readonly List m_ScaleFeedback = new List(); + readonly List m_RotateFeedback = new List(); + readonly List m_ResetScaleFeedback = new List(); + public ActionMap actionMap { get { return m_BlinkActionMap; } } @@ -205,37 +212,8 @@ void Start() } } - var defaultControls = new [] { "Crawl", "Blink", "Speed" }; - - foreach (var control in defaultControls) - { - List ids; - if (m_Controls.TryGetValue(control, out ids)) - { - foreach (var id in ids) - { - this.AddFeedbackRequest(new ProxyFeedbackRequest - { - node = node.Value, - control = id, - tooltipText = TooltipForControl(control) - }); - } - } - } - } - - string TooltipForControl(string controlName) - { - switch (controlName.ToLower()) - { - case "blink": - return m_Preferences.blinkMode ? "Blink" : "Fly"; - case "speed": - return m_Preferences.blinkMode ? "Extra distace" : "Extra speed"; - default: - return controlName; - } + ShowCrawlFeedback(); + ShowMainButtonFeedback(); } void OnDestroy() @@ -370,8 +348,9 @@ bool DoCrawl(ConsumeControlDelegate consumeControl) m_ActualRayOriginStartPosition = m_RayOriginStartPosition; m_CrawlStartTime = Time.time; + HideCrawlFeedback(); ShowScaleFeedback(); - ShowRotateFeedback(); + ShowAltRotateFeedback(); } var localRayPosition = cameraRig.position - rayOrigin.position; @@ -394,6 +373,12 @@ bool DoCrawl(ConsumeControlDelegate consumeControl) this.RemoveRayVisibilitySettings(rayOrigin, this); + if (m_StartCrawling) + { + ShowCrawlFeedback(); + HideRotateFeedback(); + } + m_StartCrawling = false; m_Crawling = false; return false; @@ -640,6 +625,48 @@ IEnumerator MoveTowardTarget(Vector3 targetPosition) m_BlinkMoving = false; } + void ShowCrawlFeedback() + { + Debug.Log("crawl"); + List ids; + if (m_Controls.TryGetValue("Crawl", out ids)) + { + foreach (var id in ids) + { + Debug.Log(id); + var request = new ProxyFeedbackRequest + { + node = node.Value, + control = id, + tooltipText = "Crawl" + }; + + this.AddFeedbackRequest(request); + m_CrawlFeedback.Add(request); + } + } + } + + void ShowMainButtonFeedback() + { + List ids; + if (m_Controls.TryGetValue("Blink", out ids)) + { + foreach (var id in ids) + { + var request = new ProxyFeedbackRequest + { + node = node.Value, + control = id, + tooltipText = m_Preferences.blinkMode ? "Blink" : "Fly" + }; + + this.AddFeedbackRequest(request); + m_MainButtonFeedback.Add(request); + } + } + } + void ShowRotateFeedback() { List ids; @@ -647,12 +674,35 @@ void ShowRotateFeedback() { foreach (var id in ids) { - this.AddFeedbackRequest(new ProxyFeedbackRequest + var request = new ProxyFeedbackRequest + { + control = id, + node = node.Value, + tooltipText = "Rotate" + }; + + this.AddFeedbackRequest(request); + m_RotateFeedback.Add(request); + } + } + } + + void ShowAltRotateFeedback() + { + List ids; + if (m_Controls.TryGetValue("Blink", out ids)) + { + foreach (var id in ids) + { + var request = new ProxyFeedbackRequest { control = id, node = node.Value, tooltipText = "Rotate" - }); + }; + + this.AddFeedbackRequest(request); + m_RotateFeedback.Add(request); } } } @@ -664,12 +714,15 @@ void ShowScaleFeedback() { foreach (var id in ids) { - this.AddFeedbackRequest(new ProxyFeedbackRequest + var request = new ProxyFeedbackRequest { control = id, node = node == Node.LeftHand ? Node.RightHand : Node.LeftHand, tooltipText = "Scale" - }); + }; + + this.AddFeedbackRequest(request); + m_ScaleFeedback.Add(request); } } } @@ -677,33 +730,91 @@ void ShowScaleFeedback() void ShowResetScaleFeedback() { List ids; - if (m_Controls.TryGetValue("Scale Reset", out ids)) + if (m_Controls.TryGetValue("ScaleReset", out ids)) { foreach (var id in ids) { - this.AddFeedbackRequest(new ProxyFeedbackRequest + var request = new ProxyFeedbackRequest { control = id, node = node.Value, tooltipText = "Reset scale" - }); + }; + + this.AddFeedbackRequest(request); + m_ResetScaleFeedback.Add(request); } } - if (m_Controls.TryGetValue("World Reset", out ids)) + if (m_Controls.TryGetValue("WorldReset", out ids)) { foreach (var id in ids) { - this.AddFeedbackRequest(new ProxyFeedbackRequest + var request = new ProxyFeedbackRequest { control = id, node = node.Value, tooltipText = "Reset position rotation and scale" - }); + }; + + this.AddFeedbackRequest(request); + m_ResetScaleFeedback.Add(request); + } + } + } + + void ShowSpeedFeedback() + { + List ids; + if (m_Controls.TryGetValue("Speed", out ids)) + { + foreach (var id in ids) + { + var request = new ProxyFeedbackRequest + { + node = node.Value, + control = id, + tooltipText = m_Preferences.blinkMode ? "Extra distace" : "Extra speed" + }; + + this.AddFeedbackRequest(request); + m_SpeedFeedback.Add(request); } } } + void HideCrawlFeedback() + { + foreach (var request in m_CrawlFeedback) + { + this.RemoveFeedbackRequest(request); + } + } + + void HideRotateFeedback() + { + foreach (var request in m_RotateFeedback) + { + this.RemoveFeedbackRequest(request); + } + } + + void HideScaleFeedback() + { + foreach (var request in m_ScaleFeedback) + { + this.RemoveFeedbackRequest(request); + } + } + + void HideResetScaleFeedback() + { + foreach (var request in m_ResetScaleFeedback) + { + this.RemoveFeedbackRequest(request); + } + } + public object OnSerializePreferences() { if (this.IsSharedUpdater(this)) From 4e41d51f7d88046ef7b6c5970030132c24221b36 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 20 Sep 2017 15:10:07 -0700 Subject: [PATCH 021/457] Finish implementing feedback in LocomotionTool --- Prefabs/Proxies/LeftTouch.prefab | 30 +-- Prefabs/Proxies/RightTouch.prefab | 40 ++-- .../Modules/TooltipModule/TooltipModule.cs | 2 - Scripts/Proxies/TwoHandedProxyBase.cs | 61 +++--- Tools/LocomotionTool/LocomotionTool.cs | 206 ++++++++++++++++-- 5 files changed, 251 insertions(+), 88 deletions(-) diff --git a/Prefabs/Proxies/LeftTouch.prefab b/Prefabs/Proxies/LeftTouch.prefab index d33631efe..311233ac3 100644 --- a/Prefabs/Proxies/LeftTouch.prefab +++ b/Prefabs/Proxies/LeftTouch.prefab @@ -396,7 +396,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 118082} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.25, y: 0, z: 0} + m_LocalPosition: {x: -0.25, y: -0.775, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 485484} @@ -1234,8 +1234,8 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1882268458449164} - m_LocalRotation: {x: -0.09117605, y: 0.99275935, z: 0.07810742, w: -0.0038822622} - m_LocalPosition: {x: -0.0536, y: -0.0241, z: -0.0261} + m_LocalRotation: {x: -0.036001876, y: 0.9469688, z: 0.31843576, w: -0.023508724} + m_LocalPosition: {x: -0.043206386, y: -0.029995611, z: -0.026119232} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 498550} @@ -1247,8 +1247,8 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1109432372925108} - m_LocalRotation: {x: -0.47878605, y: 0.87015635, z: 0.11138897, w: -0.034416135} - m_LocalPosition: {x: -0.052, y: 0.0265, z: 0.0292} + m_LocalRotation: {x: -0.2575147, y: 0.83480066, z: 0.4621716, w: -0.15228775} + m_LocalPosition: {x: -0.041980393, y: 0.05147165, z: 0.017116126} m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1.0000006} m_Children: [] m_Father: {fileID: 498550} @@ -1260,21 +1260,21 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1026636374437032} - m_LocalRotation: {x: 0.33000115, y: 0.91632354, z: 0.2230584, w: 0.041176602} - m_LocalPosition: {x: 0.042, y: 0.0306, z: 0.0413} - m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1.0000006} + m_LocalRotation: {x: 0.35172954, y: 0.88359857, z: 0.3072935, w: 0.033327878} + m_LocalPosition: {x: 0.07429461, y: 0.03352204, z: 0.020555971} + m_LocalScale: {x: 0.42783472, y: 1.0000005, z: 1.0000006} m_Children: [] m_Father: {fileID: 498550} m_RootOrder: 9 - m_LocalEulerAnglesHint: {x: -22.433, y: -193.93999, z: -317.611} + m_LocalEulerAnglesHint: {x: -35.649002, y: -194.698, z: -336.566} --- !u!4 &4442266189860376 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1800859972846318} - m_LocalRotation: {x: -0.47878605, y: 0.87015635, z: 0.11138897, w: -0.034416135} - m_LocalPosition: {x: -0.057, y: -0.0111, z: 0.0238} + m_LocalRotation: {x: -0.51841843, y: 0.7203171, z: 0.36884463, w: -0.27629557} + m_LocalPosition: {x: -0.07252136, y: -0.0017951168, z: 0.041165117} m_LocalScale: {x: 1.0000007, y: 1.000001, z: 1.0000012} m_Children: [] m_Father: {fileID: 498550} @@ -1286,13 +1286,13 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1365665863623068} - m_LocalRotation: {x: -0.000000009313225, y: -0.99875486, z: 0.00000008940696, w: -0.049887232} - m_LocalPosition: {x: -0.0127, y: 0.0597, z: 0.014} - m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005} + m_LocalRotation: {x: -0.0037376191, y: -0.9212345, z: -0.38850796, w: 0.019355591} + m_LocalPosition: {x: -0.0009559246, y: 0.08051417, z: 0.047581732} + m_LocalScale: {x: 0.8193403, y: 1.0000005, z: 1.0000005} m_Children: [] m_Father: {fileID: 498550} m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: -185.719, z: 0} + m_LocalEulerAnglesHint: {x: -45.722004, y: -177.311, z: -0.669} --- !u!65 &65047749595656640 BoxCollider: m_ObjectHideFlags: 1 diff --git a/Prefabs/Proxies/RightTouch.prefab b/Prefabs/Proxies/RightTouch.prefab index 707da161a..7cd8d555c 100644 --- a/Prefabs/Proxies/RightTouch.prefab +++ b/Prefabs/Proxies/RightTouch.prefab @@ -331,8 +331,8 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 141214} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.25, y: -0.775, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 484770} @@ -1232,65 +1232,65 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1787517956260218} - m_LocalRotation: {x: 0.25962713, y: 0.9586458, z: 0.056264184, w: -0.10210912} - m_LocalPosition: {x: 0.072, y: -0.0078, z: 0.0201} + m_LocalRotation: {x: 0.51841843, y: 0.7203171, z: 0.36884466, w: 0.27629554} + m_LocalPosition: {x: 0.0725214, y: -0.0017951243, z: 0.041165117} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 449518} m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -330.481} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4458782614489772 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1874640749952246} - m_LocalRotation: {x: 0.25962713, y: 0.9586459, z: 0.056264214, w: -0.10210911} - m_LocalPosition: {x: 0.05200003, y: 0.0265, z: 0.0292} - m_LocalScale: {x: 1.0000006, y: 1.0000006, z: 1.000001} + m_LocalRotation: {x: 0.2575147, y: 0.8348006, z: 0.4621716, w: 0.15228775} + m_LocalPosition: {x: 0.041980393, y: 0.051471658, z: 0.017116126} + m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 449518} m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -330.481} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4512895743762768 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1172441472411894} - m_LocalRotation: {x: -0.016156727, y: 0.99761605, z: -0.059107296, w: -0.031740725} - m_LocalPosition: {x: 0.0536, y: -0.0241, z: -0.0261} + m_LocalRotation: {x: 0.036001876, y: 0.9469688, z: 0.31843576, w: 0.023508724} + m_LocalPosition: {x: 0.0432064, y: -0.029995611, z: -0.026119232} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 449518} m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 6.8320003, y: -176.453, z: -361.644} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4733308111900852 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1339159515951860} - m_LocalRotation: {x: -6.120436e-17, y: -0.9995429, z: 0.000000059604638, w: 0.030231994} - m_LocalPosition: {x: 0.0127, y: 0.05970001, z: 0.013999991} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalRotation: {x: 0.0037376198, y: -0.9212345, z: -0.388508, w: -0.019355595} + m_LocalPosition: {x: 0.0009559395, y: 0.08051417, z: 0.047581732} + m_LocalScale: {x: 0.9982224, y: 1.000015, z: 1.0021566} m_Children: [] m_Father: {fileID: 449518} m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: -176.535, z: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4852355382428020 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1253209964145740} - m_LocalRotation: {x: -0.4478652, y: 0.88833606, z: 0.085730694, w: -0.054093756} - m_LocalPosition: {x: -0.042, y: 0.0306, z: 0.0413} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalRotation: {x: -0.3517295, y: 0.88359857, z: 0.30729347, w: -0.033327874} + m_LocalPosition: {x: -0.07429464, y: 0.03352204, z: 0.020555971} + m_LocalScale: {x: 0.9537753, y: 1.0450228, z: 1.0630285} m_Children: [] m_Father: {fileID: 449518} m_RootOrder: 9 - m_LocalEulerAnglesHint: {x: -5.9620004, y: -169.98901, z: -414.034} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!65 &65185470389824374 BoxCollider: m_ObjectHideFlags: 1 diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index e293f3b41..a19c765da 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -233,8 +233,6 @@ public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duratio if (m_Tooltips.ContainsKey(tooltip)) return; - Debug.Log(tooltip.tooltipText); - m_Tooltips[tooltip] = new TooltipData { startTime = Time.time, diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 5bd56892e..f884cf817 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -22,7 +22,7 @@ public class ProxyFeedbackRequest : FeedbackRequest abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility, ISetHighlight { const int k_RendererQueue = 9000; - const float k_FeedbackDuration = 50f; + const float k_FeedbackDuration = 3f; [SerializeField] protected GameObject m_LeftHandProxyPrefab; @@ -46,9 +46,6 @@ abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, IS readonly Dictionary> m_Buttons = new Dictionary>(); - // Local method use only -- created here to reduce garbage collection - readonly List m_FeedbackToRemove = new List(); - public Transform leftHand { get { return m_LeftHand; } } public Transform rightHand { get { return m_RightHand; } } @@ -191,11 +188,9 @@ public void AddFeedbackRequest(FeedbackRequest request) var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) { - m_FeedbackToRemove.Clear(); foreach (var existingRequest in new List(m_FeedbackRequests)) { - if (existingRequest.node == proxyRequest.node - && existingRequest.control == proxyRequest.control) + if (existingRequest.node == proxyRequest.node && existingRequest.control == proxyRequest.control) { if (existingRequest.priority <= proxyRequest.priority) RemoveFeedbackRequest(existingRequest); @@ -204,34 +199,34 @@ public void AddFeedbackRequest(FeedbackRequest request) } } - foreach (var feedback in m_FeedbackToRemove) - { - RemoveFeedbackRequest(feedback); - } + ExecuteFeedback(proxyRequest); + + m_FeedbackRequests.Add(proxyRequest); + } + } - Dictionary buttons; - if (m_Buttons.TryGetValue(proxyRequest.node, out buttons)) + void ExecuteFeedback(ProxyFeedbackRequest request) + { + Dictionary buttons; + if (m_Buttons.TryGetValue(request.node, out buttons)) + { + ProxyHelper.ButtonObject button; + if (buttons.TryGetValue(request.control, out button)) { - ProxyHelper.ButtonObject button; - if (buttons.TryGetValue(proxyRequest.control, out button)) - { - if (button.renderer) - this.SetHighlight(button.renderer.gameObject, true, duration: k_FeedbackDuration); + if (button.renderer) + this.SetHighlight(button.renderer.gameObject, true, duration: k_FeedbackDuration); - if (button.transform) + if (button.transform) + { + var tooltip = button.transform.GetComponent(); + var tooltipText = request.tooltipText; + if (!string.IsNullOrEmpty(tooltipText) && tooltip) { - var tooltip = button.transform.GetComponent(); - var tooltipText = proxyRequest.tooltipText; - if (!string.IsNullOrEmpty(tooltipText) && tooltip) - { - tooltip.tooltipText = tooltipText; - this.ShowTooltip(tooltip, true, k_FeedbackDuration); - } + tooltip.tooltipText = tooltipText; + this.ShowTooltip(tooltip, true, k_FeedbackDuration); } } } - - m_FeedbackRequests.Add(proxyRequest); } } @@ -266,8 +261,16 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) } } } - m_FeedbackRequests.Remove(request); + + foreach (var existingRequest in new List(m_FeedbackRequests)) + { + if (existingRequest.node == request.node && existingRequest.control == request.control) + { + ExecuteFeedback(existingRequest); + break; + } + } } public void ClearFeedbackRequests(IRequestFeedback caller) diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 33d902503..a3d60b5d8 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -251,8 +251,64 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon bool DoFlying(ConsumeControlDelegate consumeControl) { - var reverse = m_LocomotionInput.reverse.isHeld; - var moving = m_LocomotionInput.forward.isHeld || reverse; + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + if (locomotionTool.m_LocomotionInput != null && locomotionTool.m_LocomotionInput.crawl.isHeld) + return false; + } + + var forwardControl = m_LocomotionInput.forward; + var reverseControl = m_LocomotionInput.reverse; + if (forwardControl.wasJustPressed || reverseControl.wasJustPressed) + { + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + if (locomotionTool == this) + { + locomotionTool.HideMainButtonFeedback(); + locomotionTool.ShowRotateFeedback(); + } + + locomotionTool.HideCrawlFeedback(); + } + } + + if (forwardControl.wasJustReleased || reverseControl.wasJustReleased) + { + var otherControlHeld = false; + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + if (locomotionTool == this) + continue; + + var input = locomotionTool.m_LocomotionInput; + if (input.forward.isHeld || input.reverse.isHeld) + { + otherControlHeld = true; + break; + } + } + + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + if (locomotionTool == this) + { + locomotionTool.HideSpeedFeedback(); + locomotionTool.HideRotateFeedback(); + locomotionTool.ShowMainButtonFeedback(); + } + + if (!otherControlHeld) + locomotionTool.ShowCrawlFeedback(); + } + } + + var reverse = reverseControl.isHeld; + var moving = forwardControl.isHeld || reverse; if (moving) { var speed = k_SlowMoveSpeed; @@ -262,6 +318,11 @@ bool DoFlying(ConsumeControlDelegate consumeControl) { speed = k_SlowMoveSpeed + speedControlValue * (k_FastMoveSpeed - k_SlowMoveSpeed); consumeControl(speedControl); + HideSpeedFeedback(); + } + else if (m_SpeedFeedback.Count == 0) + { + ShowSpeedFeedback(); } speed *= this.GetViewerScale(); @@ -271,7 +332,7 @@ bool DoFlying(ConsumeControlDelegate consumeControl) m_Rotating = false; cameraRig.Translate(Quaternion.Inverse(cameraRig.rotation) * rayOrigin.forward * speed * Time.unscaledDeltaTime); - consumeControl(m_LocomotionInput.forward); + consumeControl(forwardControl); return true; } @@ -286,6 +347,15 @@ bool DoRotating(ConsumeControlDelegate consumeControl) { if (m_LocomotionInput.rotate.isHeld) { + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + locomotionTool.HideMainButtonFeedback(); + locomotionTool.HideRotateFeedback(); + locomotionTool.HideScaleFeedback(); + locomotionTool.HideSpeedFeedback(); + } + var localRayRotation = Quaternion.Inverse(cameraRig.rotation) * rayOrigin.rotation; var localRayForward = localRayRotation * Vector3.forward; if (Mathf.Abs(Vector3.Dot(localRayForward, Vector3.up)) > k_RotationThreshold) @@ -332,7 +402,30 @@ bool DoRotating(ConsumeControlDelegate consumeControl) } if (!m_LocomotionInput.rotate.isHeld) + { + if (m_WasRotating) + { + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + var input = locomotionTool.m_LocomotionInput; + if (input.blink.isHeld) + { + locomotionTool.ShowSpeedFeedback(); + locomotionTool.ShowRotateFeedback(); + } + else + { + if (locomotionTool == this) + locomotionTool.ShowAltRotateFeedback(); + else if (!input.crawl.isHeld) + locomotionTool.ShowMainButtonFeedback(); + } + } + } + m_WasRotating = false; + } m_Rotating = false; return false; @@ -340,7 +433,9 @@ bool DoRotating(ConsumeControlDelegate consumeControl) bool DoCrawl(ConsumeControlDelegate consumeControl) { - if (!m_LocomotionInput.forward.isHeld && !m_LocomotionInput.blink.isHeld && m_LocomotionInput.crawl.isHeld) + var crawl = m_LocomotionInput.crawl; + var blink = m_LocomotionInput.blink; + if (!m_LocomotionInput.forward.isHeld && !blink.isHeld && crawl.isHeld) { if (!m_StartCrawling && !m_WasRotating) { @@ -348,9 +443,11 @@ bool DoCrawl(ConsumeControlDelegate consumeControl) m_ActualRayOriginStartPosition = m_RayOriginStartPosition; m_CrawlStartTime = Time.time; - HideCrawlFeedback(); - ShowScaleFeedback(); - ShowAltRotateFeedback(); + foreach (var linkedObject in linkedObjects) + { + ((LocomotionTool)linkedObject).HideCrawlFeedback(); + ((LocomotionTool)linkedObject).HideMainButtonFeedback(); + } } var localRayPosition = cameraRig.position - rayOrigin.position; @@ -368,15 +465,47 @@ bool DoCrawl(ConsumeControlDelegate consumeControl) if (m_Crawling) cameraRig.position = m_RigStartPosition + localRayPosition - m_RayOriginStartPosition; + if (m_RotateFeedback.Count == 0) + { + HideMainButtonFeedback(); + ShowAltRotateFeedback(); + } + + if (m_ScaleFeedback.Count == 0) + ShowScaleFeedback(); + return true; } this.RemoveRayVisibilitySettings(rayOrigin, this); - if (m_StartCrawling) + if (crawl.isHeld && blink.wasJustReleased || crawl.wasJustReleased) { - ShowCrawlFeedback(); - HideRotateFeedback(); + var otherCrawlHeld = false; + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + if (locomotionTool == this) + continue; + + if (locomotionTool.m_LocomotionInput.crawl.isHeld) + { + otherCrawlHeld = true; + break; + } + } + + if (!otherCrawlHeld) + { + HideRotateFeedback(); + HideScaleFeedback(); + foreach (var linkedObject in linkedObjects) + { + var locomotionTool = (LocomotionTool)linkedObject; + locomotionTool.ShowCrawlFeedback(); + locomotionTool.ShowMainButtonFeedback(); + } + } } m_StartCrawling = false; @@ -418,6 +547,12 @@ bool DoBlink(ConsumeControlDelegate consumeControl) bool DoTwoHandedScaling(ConsumeControlDelegate consumeControl) { + foreach (var linkedObject in linkedObjects) + { + if (((LocomotionTool)linkedObject).m_Rotating) + return false; + } + if (this.IsSharedUpdater(this)) { var crawl = m_LocomotionInput.crawl; @@ -428,11 +563,11 @@ bool DoTwoHandedScaling(ConsumeControlDelegate consumeControl) var otherGripHeld = false; foreach (var linkedObject in linkedObjects) { - var locomotionTool = (LocomotionTool)linkedObject; - if (locomotionTool == this) + var otherLocomotionTool = (LocomotionTool)linkedObject; + if (otherLocomotionTool == this) continue; - var otherLocomotionInput = locomotionTool.m_LocomotionInput; + var otherLocomotionInput = otherLocomotionTool.m_LocomotionInput; if (otherLocomotionInput == null) // This can occur if crawl is pressed when EVR is opened continue; @@ -450,7 +585,7 @@ bool DoTwoHandedScaling(ConsumeControlDelegate consumeControl) consumeControl(otherLocomotionInput.vertical); var thisPosition = cameraRig.InverseTransformPoint(rayOrigin.position); - var otherRayOrigin = locomotionTool.rayOrigin; + var otherRayOrigin = otherLocomotionTool.rayOrigin; var otherPosition = cameraRig.InverseTransformPoint(otherRayOrigin.position); var distance = Vector3.Distance(thisPosition, otherPosition); @@ -473,15 +608,22 @@ bool DoTwoHandedScaling(ConsumeControlDelegate consumeControl) m_StartDirection = rayToRay; m_StartYaw = cameraRig.rotation.eulerAngles.y; - locomotionTool.m_Scaling = true; - locomotionTool.m_Crawling = false; - locomotionTool.m_StartCrawling = false; + otherLocomotionTool.m_Scaling = true; + otherLocomotionTool.m_Crawling = false; + otherLocomotionTool.m_StartCrawling = false; m_ViewerScaleVisuals.leftHand = rayOrigin; m_ViewerScaleVisuals.rightHand = otherRayOrigin; m_ViewerScaleVisuals.gameObject.SetActive(true); - ShowResetScaleFeedback(); + foreach (var obj in linkedObjects) + { + var locomotionTool = (LocomotionTool)obj; + locomotionTool.HideScaleFeedback(); + locomotionTool.HideRotateFeedback(); + locomotionTool.HideMainButtonFeedback(); + locomotionTool.ShowResetScaleFeedback(); + } } m_Scaling = true; @@ -594,9 +736,9 @@ void CancelScale() } locomotionTool.m_Scaling = false; + locomotionTool.HideResetScaleFeedback(); } - m_ViewerScaleVisuals.gameObject.SetActive(false); } @@ -627,13 +769,11 @@ IEnumerator MoveTowardTarget(Vector3 targetPosition) void ShowCrawlFeedback() { - Debug.Log("crawl"); List ids; if (m_Controls.TryGetValue("Crawl", out ids)) { foreach (var id in ids) { - Debug.Log(id); var request = new ProxyFeedbackRequest { node = node.Value, @@ -774,7 +914,7 @@ void ShowSpeedFeedback() { node = node.Value, control = id, - tooltipText = m_Preferences.blinkMode ? "Extra distace" : "Extra speed" + tooltipText = m_Preferences.blinkMode ? "Extra distance" : "Extra speed" }; this.AddFeedbackRequest(request); @@ -783,12 +923,22 @@ void ShowSpeedFeedback() } } + void HideMainButtonFeedback() + { + foreach (var request in m_MainButtonFeedback) + { + this.RemoveFeedbackRequest(request); + } + m_MainButtonFeedback.Clear(); + } + void HideCrawlFeedback() { foreach (var request in m_CrawlFeedback) { this.RemoveFeedbackRequest(request); } + m_CrawlFeedback.Clear(); } void HideRotateFeedback() @@ -797,6 +947,7 @@ void HideRotateFeedback() { this.RemoveFeedbackRequest(request); } + m_RotateFeedback.Clear(); } void HideScaleFeedback() @@ -805,6 +956,16 @@ void HideScaleFeedback() { this.RemoveFeedbackRequest(request); } + m_ScaleFeedback.Clear(); + } + + void HideSpeedFeedback() + { + foreach (var request in m_SpeedFeedback) + { + this.RemoveFeedbackRequest(request); + } + m_SpeedFeedback.Clear(); } void HideResetScaleFeedback() @@ -813,6 +974,7 @@ void HideResetScaleFeedback() { this.RemoveFeedbackRequest(request); } + m_ResetScaleFeedback.Clear(); } public object OnSerializePreferences() From 743a47a6e97b28f2e868c6206ae34be4715bafd9 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 20 Sep 2017 15:32:49 -0700 Subject: [PATCH 022/457] Refresh show/hide timer on all changes to feedback state to syncronize show/hide of feedback across entire proxy --- .../Modules/TooltipModule/TooltipModule.cs | 8 +++- Scripts/Proxies/TwoHandedProxyBase.cs | 37 ++++++++++--------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index a19c765da..a6bf4f8e0 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -230,8 +230,14 @@ public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duratio if (!IsValidTooltip(tooltip)) return; - if (m_Tooltips.ContainsKey(tooltip)) + TooltipData data; + if (m_Tooltips.TryGetValue(tooltip, out data)) + { + data.startTime = Time.time; + data.persistent |= persistent; + data.duration = duration; return; + } m_Tooltips[tooltip] = new TooltipData { diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index f884cf817..377ff78bc 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -22,7 +22,7 @@ public class ProxyFeedbackRequest : FeedbackRequest abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility, ISetHighlight { const int k_RendererQueue = 9000; - const float k_FeedbackDuration = 3f; + const float k_FeedbackDuration = 5f; [SerializeField] protected GameObject m_LeftHandProxyPrefab; @@ -199,20 +199,30 @@ public void AddFeedbackRequest(FeedbackRequest request) } } - ExecuteFeedback(proxyRequest); - m_FeedbackRequests.Add(proxyRequest); } + + ExecuteFeedback(); } - void ExecuteFeedback(ProxyFeedbackRequest request) + void ExecuteFeedback() { - Dictionary buttons; - if (m_Buttons.TryGetValue(request.node, out buttons)) + foreach (var proxyNode in m_Buttons) { - ProxyHelper.ButtonObject button; - if (buttons.TryGetValue(request.control, out button)) + foreach (var kvp in proxyNode.Value) { + ProxyFeedbackRequest request = null; + foreach (var req in m_FeedbackRequests) + { + if (req.node == proxyNode.Key && req.control == kvp.Key + && (request == null || req.priority > request.priority)) + request = req; + } + + if (request == null) + continue; + + var button = kvp.Value; if (button.renderer) this.SetHighlight(button.renderer.gameObject, true, duration: k_FeedbackDuration); @@ -234,9 +244,7 @@ public void RemoveFeedbackRequest(FeedbackRequest request) { var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) - { RemoveFeedbackRequest(proxyRequest); - } } void RemoveFeedbackRequest(ProxyFeedbackRequest request) @@ -263,14 +271,7 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) } m_FeedbackRequests.Remove(request); - foreach (var existingRequest in new List(m_FeedbackRequests)) - { - if (existingRequest.node == request.node && existingRequest.control == request.control) - { - ExecuteFeedback(existingRequest); - break; - } - } + ExecuteFeedback(); } public void ClearFeedbackRequests(IRequestFeedback caller) From 7696c40f079f0f504fe967584c8ca6694657acda Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 20 Sep 2017 16:46:28 -0700 Subject: [PATCH 023/457] Implement feedback in other tools; Modify TwoHandedProxyBase feedback response to allow systems to override each other--synchronize feedback updates by caller --- Prefabs/Proxies/LeftTouch.prefab | 4 +- Prefabs/Proxies/RightTouch.prefab | 6 +- .../IStandardActionMap.cs | 5 +- Scripts/Modules/DeviceInputModule.cs | 3 + .../Modules/TooltipModule/TooltipModule.cs | 6 +- Scripts/Proxies/TwoHandedProxyBase.cs | 25 +++---- Scripts/Utilities/InputUtils.cs | 25 +++++++ .../CreatePrimitiveTool.cs | 23 ++++-- Tools/LocomotionTool/LocomotionTool.cs | 26 +------ Tools/LocomotionTool/LocomotionTool.cs.meta | 6 +- .../MoveWorkspacesTool/MoveWorkspacesTool.cs | 1 + Tools/SelectionTool/SelectionTool.cs | 23 +++++- Tools/VacuumTool/VacuumTool.cs | 70 ++++++++++++++----- 13 files changed, 150 insertions(+), 73 deletions(-) diff --git a/Prefabs/Proxies/LeftTouch.prefab b/Prefabs/Proxies/LeftTouch.prefab index 311233ac3..4f3130a20 100644 --- a/Prefabs/Proxies/LeftTouch.prefab +++ b/Prefabs/Proxies/LeftTouch.prefab @@ -1235,7 +1235,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1882268458449164} m_LocalRotation: {x: -0.036001876, y: 0.9469688, z: 0.31843576, w: -0.023508724} - m_LocalPosition: {x: -0.043206386, y: -0.029995611, z: -0.026119232} + m_LocalPosition: {x: -0.0319, y: -0.0291, z: -0.0264} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 498550} @@ -1433,7 +1433,7 @@ MonoBehaviour: m_TooltipText: m_TooltipTarget: {fileID: 4032307745343326} m_TooltipSource: {fileID: 450394} - m_TooltipAlignment: 1 + m_TooltipAlignment: 0 --- !u!114 &114543264181638874 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Prefabs/Proxies/RightTouch.prefab b/Prefabs/Proxies/RightTouch.prefab index 7cd8d555c..8a8cc1763 100644 --- a/Prefabs/Proxies/RightTouch.prefab +++ b/Prefabs/Proxies/RightTouch.prefab @@ -332,7 +332,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 141214} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0.25, y: -0.775, z: 0} + m_LocalPosition: {x: 0, y: -0.775, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 484770} @@ -1259,7 +1259,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1172441472411894} m_LocalRotation: {x: 0.036001876, y: 0.9469688, z: 0.31843576, w: 0.023508724} - m_LocalPosition: {x: 0.0432064, y: -0.029995611, z: -0.026119232} + m_LocalPosition: {x: 0.0326, y: -0.0291, z: -0.0263} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 449518} @@ -1488,7 +1488,7 @@ MonoBehaviour: m_TooltipText: m_TooltipTarget: {fileID: 4512895743762768} m_TooltipSource: {fileID: 431526} - m_TooltipAlignment: 1 + m_TooltipAlignment: 2 --- !u!114 &114713234785505344 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Scripts/Interfaces/FunctionalityInjection/IStandardActionMap.cs b/Scripts/Interfaces/FunctionalityInjection/IStandardActionMap.cs index b2a8a853f..b9c6b75ec 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IStandardActionMap.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IStandardActionMap.cs @@ -1,4 +1,6 @@ -#if UNITY_EDITOR +using UnityEngine.InputNew; + +#if UNITY_EDITOR namespace UnityEditor.Experimental.EditorVR { /// @@ -6,6 +8,7 @@ namespace UnityEditor.Experimental.EditorVR /// public interface IStandardActionMap : IProcessInput { + ActionMap standardActionMap { set; } } } #endif diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 2676f8989..9432012d1 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -141,7 +141,10 @@ public ActionMapInput CreateActionMapInputForObject(object obj, InputDevice devi var standardMap = obj as IStandardActionMap; if (standardMap != null) + { + standardMap.standardActionMap = m_StandardToolActionMap; return CreateActionMapInput(m_StandardToolActionMap, device); + } return null; } diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index a6bf4f8e0..34095d971 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -29,6 +29,7 @@ sealed class TooltipModule : MonoBehaviour, IUsesViewerScale class TooltipData { public float startTime; + public float lastModifiedTime; public TooltipUI tooltipUI; public bool persistent; public float duration; @@ -97,7 +98,7 @@ void Update() if (tooltipData.persistent) { var duration = tooltipData.duration; - if (duration > 0 && hoverTime + k_Delay > duration) + if (duration > 0 && Time.time - tooltipData.lastModifiedTime + k_Delay > duration) m_TooltipsToHide.Add(tooltip); } } @@ -233,7 +234,7 @@ public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duratio TooltipData data; if (m_Tooltips.TryGetValue(tooltip, out data)) { - data.startTime = Time.time; + data.lastModifiedTime = Time.time; data.persistent |= persistent; data.duration = duration; return; @@ -242,6 +243,7 @@ public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duratio m_Tooltips[tooltip] = new TooltipData { startTime = Time.time, + lastModifiedTime = Time.time, persistent = persistent, duration = duration }; diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 377ff78bc..f4b8b7b37 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -188,24 +188,12 @@ public void AddFeedbackRequest(FeedbackRequest request) var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) { - foreach (var existingRequest in new List(m_FeedbackRequests)) - { - if (existingRequest.node == proxyRequest.node && existingRequest.control == proxyRequest.control) - { - if (existingRequest.priority <= proxyRequest.priority) - RemoveFeedbackRequest(existingRequest); - else - return; - } - } - m_FeedbackRequests.Add(proxyRequest); + ExecuteFeedback(proxyRequest); } - - ExecuteFeedback(); } - void ExecuteFeedback() + void ExecuteFeedback(ProxyFeedbackRequest changedRequest) { foreach (var proxyNode in m_Buttons) { @@ -214,8 +202,11 @@ void ExecuteFeedback() ProxyFeedbackRequest request = null; foreach (var req in m_FeedbackRequests) { - if (req.node == proxyNode.Key && req.control == kvp.Key - && (request == null || req.priority > request.priority)) + var matchChanged = req.node == changedRequest.node && req.control == changedRequest.control; + var matchButton = req.node == proxyNode.Key && req.control == kvp.Key; + var sameCaller = req.caller == changedRequest.caller; + var priority = request == null || req.priority >= request.priority; + if (matchButton && priority && (matchChanged || sameCaller)) request = req; } @@ -271,7 +262,7 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) } m_FeedbackRequests.Remove(request); - ExecuteFeedback(); + ExecuteFeedback(request); } public void ClearFeedbackRequests(IRequestFeedback caller) diff --git a/Scripts/Utilities/InputUtils.cs b/Scripts/Utilities/InputUtils.cs index d31ccb764..bcf6bef03 100644 --- a/Scripts/Utilities/InputUtils.cs +++ b/Scripts/Utilities/InputUtils.cs @@ -42,6 +42,31 @@ public static void CollectDeviceSlotsFromActionMapInput(ActionMapInput actionMap deviceSlots.Add(deviceSlot); } } + + public static void GetBindingDictionaryFromActionMap(ActionMap actionMap, Dictionary> bindingDictionary) + { + var actions = actionMap.actions; + foreach (var scheme in actionMap.controlSchemes) + { + var bindings = scheme.bindings; + for (var i = 0; i < bindings.Count; i++) + { + var binding = bindings[i]; + var action = actions[i].name; + List controls; + if (!bindingDictionary.TryGetValue(action, out controls)) + { + controls = new List(); + bindingDictionary[action] = controls; + } + + foreach (var source in binding.sources) + { + bindingDictionary[action].Add((VRInputDevice.VRControl)source.controlIndex); + } + } + } + } } } #endif diff --git a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs index 921f12fd8..e77eb932a 100644 --- a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs +++ b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs @@ -1,4 +1,5 @@ #if UNITY_EDITOR +using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -28,6 +29,8 @@ sealed class CreatePrimitiveTool : MonoBehaviour, ITool, IStandardActionMap, ICo PrimitiveCreationStates m_State = PrimitiveCreationStates.StartPoint; + readonly Dictionary> m_Controls = new Dictionary>(); + public Transform rayOrigin { get; set; } public Node? node { get; set; } @@ -46,12 +49,20 @@ void Start() createPrimitiveMenu.selectPrimitive = SetSelectedPrimitive; createPrimitiveMenu.close = Close; - this.AddFeedbackRequest(new ProxyFeedbackRequest + InputUtils.GetBindingDictionaryFromActionMap(standardActionMap, m_Controls); + + foreach (var control in m_Controls) { - node = node.Value, - control = VRInputDevice.VRControl.Trigger1, - tooltipText = "Draw" - }); + foreach (var id in control.Value) + { + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + node = node.Value, + control = id, + tooltipText = "Draw" + }); + } + } } public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) @@ -173,6 +184,8 @@ void OnDestroy() this.RemoveRayVisibilitySettings(rayOrigin, this); this.ClearFeedbackRequests(); } + + public ActionMap standardActionMap { private get; set; } } } #endif diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index a3d60b5d8..5d10ee7a7 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -39,7 +39,7 @@ sealed class LocomotionTool : MonoBehaviour, ITool, ILocomotor, IUsesRayOrigin, GameObject m_ViewerScaleVisualsPrefab; [SerializeField] - ActionMap m_BlinkActionMap; + ActionMap m_ActionMap; [SerializeField] GameObject m_SettingsMenuItemPrefab; @@ -105,7 +105,7 @@ class Preferences readonly List m_ResetScaleFeedback = new List(); - public ActionMap actionMap { get { return m_BlinkActionMap; } } + public ActionMap actionMap { get { return m_ActionMap; } } public Transform rayOrigin { get; set; } @@ -190,27 +190,7 @@ void Start() m_ViewerScaleVisuals = viewerScaleObject.GetComponent(); viewerScaleObject.SetActive(false); - var actions = m_BlinkActionMap.actions; - foreach (var scheme in m_BlinkActionMap.controlSchemes) - { - var bindings = scheme.bindings; - for (var i = 0; i < bindings.Count; i++) - { - var binding = bindings[i]; - var action = actions[i].name; - List controls; - if (!m_Controls.TryGetValue(action, out controls)) - { - controls = new List(); - m_Controls[action] = controls; - } - - foreach (var source in binding.sources) - { - m_Controls[action].Add((VRInputDevice.VRControl)source.controlIndex); - } - } - } + InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); ShowCrawlFeedback(); ShowMainButtonFeedback(); diff --git a/Tools/LocomotionTool/LocomotionTool.cs.meta b/Tools/LocomotionTool/LocomotionTool.cs.meta index 62a7fd4e7..56fd36fd1 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs.meta +++ b/Tools/LocomotionTool/LocomotionTool.cs.meta @@ -1,7 +1,7 @@ fileFormatVersion: 2 guid: 403957a6dcd8bfe4a905881513f309b0 -timeCreated: 1501023394 -licenseType: Free +timeCreated: 1505948008 +licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: @@ -9,7 +9,7 @@ MonoImporter: type: 2} - m_ViewerScaleVisualsPrefab: {fileID: 1000012817627458, guid: 60a4bda9bfa0dcc4e9ccab99d39c295f, type: 2} - - m_BlinkActionMap: {fileID: 11400000, guid: 9729abfd6d2540f4db055be042af7175, type: 2} + - m_ActionMap: {fileID: 11400000, guid: 9729abfd6d2540f4db055be042af7175, type: 2} - m_SettingsMenuItemPrefab: {fileID: 1000013404610172, guid: f1141ca24ceb64f49a6e988175713e3d, type: 2} executionOrder: 0 diff --git a/Tools/MoveWorkspacesTool/MoveWorkspacesTool.cs b/Tools/MoveWorkspacesTool/MoveWorkspacesTool.cs index e98da093b..ca83be365 100644 --- a/Tools/MoveWorkspacesTool/MoveWorkspacesTool.cs +++ b/Tools/MoveWorkspacesTool/MoveWorkspacesTool.cs @@ -36,6 +36,7 @@ enum State public Transform rayOrigin { private get; set; } public List allWorkspaces { private get; set; } + public ActionMap standardActionMap { private get; set; } public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index edf7bd911..6f7df2a03 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -14,7 +14,7 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR ISetHighlight, ISelectObject, ISetManipulatorsVisible, IIsHoveringOverUI, IUsesDirectSelection, ILinkedObject, ICanGrabObject, IGetManipulatorDragState, IUsesNode, IGetRayVisibility, IIsMainMenuVisible, IIsInMiniWorld, IRayToNode, IGetDefaultRayColor, ISetDefaultRayColor, ITooltip, ITooltipPlacement, ISetTooltipVisibility, - IUsesProxyType + IUsesProxyType, IRequestFeedback { const float k_MultiselectHueShift = 0.5f; static readonly Vector3 k_TooltipPosition = new Vector3(0, 0.05f, -0.03f); @@ -32,6 +32,9 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR Color m_MultiselectRayColor; bool m_MultiSelect; + readonly Dictionary> m_Controls = new Dictionary>(); + readonly List m_SelectFeedback = new List(); + readonly Dictionary m_HoverGameObjects = new Dictionary(); readonly Dictionary m_SelectionHoverGameObjects = new Dictionary(); @@ -60,6 +63,24 @@ void Start() tooltipTarget = ObjectUtils.CreateEmptyGameObject("SelectionTool Tooltip Target", rayOrigin).transform; tooltipTarget.localPosition = k_TooltipPosition; tooltipTarget.localRotation = k_TooltipRotation; + + InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); + + foreach (var control in m_Controls) + { + if (control.Key != "Select") + continue; + + foreach (var id in control.Value) + { + this.AddFeedbackRequest(new ProxyFeedbackRequest + { + node = node.Value, + control = id, + tooltipText = "Select" + }); + } + } } public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) diff --git a/Tools/VacuumTool/VacuumTool.cs b/Tools/VacuumTool/VacuumTool.cs index 54db93ba6..48c87753e 100644 --- a/Tools/VacuumTool/VacuumTool.cs +++ b/Tools/VacuumTool/VacuumTool.cs @@ -1,13 +1,14 @@ #if UNITY_EDITOR using System.Collections; using System.Collections.Generic; +using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR.Tools { - sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin, IUsesViewerScale + sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin, IUsesViewerScale, IRequestFeedback, IUsesNode { [SerializeField] ActionMap m_ActionMap; @@ -15,6 +16,9 @@ sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin float m_LastClickTime; readonly Dictionary m_VacuumingCoroutines = new Dictionary(); + readonly Dictionary> m_Controls = new Dictionary>(); + readonly List m_Feedback = new List(); + public ActionMap actionMap { get { return m_ActionMap; } } public List vacuumables { private get; set; } @@ -23,38 +27,72 @@ sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin public Vector3 defaultOffset { private get; set; } public Quaternion defaultTilt { private get; set; } + public Node? node { private get; set; } + + void Start() + { + InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); + } public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { - var vacuumInput = (VacuumInput)input; - if (vacuumInput.vacuum.wasJustPressed) + var hit = false; + foreach (var vacuumable in vacuumables) { - var realTime = Time.realtimeSinceStartup; - if (UIUtils.IsDoubleClick(realTime - m_LastClickTime)) + var vacuumableTransform = vacuumable.transform; + var ray = new Ray(rayOrigin.position, rayOrigin.forward); + ray.origin = vacuumableTransform.InverseTransformPoint(ray.origin); + ray.direction = vacuumableTransform.InverseTransformDirection(ray.direction); + if (vacuumable.vacuumBounds.IntersectRay(ray)) { - var hit = false; - foreach (var vacuumable in vacuumables) + hit = true; + var vacuumInput = (VacuumInput)input; + if (vacuumInput.vacuum.wasJustPressed) { - var vacuumableTransform = vacuumable.transform; - var ray = new Ray(rayOrigin.position, rayOrigin.forward); - ray.origin = vacuumableTransform.InverseTransformPoint(ray.origin); - ray.direction = vacuumableTransform.InverseTransformDirection(ray.direction); - if (vacuumable.vacuumBounds.IntersectRay(ray)) + var realTime = Time.realtimeSinceStartup; + if (UIUtils.IsDoubleClick(realTime - m_LastClickTime)) { - hit = true; Coroutine coroutine; if (m_VacuumingCoroutines.TryGetValue(vacuumableTransform, out coroutine)) StopCoroutine(coroutine); m_VacuumingCoroutines[vacuumableTransform] = StartCoroutine(VacuumToViewer(vacuumable)); + consumeControl(vacuumInput.vacuum); } + + m_LastClickTime = realTime; } - if (hit) - consumeControl(vacuumInput.vacuum); + if (m_Feedback.Count == 0) + { + foreach (var kvp in m_Controls) + { + foreach (var id in kvp.Value) + { + var request = new ProxyFeedbackRequest + { + control = id, + node = node.Value, + tooltipText = "Double-tap to summon workspace" + }; + + m_Feedback.Add(request); + this.AddFeedbackRequest(request); + } + } + } + + break; } + } - m_LastClickTime = realTime; + if (!hit) + { + foreach (var request in m_Feedback) + { + this.RemoveFeedbackRequest(request); + } + m_Feedback.Clear(); } } From 6c4281f1320d189e74127c6df1131e5f9e37ef71 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 20 Sep 2017 22:55:57 -0700 Subject: [PATCH 024/457] Fix stuck tooltip by only overwriting duration for persistent show events; Clean up feedback in default tools; Add documentation to IRequestFeedback --- .../FunctionalityInjection/IRequestFeedback.cs | 18 ++++++++++++++++-- Scripts/Modules/TooltipModule/TooltipModule.cs | 8 ++++++-- Tools/SelectionTool/SelectionTool.cs | 6 +++++- Tools/VacuumTool/VacuumTool.cs | 8 +++++++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs index 7c2faa9b4..bb201d594 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs @@ -12,18 +12,32 @@ public static class IRequestFeedbackMethods public static Action removeFeedbackRequest { private get; set; } public static Action clearFeedbackRequests { private get; set; } - public static void AddFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request) where TFeedbackRequest : FeedbackRequest + /// + /// Add a feedback request to the system + /// + /// The caller object + /// The feedback request + public static void AddFeedbackRequest(this IRequestFeedback obj, FeedbackRequest request) { request.caller = obj; addFeedbackRequest(request); } - public static void RemoveFeedbackRequest(this IRequestFeedback obj, TFeedbackRequest request) where TFeedbackRequest : FeedbackRequest + /// + /// Remove a feedback request from the system + /// + /// The caller object + /// The feedback request + public static void RemoveFeedbackRequest(this IRequestFeedback obj, FeedbackRequest request) { request.caller = obj; removeFeedbackRequest(request); } + /// + /// Clear all feedback requests submitted by this caller from the system + /// + /// The caller object public static void ClearFeedbackRequests(this IRequestFeedback obj) { clearFeedbackRequests(obj); diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index 34095d971..e4677d04c 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -234,9 +234,13 @@ public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duratio TooltipData data; if (m_Tooltips.TryGetValue(tooltip, out data)) { - data.lastModifiedTime = Time.time; data.persistent |= persistent; - data.duration = duration; + if (duration > 0) + { + data.duration = duration; + data.lastModifiedTime = Time.time; + } + return; } diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 6f7df2a03..804d11eb7 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -33,7 +33,6 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR bool m_MultiSelect; readonly Dictionary> m_Controls = new Dictionary>(); - readonly List m_SelectFeedback = new List(); readonly Dictionary m_HoverGameObjects = new Dictionary(); @@ -83,6 +82,11 @@ void Start() } } + void OnDestroy() + { + this.ClearFeedbackRequests(); + } + public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { if (this.GetManipulatorDragState()) diff --git a/Tools/VacuumTool/VacuumTool.cs b/Tools/VacuumTool/VacuumTool.cs index 48c87753e..a929c1e6a 100644 --- a/Tools/VacuumTool/VacuumTool.cs +++ b/Tools/VacuumTool/VacuumTool.cs @@ -8,7 +8,8 @@ namespace UnityEditor.Experimental.EditorVR.Tools { - sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin, IUsesViewerScale, IRequestFeedback, IUsesNode + sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin, IUsesViewerScale, + IRequestFeedback, IUsesNode { [SerializeField] ActionMap m_ActionMap; @@ -34,6 +35,11 @@ void Start() InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); } + void OnDestroy() + { + this.ClearFeedbackRequests(); + } + public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { var hit = false; From 4f1709557f6eb731b32716462473567df807af31 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 20 Sep 2017 23:31:30 -0700 Subject: [PATCH 025/457] Address blink feedback --- Tools/LocomotionTool/LocomotionTool.cs | 45 +++++++++++++++++----- Tools/SelectionTool/SelectionTool.cs | 53 ++++++++++++++++++-------- 2 files changed, 73 insertions(+), 25 deletions(-) diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 5d10ee7a7..99c82c512 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -191,9 +191,6 @@ void Start() viewerScaleObject.SetActive(false); InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); - - ShowCrawlFeedback(); - ShowMainButtonFeedback(); } void OnDestroy() @@ -330,10 +327,12 @@ bool DoRotating(ConsumeControlDelegate consumeControl) foreach (var linkedObject in linkedObjects) { var locomotionTool = (LocomotionTool)linkedObject; - locomotionTool.HideMainButtonFeedback(); locomotionTool.HideRotateFeedback(); + locomotionTool.HideCrawlFeedback(); locomotionTool.HideScaleFeedback(); locomotionTool.HideSpeedFeedback(); + if (!m_Preferences.blinkMode) + locomotionTool.HideMainButtonFeedback(); } var localRayRotation = Quaternion.Inverse(cameraRig.rotation) * rayOrigin.rotation; @@ -413,6 +412,12 @@ bool DoRotating(ConsumeControlDelegate consumeControl) bool DoCrawl(ConsumeControlDelegate consumeControl) { + foreach (var linkedObject in linkedObjects) + { + if (((LocomotionTool)linkedObject).m_Rotating) + return false; + } + var crawl = m_LocomotionInput.crawl; var blink = m_LocomotionInput.blink; if (!m_LocomotionInput.forward.isHeld && !blink.isHeld && crawl.isHeld) @@ -495,22 +500,38 @@ bool DoCrawl(ConsumeControlDelegate consumeControl) bool DoBlink(ConsumeControlDelegate consumeControl) { - if (m_LocomotionInput.blink.wasJustPressed) + var blink = m_LocomotionInput.blink; + if (blink.wasJustPressed) + { + HideMainButtonFeedback(); + HideCrawlFeedback(); ShowRotateFeedback(); + } - if (m_LocomotionInput.blink.isHeld) + if (blink.isHeld) { this.AddRayVisibilitySettings(rayOrigin, this, false, false); - m_BlinkVisuals.extraSpeed = m_LocomotionInput.speed.value; + var speed = m_LocomotionInput.speed.value; + m_BlinkVisuals.extraSpeed = speed; + + if (speed < 0) + HideSpeedFeedback(); + else if (m_SpeedFeedback.Count == 0) + ShowSpeedFeedback(); + m_BlinkVisuals.visible = true; - consumeControl(m_LocomotionInput.blink); + consumeControl(blink); return true; } - if (m_LocomotionInput.blink.wasJustReleased) + if (blink.wasJustReleased) { this.RemoveRayVisibilitySettings(rayOrigin, this); + HideRotateFeedback(); + HideSpeedFeedback(); + ShowMainButtonFeedback(); + ShowCrawlFeedback(); m_BlinkVisuals.visible = false; @@ -984,9 +1005,13 @@ public void OnDeserializePreferences(object obj) // Share one preferences object across all instances foreach (var linkedObject in linkedObjects) { - ((LocomotionTool)linkedObject).m_Preferences = m_Preferences; + var locomotionTool = (LocomotionTool)linkedObject; + locomotionTool.m_Preferences = m_Preferences; m_BlinkToggle.isOn = m_Preferences.blinkMode; m_FlyToggle.isOn = !m_Preferences.blinkMode; + + locomotionTool.ShowCrawlFeedback(); + locomotionTool.ShowMainButtonFeedback(); } } } diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 804d11eb7..bfd67fbe7 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -33,6 +33,7 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR bool m_MultiSelect; readonly Dictionary> m_Controls = new Dictionary>(); + readonly List m_SelectFeedback = new List(); readonly Dictionary m_HoverGameObjects = new Dictionary(); @@ -65,21 +66,7 @@ void Start() InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); - foreach (var control in m_Controls) - { - if (control.Key != "Select") - continue; - - foreach (var id in control.Value) - { - this.AddFeedbackRequest(new ProxyFeedbackRequest - { - node = node.Value, - control = id, - tooltipText = "Select" - }); - } - } + ShowSelectFeedback(); } void OnDestroy() @@ -216,6 +203,11 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } } + if (!this.IsRayVisible(rayOrigin)) + HideSelectFeedback(); + else if (m_SelectFeedback.Count == 0) + ShowSelectFeedback(); + if (!IsRayActive()) return; @@ -312,6 +304,37 @@ void OnDisable() } public void OnResetDirectSelectionState() { } + + void ShowSelectFeedback() + { + foreach (var control in m_Controls) + { + if (control.Key != "Select") + continue; + + foreach (var id in control.Value) + { + var request = new ProxyFeedbackRequest + { + node = node.Value, + control = id, + tooltipText = "Select" + }; + + this.AddFeedbackRequest(request); + m_SelectFeedback.Add(request); + } + } + } + + void HideSelectFeedback() + { + foreach (var request in m_SelectFeedback) + { + this.RemoveFeedbackRequest(request); + } + m_SelectFeedback.Clear(); + } } } #endif From dadf4920c3f254eaa61fc6764450679bc321a2d1 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 21 Sep 2017 00:13:01 -0700 Subject: [PATCH 026/457] Add feedback settings menu item --- .../Modules/FeedbackModule/FeedbackModule.cs | 100 +++++- .../FeedbackModule/FeedbackModule.cs.meta | 6 +- .../Modules/FeedbackModule/SettingsUI.prefab | 325 ++++++++++++++++++ .../FeedbackModule/SettingsUI.prefab.meta | 9 + .../Modules/SnappingModule/SnappingModule.cs | 4 +- Scripts/Proxies/TwoHandedProxyBase.cs | 5 +- 6 files changed, 440 insertions(+), 9 deletions(-) create mode 100644 Scripts/Modules/FeedbackModule/SettingsUI.prefab create mode 100644 Scripts/Modules/FeedbackModule/SettingsUI.prefab.meta diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index 3f6971eee..a1f73d66b 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -1,19 +1,68 @@ #if UNITY_EDITOR +using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Core; +using UnityEditor.Experimental.EditorVR.Handles; +using UnityEditor.Experimental.EditorVR.Tools; using UnityEngine; +using UnityEngine.UI; namespace UnityEditor.Experimental.EditorVR { public abstract class FeedbackRequest { public IRequestFeedback caller; + public GameObject settingsMenuItemPrefab { get; private set; } + public GameObject settingsMenuItemInstance { get; set; } + } - public class FeedbackModule : MonoBehaviour, IInterfaceConnector + public class FeedbackModule : MonoBehaviour, IInterfaceConnector, ISettingsMenuItemProvider, ISerializePreferences { + [Serializable] + class Preferences + { + [SerializeField] + bool m_Enabled = true; + + public bool enabled { get { return m_Enabled; } set { m_Enabled = value; } } + } + + [SerializeField] + GameObject m_SettingsMenuItemPrefab; + + readonly List m_Toggles = new List(); + + Preferences m_Preferences; + readonly List m_FeedbackReceivers = new List(); + public GameObject settingsMenuItemPrefab { get { return m_SettingsMenuItemPrefab; } } + + public GameObject settingsMenuItemInstance + { + set + { + var toggle = value.GetComponent(); + if (m_Preferences != null) + toggle.isOn = m_Preferences.enabled; + + m_Toggles.Add(toggle); + var label = value.GetComponentInChildren(); + toggle.onValueChanged.AddListener(isOn => + { + label.text = isOn ? "Feedback enabled" : "Feedback disabled"; + SetEnabled(isOn); + }); + + var handle = value.GetComponent(); + handle.hoverStarted += (baseHandle, data) => { label.text = m_Preferences.enabled ? "Disable feedback" : "Enable feedback"; }; + handle.hoverEnded += (baseHandle, data) => { label.text = m_Preferences.enabled ? "Feedback enabled" : "Feedback disabled"; }; + } + } + + public Transform rayOrigin { get { return null; } } + void Awake() { IRequestFeedbackMethods.addFeedbackRequest = AddFeedbackRequest; @@ -21,6 +70,12 @@ void Awake() IRequestFeedbackMethods.clearFeedbackRequests = ClearFeedbackRequests; } + void Start() + { + if (m_Preferences == null) + m_Preferences = new Preferences(); + } + public void ConnectInterface(object obj, Transform rayOrigin = null) { var feedbackReceiver = obj as IFeedbackReciever; @@ -35,30 +90,67 @@ public void DisconnectInterface(object obj, Transform rayOrigin = null) m_FeedbackReceivers.Remove(feedbackReceiver); } + void SetEnabled(bool enabled) + { + if (m_Preferences.enabled != enabled) + { + m_Preferences.enabled = enabled; + if (!enabled) + { + foreach (var receiver in m_FeedbackReceivers) + { + receiver.ClearFeedbackRequests(null); + } + } + } + } + void AddFeedbackRequest(FeedbackRequest request) { + if (!m_Preferences.enabled) + return; + foreach (var receiver in m_FeedbackReceivers) { receiver.AddFeedbackRequest(request); } } - public void RemoveFeedbackRequest(FeedbackRequest request) + void RemoveFeedbackRequest(FeedbackRequest request) { - //Debug.Log("add"); foreach (var receiver in m_FeedbackReceivers) { receiver.RemoveFeedbackRequest(request); } } - public void ClearFeedbackRequests(IRequestFeedback caller) + void ClearFeedbackRequests(IRequestFeedback caller) { + if (caller == null) // Requesters are not allowed to clear all requests + return; + foreach (var reciever in m_FeedbackReceivers) { reciever.ClearFeedbackRequests(caller); } } + + public object OnSerializePreferences() + { + return m_Preferences; + } + + public void OnDeserializePreferences(object obj) + { + var preferences = obj as Preferences; + if (preferences != null) + m_Preferences = preferences; + + foreach (var toggle in m_Toggles) + { + toggle.isOn = m_Preferences.enabled; + } + } } } #endif diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta b/Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta index 0732e8780..146d7878d 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs.meta @@ -1,10 +1,12 @@ fileFormatVersion: 2 guid: 0c0af8559f906454db081815e6275f48 -timeCreated: 1505752823 +timeCreated: 1505977262 licenseType: Pro MonoImporter: serializedVersion: 2 - defaultReferences: [] + defaultReferences: + - m_SettingsMenuItemPrefab: {fileID: 1871321269361264, guid: 19cfca3e999de7f4a8ce17a546f821b0, + type: 2} executionOrder: 0 icon: {instanceID: 0} userData: diff --git a/Scripts/Modules/FeedbackModule/SettingsUI.prefab b/Scripts/Modules/FeedbackModule/SettingsUI.prefab new file mode 100644 index 000000000..413fc6051 --- /dev/null +++ b/Scripts/Modules/FeedbackModule/SettingsUI.prefab @@ -0,0 +1,325 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1871321269361264} + m_IsPrefabParent: 1 +--- !u!1 &1082264891174920 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224171904768544026} + - component: {fileID: 222812621535630740} + - component: {fileID: 114103337935952270} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1106373738361608 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224480973526858598} + - component: {fileID: 222229311677709098} + - component: {fileID: 114126329478329400} + m_Layer: 5 + m_Name: Foreground + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1783597616570472 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224489708011733936} + - component: {fileID: 222346717056121606} + - component: {fileID: 114735008874531044} + m_Layer: 5 + m_Name: Border + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1871321269361264 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224941029338454860} + - component: {fileID: 114548669865996182} + - component: {fileID: 222628525624526828} + - component: {fileID: 114248162690192462} + m_Layer: 5 + m_Name: SettingsUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &114103337935952270 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1082264891174920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: dec2d25be9058334c91a0402762efa61, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: 013679fd6ee2085428a7f896aa7b50cc, type: 3} + m_FontSize: 20 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 3 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Feedback enabled +--- !u!114 &114126329478329400 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1106373738361608} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: dec2d25be9058334c91a0402762efa61, type: 2} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!114 &114248162690192462 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1871321269361264} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114548669865996182 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1871321269361264} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 0, g: 0, b: 0, a: 0.76} + m_HighlightedColor: {r: 0, g: 0, b: 0, a: 0.866} + m_PressedColor: {r: 0, g: 0, b: 0, a: 0.76} + m_DisabledColor: {r: 0, g: 0, b: 0, a: 0.76} + m_ColorMultiplier: 1 + m_FadeDuration: 0.2 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 114126329478329400} + toggleTransition: 1 + graphic: {fileID: 114735008874531044} + m_Group: {fileID: 0} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Toggle+ToggleEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null + m_IsOn: 1 +--- !u!114 &114735008874531044 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1783597616570472} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: db3c88ad8f7fe11479d2d3e48c08e6f0, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!222 &222229311677709098 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1106373738361608} +--- !u!222 &222346717056121606 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1783597616570472} +--- !u!222 &222628525624526828 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1871321269361264} +--- !u!222 &222812621535630740 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1082264891174920} +--- !u!224 &224171904768544026 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1082264891174920} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224941029338454860} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 5, y: 0} + m_SizeDelta: {x: -10, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224480973526858598 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1106373738361608} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224941029338454860} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224489708011733936 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1783597616570472} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224941029338454860} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 2, y: 2} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224941029338454860 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1871321269361264} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 224489708011733936} + - {fileID: 224480973526858598} + - {fileID: 224171904768544026} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: 411.55017} + m_SizeDelta: {x: 263.2, y: 45} + m_Pivot: {x: 0.5, y: 0.5} diff --git a/Scripts/Modules/FeedbackModule/SettingsUI.prefab.meta b/Scripts/Modules/FeedbackModule/SettingsUI.prefab.meta new file mode 100644 index 000000000..79beb4d8c --- /dev/null +++ b/Scripts/Modules/FeedbackModule/SettingsUI.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 19cfca3e999de7f4a8ce17a546f821b0 +timeCreated: 1505976608 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/SnappingModule/SnappingModule.cs b/Scripts/Modules/SnappingModule/SnappingModule.cs index 1bb7fdda4..f63bab93a 100644 --- a/Scripts/Modules/SnappingModule/SnappingModule.cs +++ b/Scripts/Modules/SnappingModule/SnappingModule.cs @@ -880,7 +880,7 @@ void SetupUI() }); var handle = snappingEnabledUI.GetComponent(); - handle.hoverStarted += (baseHandle, data) => { text.text = m_Preferences.disableAll ? "Enable Snapping" : "Disable snapping"; }; + handle.hoverStarted += (baseHandle, data) => { text.text = m_Preferences.disableAll ? "Enable snapping" : "Disable snapping"; }; handle.hoverEnded += (baseHandle, data) => { text.text = m_Preferences.disableAll ? "Snapping disabled" : "Snapping enabled"; }; var groundSnappingUI = m_SnappingModuleSettingsUI.groundSnappingEnabled; @@ -963,4 +963,4 @@ void SetSessionGradientMaterial(GradientPair gradientPair) } } } -#endif \ No newline at end of file +#endif diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index f4b8b7b37..8a0391f5c 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -267,7 +267,10 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) public void ClearFeedbackRequests(IRequestFeedback caller) { - var requests = m_FeedbackRequests.Where(feedbackRequest => feedbackRequest.caller == caller).ToList(); + var requests = caller == null + ? new List(m_FeedbackRequests) + : m_FeedbackRequests.Where(feedbackRequest => feedbackRequest.caller == caller).ToList(); + foreach (var feedbackRequest in requests) { RemoveFeedbackRequest(feedbackRequest); From d88c8902460169a81eb402b97a370637ddff0c17 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 21 Sep 2017 00:26:58 -0700 Subject: [PATCH 027/457] Clean up code --- Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs | 4 +++- .../FunctionalityInjection/ISetTooltipVisibility.cs | 2 -- Scripts/Modules/FeedbackModule/FeedbackModule.cs | 1 - Scripts/Modules/SnappingModule/SnappingModuleSettingsUI.cs | 3 +-- Tools/LocomotionTool/LocomotionTool.cs | 2 -- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs index bb201d594..ecff6aa6b 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IRequestFeedback.cs @@ -1,4 +1,5 @@ -using System; +#if UNITY_EDITOR +using System; namespace UnityEditor.Experimental.EditorVR { @@ -44,3 +45,4 @@ public static void ClearFeedbackRequests(this IRequestFeedback obj) } } } +#endif diff --git a/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs b/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs index c5c925d04..2f79c83bf 100644 --- a/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs +++ b/Scripts/Interfaces/FunctionalityInjection/ISetTooltipVisibility.cs @@ -1,6 +1,4 @@ #if UNITY_EDITOR -using System; - namespace UnityEditor.Experimental.EditorVR { /// diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index a1f73d66b..1df66def7 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Handles; -using UnityEditor.Experimental.EditorVR.Tools; using UnityEngine; using UnityEngine.UI; diff --git a/Scripts/Modules/SnappingModule/SnappingModuleSettingsUI.cs b/Scripts/Modules/SnappingModule/SnappingModuleSettingsUI.cs index caa894bd5..4a881dcff 100644 --- a/Scripts/Modules/SnappingModule/SnappingModuleSettingsUI.cs +++ b/Scripts/Modules/SnappingModule/SnappingModuleSettingsUI.cs @@ -1,6 +1,5 @@ #if UNITY_EDITOR using UnityEngine; -using UnityEngine.Serialization; using UnityEngine.UI; namespace UnityEditor.Experimental.EditorVR @@ -86,4 +85,4 @@ public void SetToggleValue(Toggle toggle, bool isOn) } } } -#endif \ No newline at end of file +#endif diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 99c82c512..fb1f3dcaa 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -2,9 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using UnityEditor.Experimental.EditorVR.Core; -using UnityEditor.Experimental.EditorVR.Modules; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; From 47e78b5c8d17aa23005630370873bf872f265a43 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 21 Sep 2017 18:10:14 -0700 Subject: [PATCH 028/457] Implement block selection --- Scripts/Core/Interfaces/IGetPointerLength.cs | 5 + .../FunctionalityInjection/ICheckBounds.cs | 33 +++++ .../ICheckBounds.cs.meta | 12 ++ .../IntersectionModule/IntersectionModule.cs | 28 +++++ Scripts/Utilities/IntersectionUtils.cs | 19 +++ Tools/SelectionTool/BlockSelect.mat | 76 ++++++++++++ Tools/SelectionTool/BlockSelect.mat.meta | 9 ++ Tools/SelectionTool/BlockSelectCube.prefab | 82 ++++++++++++ .../SelectionTool/BlockSelectCube.prefab.meta | 9 ++ Tools/SelectionTool/SelectionTool.cs | 117 +++++++++++++++--- Tools/SelectionTool/SelectionTool.cs.meta | 4 +- Workspaces/Base/WorkspaceUI.cs | 17 +-- 12 files changed, 383 insertions(+), 28 deletions(-) create mode 100644 Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs create mode 100644 Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs.meta create mode 100644 Tools/SelectionTool/BlockSelect.mat create mode 100644 Tools/SelectionTool/BlockSelect.mat.meta create mode 100644 Tools/SelectionTool/BlockSelectCube.prefab create mode 100644 Tools/SelectionTool/BlockSelectCube.prefab.meta diff --git a/Scripts/Core/Interfaces/IGetPointerLength.cs b/Scripts/Core/Interfaces/IGetPointerLength.cs index c8650317d..c8297ca02 100644 --- a/Scripts/Core/Interfaces/IGetPointerLength.cs +++ b/Scripts/Core/Interfaces/IGetPointerLength.cs @@ -16,6 +16,11 @@ public static float GetPointerLength(this IGetPointerLength obj, Transform rayOr { return getPointerLength(rayOrigin); } + + public static Vector3 GetPointerPosition(this IGetPointerLength obj, Transform rayOrigin) + { + return rayOrigin.position + rayOrigin.forward * obj.GetPointerLength(rayOrigin); + } } } #endif diff --git a/Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs b/Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs new file mode 100644 index 000000000..fc39cf46f --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs @@ -0,0 +1,33 @@ +#if UNITY_EDITOR +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.Experimental.EditorVR +{ + /// + /// Gives decorated class access to IntersectionModule.CheckBounds + /// + public interface ICheckBounds + { + } + + public static class ICheckBoundsMethods + { + public delegate bool CheckBoundsDelegate(Bounds bounds, List objects, List ignoreList = null); + + public static CheckBoundsDelegate checkBounds { get; set; } + + /// + /// Do a bounds check against all Renderers + /// + /// The bounds against which to test for Renderers + /// The list to which intersected Renderers will be added + /// (optional) A list of Renderers to ignore + /// Whether the bounds intersected any objects + public static bool CheckBounds(this ICheckBounds obj, Bounds bounds, List objects, List ignoreList = null) + { + return checkBounds(bounds, objects, ignoreList); + } + } +} +#endif diff --git a/Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs.meta b/Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs.meta new file mode 100644 index 000000000..fa80d0c9e --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/ICheckBounds.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 15896e72bc1f45a41a06b915e99f9818 +timeCreated: 1501022830 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/IntersectionModule/IntersectionModule.cs b/Scripts/Modules/IntersectionModule/IntersectionModule.cs index 7a7c09670..f8a10e0ce 100644 --- a/Scripts/Modules/IntersectionModule/IntersectionModule.cs +++ b/Scripts/Modules/IntersectionModule/IntersectionModule.cs @@ -43,6 +43,7 @@ void Awake() IntersectionUtils.BakedMesh = new Mesh(); // Create a new Mesh in each Awake because it is destroyed on scene load IRaycastMethods.raycast = Raycast; + ICheckBoundsMethods.checkBounds = CheckBounds; } internal void Setup(SpatialHash hash) @@ -245,6 +246,33 @@ internal bool Raycast(Ray ray, out RaycastHit hit, out GameObject obj, float max return result; } + + internal bool CheckBounds(Bounds bounds, List objects, List ignoreList = null) + { + var result = false; + m_Intersections.Clear(); + if (m_SpatialHash.GetIntersections(m_Intersections, bounds)) + { + for (var i = 0; i < m_Intersections.Count; i++) + { + var renderer = m_Intersections[i]; + if (ignoreList != null && ignoreList.Contains(renderer)) + continue; + + var transform = renderer.transform; + + IntersectionUtils.SetupCollisionTester(m_CollisionTester, transform); + + if (IntersectionUtils.TestBox(m_CollisionTester, transform, bounds.center, bounds.extents, Quaternion.identity)) + { + objects.Add(renderer.gameObject); + result = true; + } + } + } + + return result; + } } } #endif diff --git a/Scripts/Utilities/IntersectionUtils.cs b/Scripts/Utilities/IntersectionUtils.cs index f3056f69f..509012b75 100644 --- a/Scripts/Utilities/IntersectionUtils.cs +++ b/Scripts/Utilities/IntersectionUtils.cs @@ -1,4 +1,5 @@ #if UNITY_EDITOR +using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Modules; using UnityEngine; @@ -181,6 +182,24 @@ public static bool TestRay(MeshCollider collisionTester, Transform obj, Ray ray, return collisionTester.Raycast(ray, out hit, maxDistance); } + /// + /// Tests a box against a collider + /// + /// A mesh collider located at the origin used to test the object in it's local space + /// The object to test collision on + /// The center of the box + /// Half the size of the box in each dimension + /// The rotation of the box + /// The result of whether the box intersects with the object + public static bool TestBox(MeshCollider collisionTester, Transform obj, Vector3 center, Vector3 halfExtents, Quaternion orientation) + { + center = obj.InverseTransformPoint(center); + halfExtents = Vector3.Scale(halfExtents, obj.lossyScale.Inverse()); + orientation = Quaternion.Inverse(obj.rotation) * orientation; + + return Physics.CheckBox(center, halfExtents, orientation); + } + public static void SetupCollisionTester(MeshCollider collisionTester, Transform obj) { var mf = obj.GetComponent(); diff --git a/Tools/SelectionTool/BlockSelect.mat b/Tools/SelectionTool/BlockSelect.mat new file mode 100644 index 000000000..4e01cc2d7 --- /dev/null +++ b/Tools/SelectionTool/BlockSelect.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: BlockSelect + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _ALPHAPREMULTIPLY_ON + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 10 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 3 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 0 + m_Colors: + - _Color: {r: 0.5514706, g: 0.7030426, b: 1, a: 0.166} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Tools/SelectionTool/BlockSelect.mat.meta b/Tools/SelectionTool/BlockSelect.mat.meta new file mode 100644 index 000000000..c954b2928 --- /dev/null +++ b/Tools/SelectionTool/BlockSelect.mat.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: dc3ff3f82bbe0a645b072abbf3070b96 +timeCreated: 1506033188 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tools/SelectionTool/BlockSelectCube.prefab b/Tools/SelectionTool/BlockSelectCube.prefab new file mode 100644 index 000000000..7f5518208 --- /dev/null +++ b/Tools/SelectionTool/BlockSelectCube.prefab @@ -0,0 +1,82 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1345258128224670} + m_IsPrefabParent: 1 +--- !u!1 &1345258128224670 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4664823842438600} + - component: {fileID: 33678997985348706} + - component: {fileID: 23835500417344658} + m_Layer: 0 + m_Name: BlockSelectCube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4664823842438600 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1345258128224670} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23835500417344658 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1345258128224670} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: dc3ff3f82bbe0a645b072abbf3070b96, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33678997985348706 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1345258128224670} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Tools/SelectionTool/BlockSelectCube.prefab.meta b/Tools/SelectionTool/BlockSelectCube.prefab.meta new file mode 100644 index 000000000..e32301a29 --- /dev/null +++ b/Tools/SelectionTool/BlockSelectCube.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e360a4c31cf4bf54fa01f9fa5b916ec6 +timeCreated: 1506034358 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 94faff11f..5a41b08e3 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -14,9 +14,10 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR ISetHighlight, ISelectObject, ISetManipulatorsVisible, IIsHoveringOverUI, IUsesDirectSelection, ILinkedObject, ICanGrabObject, IGetManipulatorDragState, IUsesNode, IGetRayVisibility, IIsMainMenuVisible, IIsInMiniWorld, IRayToNode, IGetDefaultRayColor, ISetDefaultRayColor, ITooltip, ITooltipPlacement, ISetTooltipVisibility, - IUsesProxyType, IMenuIcon + IUsesProxyType, IMenuIcon, IGetPointerLength, IRayVisibilitySettings, IUsesViewerScale, ICheckBounds { const float k_MultiselectHueShift = 0.5f; + const float k_BLockSelectDragThreshold = 0.01f; static readonly Vector3 k_TooltipPosition = new Vector3(0, 0.05f, -0.03f); static readonly Quaternion k_TooltipRotation = Quaternion.AngleAxis(90, Vector3.right); @@ -26,6 +27,9 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR [SerializeField] ActionMap m_ActionMap; + [SerializeField] + GameObject m_BlockSelectCube; + GameObject m_PressedObject; SelectionInput m_SelectionInput; @@ -34,10 +38,13 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR Color m_NormalRayColor; Color m_MultiselectRayColor; bool m_MultiSelect; + bool m_BlockSelect; + Vector3 m_SelectStartPosition; + Renderer m_BlockSelectCubeRenderer; readonly Dictionary m_HoverGameObjects = new Dictionary(); - readonly Dictionary m_SelectionHoverGameObjects = new Dictionary(); + readonly List m_BlockSelectHoverGameObjects = new List(); public ActionMap actionMap { get { return m_ActionMap; } } @@ -65,6 +72,15 @@ void Start() tooltipTarget = ObjectUtils.CreateEmptyGameObject("SelectionTool Tooltip Target", rayOrigin).transform; tooltipTarget.localPosition = k_TooltipPosition; tooltipTarget.localRotation = k_TooltipRotation; + + m_BlockSelectCube = ObjectUtils.Instantiate(m_BlockSelectCube, transform); + m_BlockSelectCube.SetActive(false); + m_BlockSelectCubeRenderer = m_BlockSelectCube.GetComponent(); + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_BlockSelectCube); } public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) @@ -111,11 +127,16 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon foreach (var linkedObject in linkedObjects) { var selectionTool = (SelectionTool)linkedObject; - var selectionRayOrigin = selectionTool.rayOrigin; + if (selectionTool.m_BlockSelect) + continue; if (!selectionTool.IsRayActive()) continue; + var selectionRayOrigin = selectionTool.rayOrigin; + if (!this.IsRayVisible(selectionRayOrigin)) + continue; + var hover = this.GetFirstGameObject(selectionRayOrigin); if (!selectionTool.GetSelectionCandidate(ref hover)) @@ -170,6 +191,9 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (selectionTool == null) continue; + if (selectionTool.m_BlockSelect) + continue; + if (!selectionTool.IsDirectActive()) { m_HoverGameObjects.Remove(directRayOrigin); @@ -208,26 +232,90 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (!GetSelectionCandidate(ref hoveredObject)) return; + var pointerPosition = this.GetPointerPosition(rayOrigin); + // Capture object on press - if (m_SelectionInput.select.wasJustPressed) - m_PressedObject = hoveredObject; + var select = m_SelectionInput.select; + if (select.wasJustPressed) + { + m_SelectStartPosition = pointerPosition; + + // Ray selection only if ray is visible + if (this.IsRayVisible(rayOrigin)) + m_PressedObject = hoveredObject; + } + + if (select.isHeld) + { + var startToEnd = pointerPosition - m_SelectStartPosition; + if (!m_BlockSelect && startToEnd.magnitude > k_BLockSelectDragThreshold * this.GetViewerScale()) + { + m_BlockSelect = true; + m_BlockSelectCube.SetActive(true); + m_PressedObject = null; + this.AddRayVisibilitySettings(rayOrigin, this, false, true); + } + + if (m_BlockSelect) + this.SetManipulatorsVisible(this, false); + + m_BlockSelectCube.transform.localScale = startToEnd; + m_BlockSelectCube.transform.position = m_SelectStartPosition + startToEnd * 0.5f; + + foreach (var hover in m_BlockSelectHoverGameObjects) + { + this.SetHighlight(hover, false, rayOrigin); + } + + m_BlockSelectHoverGameObjects.Clear(); + this.CheckBounds(m_BlockSelectCubeRenderer.bounds, m_BlockSelectHoverGameObjects); + + foreach (var hover in m_BlockSelectHoverGameObjects) + { + this.SetHighlight(hover, true, rayOrigin); + } + } // Select button on release - if (m_SelectionInput.select.wasJustReleased) + if (select.wasJustReleased) { - if (m_PressedObject == hoveredObject) + if (m_BlockSelect) { - this.SelectObject(m_PressedObject, rayOrigin, m_MultiSelect, true); - this.ResetDirectSelectionState(); + if (!m_MultiSelect) + { + this.SetManipulatorsVisible(this, true); + Selection.activeGameObject = null; + } - if (m_PressedObject != null) - this.SetHighlight(m_PressedObject, false, rayOrigin); + foreach (var hover in m_BlockSelectHoverGameObjects) + { + this.SelectObject(hover, rayOrigin, true); + + if (hover != null) + this.SetHighlight(hover, false, rayOrigin); + } + + this.ResetDirectSelectionState(); } + else + { + if (m_PressedObject == hoveredObject) + { + this.SelectObject(m_PressedObject, rayOrigin, m_MultiSelect, true); + this.ResetDirectSelectionState(); - if (m_PressedObject) - consumeControl(m_SelectionInput.select); + if (m_PressedObject != null) + this.SetHighlight(m_PressedObject, false, rayOrigin); + } + + if (m_PressedObject) + consumeControl(select); + } + this.RemoveRayVisibilitySettings(rayOrigin, this); + m_BlockSelectCube.SetActive(false); m_PressedObject = null; + m_BlockSelect = false; } } @@ -276,9 +364,6 @@ bool IsRayActive() if (this.IsInMiniWorld(rayOrigin)) return false; - if (!this.IsRayVisible(rayOrigin)) - return false; - return true; } diff --git a/Tools/SelectionTool/SelectionTool.cs.meta b/Tools/SelectionTool/SelectionTool.cs.meta index 2da0979de..bc3f7da89 100644 --- a/Tools/SelectionTool/SelectionTool.cs.meta +++ b/Tools/SelectionTool/SelectionTool.cs.meta @@ -1,12 +1,14 @@ fileFormatVersion: 2 guid: aab8fcc587f237c4cb48fb7bc8a59909 -timeCreated: 1492561521 +timeCreated: 1506034376 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: - m_Icon: {fileID: 21300000, guid: 6226464a462df6949a63407a4aed1753, type: 3} - m_ActionMap: {fileID: 11400000, guid: 9bdc23bc93bcec343934b99348f0ecf4, type: 2} + - m_BlockSelectCube: {fileID: 1345258128224670, guid: e360a4c31cf4bf54fa01f9fa5b916ec6, + type: 2} executionOrder: 0 icon: {instanceID: 0} userData: diff --git a/Workspaces/Base/WorkspaceUI.cs b/Workspaces/Base/WorkspaceUI.cs index 4969b086f..bed1abf4f 100644 --- a/Workspaces/Base/WorkspaceUI.cs +++ b/Workspaces/Base/WorkspaceUI.cs @@ -179,7 +179,7 @@ public DragState(WorkspaceUI workspaceUI, Transform rayOrigin, bool resizing) if (resizing) { - var pointerPosition = m_WorkspaceUI.GetPointerPositionForRayOrigin(rayOrigin); + var pointerPosition = m_WorkspaceUI.GetPointerPosition(rayOrigin); m_DragStart = pointerPosition; m_PositionStart = workspaceUI.transform.parent.position; m_BoundsSizeStart = workspaceUI.bounds.size; @@ -197,7 +197,7 @@ public void OnDragging() if (m_Resizing) { var viewerScale = m_WorkspaceUI.GetViewerScale(); - var pointerPosition = m_WorkspaceUI.GetPointerPositionForRayOrigin(rayOrigin); + var pointerPosition = m_WorkspaceUI.GetPointerPosition(rayOrigin); var dragVector = (pointerPosition - m_DragStart) / viewerScale; var bounds = m_WorkspaceUI.bounds; var transform = m_WorkspaceUI.transform; @@ -673,7 +673,7 @@ public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeCon if (m_HovereringRayOrigins.Contains(rayOrigin)) { - var localPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rayOrigin)); + var localPosition = transform.InverseTransformPoint(this.GetPointerPosition(rayOrigin)); var direction = GetResizeDirectionForLocalPosition(localPosition); GetResizeIconForDirection(direction); } @@ -714,7 +714,7 @@ public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeCon } const float kVisibleOpacity = 0.75f; - var localPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rayOrigin)); + var localPosition = transform.InverseTransformPoint(this.GetPointerPosition(rayOrigin)); var direction = GetResizeDirectionForLocalPosition(localPosition); var resizeIcon = GetResizeIconForDirection(direction); @@ -767,7 +767,7 @@ public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeCon if (!dragRayOrigin) { var leftPosition = transform.InverseTransformPoint(leftRayOrigin.position); - var leftPointerPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(leftRayOrigin)); + var leftPointerPosition = transform.InverseTransformPoint(this.GetPointerPosition(leftRayOrigin)); if (moveResizeLeft.wasJustPressed && (adjustedBounds.Contains(leftPosition) || adjustedBounds.Contains(leftPointerPosition))) { dragRayOrigin = leftRayOrigin; @@ -776,7 +776,7 @@ public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeCon } var rightPosition = transform.InverseTransformPoint(rightRayOrigin.position); - var rightPointerPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rightRayOrigin)); + var rightPointerPosition = transform.InverseTransformPoint(this.GetPointerPosition(rightRayOrigin)); if (moveResizeRight.wasJustPressed && (adjustedBounds.Contains(rightPosition) || adjustedBounds.Contains(rightPointerPosition))) { dragRayOrigin = rightRayOrigin; @@ -802,11 +802,6 @@ public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeCon } } - Vector3 GetPointerPositionForRayOrigin(Transform rayOrigin) - { - return rayOrigin.position + rayOrigin.forward * this.GetPointerLength(rayOrigin); - } - void OnDestroy() { ObjectUtils.Destroy(m_TopFaceMaterial); From 02aaf1286ab7f6fd04d54a5181ffae6e1c54acf2 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 22 Sep 2017 13:52:23 -0700 Subject: [PATCH 029/457] Add sphere selection mode and settings menu item to switch modes --- .../FunctionalityInjection/ICheckSphere.cs | 34 + .../ICheckSphere.cs.meta | 12 + .../IntersectionModule/IntersectionModule.cs | 29 + Scripts/Utilities/IntersectionUtils.cs | 16 + Tools/SelectionTool/Materials.meta | 9 + .../{ => Materials}/BlockSelect.mat | 0 .../{ => Materials}/BlockSelect.mat.meta | 0 Tools/SelectionTool/Prefabs.meta | 9 + .../{ => Prefabs}/BlockSelectCube.prefab | 0 .../{ => Prefabs}/BlockSelectCube.prefab.meta | 0 .../Prefabs/BlockSelectSphere.prefab | 82 ++ .../Prefabs/BlockSelectSphere.prefab.meta | 9 + Tools/SelectionTool/Prefabs/SettingsUI.prefab | 827 ++++++++++++++++++ .../Prefabs/SettingsUI.prefab.meta | 8 + Tools/SelectionTool/SelectionTool.cs | 153 +++- Tools/SelectionTool/SelectionTool.cs.meta | 6 +- 16 files changed, 1182 insertions(+), 12 deletions(-) create mode 100644 Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs create mode 100644 Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs.meta create mode 100644 Tools/SelectionTool/Materials.meta rename Tools/SelectionTool/{ => Materials}/BlockSelect.mat (100%) rename Tools/SelectionTool/{ => Materials}/BlockSelect.mat.meta (100%) create mode 100644 Tools/SelectionTool/Prefabs.meta rename Tools/SelectionTool/{ => Prefabs}/BlockSelectCube.prefab (100%) rename Tools/SelectionTool/{ => Prefabs}/BlockSelectCube.prefab.meta (100%) create mode 100644 Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab create mode 100644 Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab.meta create mode 100644 Tools/SelectionTool/Prefabs/SettingsUI.prefab create mode 100644 Tools/SelectionTool/Prefabs/SettingsUI.prefab.meta diff --git a/Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs b/Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs new file mode 100644 index 000000000..cf0bca58d --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs @@ -0,0 +1,34 @@ +#if UNITY_EDITOR +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.Experimental.EditorVR +{ + /// + /// Gives decorated class access to IntersectionModule.CheckSphere + /// + public interface ICheckSphere + { + } + + public static class ICheckSphereMethods + { + public delegate bool CheckSphereDelegate(Vector3 center, float radius, List objects, List ignoreList = null); + + public static CheckSphereDelegate checkSphere { get; set; } + + /// + /// Do a sphere check against all Renderers + /// + /// The center of the sphere + /// The radius of the sphere + /// The list to which intersected Renderers will be added + /// (optional) A list of Renderers to ignore + /// Whether the sphere intersected any objects + public static bool CheckSphere(this ICheckBounds obj, Vector3 center, float radius, List objects, List ignoreList = null) + { + return checkSphere(center, radius, objects, ignoreList); + } + } +} +#endif diff --git a/Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs.meta b/Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs.meta new file mode 100644 index 000000000..86dd5e95e --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/ICheckSphere.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6ba0e30c339f7b84a9a3528bda8085fd +timeCreated: 1501022830 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/IntersectionModule/IntersectionModule.cs b/Scripts/Modules/IntersectionModule/IntersectionModule.cs index f8a10e0ce..f474c8526 100644 --- a/Scripts/Modules/IntersectionModule/IntersectionModule.cs +++ b/Scripts/Modules/IntersectionModule/IntersectionModule.cs @@ -44,6 +44,7 @@ void Awake() IRaycastMethods.raycast = Raycast; ICheckBoundsMethods.checkBounds = CheckBounds; + ICheckSphereMethods.checkSphere = CheckSphere; } internal void Setup(SpatialHash hash) @@ -273,6 +274,34 @@ internal bool CheckBounds(Bounds bounds, List objects, List objects, List ignoreList = null) + { + var result = false; + m_Intersections.Clear(); + var bounds = new Bounds(center, Vector3.one * radius * 2); + if (m_SpatialHash.GetIntersections(m_Intersections, bounds)) + { + for (var i = 0; i < m_Intersections.Count; i++) + { + var renderer = m_Intersections[i]; + if (ignoreList != null && ignoreList.Contains(renderer)) + continue; + + var transform = renderer.transform; + + IntersectionUtils.SetupCollisionTester(m_CollisionTester, transform); + + if (IntersectionUtils.TestSphere(m_CollisionTester, transform, center, radius)) + { + objects.Add(renderer.gameObject); + result = true; + } + } + } + + return result; + } } } #endif diff --git a/Scripts/Utilities/IntersectionUtils.cs b/Scripts/Utilities/IntersectionUtils.cs index 509012b75..e743132ad 100644 --- a/Scripts/Utilities/IntersectionUtils.cs +++ b/Scripts/Utilities/IntersectionUtils.cs @@ -200,6 +200,22 @@ public static bool TestBox(MeshCollider collisionTester, Transform obj, Vector3 return Physics.CheckBox(center, halfExtents, orientation); } + /// + /// Tests a sphere against a collider + /// + /// A mesh collider located at the origin used to test the object in it's local space + /// The object to test collision on + /// The center of the sphere + /// The radius of the sphere + /// The result of whether the sphere intersects with the object + public static bool TestSphere(MeshCollider collisionTester, Transform obj, Vector3 center, float radius) + { + center = obj.InverseTransformPoint(center); + radius *= obj.lossyScale.Inverse().x; + + return Physics.CheckSphere(center, radius); + } + public static void SetupCollisionTester(MeshCollider collisionTester, Transform obj) { var mf = obj.GetComponent(); diff --git a/Tools/SelectionTool/Materials.meta b/Tools/SelectionTool/Materials.meta new file mode 100644 index 000000000..98e8b1c6b --- /dev/null +++ b/Tools/SelectionTool/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 537883215175ce646b4e8ccc083ad236 +folderAsset: yes +timeCreated: 1506101783 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tools/SelectionTool/BlockSelect.mat b/Tools/SelectionTool/Materials/BlockSelect.mat similarity index 100% rename from Tools/SelectionTool/BlockSelect.mat rename to Tools/SelectionTool/Materials/BlockSelect.mat diff --git a/Tools/SelectionTool/BlockSelect.mat.meta b/Tools/SelectionTool/Materials/BlockSelect.mat.meta similarity index 100% rename from Tools/SelectionTool/BlockSelect.mat.meta rename to Tools/SelectionTool/Materials/BlockSelect.mat.meta diff --git a/Tools/SelectionTool/Prefabs.meta b/Tools/SelectionTool/Prefabs.meta new file mode 100644 index 000000000..0e9fa1d73 --- /dev/null +++ b/Tools/SelectionTool/Prefabs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 727e110d1af66d24c851635031fb88d7 +folderAsset: yes +timeCreated: 1506101776 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tools/SelectionTool/BlockSelectCube.prefab b/Tools/SelectionTool/Prefabs/BlockSelectCube.prefab similarity index 100% rename from Tools/SelectionTool/BlockSelectCube.prefab rename to Tools/SelectionTool/Prefabs/BlockSelectCube.prefab diff --git a/Tools/SelectionTool/BlockSelectCube.prefab.meta b/Tools/SelectionTool/Prefabs/BlockSelectCube.prefab.meta similarity index 100% rename from Tools/SelectionTool/BlockSelectCube.prefab.meta rename to Tools/SelectionTool/Prefabs/BlockSelectCube.prefab.meta diff --git a/Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab b/Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab new file mode 100644 index 000000000..347384edb --- /dev/null +++ b/Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab @@ -0,0 +1,82 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1345258128224670} + m_IsPrefabParent: 1 +--- !u!1 &1345258128224670 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4664823842438600} + - component: {fileID: 33678997985348706} + - component: {fileID: 23835500417344658} + m_Layer: 0 + m_Name: BlockSelectSphere + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4664823842438600 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1345258128224670} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23835500417344658 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1345258128224670} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: dc3ff3f82bbe0a645b072abbf3070b96, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33678997985348706 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1345258128224670} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab.meta b/Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab.meta new file mode 100644 index 000000000..55a7a59ca --- /dev/null +++ b/Tools/SelectionTool/Prefabs/BlockSelectSphere.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0a44b0b9284b6e6419902d672bb94ec6 +timeCreated: 1506034358 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tools/SelectionTool/Prefabs/SettingsUI.prefab b/Tools/SelectionTool/Prefabs/SettingsUI.prefab new file mode 100644 index 000000000..c8c1c5db4 --- /dev/null +++ b/Tools/SelectionTool/Prefabs/SettingsUI.prefab @@ -0,0 +1,827 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1000013404610172} + m_IsPrefabParent: 1 +--- !u!1 &1000010398065086 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000012653929454} + - component: {fileID: 222000012891014098} + - component: {fileID: 114000012025195674} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000011430478146 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000012493860698} + - component: {fileID: 222000012612170110} + - component: {fileID: 114000010706236210} + m_Layer: 5 + m_Name: Foreground + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000011512978662 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000011405639814} + - component: {fileID: 222000011416400564} + - component: {fileID: 114000011583981380} + m_Layer: 5 + m_Name: Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000011772923556 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000010858218954} + - component: {fileID: 114000011920048442} + m_Layer: 5 + m_Name: Sphere + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000012753606596 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000010616025136} + - component: {fileID: 222000010570603678} + - component: {fileID: 114000011835530144} + m_Layer: 5 + m_Name: Foreground + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000013404610172 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000011487074538} + - component: {fileID: 222000012862005820} + - component: {fileID: 114691388261995722} + m_Layer: 5 + m_Name: SettingsUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000013494423478 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000011444372664} + - component: {fileID: 114000013714903302} + m_Layer: 5 + m_Name: Cuboid + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000013599855740 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000013724969698} + - component: {fileID: 222000011524760356} + - component: {fileID: 114000011422230102} + m_Layer: 5 + m_Name: Border + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000013796857246 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000011778163486} + - component: {fileID: 222000011646980040} + - component: {fileID: 114000013593928534} + - component: {fileID: 114000012940195592} + - component: {fileID: 114261882201029984} + m_Layer: 5 + m_Name: SelectionMode + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1000014118413922 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224000013716393632} + - component: {fileID: 222000012522696328} + - component: {fileID: 114000013077659776} + m_Layer: 5 + m_Name: Border + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1123566551031880 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 224874559224435002} + - component: {fileID: 222817483957468890} + - component: {fileID: 114210595956423184} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &114000010706236210 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011430478146} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: dec2d25be9058334c91a0402762efa61, type: 2} + m_Color: {r: 0, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!114 &114000011422230102 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013599855740} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: db3c88ad8f7fe11479d2d3e48c08e6f0, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!114 &114000011583981380 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011512978662} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: dec2d25be9058334c91a0402762efa61, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: 013679fd6ee2085428a7f896aa7b50cc, type: 3} + m_FontSize: 20 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Sphere +--- !u!114 &114000011835530144 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000012753606596} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: dec2d25be9058334c91a0402762efa61, type: 2} + m_Color: {r: 0.10196079, g: 0.10196079, b: 0.10196079, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!114 &114000011920048442 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011772923556} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 0, g: 0, b: 0, a: 0.76} + m_HighlightedColor: {r: 0, g: 0, b: 0, a: 0.866} + m_PressedColor: {r: 0, g: 0, b: 0, a: 0.76} + m_DisabledColor: {r: 0, g: 0, b: 0, a: 0.76} + m_ColorMultiplier: 1 + m_FadeDuration: 0.2 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 114000011835530144} + toggleTransition: 1 + graphic: {fileID: 114000013077659776} + m_Group: {fileID: 114000012940195592} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Toggle+ToggleEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null + m_IsOn: 0 +--- !u!114 &114000012025195674 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000010398065086} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: dec2d25be9058334c91a0402762efa61, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: 013679fd6ee2085428a7f896aa7b50cc, type: 3} + m_FontSize: 20 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Cuboid +--- !u!114 &114000012940195592 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013796857246} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -1184210157, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AllowSwitchOff: 0 +--- !u!114 &114000013077659776 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000014118413922} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: db3c88ad8f7fe11479d2d3e48c08e6f0, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!114 &114000013593928534 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013796857246} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -405508275, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 0 + m_Spacing: 0 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 1 + m_ChildControlWidth: 1 + m_ChildControlHeight: 1 +--- !u!114 &114000013714903302 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013494423478} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 2109663825, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 0, g: 0, b: 0, a: 0.76} + m_HighlightedColor: {r: 0, g: 0, b: 0, a: 0.866} + m_PressedColor: {r: 0, g: 0, b: 0, a: 0.76} + m_DisabledColor: {r: 0, g: 0, b: 0, a: 0.76} + m_ColorMultiplier: 1 + m_FadeDuration: 0.2 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 114000010706236210} + toggleTransition: 1 + graphic: {fileID: 114000011422230102} + m_Group: {fileID: 114000012940195592} + onValueChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Toggle+ToggleEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null + m_IsOn: 1 +--- !u!114 &114210595956423184 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1123566551031880} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 2100000, guid: dec2d25be9058334c91a0402762efa61, type: 2} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: 013679fd6ee2085428a7f896aa7b50cc, type: 3} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 280 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: ' Block Selection Mode:' +--- !u!114 &114261882201029984 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013796857246} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e93c342d881ae654d8d190dda4e84c44, type: 3} + m_Name: + m_EditorClassIdentifier: + m_DefaultToggle: {fileID: 114000013714903302} +--- !u!114 &114691388261995722 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013404610172} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1297475563, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Padding: + m_Left: 0 + m_Right: 0 + m_Top: 0 + m_Bottom: 0 + m_ChildAlignment: 0 + m_Spacing: 0 + m_ChildForceExpandWidth: 1 + m_ChildForceExpandHeight: 1 + m_ChildControlWidth: 1 + m_ChildControlHeight: 0 +--- !u!222 &222000010570603678 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000012753606596} +--- !u!222 &222000011416400564 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011512978662} +--- !u!222 &222000011524760356 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013599855740} +--- !u!222 &222000011646980040 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013796857246} +--- !u!222 &222000012522696328 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000014118413922} +--- !u!222 &222000012612170110 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011430478146} +--- !u!222 &222000012862005820 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013404610172} +--- !u!222 &222000012891014098 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000010398065086} +--- !u!222 &222817483957468890 +CanvasRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1123566551031880} +--- !u!224 &224000010616025136 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000012753606596} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224000010858218954} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -0.25, y: 0} + m_SizeDelta: {x: -0.5, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000010858218954 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011772923556} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 224000013716393632} + - {fileID: 224000010616025136} + - {fileID: 224000011405639814} + m_Father: {fileID: 224000011778163486} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000011405639814 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011512978662} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224000010858218954} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -0.25, y: 0} + m_SizeDelta: {x: -0.5, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000011444372664 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013494423478} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 224000013724969698} + - {fileID: 224000012493860698} + - {fileID: 224000012653929454} + m_Father: {fileID: 224000011778163486} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000011487074538 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013404610172} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 224874559224435002} + - {fileID: 224000011778163486} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 263.2, y: 60} + m_Pivot: {x: 0.5, y: 1} +--- !u!224 &224000011778163486 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013796857246} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 224000010858218954} + - {fileID: 224000011444372664} + m_Father: {fileID: 224000011487074538} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 40} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000012493860698 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000011430478146} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224000011444372664} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0.25, y: 0} + m_SizeDelta: {x: -0.5, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000012653929454 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000010398065086} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224000011444372664} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0.25, y: 0} + m_SizeDelta: {x: -0.5, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000013716393632 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000014118413922} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224000010858218954} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 2, y: 2} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224000013724969698 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1000013599855740} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224000011444372664} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 2, y: 2} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &224874559224435002 +RectTransform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1123566551031880} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 224000011487074538} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 20} + m_Pivot: {x: 0.5, y: 0.5} diff --git a/Tools/SelectionTool/Prefabs/SettingsUI.prefab.meta b/Tools/SelectionTool/Prefabs/SettingsUI.prefab.meta new file mode 100644 index 000000000..43f4ef9a4 --- /dev/null +++ b/Tools/SelectionTool/Prefabs/SettingsUI.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3f593adfd4b4c6745a99c1a237ba6902 +timeCreated: 1491439922 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 5a41b08e3..ad11b60a1 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -4,9 +4,11 @@ using System.Linq; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Proxies; +using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; +using UnityEngine.UI; namespace UnityEditor.Experimental.EditorVR.Tools { @@ -14,7 +16,8 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR ISetHighlight, ISelectObject, ISetManipulatorsVisible, IIsHoveringOverUI, IUsesDirectSelection, ILinkedObject, ICanGrabObject, IGetManipulatorDragState, IUsesNode, IGetRayVisibility, IIsMainMenuVisible, IIsInMiniWorld, IRayToNode, IGetDefaultRayColor, ISetDefaultRayColor, ITooltip, ITooltipPlacement, ISetTooltipVisibility, - IUsesProxyType, IMenuIcon, IGetPointerLength, IRayVisibilitySettings, IUsesViewerScale, ICheckBounds + IUsesProxyType, IMenuIcon, IGetPointerLength, IRayVisibilitySettings, IUsesViewerScale, ICheckBounds, + ISettingsMenuItemProvider, ISerializePreferences { const float k_MultiselectHueShift = 0.5f; const float k_BLockSelectDragThreshold = 0.01f; @@ -30,6 +33,23 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR [SerializeField] GameObject m_BlockSelectCube; + [SerializeField] + GameObject m_BlockSelectSphere; + + [SerializeField] + GameObject m_SettingsMenuItemPrefab; + + [Serializable] + class Preferences + { + [SerializeField] + bool m_SphereMode; + + public bool sphereMode { get { return m_SphereMode; } set { m_SphereMode = value; } } + } + + Preferences m_Preferences; + GameObject m_PressedObject; SelectionInput m_SelectionInput; @@ -42,13 +62,17 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR Vector3 m_SelectStartPosition; Renderer m_BlockSelectCubeRenderer; + Toggle m_CubeToggle; + Toggle m_SphereToggle; + bool m_BlockValueChangedListener; + readonly Dictionary m_HoverGameObjects = new Dictionary(); readonly Dictionary m_SelectionHoverGameObjects = new Dictionary(); readonly List m_BlockSelectHoverGameObjects = new List(); public ActionMap actionMap { get { return m_ActionMap; } } - public Transform rayOrigin { private get; set; } + public Transform rayOrigin { get; set; } public Node? node { private get; set; } public Sprite icon { get { return m_Icon; } } @@ -63,8 +87,62 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR public Transform tooltipSource { get { return rayOrigin; } } public TextAlignment tooltipAlignment { get { return TextAlignment.Center; } } + public GameObject settingsMenuItemPrefab { get { return m_SettingsMenuItemPrefab; } } + + public GameObject settingsMenuItemInstance + { + set + { + var defaultToggleGroup = value.GetComponentInChildren(); + foreach (var toggle in value.GetComponentsInChildren()) + { + if (toggle == defaultToggleGroup.defaultToggle) + { + m_CubeToggle = toggle; + toggle.onValueChanged.AddListener(isOn => + { + if (m_BlockValueChangedListener) + return; + + // m_Preferences on all instances refer + m_Preferences.sphereMode = !isOn; + foreach (var linkedObject in linkedObjects) + { + var selectionTool = (SelectionTool)linkedObject; + if (selectionTool != this) + { + selectionTool.m_BlockValueChangedListener = true; + + //selectionTool.m_ToggleGroup.NotifyToggleOn(isOn ? m_CubeToggle : m_SphereToggle); + // HACK: Toggle Group claims these toggles are not a part of the group + selectionTool.m_CubeToggle.isOn = isOn; + selectionTool.m_SphereToggle.isOn = !isOn; + selectionTool.m_BlockValueChangedListener = false; + } + } + }); + } + else + { + m_SphereToggle = toggle; + } + } + } + } + void Start() { + if (this.IsSharedUpdater(this) && m_Preferences == null) + { + m_Preferences = new Preferences(); + + // Share one preferences object across all instances + foreach (var linkedObject in linkedObjects) + { + ((SelectionTool)linkedObject).m_Preferences = m_Preferences; + } + } + m_NormalRayColor = this.GetDefaultRayColor(rayOrigin); m_MultiselectRayColor = m_NormalRayColor; m_MultiselectRayColor = MaterialUtils.HueShift(m_MultiselectRayColor, k_MultiselectHueShift); @@ -76,6 +154,9 @@ void Start() m_BlockSelectCube = ObjectUtils.Instantiate(m_BlockSelectCube, transform); m_BlockSelectCube.SetActive(false); m_BlockSelectCubeRenderer = m_BlockSelectCube.GetComponent(); + + m_BlockSelectSphere= ObjectUtils.Instantiate(m_BlockSelectSphere, transform); + m_BlockSelectSphere.SetActive(false); } void OnDestroy() @@ -248,10 +329,13 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (select.isHeld) { var startToEnd = pointerPosition - m_SelectStartPosition; - if (!m_BlockSelect && startToEnd.magnitude > k_BLockSelectDragThreshold * this.GetViewerScale()) + var visuals = m_Preferences.sphereMode ? m_BlockSelectSphere : m_BlockSelectCube; + var distance = startToEnd.magnitude; + if (!m_BlockSelect && distance > k_BLockSelectDragThreshold * this.GetViewerScale()) { m_BlockSelect = true; - m_BlockSelectCube.SetActive(true); + visuals.SetActive(true); + m_PressedObject = null; this.AddRayVisibilitySettings(rayOrigin, this, false, true); } @@ -259,21 +343,33 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (m_BlockSelect) this.SetManipulatorsVisible(this, false); - m_BlockSelectCube.transform.localScale = startToEnd; - m_BlockSelectCube.transform.position = m_SelectStartPosition + startToEnd * 0.5f; - + //TODO: use hashsets to only unset highlights for removed objects foreach (var hover in m_BlockSelectHoverGameObjects) { this.SetHighlight(hover, false, rayOrigin); } - m_BlockSelectHoverGameObjects.Clear(); - this.CheckBounds(m_BlockSelectCubeRenderer.bounds, m_BlockSelectHoverGameObjects); + + var visualsTransform = visuals.transform; + if (m_Preferences.sphereMode) + { + visualsTransform.localScale = Vector3.one * distance * 2; + visualsTransform.position = m_SelectStartPosition; + this.CheckSphere(m_SelectStartPosition, distance, m_BlockSelectHoverGameObjects); + } + else + { + visualsTransform.localScale = startToEnd; + visualsTransform.position = m_SelectStartPosition + startToEnd * 0.5f; + this.CheckBounds(m_BlockSelectCubeRenderer.bounds, m_BlockSelectHoverGameObjects); + } foreach (var hover in m_BlockSelectHoverGameObjects) { this.SetHighlight(hover, true, rayOrigin); } + + consumeControl(select); } // Select button on release @@ -311,9 +407,8 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (m_PressedObject) consumeControl(select); } - this.RemoveRayVisibilitySettings(rayOrigin, this); - m_BlockSelectCube.SetActive(false); + (m_Preferences.sphereMode ? m_BlockSelectSphere : m_BlockSelectCube).SetActive(false); m_PressedObject = null; m_BlockSelect = false; } @@ -377,6 +472,42 @@ void OnDisable() } public void OnResetDirectSelectionState() { } + + + public object OnSerializePreferences() + { + if (this.IsSharedUpdater(this)) + { + // Share one preferences object across all instances + foreach (var linkedObject in linkedObjects) + { + ((SelectionTool)linkedObject).m_Preferences = m_Preferences; + } + + return m_Preferences; + } + + return null; + } + + public void OnDeserializePreferences(object obj) + { + if (this.IsSharedUpdater(this)) + { + var preferences = obj as Preferences; + if (preferences != null) + m_Preferences = preferences; + + // Share one preferences object across all instances + foreach (var linkedObject in linkedObjects) + { + ((SelectionTool)linkedObject).m_Preferences = m_Preferences; + } + + m_SphereToggle.isOn = m_Preferences.sphereMode; + m_CubeToggle.isOn = !m_Preferences.sphereMode; + } + } } } #endif diff --git a/Tools/SelectionTool/SelectionTool.cs.meta b/Tools/SelectionTool/SelectionTool.cs.meta index bc3f7da89..4210b38e6 100644 --- a/Tools/SelectionTool/SelectionTool.cs.meta +++ b/Tools/SelectionTool/SelectionTool.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: aab8fcc587f237c4cb48fb7bc8a59909 -timeCreated: 1506034376 +timeCreated: 1506111717 licenseType: Pro MonoImporter: serializedVersion: 2 @@ -9,6 +9,10 @@ MonoImporter: - m_ActionMap: {fileID: 11400000, guid: 9bdc23bc93bcec343934b99348f0ecf4, type: 2} - m_BlockSelectCube: {fileID: 1345258128224670, guid: e360a4c31cf4bf54fa01f9fa5b916ec6, type: 2} + - m_BlockSelectSphere: {fileID: 1345258128224670, guid: 0a44b0b9284b6e6419902d672bb94ec6, + type: 2} + - m_SettingsMenuItemPrefab: {fileID: 1000013404610172, guid: 3f593adfd4b4c6745a99c1a237ba6902, + type: 2} executionOrder: 0 icon: {instanceID: 0} userData: From 9436f7d59dd6b4c487ab56bc5fece8a6ca3efb17 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 22 Sep 2017 16:21:38 -0700 Subject: [PATCH 030/457] Add IStandardIgnoreList for users of IntersectionModule to ignore player head and other intersectable system objects; Fix CheckSphere to handle negative or zero scales --- Scripts/Core/EditorVR.Viewer.cs | 2 +- .../IStandardIgnoreList.cs | 18 ++++++ .../IStandardIgnoreList.cs.meta | 12 ++++ .../IntersectionModule/IntersectionModule.cs | 16 ++++- .../Modules/SnappingModule/SnappingModule.cs | 4 +- Scripts/Utilities/IntersectionUtils.cs | 62 +++++++++++++++++-- Tools/SelectionTool/SelectionTool.cs | 45 ++++++++------ 7 files changed, 132 insertions(+), 27 deletions(-) create mode 100644 Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs create mode 100644 Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs.meta diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index 3a3dab5dd..d024d8e1b 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -182,7 +182,7 @@ internal void AddPlayerModel() var renderer = m_PlayerBody.GetComponent(); evr.GetModule().spatialHash.AddObject(renderer, renderer.bounds); renderer.GetComponentsInChildren(true, m_VRPlayerObjects); - evr.GetModule().ignoreList = m_VRPlayerObjects; + evr.GetModule().standardIgnoreList.AddRange(m_VRPlayerObjects); } internal bool IsOverShoulder(Transform rayOrigin) diff --git a/Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs b/Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs new file mode 100644 index 000000000..d295b48d5 --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using UnityEngine; + +#if UNITY_EDITOR +namespace UnityEditor.Experimental.EditorVR +{ + /// + /// Receive the default list of ignored objects from the system for intersection purposes + /// + public interface IStandardIgnoreList + { + /// + /// List of system objects to ignore for intersection purposes + /// + List ignoreList { set; } + } +} +#endif diff --git a/Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs.meta b/Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs.meta new file mode 100644 index 000000000..a947c87bf --- /dev/null +++ b/Scripts/Interfaces/FunctionalityInjection/IStandardIgnoreList.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 76666e5003b0b014e8630c53c9e917f6 +timeCreated: 1466632995 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/IntersectionModule/IntersectionModule.cs b/Scripts/Modules/IntersectionModule/IntersectionModule.cs index f474c8526..c74fc6394 100644 --- a/Scripts/Modules/IntersectionModule/IntersectionModule.cs +++ b/Scripts/Modules/IntersectionModule/IntersectionModule.cs @@ -1,18 +1,20 @@ #if UNITY_EDITOR using System.Collections.Generic; +using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Data; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class IntersectionModule : MonoBehaviour, IUsesGameObjectLocking + sealed class IntersectionModule : MonoBehaviour, IUsesGameObjectLocking, IInterfaceConnector { const int k_MaxTestsPerTester = 250; readonly Dictionary m_IntersectedObjects = new Dictionary(); readonly List m_Testers = new List(); readonly Dictionary m_RaycastGameObjects = new Dictionary(); // Stores which gameobject the proxies' ray origins are pointing at + readonly List m_StandardIgnoreList = new List(); SpatialHash m_SpatialHash; MeshCollider m_CollisionTester; @@ -27,6 +29,7 @@ class RayIntersection public List testers { get { return m_Testers; } } public List allObjects { get { return m_SpatialHash == null ? null : m_SpatialHash.allObjects; } } public int intersectedObjectCount { get { return m_IntersectedObjects.Count; } } + public List standardIgnoreList { get { return m_StandardIgnoreList; } } // Local method use only -- created here to reduce garbage collection readonly List m_Intersections = new List(); @@ -302,6 +305,17 @@ internal bool CheckSphere(Vector3 center, float radius, List objects return result; } + + public void ConnectInterface(object obj, Transform rayOrigin = null) + { + var standardIgnoreList = obj as IStandardIgnoreList; + if (standardIgnoreList != null) + standardIgnoreList.ignoreList = m_StandardIgnoreList; + } + + public void DisconnectInterface(object obj, Transform rayOrigin = null) + { + } } } #endif diff --git a/Scripts/Modules/SnappingModule/SnappingModule.cs b/Scripts/Modules/SnappingModule/SnappingModule.cs index 1bb7fdda4..58f678528 100644 --- a/Scripts/Modules/SnappingModule/SnappingModule.cs +++ b/Scripts/Modules/SnappingModule/SnappingModule.cs @@ -13,7 +13,7 @@ namespace UnityEditor.Experimental.EditorVR.Modules { [MainMenuItem("Snapping", "Settings", "Select snapping modes")] sealed class SnappingModule : MonoBehaviour, IUsesViewerScale, ISettingsMenuProvider, ISerializePreferences, - IRaycast + IRaycast, IStandardIgnoreList { const float k_GroundPlaneScale = 1000f; @@ -963,4 +963,4 @@ void SetSessionGradientMaterial(GradientPair gradientPair) } } } -#endif \ No newline at end of file +#endif diff --git a/Scripts/Utilities/IntersectionUtils.cs b/Scripts/Utilities/IntersectionUtils.cs index e743132ad..d3284a3b7 100644 --- a/Scripts/Utilities/IntersectionUtils.cs +++ b/Scripts/Utilities/IntersectionUtils.cs @@ -197,7 +197,13 @@ public static bool TestBox(MeshCollider collisionTester, Transform obj, Vector3 halfExtents = Vector3.Scale(halfExtents, obj.lossyScale.Inverse()); orientation = Quaternion.Inverse(obj.rotation) * orientation; - return Physics.CheckBox(center, halfExtents, orientation); + foreach (var intersection in Physics.OverlapBox(center, halfExtents, orientation)) + { + if (intersection.gameObject == collisionTester.gameObject) + return true; + } + + return false; } /// @@ -210,10 +216,58 @@ public static bool TestBox(MeshCollider collisionTester, Transform obj, Vector3 /// The result of whether the sphere intersects with the object public static bool TestSphere(MeshCollider collisionTester, Transform obj, Vector3 center, float radius) { - center = obj.InverseTransformPoint(center); - radius *= obj.lossyScale.Inverse().x; + if (obj.lossyScale == Vector3.zero) + return false; + + //Because our sphere check cannot be non-uniformly scaled, transform the test object instead + var testerTransform = collisionTester.transform; + testerTransform.position = obj.position; + testerTransform.rotation = obj.rotation; + + //Negative scales cause mesh read errors + var objScale = obj.lossyScale; + UndoInverseScale(ref objScale.x, ref center, obj); + UndoInverseScale(ref objScale.y, ref center, obj); + UndoInverseScale(ref objScale.z, ref center, obj); + + //Zero scales cause mesh read errors + PadZeroScale(ref objScale.x); + PadZeroScale(ref objScale.y); + PadZeroScale(ref objScale.z); + + testerTransform.localScale = objScale; + + var overlaps = Physics.OverlapSphere(center, radius); + + testerTransform.position = Vector3.zero; + testerTransform.localScale = Vector3.one; + testerTransform.rotation = Quaternion.identity; - return Physics.CheckSphere(center, radius); + foreach (var intersection in overlaps) + { + if (intersection.gameObject == collisionTester.gameObject) + return true; + } + + return false; + } + + static void UndoInverseScale(ref float scale, ref Vector3 center, Transform obj) + { + if (scale < 0) + { + scale *= -1; + var offset = center - obj.position; + offset = Quaternion.AngleAxis(180, obj.up) * offset; + center = obj.position + offset; + } + } + + static void PadZeroScale(ref float scale) + { + const float epsilon = 1e-5f; + if (Mathf.Approximately(scale, 0)) + scale = epsilon; } public static void SetupCollisionTester(MeshCollider collisionTester, Transform obj) diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index ad11b60a1..6280b91b0 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -17,7 +17,7 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR ICanGrabObject, IGetManipulatorDragState, IUsesNode, IGetRayVisibility, IIsMainMenuVisible, IIsInMiniWorld, IRayToNode, IGetDefaultRayColor, ISetDefaultRayColor, ITooltip, ITooltipPlacement, ISetTooltipVisibility, IUsesProxyType, IMenuIcon, IGetPointerLength, IRayVisibilitySettings, IUsesViewerScale, ICheckBounds, - ISettingsMenuItemProvider, ISerializePreferences + ISettingsMenuItemProvider, ISerializePreferences, IStandardIgnoreList, IBlockUIInteraction { const float k_MultiselectHueShift = 0.5f; const float k_BLockSelectDragThreshold = 0.01f; @@ -79,6 +79,7 @@ class Preferences public event Action hovered; + public List ignoreList { private get; set; } public List linkedObjects { get; set; } public Type proxyType { get; set; } @@ -215,8 +216,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon continue; var selectionRayOrigin = selectionTool.rayOrigin; - if (!this.IsRayVisible(selectionRayOrigin)) - continue; var hover = this.GetFirstGameObject(selectionRayOrigin); @@ -301,17 +300,19 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } } - if (!IsRayActive()) - return; - - // Need to call GetFirstGameObject a second time because we do not guarantee shared updater executes first - var hoveredObject = this.GetFirstGameObject(rayOrigin); + GameObject hoveredObject = null; + var rayActive = IsRayActive(); + if (rayActive) + { + // Need to call GetFirstGameObject a second time because we do not guarantee shared updater executes first + hoveredObject = this.GetFirstGameObject(rayOrigin); - if (hovered != null) - hovered(hoveredObject, rayOrigin); + if (hovered != null) + hovered(hoveredObject, rayOrigin); - if (!GetSelectionCandidate(ref hoveredObject)) - return; + if (!GetSelectionCandidate(ref hoveredObject)) + return; + } var pointerPosition = this.GetPointerPosition(rayOrigin); @@ -322,8 +323,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon m_SelectStartPosition = pointerPosition; // Ray selection only if ray is visible - if (this.IsRayVisible(rayOrigin)) - m_PressedObject = hoveredObject; + m_PressedObject = hoveredObject; } if (select.isHeld) @@ -338,6 +338,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon m_PressedObject = null; this.AddRayVisibilitySettings(rayOrigin, this, false, true); + this.SetUIBlockedForRayOrigin(rayOrigin, true); } if (m_BlockSelect) @@ -355,13 +356,13 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon { visualsTransform.localScale = Vector3.one * distance * 2; visualsTransform.position = m_SelectStartPosition; - this.CheckSphere(m_SelectStartPosition, distance, m_BlockSelectHoverGameObjects); + this.CheckSphere(m_SelectStartPosition, distance, m_BlockSelectHoverGameObjects, ignoreList); } else { visualsTransform.localScale = startToEnd; visualsTransform.position = m_SelectStartPosition + startToEnd * 0.5f; - this.CheckBounds(m_BlockSelectCubeRenderer.bounds, m_BlockSelectHoverGameObjects); + this.CheckBounds(m_BlockSelectCubeRenderer.bounds, m_BlockSelectHoverGameObjects, ignoreList); } foreach (var hover in m_BlockSelectHoverGameObjects) @@ -369,10 +370,11 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon this.SetHighlight(hover, true, rayOrigin); } - consumeControl(select); + if (m_BlockSelect) + consumeControl(select); } - // Select button on release + // Make selection on release if (select.wasJustReleased) { if (m_BlockSelect) @@ -393,7 +395,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon this.ResetDirectSelectionState(); } - else + else if (rayActive) { if (m_PressedObject == hoveredObject) { @@ -407,6 +409,8 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (m_PressedObject) consumeControl(select); } + + this.SetUIBlockedForRayOrigin(rayOrigin, false); this.RemoveRayVisibilitySettings(rayOrigin, this); (m_Preferences.sphereMode ? m_BlockSelectSphere : m_BlockSelectCube).SetActive(false); m_PressedObject = null; @@ -459,6 +463,9 @@ bool IsRayActive() if (this.IsInMiniWorld(rayOrigin)) return false; + if (!this.IsRayVisible(rayOrigin)) + return false; + return true; } From 9a7e40b6130aacd7bef7288c9f0f2a06a89c3513 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 26 Sep 2017 14:05:46 -0700 Subject: [PATCH 031/457] Remove consumed controls on double-click to fix sticky rotate feedback --- Tools/SelectionTool/SelectionTool.cs | 2 -- Tools/VacuumTool/VacuumTool.cs | 1 - 2 files changed, 3 deletions(-) diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index bfd67fbe7..13112f6c8 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -99,8 +99,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (m_MultiSelect) this.ShowTooltip(this); - - consumeControl(multiSelectControl); } m_LastMultiSelectClickTime = realTime; diff --git a/Tools/VacuumTool/VacuumTool.cs b/Tools/VacuumTool/VacuumTool.cs index a929c1e6a..7b6865ac3 100644 --- a/Tools/VacuumTool/VacuumTool.cs +++ b/Tools/VacuumTool/VacuumTool.cs @@ -63,7 +63,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon StopCoroutine(coroutine); m_VacuumingCoroutines[vacuumableTransform] = StartCoroutine(VacuumToViewer(vacuumable)); - consumeControl(vacuumInput.vacuum); } m_LastClickTime = realTime; From 56149317b8606da84aa851cb9296f12687070e6c Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 26 Sep 2017 15:01:39 -0700 Subject: [PATCH 032/457] Rename "reciever" misspellings; Add documentation for IFeedbackReceiver --- .../Capability/IFeedbackReceiver.cs | 29 +++++++++++++++++++ ...ever.cs.meta => IFeedbackReceiver.cs.meta} | 0 .../Capability/IFeedbackReciever.cs | 14 --------- .../Modules/FeedbackModule/FeedbackModule.cs | 10 +++---- Scripts/Proxies/TwoHandedProxyBase.cs | 2 +- 5 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 Scripts/Interfaces/Capability/IFeedbackReceiver.cs rename Scripts/Interfaces/Capability/{IFeedbackReciever.cs.meta => IFeedbackReceiver.cs.meta} (100%) delete mode 100644 Scripts/Interfaces/Capability/IFeedbackReciever.cs diff --git a/Scripts/Interfaces/Capability/IFeedbackReceiver.cs b/Scripts/Interfaces/Capability/IFeedbackReceiver.cs new file mode 100644 index 000000000..3b4ebf6ba --- /dev/null +++ b/Scripts/Interfaces/Capability/IFeedbackReceiver.cs @@ -0,0 +1,29 @@ +#if UNITY_EDITOR +namespace UnityEditor.Experimental.EditorVR +{ + /// + /// Implementors can receive Feedback Requests + /// + public interface IFeedbackReceiver + { + /// + /// Add a feedback request to be presented by this receiver + /// + /// Information about the request, usually cast to a custom type defined by the receiver + void AddFeedbackRequest(FeedbackRequest request); + + /// + /// Remove a feedback request and stop presenting it + /// + /// The request object used in AddFeedbackRequest + void RemoveFeedbackRequest(FeedbackRequest request); + + /// + /// Clear feedback requests that were added by this caller. + /// The FeedbackModule can also call this with a null argument, signaling the intent to clear all requests from all callers. + /// + /// The IRequestFeedback whose requests will be cleared + void ClearFeedbackRequests(IRequestFeedback caller); + } +} +#endif diff --git a/Scripts/Interfaces/Capability/IFeedbackReciever.cs.meta b/Scripts/Interfaces/Capability/IFeedbackReceiver.cs.meta similarity index 100% rename from Scripts/Interfaces/Capability/IFeedbackReciever.cs.meta rename to Scripts/Interfaces/Capability/IFeedbackReceiver.cs.meta diff --git a/Scripts/Interfaces/Capability/IFeedbackReciever.cs b/Scripts/Interfaces/Capability/IFeedbackReciever.cs deleted file mode 100644 index 27a1f544d..000000000 --- a/Scripts/Interfaces/Capability/IFeedbackReciever.cs +++ /dev/null @@ -1,14 +0,0 @@ -#if UNITY_EDITOR -namespace UnityEditor.Experimental.EditorVR -{ - /// - /// Implementors can receive Feedback Requests - /// - public interface IFeedbackReciever - { - void AddFeedbackRequest(FeedbackRequest request); - void RemoveFeedbackRequest(FeedbackRequest request); - void ClearFeedbackRequests(IRequestFeedback caller); - } -} -#endif diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index 1df66def7..49124017f 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -34,7 +34,7 @@ class Preferences Preferences m_Preferences; - readonly List m_FeedbackReceivers = new List(); + readonly List m_FeedbackReceivers = new List(); public GameObject settingsMenuItemPrefab { get { return m_SettingsMenuItemPrefab; } } @@ -77,14 +77,14 @@ void Start() public void ConnectInterface(object obj, Transform rayOrigin = null) { - var feedbackReceiver = obj as IFeedbackReciever; + var feedbackReceiver = obj as IFeedbackReceiver; if (feedbackReceiver != null) m_FeedbackReceivers.Add(feedbackReceiver); } public void DisconnectInterface(object obj, Transform rayOrigin = null) { - var feedbackReceiver = obj as IFeedbackReciever; + var feedbackReceiver = obj as IFeedbackReceiver; if (feedbackReceiver != null) m_FeedbackReceivers.Remove(feedbackReceiver); } @@ -128,9 +128,9 @@ void ClearFeedbackRequests(IRequestFeedback caller) if (caller == null) // Requesters are not allowed to clear all requests return; - foreach (var reciever in m_FeedbackReceivers) + foreach (var receiver in m_FeedbackReceivers) { - reciever.ClearFeedbackRequests(caller); + receiver.ClearFeedbackRequests(caller); } } diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 8a0391f5c..981464d7f 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -19,7 +19,7 @@ public class ProxyFeedbackRequest : FeedbackRequest public string tooltipText; } - abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReciever, ISetTooltipVisibility, ISetHighlight + abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, ISetTooltipVisibility, ISetHighlight { const int k_RendererQueue = 9000; const float k_FeedbackDuration = 5f; From 4eae5bca0c3cd0c0ae08b6be881f4a6f2150e6c0 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 26 Sep 2017 15:12:59 -0700 Subject: [PATCH 033/457] Respond to PR feedback --- .../Modules/FeedbackModule/FeedbackModule.cs | 13 +++++++++---- Scripts/Utilities/IntersectionUtils.cs | 18 ++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index 49124017f..bd59e406a 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -13,7 +13,6 @@ public abstract class FeedbackRequest public IRequestFeedback caller; public GameObject settingsMenuItemPrefab { get; private set; } public GameObject settingsMenuItemInstance { get; set; } - } public class FeedbackModule : MonoBehaviour, IInterfaceConnector, ISettingsMenuItemProvider, ISerializePreferences @@ -48,15 +47,21 @@ public GameObject settingsMenuItemInstance m_Toggles.Add(toggle); var label = value.GetComponentInChildren(); + + const string feedbackEnabled = "Feedback enabled"; + const string feedbackDisabled = "Feedback disabled"; + const string enableFeedback = "Enable feedback"; + const string disableFeedback = "Disable feedback"; + toggle.onValueChanged.AddListener(isOn => { - label.text = isOn ? "Feedback enabled" : "Feedback disabled"; + label.text = isOn ? feedbackEnabled : feedbackDisabled; SetEnabled(isOn); }); var handle = value.GetComponent(); - handle.hoverStarted += (baseHandle, data) => { label.text = m_Preferences.enabled ? "Disable feedback" : "Enable feedback"; }; - handle.hoverEnded += (baseHandle, data) => { label.text = m_Preferences.enabled ? "Feedback enabled" : "Feedback disabled"; }; + handle.hoverStarted += (baseHandle, data) => { label.text = m_Preferences.enabled ? disableFeedback : enableFeedback; }; + handle.hoverEnded += (baseHandle, data) => { label.text = m_Preferences.enabled ? feedbackEnabled : feedbackDisabled; }; } } diff --git a/Scripts/Utilities/IntersectionUtils.cs b/Scripts/Utilities/IntersectionUtils.cs index c4ea2116e..952ab5b39 100644 --- a/Scripts/Utilities/IntersectionUtils.cs +++ b/Scripts/Utilities/IntersectionUtils.cs @@ -134,7 +134,7 @@ public static bool TestRay(MeshCollider collisionTester, Transform obj, Ray ray) { ray.origin = obj.InverseTransformPoint(ray.origin); ray.direction = obj.InverseTransformDirection(ray.direction); - + var boundsSize = collisionTester.bounds.size.magnitude; var maxDistance = boundsSize * 2f; @@ -148,7 +148,7 @@ public static bool TestRay(MeshCollider collisionTester, Transform obj, Ray ray) forwardHit = hitInfo.point; else return false; - + // Shoot a ray in the other direction, too, from outside the object (due to face normals) Vector3 behindHit; var behindRay = new Ray(ray.origin, -ray.direction); @@ -189,17 +189,15 @@ public static void SetupCollisionTester(MeshCollider collisionTester, Transform { collisionTester.sharedMesh = mf.sharedMesh; collisionTester.transform.localScale = Vector3.one; + return; } - if (!mf) + var smr = obj.GetComponent(); + if (smr) { - var smr = obj.GetComponent(); - if (smr) - { - smr.BakeMesh(BakedMesh); - collisionTester.sharedMesh = BakedMesh; - collisionTester.transform.localScale = obj.transform.lossyScale.Inverse(); - } + smr.BakeMesh(BakedMesh); + collisionTester.sharedMesh = BakedMesh; + collisionTester.transform.localScale = obj.transform.lossyScale.Inverse(); } } } From 3b2515eb73ab70468d94a380df9351a867e5a7b3 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 26 Sep 2017 17:27:19 -0700 Subject: [PATCH 034/457] Fix bug in TooltipModule where tooltips without ISetCustomTooltipColor would have black borders --- Scripts/Modules/TooltipModule/TooltipModule.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index af1f12a54..075d93862 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -80,7 +80,7 @@ void Update() var tooltipObject = Instantiate(m_TooltipPrefab, m_TooltipCanvas); tooltipUI = tooltipObject.GetComponent(); tooltipData.tooltipUI = tooltipUI; - tooltipUI.highlight.material = m_HighlightMaterial; + tooltipUI.highlight.material = tooltipData.customHighlightMaterial ?? m_HighlightMaterial; tooltipUI.background.material = m_TooltipBackgroundMaterial; var tooltipTransform = tooltipObject.transform; MathUtilsExt.SetTransformOffset(target, tooltipTransform, Vector3.zero, Quaternion.identity); @@ -142,11 +142,6 @@ void UpdateVisuals(ITooltip tooltip, TooltipUI tooltipUI, Transform target, floa var viewerScale = this.GetViewerScale(); tooltipTransform.localScale = m_TooltipScale * lerp * viewerScale; - TooltipData toolTipData; - m_Tooltips.TryGetValue(tooltip, out toolTipData); - var highlightMaterial = toolTipData != null ? toolTipData.customHighlightMaterial : m_HighlightMaterial; - tooltipUI.highlight.material= highlightMaterial; - m_TooltipBackgroundMaterial.SetColor("_Color", Color.Lerp(UnityBrandColorScheme.darker, m_OriginalBackgroundColor, lerp)); var placement = tooltip as ITooltipPlacement; From f064b57fca5b4e1285928b549c56a778f653ed84 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 26 Sep 2017 17:32:06 -0700 Subject: [PATCH 035/457] Standardize capitalization of tooltip (not toolTip) --- Menus/ToolsMenu/Scripts/ToolsMenuUI.cs | 2 +- Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs | 12 ++++++------ Scripts/Interfaces/Entity/IToolsMenuButton.cs | 4 ++-- Scripts/Interfaces/ISetCustomTooltipColor.cs | 2 +- Scripts/Modules/TooltipModule/TooltipModule.cs | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs b/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs index c751d44d3..c4062cc55 100644 --- a/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs +++ b/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs @@ -275,7 +275,7 @@ void ShowOnlyMenuAndActiveToolButtons() for (int i = 0; i < m_OrderedButtons.Count; ++i) { var button = m_OrderedButtons[i]; - button.toolTipVisible = false; + button.tooltipVisible = false; if (IsMainMenuButton(button)) Reinsert(button, k_MenuButtonOrderPosition, true); // Return the main menu button to its original position after being hidden when showing tool buttons else diff --git a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs index 0518bca6d..fe37c9f2b 100644 --- a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs +++ b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs @@ -18,7 +18,7 @@ sealed class ToolsMenuButton : MonoBehaviour, IToolsMenuButton, ITooltip, ITool const float k_AlternateLocalScaleMultiplier = 0.85f; // Meets outer bounds of the radial menu const string k_MaterialColorProperty = "_Color"; - const string k_SelectionToolTipText = "Selection Tool (cannot be closed)"; + const string k_SelectionTooltipText = "Selection Tool (cannot be closed)"; const string k_MainMenuTipText = "Main Menu"; readonly Vector3 k_ToolButtonActivePosition = new Vector3(0f, 0f, -0.035f); @@ -106,7 +106,7 @@ sealed class ToolsMenuButton : MonoBehaviour, IToolsMenuButton, ITooltip, ITool public Transform rayOrigin { get; set; } public Node node { get; set; } public ITooltip tooltip { private get; set; } // Overrides text - public GradientPair customToolTipHighlightColor { get; set; } + public GradientPair customTooltipHighlightColor { get; set; } public bool isSelectionTool { get { return m_ToolType != null && m_ToolType == typeof(Tools.SelectionTool); } } public bool isMainMenu { get { return m_ToolType != null && m_ToolType == typeof(IMainMenu); } } public int activeButtonCount { get; set; } @@ -144,7 +144,7 @@ public Type toolType if (isSelectionTool || isMainMenu) { - tooltipText = isSelectionTool ? k_SelectionToolTipText : k_MainMenuTipText; + tooltipText = isSelectionTool ? k_SelectionTooltipText : k_MainMenuTipText; secondaryButtonCollidersEnabled = false; } else @@ -189,7 +189,7 @@ public GradientPair gradientPair set { m_GradientPair = value; - customToolTipHighlightColor = value; + customTooltipHighlightColor = value; } } @@ -248,7 +248,7 @@ public string previewToolDescription else { m_PreviewToolDescription = null; - toolTipVisible = false; + tooltipVisible = false; } } } @@ -316,7 +316,7 @@ public bool interactable public bool secondaryButtonHighlighted { get { return m_CloseButton.highlighted; } } - public bool toolTipVisible + public bool tooltipVisible { set { diff --git a/Scripts/Interfaces/Entity/IToolsMenuButton.cs b/Scripts/Interfaces/Entity/IToolsMenuButton.cs index 77d0622b8..091f950f7 100644 --- a/Scripts/Interfaces/Entity/IToolsMenuButton.cs +++ b/Scripts/Interfaces/Entity/IToolsMenuButton.cs @@ -58,7 +58,7 @@ public interface IToolsMenuButton /// /// Bool denoting that the tooltip is visible /// - bool toolTipVisible { set; } + bool tooltipVisible { set; } /// /// Bool denoting that this button implements a secondary button @@ -72,7 +72,7 @@ public interface IToolsMenuButton Vector3 primaryUIContentContainerLocalScale { get; set; } /// - /// Transform used for reference when placing toolTips + /// Transform used for reference when placing tooltips /// Transform tooltipTarget { set; } diff --git a/Scripts/Interfaces/ISetCustomTooltipColor.cs b/Scripts/Interfaces/ISetCustomTooltipColor.cs index 53d5f5d39..c8e4345c5 100644 --- a/Scripts/Interfaces/ISetCustomTooltipColor.cs +++ b/Scripts/Interfaces/ISetCustomTooltipColor.cs @@ -11,7 +11,7 @@ public interface ISetCustomTooltipColor /// /// Custom tooltip highlight color /// - GradientPair customToolTipHighlightColor { get; } + GradientPair customTooltipHighlightColor { get; } } } #endif diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index 075d93862..2c7d2a869 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -260,13 +260,13 @@ public void ShowTooltip(ITooltip tooltip, bool persistent = false, float duratio } Material highlightMaterial = null; - var customToolTipColor = tooltip as ISetCustomTooltipColor; - if (customToolTipColor != null) + var customTooltipColor = tooltip as ISetCustomTooltipColor; + if (customTooltipColor != null) { highlightMaterial = Instantiate(m_HighlightMaterial); - var customToolTipHighlightColor = customToolTipColor.customToolTipHighlightColor; - highlightMaterial.SetColor(k_MaterialColorTopProperty, customToolTipHighlightColor.a); - highlightMaterial.SetColor(k_MaterialColorBottomProperty, customToolTipHighlightColor.b); + var customTooltipHighlightColor = customTooltipColor.customTooltipHighlightColor; + highlightMaterial.SetColor(k_MaterialColorTopProperty, customTooltipHighlightColor.a); + highlightMaterial.SetColor(k_MaterialColorBottomProperty, customTooltipHighlightColor.b); } m_Tooltips[tooltip] = new TooltipData From 9cfea9e4bba896639874b91e1ec777b8d48b891f Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 26 Sep 2017 17:58:36 -0700 Subject: [PATCH 036/457] Fix compilation test --- Tools/SelectionTool/SelectionTool.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 49612cdbc..eb4a5f2bc 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; From ecedf72549792c0fb2ca946132c8cff27ea9853f Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 00:24:33 -0700 Subject: [PATCH 037/457] Fix exceptions in GetMaterialClone for renderers that are missing materials --- Scripts/Utilities/MaterialUtils.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Scripts/Utilities/MaterialUtils.cs b/Scripts/Utilities/MaterialUtils.cs index 6bbc93bf9..6d65b0e0c 100644 --- a/Scripts/Utilities/MaterialUtils.cs +++ b/Scripts/Utilities/MaterialUtils.cs @@ -21,7 +21,15 @@ static class MaterialUtils public static UnityMaterial GetMaterialClone(Renderer renderer) { // The following is equivalent to renderer.material, but gets rid of the error messages in edit mode - return renderer.material = UnityObject.Instantiate(renderer.sharedMaterial); + Material clonedMaterial = null; + var sharedMaterial = renderer.sharedMaterial; + if (sharedMaterial) + { + clonedMaterial = UnityObject.Instantiate(sharedMaterial); + renderer.material = clonedMaterial; + } + + return clonedMaterial; } /// From 4092230ddbb32b56539f87bbe04f73c88f16154e Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 00:26:04 -0700 Subject: [PATCH 038/457] Add first pass of ProxyUI --- Scripts/Helpers/ProxyUI.cs | 155 ++++++++++++++++++++++++++++++++ Scripts/Helpers/ProxyUI.cs.meta | 12 +++ 2 files changed, 167 insertions(+) create mode 100644 Scripts/Helpers/ProxyUI.cs create mode 100644 Scripts/Helpers/ProxyUI.cs.meta diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs new file mode 100644 index 000000000..5b5aee08a --- /dev/null +++ b/Scripts/Helpers/ProxyUI.cs @@ -0,0 +1,155 @@ +#if UNITY_EDITOR +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEditor.Experimental.EditorVR.Core; +using UnityEditor.Experimental.EditorVR.Extensions; +using UnityEditor.Experimental.EditorVR.Utilities; +using UnityEngine; +using UnityEngine.InputNew; + +namespace UnityEditor.Experimental.EditorVR.Proxies +{ + public class ProxyUI : MonoBehaviour + { + List m_BodyRenderers; // Renderers not associated with controls, & will be hidden when displaying feedback/tooltips + bool m_BodyRenderersVisible = true; // Renderers default to visible/true + AffordanceObject[] m_Affordances; + List m_BodyMaterials; // Collection of unique body MeshRenderer materials + Coroutine m_BodyVisibilityCoroutine; + + private class ColorPair + { + /// + /// The original/cached color of the material + /// + public Color originalColor { get; set; } + + /// + /// The color to lerp FROM as the current color when animating visibility + /// + public Color animateFromColor { get; set; } + + public ColorPair(Color originalColor, Color animateFromColor) + { + this.originalColor = originalColor; + this.animateFromColor = animateFromColor; + } + } + + // Map of unique body materials to their original Colors (used for affordances with the "color" visibility control type) + // The second/nested dictionary of color has a key, representing the original cached color, and a value, representing the color to lerp FROM when animating visibility + Dictionary m_BodyMaterialOriginalColorMap = new Dictionary(); + Dictionary> m_AffordanceMaterialOriginalColorMap = new Dictionary>(); + + [SerializeField] + ProxyAffordanceMap m_AffordanceMap; + + //public Dictionary controlToAffordanceMap { private get; set; } + + //[SerializeField] + //ProxyHelper m_ProxyHelper; + + //[SerializeField] + //ProxyHelper.VisibilityControlType m_BodyVisibilityControlType; + + //public ProxyHelper.ButtonObject[] buttons { get; set; } + + public AffordanceObject[] Affordances + { + set + { + //build body material original color map for each control with color chosen as visibilty type in the affordance map that has a matching control + + if (m_Affordances != null) + return; + + if (m_AffordanceMap == null) + { + Debug.LogError("An Affordance Map must be assigned to ProxyUI on : " + gameObject.name); + return; + } + + m_Affordances = value; + var affordanceRenderers = new List(); + foreach (var affordanceDefinition in m_AffordanceMap.AffordanceDefinitions) + { + var control = affordanceDefinition.control; + var affordance = m_Affordances.Where(x => x.control == control).FirstOrDefault(); + if (affordance != null) + { + var renderer = affordance.renderer; + if (renderer != null) + { + var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials + if (materialClone != null) + { + var originalColor = materialClone.color; + var materialToOriginalColorMap = new Dictionary(); + affordanceRenderers.Add(renderer); // Add to collection for later comparison again body renderers + materialToOriginalColorMap[materialClone] = originalColor; + m_AffordanceMaterialOriginalColorMap[control] = materialToOriginalColorMap; + } + } + } + } + // Collect renderers not associated with affordances + m_BodyRenderers = GetComponentsInChildren(true).Where(x => !affordanceRenderers.Contains(x)).ToList(); + foreach (var renderer in m_BodyRenderers) + { + // TODO: support for skipping the cloning of materials in the body that are shared between objects, to reduce draw calls + var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials per-renderer + if (materialClone != null) + { + var originalColor = materialClone.color; + m_BodyMaterialOriginalColorMap[materialClone] = new ColorPair(originalColor, originalColor); + } + } + } + } + + /// + /// Set the visibility of the renderers not associated with controls/input + /// + public bool bodyRenderersVisible + { + set + { + if (!gameObject.activeInHierarchy || m_BodyRenderersVisible == value) + return; + + m_BodyRenderersVisible = value; + this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateBodyVisibility(value)); + } + } + + IEnumerator AnimateBodyVisibility(bool isVisible) + { + foreach (var kvp in m_BodyMaterialOriginalColorMap) + { + kvp.Value.animateFromColor = kvp.Key.GetColor("_Color"); + } + + const float kSpeedScalar = 2f; + const float kTargetAmount = 1f; + var currentAmount = 0f; + while (currentAmount < kTargetAmount) + { + currentAmount += Time.unscaledDeltaTime * kSpeedScalar; + var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount); + foreach (var kvp in m_BodyMaterialOriginalColorMap) + { + // Set original cached color when visible, transparent when hidden + var colorFrom = kvp.Value.animateFromColor; + var colorTo = isVisible ? kvp.Value.originalColor : new Color(colorFrom.r, colorFrom.g, colorFrom.b, 0.25f); + var currentColor = Color.Lerp(colorFrom, colorTo, smoothedAmount); + kvp.Key.color = currentColor; + } + + yield return null; + } + } + } +} +#endif diff --git a/Scripts/Helpers/ProxyUI.cs.meta b/Scripts/Helpers/ProxyUI.cs.meta new file mode 100644 index 000000000..4fb67c955 --- /dev/null +++ b/Scripts/Helpers/ProxyUI.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d1ee80ff6078a6344b26cc7dfb8dc8b5 +timeCreated: 1506553865 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 04db087c1ac0c5349ba1c0c56a41d1275d6cb958 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 02:03:18 -0700 Subject: [PATCH 039/457] Set left+right touch controller materials to FADE rendering mode --- Models/Touch/Models/L_controller_MAT.mat | 15 ++++++++------- Models/Touch/Models/L_controller_gloss_MAT.mat | 15 ++++++++------- Models/Touch/Models/R_controller_MAT.mat | 15 ++++++++------- Models/Touch/Models/R_controller_gloss_MAT.mat | 15 ++++++++------- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/Models/Touch/Models/L_controller_MAT.mat b/Models/Touch/Models/L_controller_MAT.mat index 82ad3c637..3d9c88aee 100644 --- a/Models/Touch/Models/L_controller_MAT.mat +++ b/Models/Touch/Models/L_controller_MAT.mat @@ -8,11 +8,12 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: L_controller_MAT m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _NORMALMAP - m_LightmapFlags: 5 + m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _NORMALMAP + m_LightmapFlags: 1 m_EnableInstancingVariants: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent disabledShaderPasses: [] m_SavedProperties: serializedVersion: 3 @@ -57,17 +58,17 @@ Material: - _BumpScale: 0.1 - _Cutoff: 0.5 - _DetailNormalMapScale: 1 - - _DstBlend: 0 + - _DstBlend: 10 - _GlossMapScale: 1 - _Glossiness: 0.34 - _GlossyReflections: 1 - _Metallic: 0 - - _Mode: 0 + - _Mode: 2 - _OcclusionStrength: 1 - _Parallax: 0.02 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - - _SrcBlend: 1 + - _SrcBlend: 5 - _UVSec: 0 - _ZWrite: 1 m_Colors: diff --git a/Models/Touch/Models/L_controller_gloss_MAT.mat b/Models/Touch/Models/L_controller_gloss_MAT.mat index dd294cd40..b2ed5e837 100644 --- a/Models/Touch/Models/L_controller_gloss_MAT.mat +++ b/Models/Touch/Models/L_controller_gloss_MAT.mat @@ -8,11 +8,12 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: L_controller_gloss_MAT m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _NORMALMAP - m_LightmapFlags: 5 + m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _NORMALMAP + m_LightmapFlags: 1 m_EnableInstancingVariants: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent disabledShaderPasses: [] m_SavedProperties: serializedVersion: 3 @@ -57,17 +58,17 @@ Material: - _BumpScale: 0.1 - _Cutoff: 0.5 - _DetailNormalMapScale: 1 - - _DstBlend: 0 + - _DstBlend: 10 - _GlossMapScale: 1 - _Glossiness: 0.9 - _GlossyReflections: 1 - _Metallic: 0 - - _Mode: 0 + - _Mode: 2 - _OcclusionStrength: 1 - _Parallax: 0.02 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - - _SrcBlend: 1 + - _SrcBlend: 5 - _UVSec: 0 - _ZWrite: 1 m_Colors: diff --git a/Models/Touch/Models/R_controller_MAT.mat b/Models/Touch/Models/R_controller_MAT.mat index 0e70d1379..85dd212e0 100644 --- a/Models/Touch/Models/R_controller_MAT.mat +++ b/Models/Touch/Models/R_controller_MAT.mat @@ -8,11 +8,12 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: R_controller_MAT m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _NORMALMAP - m_LightmapFlags: 5 + m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _NORMALMAP + m_LightmapFlags: 1 m_EnableInstancingVariants: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent disabledShaderPasses: [] m_SavedProperties: serializedVersion: 3 @@ -57,17 +58,17 @@ Material: - _BumpScale: 0.1 - _Cutoff: 0.5 - _DetailNormalMapScale: 1 - - _DstBlend: 0 + - _DstBlend: 10 - _GlossMapScale: 1 - _Glossiness: 0.49 - _GlossyReflections: 1 - _Metallic: 0 - - _Mode: 0 + - _Mode: 2 - _OcclusionStrength: 1 - _Parallax: 0.02 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - - _SrcBlend: 1 + - _SrcBlend: 5 - _UVSec: 0 - _ZWrite: 1 m_Colors: diff --git a/Models/Touch/Models/R_controller_gloss_MAT.mat b/Models/Touch/Models/R_controller_gloss_MAT.mat index da044b589..070e4761a 100644 --- a/Models/Touch/Models/R_controller_gloss_MAT.mat +++ b/Models/Touch/Models/R_controller_gloss_MAT.mat @@ -8,11 +8,12 @@ Material: m_PrefabInternal: {fileID: 0} m_Name: R_controller_gloss_MAT m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _NORMALMAP - m_LightmapFlags: 5 + m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _NORMALMAP + m_LightmapFlags: 1 m_EnableInstancingVariants: 0 - m_CustomRenderQueue: -1 - stringTagMap: {} + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent disabledShaderPasses: [] m_SavedProperties: serializedVersion: 3 @@ -57,17 +58,17 @@ Material: - _BumpScale: 0.1 - _Cutoff: 0.5 - _DetailNormalMapScale: 1 - - _DstBlend: 0 + - _DstBlend: 10 - _GlossMapScale: 1 - _Glossiness: 0.9 - _GlossyReflections: 1 - _Metallic: 0 - - _Mode: 0 + - _Mode: 2 - _OcclusionStrength: 1 - _Parallax: 0.02 - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - - _SrcBlend: 1 + - _SrcBlend: 5 - _UVSec: 0 - _ZWrite: 1 m_Colors: From a6dccd944192fa623118fb627a92545be81bea55 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 02:06:49 -0700 Subject: [PATCH 040/457] Update touch(L+R) prefabs with new proxy changes --- Prefabs/Proxies/LeftTouch.prefab | 17 ++++++++++++++++- Prefabs/Proxies/RightTouch.prefab | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Prefabs/Proxies/LeftTouch.prefab b/Prefabs/Proxies/LeftTouch.prefab index 4f3130a20..ec3907fbe 100644 --- a/Prefabs/Proxies/LeftTouch.prefab +++ b/Prefabs/Proxies/LeftTouch.prefab @@ -25,6 +25,7 @@ GameObject: m_Component: - component: {fileID: 436998} - component: {fileID: 114000013861093962} + - component: {fileID: 114185774509489850} m_Layer: 0 m_Name: LeftTouch m_TagString: ShowInMiniWorld @@ -1382,7 +1383,8 @@ MonoBehaviour: m_PreviewOrigin: {fileID: 4000012123783760} m_FieldGrabOrigin: {fileID: 4000010810114962} m_MeshRoot: {fileID: 485484} - m_Buttons: + m_ProxyUI: {fileID: 114185774509489850} + m_Affordances: - m_Control: 2 m_Transform: {fileID: 4023718469717780} m_Renderer: {fileID: 13787692} @@ -1404,6 +1406,7 @@ MonoBehaviour: - m_Control: 1 m_Transform: {fileID: 407362} m_Renderer: {fileID: 13758356} + m_BodyVisibilityControlType: 0 --- !u!114 &114015681421713280 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1434,6 +1437,18 @@ MonoBehaviour: m_TooltipTarget: {fileID: 4032307745343326} m_TooltipSource: {fileID: 450394} m_TooltipAlignment: 0 +--- !u!114 &114185774509489850 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 118082} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d1ee80ff6078a6344b26cc7dfb8dc8b5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AffordanceMap: {fileID: 11400000, guid: 129b6143c3275c34d8eb78fdc637e1bf, type: 2} --- !u!114 &114543264181638874 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Prefabs/Proxies/RightTouch.prefab b/Prefabs/Proxies/RightTouch.prefab index 8a8cc1763..1b1a40558 100644 --- a/Prefabs/Proxies/RightTouch.prefab +++ b/Prefabs/Proxies/RightTouch.prefab @@ -111,6 +111,7 @@ GameObject: m_Component: - component: {fileID: 401760} - component: {fileID: 114000011379258124} + - component: {fileID: 114144120838688752} m_Layer: 0 m_Name: RightTouch m_TagString: ShowInMiniWorld @@ -1356,7 +1357,8 @@ MonoBehaviour: m_PreviewOrigin: {fileID: 4000013824268610} m_FieldGrabOrigin: {fileID: 4000013218449236} m_MeshRoot: {fileID: 484770} - m_Buttons: + m_ProxyUI: {fileID: 114144120838688752} + m_Affordances: - m_Control: 2 m_Transform: {fileID: 482366} m_Renderer: {fileID: 13788364} @@ -1378,6 +1380,7 @@ MonoBehaviour: - m_Control: 1 m_Transform: {fileID: 451284} m_Renderer: {fileID: 13768278} + m_BodyVisibilityControlType: 0 --- !u!114 &114099124700230328 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1390,6 +1393,18 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_SelectionFlags: 3 +--- !u!114 &114144120838688752 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 141214} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d1ee80ff6078a6344b26cc7dfb8dc8b5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_AffordanceMap: {fileID: 11400000, guid: 129b6143c3275c34d8eb78fdc637e1bf, type: 2} --- !u!114 &114431176106213124 MonoBehaviour: m_ObjectHideFlags: 1 From 9ce067704a5a591dd455e4ec222767393a69a302 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 02:08:53 -0700 Subject: [PATCH 041/457] Add TouchAffordanceMap (shared between L+R touch) --- Scripts/Proxies/Touch/AffordanceMaps.meta | 9 ++++ .../AffordanceMaps/TouchAffordanceMap.asset | 50 +++++++++++++++++++ .../TouchAffordanceMap.asset.meta | 9 ++++ 3 files changed, 68 insertions(+) create mode 100644 Scripts/Proxies/Touch/AffordanceMaps.meta create mode 100644 Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset create mode 100644 Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset.meta diff --git a/Scripts/Proxies/Touch/AffordanceMaps.meta b/Scripts/Proxies/Touch/AffordanceMaps.meta new file mode 100644 index 000000000..03417b9d6 --- /dev/null +++ b/Scripts/Proxies/Touch/AffordanceMaps.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 402f7c63c93b19940b24f933135577bc +folderAsset: yes +timeCreated: 1506565960 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset b/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset new file mode 100644 index 000000000..57eb7ece9 --- /dev/null +++ b/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset @@ -0,0 +1,50 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d08c49347620dd64bbecec4a7432ed62, type: 3} + m_Name: TouchAffordanceMap + m_EditorClassIdentifier: + m_BodyVisibilityType: 0 + m_AffordanceDefinitions: + - m_Control: 2 + m_VisibilityType: 0 + m_ColorVisibilityProperty: _Color + m_AlphaVisibilityProperty: + m_PropertyHiddenValue: 0 + - m_Control: 3 + m_VisibilityType: 0 + m_ColorVisibilityProperty: + m_AlphaVisibilityProperty: + m_PropertyHiddenValue: 0 + - m_Control: 17 + m_VisibilityType: 0 + m_ColorVisibilityProperty: + m_AlphaVisibilityProperty: + m_PropertyHiddenValue: 0 + - m_Control: 18 + m_VisibilityType: 0 + m_ColorVisibilityProperty: + m_AlphaVisibilityProperty: + m_PropertyHiddenValue: 0 + - m_Control: 22 + m_VisibilityType: 0 + m_ColorVisibilityProperty: + m_AlphaVisibilityProperty: + m_PropertyHiddenValue: 0 + - m_Control: 0 + m_VisibilityType: 0 + m_ColorVisibilityProperty: + m_AlphaVisibilityProperty: + m_PropertyHiddenValue: 0 + - m_Control: 1 + m_VisibilityType: 0 + m_ColorVisibilityProperty: + m_AlphaVisibilityProperty: + m_PropertyHiddenValue: 0 diff --git a/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset.meta b/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset.meta new file mode 100644 index 000000000..87f4eb75f --- /dev/null +++ b/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 129b6143c3275c34d8eb78fdc637e1bf +timeCreated: 1506565977 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: From 82c09b590d295f0d8cc075bd9c9e770567ffd5cc Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 02:11:38 -0700 Subject: [PATCH 042/457] Move Touch proxy content into individual folder --- Scripts/Proxies/Touch.meta | 9 +++++++++ Scripts/Proxies/{ => Touch}/TouchProxy.cs | 0 Scripts/Proxies/{ => Touch}/TouchProxy.cs.meta | 0 3 files changed, 9 insertions(+) create mode 100644 Scripts/Proxies/Touch.meta rename Scripts/Proxies/{ => Touch}/TouchProxy.cs (100%) rename Scripts/Proxies/{ => Touch}/TouchProxy.cs.meta (100%) diff --git a/Scripts/Proxies/Touch.meta b/Scripts/Proxies/Touch.meta new file mode 100644 index 000000000..13262ff26 --- /dev/null +++ b/Scripts/Proxies/Touch.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1fbfcb20cfeab214599df9e3414a2ec0 +folderAsset: yes +timeCreated: 1506566113 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Proxies/TouchProxy.cs b/Scripts/Proxies/Touch/TouchProxy.cs similarity index 100% rename from Scripts/Proxies/TouchProxy.cs rename to Scripts/Proxies/Touch/TouchProxy.cs diff --git a/Scripts/Proxies/TouchProxy.cs.meta b/Scripts/Proxies/Touch/TouchProxy.cs.meta similarity index 100% rename from Scripts/Proxies/TouchProxy.cs.meta rename to Scripts/Proxies/Touch/TouchProxy.cs.meta From 56d7147a0f1cabc02ffa1bb84a19335561dc9835 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 02:14:26 -0700 Subject: [PATCH 043/457] Add ProxyAffordanceMap; scriptable object housing control-based details for ProxyUI --- Scripts/Helpers/ProxyAffordanceMap.cs | 88 ++++++++++++++++++++++ Scripts/Helpers/ProxyAffordanceMap.cs.meta | 12 +++ 2 files changed, 100 insertions(+) create mode 100644 Scripts/Helpers/ProxyAffordanceMap.cs create mode 100644 Scripts/Helpers/ProxyAffordanceMap.cs.meta diff --git a/Scripts/Helpers/ProxyAffordanceMap.cs b/Scripts/Helpers/ProxyAffordanceMap.cs new file mode 100644 index 000000000..4c40ef1ca --- /dev/null +++ b/Scripts/Helpers/ProxyAffordanceMap.cs @@ -0,0 +1,88 @@ +#if UNITY_EDITOR +using System; +using System.IO; +using UnityEngine; +using UnityEngine.InputNew; +using UnityEngine.Serialization; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + [CreateAssetMenu(menuName = "EditorVR/EXR Proxy Affordance Map", fileName = "NewProxyAffordanceMap.asset")] + public class ProxyAffordanceMap : ScriptableObject + { + // TODO REMOVE - 5.6 HACK for items not appearing in the create menu +#if UNITY_EDITOR + [MenuItem("Assets/Create/EditorVR/EditorVR Proxy Affordance Map")] + public static void Create() + { + var path = AssetDatabase.GetAssetPath(Selection.activeObject); + + if (string.IsNullOrEmpty(path)) + path = "Assets"; + + if (!Directory.Exists(path)) + path = Path.GetDirectoryName(path); + + var affordanceMap = ScriptableObject.CreateInstance(); + path = AssetDatabase.GenerateUniqueAssetPath(path + "/NewProxyAffordanceMap.asset"); + AssetDatabase.CreateAsset(affordanceMap, path); + } +#endif + + public enum VisibilityControlType + { + colorProperty, + alphaProperty, + materialSwap + } + + [Serializable] + public class ButtonObject + { + [SerializeField] + VRInputDevice.VRControl m_Control; + + [SerializeField] + VisibilityControlType m_VisibilityType; + + //TODO Expose each visibility control type field set based on the selected visibility control type + + [SerializeField] + string m_ColorVisibilityProperty; // Consider custom inspector that only displays this if "shaderProperty" is chosen + + [SerializeField] + string m_AlphaVisibilityProperty; // Consider custom inspector that only displays this if "shaderProperty" is chosen + + [SerializeField] + Material m_SwapMaterial; + + //[SerializeField] + //float m_PropertyHiddenValue; + + public VRInputDevice.VRControl control { get { return m_Control; } } + public VisibilityControlType visibilityControlType { get { return m_VisibilityType; } } + public string colorVisibilityProperty { get { return m_ColorVisibilityProperty; } } + public string alphaVisibilityProperty { get { return m_AlphaVisibilityProperty; } } + public Material swapMaterial { get { return m_SwapMaterial; } } + } + + [SerializeField] + VisibilityControlType m_BodyVisibilityType; + + [SerializeField] + [FormerlySerializedAs("m_Buttons")] + ButtonObject[] m_AffordanceDefinitions; + + public ButtonObject[] AffordanceDefinitions { get { return m_AffordanceDefinitions; } } + public VisibilityControlType BodyVisibilityControlType { get { return m_BodyVisibilityType; } } + + /* + // Don't allow public setting of value; use inspector-set values + public float duration { get { return m_Duration; } internal set { m_Duration = value; } } + public float intensity { get { return m_Intensity; } internal set { m_Intensity = value; } } + public bool fadeIn { get { return m_FadeIn; } } + public bool fadeOut { get { return m_FadeOut; } } + */ + } +} +#endif diff --git a/Scripts/Helpers/ProxyAffordanceMap.cs.meta b/Scripts/Helpers/ProxyAffordanceMap.cs.meta new file mode 100644 index 000000000..63b3a4a8b --- /dev/null +++ b/Scripts/Helpers/ProxyAffordanceMap.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d08c49347620dd64bbecec4a7432ed62 +timeCreated: 1496959572 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From ca84e02b4c7f2be716560a5c4a7f51762b795a16 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 02:20:09 -0700 Subject: [PATCH 044/457] Refactor ProxyHelper to accommodate the ProxyUI changes/addition --- Scripts/Helpers/ProxyHelper.cs | 72 +++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index e92717fac..cbe1ad80b 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -1,31 +1,37 @@ #if UNITY_EDITOR using System; +using System.Collections.Generic; using UnityEngine; using UnityEngine.InputNew; +using UnityEngine.Serialization; +using VisibilityControlType = UnityEditor.Experimental.EditorVR.Core.ProxyAffordanceMap.VisibilityControlType; namespace UnityEditor.Experimental.EditorVR.Proxies { + [Serializable] + public class AffordanceObject + { + [SerializeField] + VRInputDevice.VRControl m_Control; + + [SerializeField] + Transform m_Transform; + + [SerializeField] + Renderer m_Renderer; + + public VRInputDevice.VRControl control { get { return m_Control; } } + public Transform transform { get { return m_Transform; } } + public Renderer renderer { get { return m_Renderer; } } + } + /// /// Reference container for additional content origins on a device /// sealed class ProxyHelper : MonoBehaviour { - [Serializable] - public class ButtonObject - { - [SerializeField] - VRInputDevice.VRControl m_Control; - - [SerializeField] - Transform m_Transform; - - [SerializeField] - Renderer m_Renderer; - - public VRInputDevice.VRControl control { get { return m_Control; } } - public Transform transform { get { return m_Transform; } } - public Renderer renderer { get { return m_Renderer; } } - } + List m_BodyRenderers; // renderers not associated with controls, & will be hidden when displaying feedback/tooltips + bool m_BodyRenderersVisible; /// /// The transform that the device's ray contents (default ray, custom ray, etc) will be parented under @@ -94,9 +100,39 @@ public Transform meshRoot private Transform m_MeshRoot; [SerializeField] - ButtonObject[] m_Buttons; + ProxyUI m_ProxyUI; + + [SerializeField] + [FormerlySerializedAs("m_Buttons")] + AffordanceObject[] m_Affordances; + + public AffordanceObject[] Affordances { get { return m_Affordances; } } + + [SerializeField] + VisibilityControlType m_BodyVisibilityControlType; - public ButtonObject[] buttons { get { return m_Buttons; } } + /// + /// Set the visibility of the renderers not associated with controls/input + /// + public bool bodyRenderersVisible { set { if (m_ProxyUI != null) m_ProxyUI.bodyRenderersVisible = value; } } + + void Start() + { + m_ProxyUI.Affordances = m_Affordances; + } + + public void ShowAllControls() + { + foreach (var button in m_Affordances) + { + button.renderer.enabled = true; + } + } + + public void HideAffordances(AffordanceObject[] affordanceObjects) + { + // HIDE specific affordances + } } } #endif From c980fff1644e2c2eaf2f5c71102ab1818bc3c126 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Thu, 28 Sep 2017 02:22:28 -0700 Subject: [PATCH 045/457] Perform initial set of required changes to TwoHandedProxyBase --- Scripts/Proxies/TwoHandedProxyBase.cs | 155 ++++++++++++++++++++------ 1 file changed, 121 insertions(+), 34 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 981464d7f..9f4e7713b 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -39,12 +39,16 @@ abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, IS protected Transform m_RightHand; readonly List m_Materials = new List(); readonly List m_FeedbackRequests = new List(); + readonly Dictionary m_ActiveFeedbackRequests = new Dictionary(); protected Dictionary m_RayOrigins; + ProxyHelper m_LeftProxyHelper; + ProxyHelper m_RightProxyHelper; + int m_ElementsHighlighted; List m_ProxyMeshRoots = new List(); - readonly Dictionary> m_Buttons = new Dictionary>(); + readonly Dictionary> m_Affordances = new Dictionary>(); public Transform leftHand { get { return m_LeftHand; } } public Transform rightHand { get { return m_RightHand; } } @@ -70,6 +74,8 @@ public virtual bool hidden m_Hidden = value; m_LeftHand.gameObject.SetActive(!value); m_RightHand.gameObject.SetActive(!value); + leftBodyRenderersVisible = !value; // TODO support checking for existing feedback requests and handling body visibility when hiding/unHiding + rightBodyRenderersVisible = !value; } } } @@ -81,59 +87,72 @@ public virtual bool hidden public Dictionary previewOrigins { get; set; } public Dictionary fieldGrabOrigins { get; set; } + private bool leftBodyRenderersVisible { set { m_LeftProxyHelper.bodyRenderersVisible = value; } } + private bool rightBodyRenderersVisible { set { m_RightProxyHelper.bodyRenderersVisible = value; } } + public virtual void Awake() { m_LeftHand = ObjectUtils.Instantiate(m_LeftHandProxyPrefab, transform).transform; m_RightHand = ObjectUtils.Instantiate(m_RightHandProxyPrefab, transform).transform; - var leftProxyHelper = m_LeftHand.GetComponent(); - var rightProxyHelper = m_RightHand.GetComponent(); - m_ProxyMeshRoots.Add(leftProxyHelper.meshRoot); - m_ProxyMeshRoots.Add(rightProxyHelper.meshRoot); + m_LeftProxyHelper = m_LeftHand.GetComponent(); + m_RightProxyHelper = m_RightHand.GetComponent(); + + m_ProxyMeshRoots.Add(m_LeftProxyHelper.meshRoot); + m_ProxyMeshRoots.Add(m_RightProxyHelper.meshRoot); + + m_ActiveFeedbackRequests.Add(Node.LeftHand, 0); + m_ActiveFeedbackRequests.Add(Node.RightHand, 0); - var leftButtons = new Dictionary(); - foreach (var button in leftProxyHelper.buttons) + var leftButtons = new Dictionary(); + foreach (var button in m_LeftProxyHelper.Affordances) { leftButtons[button.control] = button; } - m_Buttons[Node.LeftHand] = leftButtons; + m_Affordances[Node.LeftHand] = leftButtons; + //m_LeftProxyHelper.controlToAffordanceMap = leftButtons; - var rightButtons = new Dictionary(); - foreach (var button in rightProxyHelper.buttons) + var rightButtons = new Dictionary(); + foreach (var button in m_RightProxyHelper.Affordances) { rightButtons[button.control] = button; } - m_Buttons[Node.RightHand] = rightButtons; + m_Affordances[Node.RightHand] = rightButtons; + //m_RightProxyHelper.controlToAffordanceMap = rightButtons; m_RayOrigins = new Dictionary { - { Node.LeftHand, leftProxyHelper.rayOrigin }, - { Node.RightHand, rightProxyHelper.rayOrigin } + { Node.LeftHand, m_LeftProxyHelper.rayOrigin }, + { Node.RightHand, m_RightProxyHelper.rayOrigin } }; menuOrigins = new Dictionary() { - { leftProxyHelper.rayOrigin, leftProxyHelper.menuOrigin }, - { rightProxyHelper.rayOrigin, rightProxyHelper.menuOrigin }, + { m_LeftProxyHelper.rayOrigin, m_LeftProxyHelper.menuOrigin }, + { m_RightProxyHelper.rayOrigin, m_RightProxyHelper.menuOrigin }, }; alternateMenuOrigins = new Dictionary() { - { leftProxyHelper.rayOrigin, leftProxyHelper.alternateMenuOrigin }, - { rightProxyHelper.rayOrigin, rightProxyHelper.alternateMenuOrigin }, + { m_LeftProxyHelper.rayOrigin, m_LeftProxyHelper.alternateMenuOrigin }, + { m_RightProxyHelper.rayOrigin, m_RightProxyHelper.alternateMenuOrigin }, }; previewOrigins = new Dictionary { - { leftProxyHelper.rayOrigin, leftProxyHelper.previewOrigin }, - { rightProxyHelper.rayOrigin, rightProxyHelper.previewOrigin } + { m_LeftProxyHelper.rayOrigin, m_LeftProxyHelper.previewOrigin }, + { m_RightProxyHelper.rayOrigin, m_RightProxyHelper.previewOrigin } }; fieldGrabOrigins = new Dictionary { - { leftProxyHelper.rayOrigin, leftProxyHelper.fieldGrabOrigin }, - { rightProxyHelper.rayOrigin, rightProxyHelper.fieldGrabOrigin } + { m_LeftProxyHelper.rayOrigin, m_LeftProxyHelper.fieldGrabOrigin }, + { m_RightProxyHelper.rayOrigin, m_RightProxyHelper.fieldGrabOrigin } }; + + var m_LeftTooltips = new List(); + var m_RightTooltips = new List(); + } public virtual IEnumerator Start() @@ -180,30 +199,36 @@ public virtual void Update() m_RightHand.localPosition = trackedObjectInput.rightPosition.vector3; m_RightHand.localRotation = trackedObjectInput.rightRotation.quaternion; + + Debug.LogError("FeedbackRequests: " + m_FeedbackRequests.Count + ""); + Debug.LogError("ACTIVE LEFT FeedbackRequests: " + m_ActiveFeedbackRequests[Node.LeftHand] + ""); } } public void AddFeedbackRequest(FeedbackRequest request) { + //validate requests for duplicates + Debug.LogError("RequestAdded"); var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) { - m_FeedbackRequests.Add(proxyRequest); + m_FeedbackRequests.Add(proxyRequest); // TODO delete after dictionary addition? ExecuteFeedback(proxyRequest); } } void ExecuteFeedback(ProxyFeedbackRequest changedRequest) { - foreach (var proxyNode in m_Buttons) + foreach (var proxyNode in m_Affordances) { foreach (var kvp in proxyNode.Value) { ProxyFeedbackRequest request = null; foreach (var req in m_FeedbackRequests) { - var matchChanged = req.node == changedRequest.node && req.control == changedRequest.control; - var matchButton = req.node == proxyNode.Key && req.control == kvp.Key; + var node = req.node; + var matchChanged = node == changedRequest.node && req.control == changedRequest.control; + var matchButton = node == proxyNode.Key && req.control == kvp.Key; var sameCaller = req.caller == changedRequest.caller; var priority = request == null || req.priority >= request.priority; if (matchButton && priority && (matchChanged || sameCaller)) @@ -219,50 +244,97 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) if (button.transform) { - var tooltip = button.transform.GetComponent(); + var tooltip = button.transform.GetComponent(); // TODO optimize GetComponent calls on buttons via cacheing var tooltipText = request.tooltipText; if (!string.IsNullOrEmpty(tooltipText) && tooltip) { tooltip.tooltipText = tooltipText; this.ShowTooltip(tooltip, true, k_FeedbackDuration); + + /* + var existingFeedback = m_ActiveFeedbackRequests.ContainsKey(tooltip); + if (existingFeedback) + m_ActiveFeedbackRequests[tooltip] = request; // Tooltips will hide themselves, replace the last existing reference + else + m_ActiveFeedbackRequests.Add(tooltip, request); + */ } } + + m_ActiveFeedbackRequests[Node.LeftHand] += 1; // Increase feedback request count for this hand/node } } + + UpdateBodyTransparency(); } public void RemoveFeedbackRequest(FeedbackRequest request) { + Debug.LogError("RequestRemoved - PUBLIC"); + m_ActiveFeedbackRequests[Node.LeftHand] -= 1; // Increase feedback request count for this hand/node + var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) RemoveFeedbackRequest(proxyRequest); + + /* + var existingFeedback = m_ActiveFeedbackRequests.ContainsValue(proxyRequest); + if (existingFeedback) + { + //m_ActiveFeedbackRequests.Remove()[tooltip] = request; // Tooltips will hide themselves, remove the last existing reference + var tooltip = m_ActiveFeedbackRequests.FirstOrDefault(x => x.Value == proxyRequest).Key; + if (tooltip != null) + m_ActiveFeedbackRequests.Remove(tooltip); + } + + foreach (var proxyNode in m_Buttons) + { + foreach (var kvp in proxyNode.Value) + { + var button = kvp.Value; + foreach (var x in m_ActiveFeedbackRequests.Values) + { + + } + } + + var existingFeedback = m_ActiveFeedbackRequests.ContainsKey(tooltip); + if (existingFeedback) + m_ActiveFeedbackRequests.Remove(tooltip); // Tooltips will hide themselves, remove the last existing reference + */ } void RemoveFeedbackRequest(ProxyFeedbackRequest request) { - Dictionary buttons; - if (m_Buttons.TryGetValue(request.node, out buttons)) + Debug.LogError("RequestRemoved - PRIVATE"); + Dictionary buttons; + if (m_Affordances.TryGetValue(request.node, out buttons)) { - ProxyHelper.ButtonObject button; - if (buttons.TryGetValue(request.control, out button)) + AffordanceObject affordance; + if (buttons.TryGetValue(request.control, out affordance)) { - if (button.renderer) - this.SetHighlight(button.renderer.gameObject, false); + if (affordance.renderer) + this.SetHighlight(affordance.renderer.gameObject, false); - if (button.transform) + if (affordance.transform) { - var tooltip = button.transform.GetComponent(); + var tooltip = affordance.transform.GetComponent(); if (tooltip) { tooltip.tooltipText = string.Empty; this.HideTooltip(tooltip, true); + //m_ActiveFeedbackRequests.Remove(tooltip); } } } } + + //m_ActiveFeedbackRequests[Node.LeftHand] -= 1; // Increase feedback request count for this hand/node m_FeedbackRequests.Remove(request); ExecuteFeedback(request); + + UpdateBodyTransparency(); } public void ClearFeedbackRequests(IRequestFeedback caller) @@ -274,6 +346,21 @@ public void ClearFeedbackRequests(IRequestFeedback caller) foreach (var feedbackRequest in requests) { RemoveFeedbackRequest(feedbackRequest); + //m_ActiveFeedbackRequests.Remove(feedbackRequest.tooltipText); + } + } + + void UpdateBodyTransparency() + { + //Debug.LogError("" + m_FeedbackRequests.Count + ""); + if (m_ActiveFeedbackRequests.Count > 0) + { + //var leftProxyRequestsExist = m_ActiveFeedbackRequests.Where(x => x.Value.node == Node.LeftHand).Any(); + //var rightProxyRequestsExist = m_ActiveFeedbackRequests.Where(x => x.Value.node == Node.RightHand).Any(); + var leftProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.LeftHand).Any(); + var rightProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.RightHand).Any(); + leftBodyRenderersVisible = !leftProxyRequestsExist; + rightBodyRenderersVisible = !rightProxyRequestsExist; } } } From 6539ae146f8a66cbf1557f9e19c071021cfbb461 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 28 Sep 2017 20:23:47 -0700 Subject: [PATCH 046/457] WIP on proxyanimator --- Action Maps/ProxyAnimatorInput.asset | 237 ++++++++++++++++++ Action Maps/ProxyAnimatorInput.asset.meta | 8 + Action Maps/ProxyAnimatorInput.cs | 18 ++ Action Maps/ProxyAnimatorInput.cs.meta | 12 + Manipulators/BaseManipulator.cs | 2 +- Manipulators/DirectManipulator.cs | 2 +- Manipulators/StandardManipulator.cs | 2 +- Prefabs/Proxies/LeftTouch.prefab | 28 +++ Prefabs/Proxies/RightTouch.prefab | 28 +++ Scripts/Core/Interfaces/IAxisConstraints.cs | 2 +- .../Data/{ConstrainedAxis.cs => AxisFlags.cs} | 2 +- ...strainedAxis.cs.meta => AxisFlags.cs.meta} | 0 Scripts/Handles/LinearHandle.cs | 4 +- Scripts/Handles/PlaneHandle.cs | 4 +- Scripts/Helpers/ProxyHelper.cs | 19 ++ Scripts/Interfaces/Entity/IManipulator.cs | 2 +- .../FunctionalityInjection/IUsesSnapping.cs | 4 +- .../Modules/SnappingModule/SnappingModule.cs | 10 +- Scripts/Proxies/ProxyAnimator.cs | 91 +++++++ Scripts/Proxies/ProxyAnimator.cs.meta | 12 + Scripts/UI/KeyboardUI.cs | 2 +- Tools/TransformTool/TransformTool.cs | 8 +- 22 files changed, 475 insertions(+), 22 deletions(-) create mode 100644 Action Maps/ProxyAnimatorInput.asset create mode 100644 Action Maps/ProxyAnimatorInput.asset.meta create mode 100644 Action Maps/ProxyAnimatorInput.cs create mode 100644 Action Maps/ProxyAnimatorInput.cs.meta rename Scripts/Data/{ConstrainedAxis.cs => AxisFlags.cs} (87%) rename Scripts/Data/{ConstrainedAxis.cs.meta => AxisFlags.cs.meta} (100%) create mode 100644 Scripts/Proxies/ProxyAnimator.cs create mode 100644 Scripts/Proxies/ProxyAnimator.cs.meta diff --git a/Action Maps/ProxyAnimatorInput.asset b/Action Maps/ProxyAnimatorInput.asset new file mode 100644 index 000000000..f1113cc3f --- /dev/null +++ b/Action Maps/ProxyAnimatorInput.asset @@ -0,0 +1,237 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 24e5bc088c9caeb44bc4283dc321b033, type: 3} + m_Name: ProxyAnimatorInput + m_EditorClassIdentifier: + m_Actions: + - {fileID: 114000013893770434} + - {fileID: 114239873159418850} + - {fileID: 114666271280023424} + - {fileID: 114483350316906194} + - {fileID: 114690423600857684} + - {fileID: 114637330144854630} + - {fileID: 114938083758142960} + m_ControlSchemes: + - m_Name: VRInputDevice + m_DeviceSlots: + - m_Key: 1 + m_Type: + m_TypeName: UnityEngine.InputNew.VRInputDevice, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_TagIndex: -1 + m_ActionMap: {fileID: 11400000} + m_Bindings: + - sources: + - controlIndex: 2 + deviceKey: 1 + deadZone: 0.3 + buttonAxisSources: [] + gravity: 1000 + sensitivity: 1000 + snap: 1 + primaryIsButtonAxis: 0 + - sources: + - controlIndex: 3 + deviceKey: 1 + deadZone: 0.3 + buttonAxisSources: [] + gravity: 1000 + sensitivity: 1000 + snap: 1 + primaryIsButtonAxis: 0 + - sources: + - controlIndex: 17 + deviceKey: 1 + deadZone: 0.3 + buttonAxisSources: [] + gravity: 1000 + sensitivity: 1000 + snap: 1 + primaryIsButtonAxis: 0 + - sources: + - controlIndex: 18 + deviceKey: 1 + deadZone: 0.3 + buttonAxisSources: [] + gravity: 1000 + sensitivity: 1000 + snap: 1 + primaryIsButtonAxis: 0 + - sources: + - controlIndex: 22 + deviceKey: 1 + deadZone: 0.3 + buttonAxisSources: [] + gravity: 1000 + sensitivity: 1000 + snap: 1 + primaryIsButtonAxis: 0 + - sources: + - controlIndex: 0 + deviceKey: 1 + deadZone: 0.3 + buttonAxisSources: [] + gravity: 1000 + sensitivity: 1000 + snap: 1 + primaryIsButtonAxis: 0 + - sources: + - controlIndex: 1 + deviceKey: 1 + deadZone: 0.3 + buttonAxisSources: [] + gravity: 1000 + sensitivity: 1000 + snap: 1 + primaryIsButtonAxis: 0 + m_MapTypeName: ProxyAnimatorInput, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + m_CustomNamespace: +--- !u!114 &114000013893770434 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5eba7b4b2e3ea134991ccbff5f47c2c8, type: 3} + m_Name: Trigger1 + m_EditorClassIdentifier: + m_ActionMap: {fileID: 11400000} + m_ActionIndex: 0 + m_ControlData: + componentControlIndices: + controlType: + m_TypeName: UnityEngine.InputNew.ButtonInputControl, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + name: Trigger1 + defaultValue: 0 +--- !u!114 &114239873159418850 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5eba7b4b2e3ea134991ccbff5f47c2c8, type: 3} + m_Name: Trigger2 + m_EditorClassIdentifier: + m_ActionMap: {fileID: 11400000} + m_ActionIndex: 1 + m_ControlData: + componentControlIndices: + controlType: + m_TypeName: UnityEngine.InputNew.AxisInputControl, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + name: Trigger2 + defaultValue: 0 +--- !u!114 &114483350316906194 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5eba7b4b2e3ea134991ccbff5f47c2c8, type: 3} + m_Name: Action2 + m_EditorClassIdentifier: + m_ActionMap: {fileID: 11400000} + m_ActionIndex: 3 + m_ControlData: + componentControlIndices: + controlType: + m_TypeName: UnityEngine.InputNew.ButtonInputControl, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + name: Action2 + defaultValue: 0 +--- !u!114 &114637330144854630 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5eba7b4b2e3ea134991ccbff5f47c2c8, type: 3} + m_Name: StickX + m_EditorClassIdentifier: + m_ActionMap: {fileID: 11400000} + m_ActionIndex: 5 + m_ControlData: + componentControlIndices: + controlType: + m_TypeName: UnityEngine.InputNew.AxisInputControl, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + name: StickX + defaultValue: 0 +--- !u!114 &114666271280023424 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5eba7b4b2e3ea134991ccbff5f47c2c8, type: 3} + m_Name: Action1 + m_EditorClassIdentifier: + m_ActionMap: {fileID: 11400000} + m_ActionIndex: 2 + m_ControlData: + componentControlIndices: + controlType: + m_TypeName: UnityEngine.InputNew.ButtonInputControl, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + name: Action1 + defaultValue: 0 +--- !u!114 &114690423600857684 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5eba7b4b2e3ea134991ccbff5f47c2c8, type: 3} + m_Name: StickButton + m_EditorClassIdentifier: + m_ActionMap: {fileID: 11400000} + m_ActionIndex: 4 + m_ControlData: + componentControlIndices: + controlType: + m_TypeName: UnityEngine.InputNew.ButtonInputControl, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + name: StickButton + defaultValue: 0 +--- !u!114 &114938083758142960 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5eba7b4b2e3ea134991ccbff5f47c2c8, type: 3} + m_Name: StickY + m_EditorClassIdentifier: + m_ActionMap: {fileID: 11400000} + m_ActionIndex: 6 + m_ControlData: + componentControlIndices: + controlType: + m_TypeName: UnityEngine.InputNew.AxisInputControl, Assembly-CSharp, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + name: StickY + defaultValue: 0 diff --git a/Action Maps/ProxyAnimatorInput.asset.meta b/Action Maps/ProxyAnimatorInput.asset.meta new file mode 100644 index 000000000..5f206f086 --- /dev/null +++ b/Action Maps/ProxyAnimatorInput.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9fba3ce585063484a937428d7ef14426 +timeCreated: 1466633556 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Action Maps/ProxyAnimatorInput.cs b/Action Maps/ProxyAnimatorInput.cs new file mode 100644 index 000000000..dd3f5e58a --- /dev/null +++ b/Action Maps/ProxyAnimatorInput.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using UnityEngine.InputNew; + +// GENERATED FILE - DO NOT EDIT MANUALLY +namespace UnityEngine.InputNew +{ + public class ProxyAnimatorInput : ActionMapInput { + public ProxyAnimatorInput (ActionMap actionMap) : base (actionMap) { } + + public ButtonInputControl @trigger1 { get { return (ButtonInputControl)this[0]; } } + public AxisInputControl @trigger2 { get { return (AxisInputControl)this[1]; } } + public ButtonInputControl @action1 { get { return (ButtonInputControl)this[2]; } } + public ButtonInputControl @action2 { get { return (ButtonInputControl)this[3]; } } + public ButtonInputControl @stickButton { get { return (ButtonInputControl)this[4]; } } + public AxisInputControl @stickX { get { return (AxisInputControl)this[5]; } } + public AxisInputControl @stickY { get { return (AxisInputControl)this[6]; } } + } +} diff --git a/Action Maps/ProxyAnimatorInput.cs.meta b/Action Maps/ProxyAnimatorInput.cs.meta new file mode 100644 index 000000000..22b585209 --- /dev/null +++ b/Action Maps/ProxyAnimatorInput.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 93fe059f217028041be8e0a0e7aa2d23 +timeCreated: 1506647298 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Manipulators/BaseManipulator.cs b/Manipulators/BaseManipulator.cs index 8bc82a50a..96354d8a7 100644 --- a/Manipulators/BaseManipulator.cs +++ b/Manipulators/BaseManipulator.cs @@ -47,7 +47,7 @@ class HandleTip public bool adjustScaleForCamera { get; set; } - public Action translate { protected get; set; } + public Action translate { protected get; set; } public Action rotate { protected get; set; } public Action scale { protected get; set; } diff --git a/Manipulators/DirectManipulator.cs b/Manipulators/DirectManipulator.cs index fb0b9c1f0..91c74b997 100644 --- a/Manipulators/DirectManipulator.cs +++ b/Manipulators/DirectManipulator.cs @@ -22,7 +22,7 @@ public Transform target Vector3 m_PositionOffset; Quaternion m_RotationOffset; - public Action translate { private get; set; } + public Action translate { private get; set; } public Action rotate { private get; set; } public Action scale { private get; set; } diff --git a/Manipulators/StandardManipulator.cs b/Manipulators/StandardManipulator.cs index 9bd7fd5eb..0a7c9acf9 100644 --- a/Manipulators/StandardManipulator.cs +++ b/Manipulators/StandardManipulator.cs @@ -69,7 +69,7 @@ protected override void OnHandleDragging(BaseHandle handle, HandleEventData even } else { - ConstrainedAxis constraints = 0; + AxisFlags constraints = 0; var constrainedHandle = handle as IAxisConstraints; if (constrainedHandle != null) constraints = constrainedHandle.constraints; diff --git a/Prefabs/Proxies/LeftTouch.prefab b/Prefabs/Proxies/LeftTouch.prefab index 4f3130a20..6e5134255 100644 --- a/Prefabs/Proxies/LeftTouch.prefab +++ b/Prefabs/Proxies/LeftTouch.prefab @@ -1386,24 +1386,52 @@ MonoBehaviour: - m_Control: 2 m_Transform: {fileID: 4023718469717780} m_Renderer: {fileID: 13787692} + m_TranslateAxes: 0 + m_RotateAxes: 1 + m_Min: 20 + m_Max: -20 - m_Control: 3 m_Transform: {fileID: 450394} m_Renderer: {fileID: 13767942} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: 0.00455765 + m_Max: -0.00455765 - m_Control: 17 m_Transform: {fileID: 442622} m_Renderer: {fileID: 13771122} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 - m_Control: 18 m_Transform: {fileID: 447250} m_Renderer: {fileID: 13791068} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 - m_Control: 22 m_Transform: {fileID: 407362} m_Renderer: {fileID: 13758356} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.0002774392 + m_Max: -0.0002774392 - m_Control: 0 m_Transform: {fileID: 407362} m_Renderer: {fileID: 13758356} + m_TranslateAxes: 0 + m_RotateAxes: 2 + m_Min: 15 + m_Max: -15 - m_Control: 1 m_Transform: {fileID: 407362} m_Renderer: {fileID: 13758356} + m_TranslateAxes: 0 + m_RotateAxes: 4 + m_Min: 15 + m_Max: -15 --- !u!114 &114015681421713280 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Prefabs/Proxies/RightTouch.prefab b/Prefabs/Proxies/RightTouch.prefab index 8a8cc1763..a8426767e 100644 --- a/Prefabs/Proxies/RightTouch.prefab +++ b/Prefabs/Proxies/RightTouch.prefab @@ -1360,24 +1360,52 @@ MonoBehaviour: - m_Control: 2 m_Transform: {fileID: 482366} m_Renderer: {fileID: 13788364} + m_TranslateAxes: 0 + m_RotateAxes: 1 + m_Min: 20 + m_Max: -20 - m_Control: 3 m_Transform: {fileID: 431526} m_Renderer: {fileID: 13791512} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: -0.00455765 + m_Max: 0.00455765 - m_Control: 17 m_Transform: {fileID: 412818} m_Renderer: {fileID: 13757144} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 - m_Control: 18 m_Transform: {fileID: 437054} m_Renderer: {fileID: 13724278} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 - m_Control: 22 m_Transform: {fileID: 451284} m_Renderer: {fileID: 13768278} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.0002774392 + m_Max: -0.0002774392 - m_Control: 0 m_Transform: {fileID: 451284} m_Renderer: {fileID: 13768278} + m_TranslateAxes: 0 + m_RotateAxes: 2 + m_Min: 15 + m_Max: -15 - m_Control: 1 m_Transform: {fileID: 451284} m_Renderer: {fileID: 13768278} + m_TranslateAxes: 0 + m_RotateAxes: 4 + m_Min: 15 + m_Max: -15 --- !u!114 &114099124700230328 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Scripts/Core/Interfaces/IAxisConstraints.cs b/Scripts/Core/Interfaces/IAxisConstraints.cs index 538bfce61..896fe695c 100644 --- a/Scripts/Core/Interfaces/IAxisConstraints.cs +++ b/Scripts/Core/Interfaces/IAxisConstraints.cs @@ -3,7 +3,7 @@ namespace UnityEditor.Experimental.EditorVR { interface IAxisConstraints { - ConstrainedAxis constraints { get; } + AxisFlags constraints { get; } } } #endif diff --git a/Scripts/Data/ConstrainedAxis.cs b/Scripts/Data/AxisFlags.cs similarity index 87% rename from Scripts/Data/ConstrainedAxis.cs rename to Scripts/Data/AxisFlags.cs index 5b6c7301f..44fb6c4b7 100644 --- a/Scripts/Data/ConstrainedAxis.cs +++ b/Scripts/Data/AxisFlags.cs @@ -7,7 +7,7 @@ namespace UnityEditor.Experimental.EditorVR /// Which axes are constrained /// [Flags] - public enum ConstrainedAxis + public enum AxisFlags { X = 1 << 0, Y = 1 << 1, diff --git a/Scripts/Data/ConstrainedAxis.cs.meta b/Scripts/Data/AxisFlags.cs.meta similarity index 100% rename from Scripts/Data/ConstrainedAxis.cs.meta rename to Scripts/Data/AxisFlags.cs.meta diff --git a/Scripts/Handles/LinearHandle.cs b/Scripts/Handles/LinearHandle.cs index 3699d4ed6..dd7dc39ff 100644 --- a/Scripts/Handles/LinearHandle.cs +++ b/Scripts/Handles/LinearHandle.cs @@ -23,13 +23,13 @@ public LinearHandleEventData(Transform rayOrigin, bool direct) : base(rayOrigin, [FlagsProperty] [SerializeField] - ConstrainedAxis m_Constraints; + AxisFlags m_Constraints; readonly Dictionary m_LastPositions = new Dictionary(k_DefaultCapacity); Plane m_Plane; - public ConstrainedAxis constraints { get { return m_Constraints; } } + public AxisFlags constraints { get { return m_Constraints; } } protected override HandleEventData GetHandleEventData(RayEventData eventData) { diff --git a/Scripts/Handles/PlaneHandle.cs b/Scripts/Handles/PlaneHandle.cs index 549ce405f..4a6108b5f 100644 --- a/Scripts/Handles/PlaneHandle.cs +++ b/Scripts/Handles/PlaneHandle.cs @@ -20,12 +20,12 @@ public PlaneHandleEventData(Transform rayOrigin, bool direct) : base(rayOrigin, [FlagsProperty] [SerializeField] - ConstrainedAxis m_Constraints; + AxisFlags m_Constraints; Plane m_Plane; readonly Dictionary m_LastPositions = new Dictionary(k_DefaultCapacity); - public ConstrainedAxis constraints { get { return m_Constraints; } } + public AxisFlags constraints { get { return m_Constraints; } } protected override HandleEventData GetHandleEventData(RayEventData eventData) { diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index e92717fac..7c57b424b 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -1,5 +1,6 @@ #if UNITY_EDITOR using System; +using UnityEditor.Experimental.EditorVR.UI; using UnityEngine; using UnityEngine.InputNew; @@ -22,9 +23,27 @@ public class ButtonObject [SerializeField] Renderer m_Renderer; + [FlagsProperty] + [SerializeField] + AxisFlags m_TranslateAxes; + + [FlagsProperty] + [SerializeField] + AxisFlags m_RotateAxes; + + [SerializeField] + float m_Min; + + [SerializeField] + float m_Max; + public VRInputDevice.VRControl control { get { return m_Control; } } public Transform transform { get { return m_Transform; } } public Renderer renderer { get { return m_Renderer; } } + public AxisFlags translateAxes { get { return m_TranslateAxes; } } + public AxisFlags rotateAxes { get { return m_RotateAxes; } } + public float min { get { return m_Min; } } + public float max { get { return m_Max; } } } /// diff --git a/Scripts/Interfaces/Entity/IManipulator.cs b/Scripts/Interfaces/Entity/IManipulator.cs index f46409021..7efb6a04f 100644 --- a/Scripts/Interfaces/Entity/IManipulator.cs +++ b/Scripts/Interfaces/Entity/IManipulator.cs @@ -13,7 +13,7 @@ public interface IManipulator /// Delegate that processes the translation, using the vector3 passed in /// Caller also provides the ray origin that is doing the action, and which axes are constrained, if any /// - Action translate { set; } + Action translate { set; } /// /// Delegate that processes the rotation, using the quaternion passed in diff --git a/Scripts/Interfaces/FunctionalityInjection/IUsesSnapping.cs b/Scripts/Interfaces/FunctionalityInjection/IUsesSnapping.cs index b791721f9..0f09665b6 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IUsesSnapping.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IUsesSnapping.cs @@ -13,7 +13,7 @@ public interface IUsesSnapping public static class IUsesSnappingMethods { - internal delegate bool ManipulatorSnapDelegate(Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, ConstrainedAxis constraints, PivotMode pivotMode); + internal delegate bool ManipulatorSnapDelegate(Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, AxisFlags constraints, PivotMode pivotMode); internal delegate bool DirectSnapDelegate(Transform rayOrigin, Transform transform, ref Vector3 position, ref Quaternion rotation, Vector3 targetPosition, Quaternion targetRotation); internal static ManipulatorSnapDelegate manipulatorSnap { get; set; } @@ -31,7 +31,7 @@ public static class IUsesSnappingMethods /// The axis constraints /// The current pivot mode /// Whether the position was set to a snapped position - public static bool ManipulatorSnap(this IUsesSnapping usesSnaping, Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, ConstrainedAxis constraints, PivotMode pivotMode) + public static bool ManipulatorSnap(this IUsesSnapping usesSnaping, Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, AxisFlags constraints, PivotMode pivotMode) { return manipulatorSnap(rayOrigin, transforms, ref position, ref rotation, delta, constraints, pivotMode); } diff --git a/Scripts/Modules/SnappingModule/SnappingModule.cs b/Scripts/Modules/SnappingModule/SnappingModule.cs index f63bab93a..908c609d8 100644 --- a/Scripts/Modules/SnappingModule/SnappingModule.cs +++ b/Scripts/Modules/SnappingModule/SnappingModule.cs @@ -435,7 +435,7 @@ void Update() } } - public bool ManipulatorSnap(Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, ConstrainedAxis constraints, PivotMode pivotMode) + public bool ManipulatorSnap(Transform rayOrigin, Transform[] transforms, ref Vector3 position, ref Quaternion rotation, Vector3 delta, AxisFlags constraints, PivotMode pivotMode) { if (transforms.Length == 0) return false; @@ -526,7 +526,7 @@ public bool DirectSnap(Transform rayOrigin, Transform transform, ref Vector3 pos return false; } - bool ManipulatorSnapConstrained(ref Vector3 position, ref Quaternion rotation, Vector3 delta, Vector3 targetPosition, Quaternion targetRotation, SnappingState state, float raycastDistance, ConstrainedAxis constraints, PivotMode pivotMode) + bool ManipulatorSnapConstrained(ref Vector3 position, ref Quaternion rotation, Vector3 delta, Vector3 targetPosition, Quaternion targetRotation, SnappingState state, float raycastDistance, AxisFlags constraints, PivotMode pivotMode) { var rotationOffset = Quaternion.AngleAxis(90, Vector3.right); var startRotation = state.startRotation; @@ -548,15 +548,15 @@ bool ManipulatorSnapConstrained(ref Vector3 position, ref Quaternion rotation, V switch (constraints) { - case ConstrainedAxis.X: + case AxisFlags.X: if (Vector3.Dot(rotation * Vector3.right, direction) > 0) projectedExtents *= -1; break; - case ConstrainedAxis.Y: + case AxisFlags.Y: if (Vector3.Dot(rotation * Vector3.up, direction) > 0) projectedExtents *= -1; break; - case ConstrainedAxis.Z: + case AxisFlags.Z: if (Vector3.Dot(rotation * Vector3.forward, direction) > 0) projectedExtents *= -1; break; diff --git a/Scripts/Proxies/ProxyAnimator.cs b/Scripts/Proxies/ProxyAnimator.cs new file mode 100644 index 000000000..c5f4cc133 --- /dev/null +++ b/Scripts/Proxies/ProxyAnimator.cs @@ -0,0 +1,91 @@ +using System.Linq; +using UnityEditor.Experimental.EditorVR; +using UnityEditor.Experimental.EditorVR.Proxies; +using UnityEngine; +using UnityEngine.InputNew; + +[RequireComponent(typeof(ProxyHelper))] +public class ProxyAnimator : MonoBehaviour, ICustomActionMap +{ + [SerializeField] + ActionMap m_ProxyActionMap; + + ProxyHelper.ButtonObject[] m_Buttons; + InputControl[] m_Controls; + Vector3[] m_InitialPositions; + Vector3[] m_InitialRotations; + + public ActionMap actionMap { get { return m_ProxyActionMap; } } + + void Start() + { + m_Buttons = GetComponent().buttons; + } + + public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) + { + var length = m_Buttons.Length; + if (m_Controls == null) + { + m_Controls = new InputControl[length]; + m_InitialPositions = new Vector3[length]; + m_InitialRotations = new Vector3[length]; + + for (var i = 0; i < input.controlCount; i++) + { + var control = input[i]; + for (var j = 0; j < length; j++) + { + var button = m_Buttons[j]; + if (control.data.componentControlIndices.Contains((int)button.control)) + { + m_Controls[j] = control; + break; + } + } + } + + for (var i = 0; i < length; i++) + { + var buttonTransform = m_Buttons[i].transform; + m_InitialPositions[i] = buttonTransform.localPosition; + m_InitialRotations[i] = buttonTransform.localRotation.eulerAngles; + } + } + + for (var i = 0; i < length; i++) + { + var button = m_Buttons[i]; + var control = m_Controls[i]; + //Assume control values are [-1, 1] + var min = button.min; + var offset = min + (control.rawValue + 1) * (button.max - min); + + var buttonTransform = button.transform; + var localPosition = m_InitialPositions[i]; + var translateAxes = button.translateAxes; + if ((translateAxes | AxisFlags.X) != 0) + localPosition.x += offset; + + if ((translateAxes | AxisFlags.Y) != 0) + localPosition.y += offset; + + if ((translateAxes | AxisFlags.Z) != 0) + localPosition.z += offset; + + var localRotation = m_InitialRotations[i]; + var rotateAxes = button.rotateAxes; + if ((rotateAxes | AxisFlags.X) != 0) + localRotation.x += offset; + + if ((rotateAxes | AxisFlags.Y) != 0) + localRotation.y += offset; + + if ((rotateAxes | AxisFlags.Z) != 0) + localRotation.z += offset; + + buttonTransform.localPosition = localPosition; + buttonTransform.localRotation = Quaternion.Euler(localRotation); + } + } +} diff --git a/Scripts/Proxies/ProxyAnimator.cs.meta b/Scripts/Proxies/ProxyAnimator.cs.meta new file mode 100644 index 000000000..710886a68 --- /dev/null +++ b/Scripts/Proxies/ProxyAnimator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 460af9702a1fe674a932ad1a15f33bfa +timeCreated: 1506644245 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/UI/KeyboardUI.cs b/Scripts/UI/KeyboardUI.cs index bd8c35968..c621a4cc3 100644 --- a/Scripts/UI/KeyboardUI.cs +++ b/Scripts/UI/KeyboardUI.cs @@ -341,7 +341,7 @@ bool InTransition() return collapsing || m_EligibleForDrag; } - void Translate(Vector3 deltaPosition, Transform rayOrigin, ConstrainedAxis constraints) + void Translate(Vector3 deltaPosition, Transform rayOrigin, AxisFlags constraints) { if (m_EligibleForDrag) transform.position += deltaPosition; diff --git a/Tools/TransformTool/TransformTool.cs b/Tools/TransformTool/TransformTool.cs index 9fa2d1d3c..02a0125b2 100644 --- a/Tools/TransformTool/TransformTool.cs +++ b/Tools/TransformTool/TransformTool.cs @@ -587,13 +587,13 @@ public void DropHeldObjects(Node node) this.ClearSnappingState(rayOrigin); } - void Translate(Vector3 delta, Transform rayOrigin, ConstrainedAxis constraints) + void Translate(Vector3 delta, Transform rayOrigin, AxisFlags constraints) { switch (constraints) { - case ConstrainedAxis.X | ConstrainedAxis.Y: - case ConstrainedAxis.Y | ConstrainedAxis.Z: - case ConstrainedAxis.X | ConstrainedAxis.Z: + case AxisFlags.X | AxisFlags.Y: + case AxisFlags.Y | AxisFlags.Z: + case AxisFlags.X | AxisFlags.Z: m_TargetPosition += delta; break; default: From 56ee9ffc52788af5dfe72a12823a74d706ce49de Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Fri, 29 Sep 2017 00:10:04 -0700 Subject: [PATCH 047/457] Cleanup ProxyUI, ProxyHelper, & ProxyAffordanceMap --- Scripts/Helpers/ProxyAffordanceMap.cs | 28 +++++++------------ Scripts/Helpers/ProxyHelper.cs | 1 - Scripts/Helpers/ProxyUI.cs | 39 ++++++++++++--------------- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/Scripts/Helpers/ProxyAffordanceMap.cs b/Scripts/Helpers/ProxyAffordanceMap.cs index 4c40ef1ca..93fca5515 100644 --- a/Scripts/Helpers/ProxyAffordanceMap.cs +++ b/Scripts/Helpers/ProxyAffordanceMap.cs @@ -10,7 +10,7 @@ namespace UnityEditor.Experimental.EditorVR.Core [CreateAssetMenu(menuName = "EditorVR/EXR Proxy Affordance Map", fileName = "NewProxyAffordanceMap.asset")] public class ProxyAffordanceMap : ScriptableObject { - // TODO REMOVE - 5.6 HACK for items not appearing in the create menu + // TODO REMOVE - 5.6 HACK that remedies items not appearing in the create menu #if UNITY_EDITOR [MenuItem("Assets/Create/EditorVR/EditorVR Proxy Affordance Map")] public static void Create() @@ -32,8 +32,8 @@ public static void Create() public enum VisibilityControlType { colorProperty, - alphaProperty, - materialSwap + //alphaProperty, // TODO: Support + //materialSwap // TODO: Support } [Serializable] @@ -47,14 +47,14 @@ public class ButtonObject //TODO Expose each visibility control type field set based on the selected visibility control type - [SerializeField] + [SerializeField] // colorProperty field string m_ColorVisibilityProperty; // Consider custom inspector that only displays this if "shaderProperty" is chosen - [SerializeField] - string m_AlphaVisibilityProperty; // Consider custom inspector that only displays this if "shaderProperty" is chosen + //[SerializeField] // alphaProperty field + //string m_AlphaVisibilityProperty; // Consider custom inspector that only displays this if "shaderProperty" is chosen - [SerializeField] - Material m_SwapMaterial; + //[SerializeField] // materialSwap field + //Material m_SwapMaterial; //[SerializeField] //float m_PropertyHiddenValue; @@ -62,8 +62,8 @@ public class ButtonObject public VRInputDevice.VRControl control { get { return m_Control; } } public VisibilityControlType visibilityControlType { get { return m_VisibilityType; } } public string colorVisibilityProperty { get { return m_ColorVisibilityProperty; } } - public string alphaVisibilityProperty { get { return m_AlphaVisibilityProperty; } } - public Material swapMaterial { get { return m_SwapMaterial; } } + //public string alphaVisibilityProperty { get { return m_AlphaVisibilityProperty; } } + //public Material swapMaterial { get { return m_SwapMaterial; } } } [SerializeField] @@ -75,14 +75,6 @@ public class ButtonObject public ButtonObject[] AffordanceDefinitions { get { return m_AffordanceDefinitions; } } public VisibilityControlType BodyVisibilityControlType { get { return m_BodyVisibilityType; } } - - /* - // Don't allow public setting of value; use inspector-set values - public float duration { get { return m_Duration; } internal set { m_Duration = value; } } - public float intensity { get { return m_Intensity; } internal set { m_Intensity = value; } } - public bool fadeIn { get { return m_FadeIn; } } - public bool fadeOut { get { return m_FadeOut; } } - */ } } #endif diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index cbe1ad80b..47223aec8 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -103,7 +103,6 @@ public Transform meshRoot ProxyUI m_ProxyUI; [SerializeField] - [FormerlySerializedAs("m_Buttons")] AffordanceObject[] m_Affordances; public AffordanceObject[] Affordances { get { return m_Affordances; } } diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index 5b5aee08a..709b82e32 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -19,6 +19,16 @@ public class ProxyUI : MonoBehaviour List m_BodyMaterials; // Collection of unique body MeshRenderer materials Coroutine m_BodyVisibilityCoroutine; + // Map of unique body materials to their original Colors (used for affordances with the "color" visibility control type) + // The second param, ColorPair, houses the original cached color, and a value, representing the color to lerp FROM when animating visibility + Dictionary m_BodyMaterialOriginalColorMap = new Dictionary(); + + // Used to draw visual attention to individual affordances + Dictionary> m_AffordanceMaterialOriginalColorMap = new Dictionary>(); + + [SerializeField] + ProxyAffordanceMap m_AffordanceMap; + private class ColorPair { /// @@ -38,30 +48,13 @@ public ColorPair(Color originalColor, Color animateFromColor) } } - // Map of unique body materials to their original Colors (used for affordances with the "color" visibility control type) - // The second/nested dictionary of color has a key, representing the original cached color, and a value, representing the color to lerp FROM when animating visibility - Dictionary m_BodyMaterialOriginalColorMap = new Dictionary(); - Dictionary> m_AffordanceMaterialOriginalColorMap = new Dictionary>(); - - [SerializeField] - ProxyAffordanceMap m_AffordanceMap; - - //public Dictionary controlToAffordanceMap { private get; set; } - - //[SerializeField] - //ProxyHelper m_ProxyHelper; - - //[SerializeField] - //ProxyHelper.VisibilityControlType m_BodyVisibilityControlType; - - //public ProxyHelper.ButtonObject[] buttons { get; set; } - + /// + /// Set ProxyHelper affordances in this ProxyUI + /// public AffordanceObject[] Affordances { set { - //build body material original color map for each control with color chosen as visibilty type in the affordance map that has a matching control - if (m_Affordances != null) return; @@ -76,7 +69,7 @@ public AffordanceObject[] Affordances foreach (var affordanceDefinition in m_AffordanceMap.AffordanceDefinitions) { var control = affordanceDefinition.control; - var affordance = m_Affordances.Where(x => x.control == control).FirstOrDefault(); + var affordance = m_Affordances.FirstOrDefault(x => x.control == control); if (affordance != null) { var renderer = affordance.renderer; @@ -87,13 +80,14 @@ public AffordanceObject[] Affordances { var originalColor = materialClone.color; var materialToOriginalColorMap = new Dictionary(); - affordanceRenderers.Add(renderer); // Add to collection for later comparison again body renderers + affordanceRenderers.Add(renderer); // Add to collection for later comparison against body renderers materialToOriginalColorMap[materialClone] = originalColor; m_AffordanceMaterialOriginalColorMap[control] = materialToOriginalColorMap; } } } } + // Collect renderers not associated with affordances m_BodyRenderers = GetComponentsInChildren(true).Where(x => !affordanceRenderers.Contains(x)).ToList(); foreach (var renderer in m_BodyRenderers) @@ -126,6 +120,7 @@ public bool bodyRenderersVisible IEnumerator AnimateBodyVisibility(bool isVisible) { + // Cache current "from" colors foreach (var kvp in m_BodyMaterialOriginalColorMap) { kvp.Value.animateFromColor = kvp.Key.GetColor("_Color"); From 82366db184f4813a72327a5a4ec6161b3a275d82 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 29 Sep 2017 00:57:29 -0700 Subject: [PATCH 048/457] Refactor IProcessInput to process in one big list --- Editor/FlagsPropertyDrawer.cs | 4 +- Menus/MainMenu/Scripts/MainMenuUI.cs | 1 - Scripts/Core/EditorVR.DirectSelection.cs | 12 +- Scripts/Core/EditorVR.Interfaces.cs | 34 +-- Scripts/Core/EditorVR.Menus.cs | 63 +++--- Scripts/Core/EditorVR.Rays.cs | 25 +-- Scripts/Core/EditorVR.Tools.cs | 91 +++----- Scripts/Core/EditorVR.ToolsMenu.cs | 6 +- Scripts/Core/EditorVR.UI.cs | 16 +- Scripts/Core/EditorVR.Viewer.cs | 10 +- Scripts/Core/EditorVR.cs | 38 +--- .../ActionsModuleConnector.cs | 13 +- .../DeviceInputModuleConnector.cs | 25 --- .../DeviceInputModuleConnector.cs.meta | 12 - .../HapticsModuleConnector.cs | 18 -- .../HapticsModuleConnector.cs.meta | 12 - .../HierarchyModuleConnector.cs | 41 ---- .../HierarchyModuleConnector.cs.meta | 12 - .../HighlightModuleConnector.cs | 38 ---- .../HighlightModuleConnector.cs.meta | 12 - .../LockModuleConnector.cs | 18 -- .../LockModuleConnector.cs.meta | 12 - .../MultipleRayInputModuleConnector.cs | 17 -- .../MultipleRayInputModuleConnector.cs.meta | 12 - .../ProjectFolderModuleConnector.cs | 41 ---- .../ProjectFolderModuleConnector.cs.meta | 12 - .../SceneObjectModuleConnector.cs | 19 -- .../SceneObjectModuleConnector.cs.meta | 12 - .../SelectionModuleConnector.cs | 20 +- .../SnappingModuleConnector.cs | 19 -- .../SnappingModuleConnector.cs.meta | 12 - .../SpatialHashModuleConnector.cs | 18 -- .../SpatialHashModuleConnector.cs.meta | 12 - .../SpatialHintModuleConnector.cs | 24 -- .../SpatialHintModuleConnector.cs.meta | 12 - .../SpatialScrollModuleConnector.cs | 18 -- .../SpatialScrollModuleConnector.cs.meta | 12 - .../TooltipModuleConnector.cs | 18 -- .../TooltipModuleConnector.cs.meta | 12 - .../WorkspaceModuleConnector.cs | 32 --- .../WorkspaceModuleConnector.cs.meta | 12 - .../Core/Interfaces/IInterfaceConnector.cs | 8 +- Scripts/Interfaces/Entity/IMenu.cs | 2 +- Scripts/Interfaces/Entity/IWorkspace.cs | 2 +- .../IConnectInterfaces.cs | 27 +-- .../FunctionalityInjection/IProcessInput.cs | 3 +- Scripts/Modules/ActionsModule.cs | 2 +- Scripts/Modules/DeviceInputModule.cs | 48 +++- .../Modules/FeedbackModule/FeedbackModule.cs | 10 +- .../Modules/HapticsModule/HapticsModule.cs | 8 +- Scripts/Modules/HierarchyModule.cs | 30 ++- .../HighlightModule/HighlightModule.cs | 19 +- Scripts/Modules/LockModule/LockModule.cs | 3 + .../MultipleRayInputModule.cs | 210 ++++++++---------- Scripts/Modules/ProjectFolderModule.cs | 30 ++- Scripts/Modules/SceneObjectModule.cs | 9 +- .../SelectionModule/SelectionModule.cs | 8 +- .../Modules/SerializedPreferencesModule.cs | 10 +- .../Modules/SnappingModule/SnappingModule.cs | 6 +- Scripts/Modules/SpatialHashModule.cs | 6 +- .../SpatialHintModule/SpatialHintModule.cs | 12 +- .../SpatialScrollModule.cs | 8 +- .../Modules/TooltipModule/TooltipModule.cs | 8 +- Scripts/Modules/WorkspaceModule.cs | 33 +-- 64 files changed, 439 insertions(+), 910 deletions(-) delete mode 100644 Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/LockModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta delete mode 100644 Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs delete mode 100644 Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta diff --git a/Editor/FlagsPropertyDrawer.cs b/Editor/FlagsPropertyDrawer.cs index a57cf5ae5..9068bf22d 100644 --- a/Editor/FlagsPropertyDrawer.cs +++ b/Editor/FlagsPropertyDrawer.cs @@ -1,4 +1,4 @@ -using UnityEditor.Experimental.EditorVR.Utilities; +using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.UI @@ -11,4 +11,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten property.intValue = UIUtils.MaskField(position, label, property.intValue, property.enumNames, UIUtils.SerializedPropertyToType(property)); } } -} \ No newline at end of file +} diff --git a/Menus/MainMenu/Scripts/MainMenuUI.cs b/Menus/MainMenu/Scripts/MainMenuUI.cs index ba5ddb2f3..c200b90b9 100644 --- a/Menus/MainMenu/Scripts/MainMenuUI.cs +++ b/Menus/MainMenu/Scripts/MainMenuUI.cs @@ -1,5 +1,4 @@ #if UNITY_EDITOR -using System; using System.Collections; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Extensions; diff --git a/Scripts/Core/EditorVR.DirectSelection.cs b/Scripts/Core/EditorVR.DirectSelection.cs index db87dc6df..2b02ea9a7 100644 --- a/Scripts/Core/EditorVR.DirectSelection.cs +++ b/Scripts/Core/EditorVR.DirectSelection.cs @@ -35,9 +35,9 @@ public DirectSelection() IGetPointerLengthMethods.getPointerLength = GetPointerLength; } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { - var grabObjects = obj as IGrabObjects; + var grabObjects = @object as IGrabObjects; if (grabObjects != null) { m_ObjectGrabbers.Add(grabObjects); @@ -46,18 +46,18 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) grabObjects.objectsTransferred += OnObjectsTransferred; } - var usesDirectSelection = obj as IUsesDirectSelection; + var usesDirectSelection = @object as IUsesDirectSelection; if (usesDirectSelection != null) m_DirectSelectionUsers.Add(usesDirectSelection); - var twoHandedScaler = obj as ITwoHandedScaler; + var twoHandedScaler = @object as ITwoHandedScaler; if (twoHandedScaler != null) m_TwoHandedScalers.Add(twoHandedScaler); } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var grabObjects = obj as IGrabObjects; + var grabObjects = @object as IGrabObjects; if (grabObjects != null) { m_ObjectGrabbers.Remove(grabObjects); diff --git a/Scripts/Core/EditorVR.Interfaces.cs b/Scripts/Core/EditorVR.Interfaces.cs index 2ca6701d6..3c462b97a 100644 --- a/Scripts/Core/EditorVR.Interfaces.cs +++ b/Scripts/Core/EditorVR.Interfaces.cs @@ -1,9 +1,6 @@ #if UNITY_EDITOR && UNITY_EDITORVR using System; using System.Collections.Generic; -using System.Linq; -using UnityEngine; -using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR.Core { @@ -13,8 +10,8 @@ class Interfaces : Nested { readonly HashSet m_ConnectedInterfaces = new HashSet(); - event IConnectInterfacesMethods.ConnectInterfacesDelegate connectInterfaces; - event IConnectInterfacesMethods.DisonnectInterfacesDelegate disconnectInterfaces; + event Action connectInterfaces; + event Action disconnectInterfaces; public Interfaces() { @@ -22,9 +19,9 @@ public Interfaces() IConnectInterfacesMethods.disconnectInterfaces = DisconnectInterfaces; } - internal void AttachInterfaceConnectors(object obj) + internal void AttachInterfaceConnectors(object @object) { - var connector = obj as IInterfaceConnector; + var connector = @object as IInterfaceConnector; if (connector != null) { connectInterfaces += connector.ConnectInterface; @@ -32,34 +29,23 @@ internal void AttachInterfaceConnectors(object obj) } } - internal void ConnectInterfaces(object obj, InputDevice device) + void ConnectInterfaces(object @object, object userData = null) { - Transform rayOrigin = null; - var deviceData = evr.m_DeviceData.FirstOrDefault(dd => dd.inputDevice == device); - if (deviceData != null) - rayOrigin = deviceData.rayOrigin; - - ConnectInterfaces(obj, rayOrigin); - } - - internal void ConnectInterfaces(object obj, Transform rayOrigin = null) - { - if (!m_ConnectedInterfaces.Add(obj)) + if (!m_ConnectedInterfaces.Add(@object)) return; if (connectInterfaces != null) - connectInterfaces(obj, rayOrigin); + connectInterfaces(@object, userData); } - internal void DisconnectInterfaces(object obj, Transform rayOrigin = null) + void DisconnectInterfaces(object @object, object userData = null) { - m_ConnectedInterfaces.Remove(obj); + m_ConnectedInterfaces.Remove(@object); if (disconnectInterfaces != null) - disconnectInterfaces(obj, rayOrigin); + disconnectInterfaces(@object, userData); } } } } - #endif diff --git a/Scripts/Core/EditorVR.Menus.cs b/Scripts/Core/EditorVR.Menus.cs index 86e0a490e..316be2ab3 100644 --- a/Scripts/Core/EditorVR.Menus.cs +++ b/Scripts/Core/EditorVR.Menus.cs @@ -5,9 +5,7 @@ using UnityEditor.Experimental.EditorVR.Menus; using UnityEditor.Experimental.EditorVR.Modules; using UnityEditor.Experimental.EditorVR.Utilities; -using UnityEditor.Experimental.EditorVR.Workspaces; using UnityEngine; -using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR.Core { @@ -15,7 +13,7 @@ partial class EditorVR { const float k_MainMenuAutoHideDelay = 0.125f; const float k_MainMenuAutoShowDelay = 0.25f; - class Menus : Nested, IInterfaceConnector, ILateBindInterfaceMethods + class Menus : Nested, IInterfaceConnector, ILateBindInterfaceMethods, IConnectInterfaces { internal class MenuHideData { @@ -47,12 +45,13 @@ public Menus() IUsesCustomMenuOriginsMethods.getCustomAlternateMenuOrigin = GetCustomAlternateMenuOrigin; } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { - var settingsMenuProvider = obj as ISettingsMenuProvider; + var rayOrigin = userData as Transform; + var settingsMenuProvider = @object as ISettingsMenuProvider; if (settingsMenuProvider != null) { - m_SettingsMenuProviders[new KeyValuePair(obj.GetType(), rayOrigin)] = settingsMenuProvider; + m_SettingsMenuProviders[new KeyValuePair(@object.GetType(), rayOrigin)] = settingsMenuProvider; foreach (var kvp in m_MainMenus) { if (rayOrigin == null || kvp.Key == rayOrigin) @@ -60,10 +59,10 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) } } - var settingsMenuItemProvider = obj as ISettingsMenuItemProvider; + var settingsMenuItemProvider = @object as ISettingsMenuItemProvider; if (settingsMenuItemProvider != null) { - m_SettingsMenuItemProviders[new KeyValuePair(obj.GetType(), rayOrigin)] = settingsMenuItemProvider; + m_SettingsMenuItemProviders[new KeyValuePair(@object.GetType(), rayOrigin)] = settingsMenuItemProvider; foreach (var kvp in m_MainMenus) { if (rayOrigin == null || kvp.Key == rayOrigin) @@ -71,8 +70,8 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) } } - var mainMenu = obj as IMainMenu; - if (mainMenu != null) + var mainMenu = @object as IMainMenu; + if (mainMenu != null && rayOrigin != null) { mainMenu.menuTools = m_MainMenuTools; mainMenu.menuWorkspaces = WorkspaceModule.workspaceTypes; @@ -81,7 +80,7 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) m_MainMenus[rayOrigin] = mainMenu; } - var menuOrigins = obj as IUsesMenuOrigins; + var menuOrigins = @object as IUsesMenuOrigins; if (menuOrigins != null) { Transform mainMenuOrigin; @@ -96,9 +95,10 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) } } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var settingsMenuProvider = obj as ISettingsMenuProvider; + var rayOrigin = userData as Transform; + var settingsMenuProvider = @object as ISettingsMenuProvider; if (settingsMenuProvider != null) { foreach (var kvp in m_MainMenus) @@ -107,10 +107,10 @@ public void DisconnectInterface(object obj, Transform rayOrigin = null) kvp.Value.RemoveSettingsMenu(settingsMenuProvider); } - m_SettingsMenuProviders.Remove(new KeyValuePair(obj.GetType(), rayOrigin)); + m_SettingsMenuProviders.Remove(new KeyValuePair(@object.GetType(), rayOrigin)); } - var settingsMenuItemProvider = obj as ISettingsMenuItemProvider; + var settingsMenuItemProvider = @object as ISettingsMenuItemProvider; if (settingsMenuItemProvider != null) { foreach (var kvp in m_MainMenus) @@ -119,11 +119,11 @@ public void DisconnectInterface(object obj, Transform rayOrigin = null) kvp.Value.RemoveSettingsMenuItem(settingsMenuItemProvider); } - m_SettingsMenuItemProviders.Remove(new KeyValuePair(obj.GetType(), rayOrigin)); + m_SettingsMenuItemProviders.Remove(new KeyValuePair(@object.GetType(), rayOrigin)); } - var mainMenu = obj as IMainMenu; - if (mainMenu != null) + var mainMenu = @object as IMainMenu; + if (mainMenu != null && rayOrigin != null) m_MainMenus.Remove(rayOrigin); } @@ -138,8 +138,7 @@ static void UpdateAlternateMenuForDevice(DeviceData deviceData) alternateMenu.menuHideFlags = deviceData.currentTool is IExclusiveMode ? 0 : deviceData.menuHideData[alternateMenu].hideFlags; // Move the Tools Menu buttons to an alternate position if the alternate menu will be shown - var toolsMenu = deviceData.ToolsMenu; - toolsMenu.alternateMenuVisible = alternateMenu.menuHideFlags == 0; + deviceData.toolsMenu.alternateMenuVisible = alternateMenu.menuHideFlags == 0; } static Transform GetCustomMenuOrigin(Transform rayOrigin) @@ -274,7 +273,7 @@ internal void UpdateMenuVisibilities() mainMenu.menuHideFlags = mainMenuHideFlags; // Disable the main menu activator if any temporary states are set - deviceData.ToolsMenu.mainMenuActivatorInteractable = (mainMenuHideFlags & MenuHideFlags.Temporary) == 0; + deviceData.toolsMenu.mainMenuActivatorInteractable = (mainMenuHideFlags & MenuHideFlags.Temporary) == 0; // Show/hide custom menu, if it exists var customMenu = deviceData.customMenu; @@ -509,45 +508,35 @@ static GameObject InstantiateMenuUI(Transform rayOrigin, IMenu prefab) return go; } - internal static IMainMenu SpawnMainMenu(Type type, InputDevice device, bool visible, out ActionMapInput input) + internal IMainMenu SpawnMainMenu(Type type, Transform rayOrigin) { - input = null; - if (!typeof(IMainMenu).IsAssignableFrom(type)) return null; var mainMenu = (IMainMenu)ObjectUtils.AddComponent(type, evr.gameObject); - input = evr.GetModule().CreateActionMapInputForObject(mainMenu, device); - evr.m_Interfaces.ConnectInterfaces(mainMenu, device); - mainMenu.menuHideFlags = visible ? 0 : MenuHideFlags.Hidden; + this.ConnectInterfaces(mainMenu, rayOrigin); return mainMenu; } - internal static IAlternateMenu SpawnAlternateMenu(Type type, InputDevice device, out ActionMapInput input) + internal IAlternateMenu SpawnAlternateMenu(Type type, Transform rayOrigin) { - input = null; - if (!typeof(IAlternateMenu).IsAssignableFrom(type)) return null; var alternateMenu = (IAlternateMenu)ObjectUtils.AddComponent(type, evr.gameObject); - input = evr.GetModule().CreateActionMapInputForObject(alternateMenu, device); - evr.m_Interfaces.ConnectInterfaces(alternateMenu, device); + this.ConnectInterfaces(alternateMenu, rayOrigin); return alternateMenu; } - internal static IToolsMenu SpawnToolsMenu(Type type, InputDevice device, out ActionMapInput input) + internal IToolsMenu SpawnToolsMenu(Type type, Transform rayOrigin) { - input = null; - if (!typeof(IToolsMenu).IsAssignableFrom(type)) return null; var menu = (IToolsMenu)ObjectUtils.AddComponent(type, evr.gameObject); - input = evr.GetModule().CreateActionMapInputForObject(menu, device); - evr.m_Interfaces.ConnectInterfaces(menu, device); + this.ConnectInterfaces(menu, rayOrigin); return menu; } diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index d20898816..2d8d0f629 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -18,7 +18,7 @@ partial class EditorVR [SerializeField] ProxyExtras m_ProxyExtras; - class Rays : Nested, IInterfaceConnector, IForEachRayOrigin + class Rays : Nested, IInterfaceConnector, IForEachRayOrigin, IConnectInterfaces { internal delegate void ForEachProxyDeviceCallback(DeviceData deviceData); @@ -58,17 +58,18 @@ internal override void OnDestroy() ObjectUtils.Destroy(((MonoBehaviour)proxy).gameObject); } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { + var rayOrigin = userData as Transform; if (rayOrigin) { var evrDeviceData = evr.m_DeviceData; - var ray = obj as IUsesRayOrigin; + var ray = @object as IUsesRayOrigin; if (ray != null) ray.rayOrigin = rayOrigin; - var rayOrigins = obj as IUsesRayOrigins; + var rayOrigins = @object as IUsesRayOrigins; if (rayOrigins != null) { List otherRayOrigins = new List(); @@ -82,16 +83,16 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) var deviceData = evrDeviceData.FirstOrDefault(dd => dd.rayOrigin == rayOrigin); - var handedRay = obj as IUsesNode; + var handedRay = @object as IUsesNode; if (handedRay != null && deviceData != null) handedRay.node = deviceData.node; - var usesProxy = obj as IUsesProxyType; + var usesProxy = @object as IUsesProxyType; if (usesProxy != null && deviceData != null) usesProxy.proxyType = deviceData.proxy.GetType(); } - var selectionModule = obj as SelectionModule; + var selectionModule = @object as SelectionModule; if (selectionModule) { selectionModule.selected += SetLastSelectionRayOrigin; // when a selection occurs in the selection tool, call show in the alternate menu, allowing it to show/hide itself. @@ -100,7 +101,7 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) } } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { } @@ -150,11 +151,10 @@ static bool OverrideSelectObject(GameObject hoveredObject) internal void CreateAllProxies() { var deviceInputModule = evr.GetModule(); - var interfaceModule = evr.GetNestedModule(); foreach (var proxyType in ObjectUtils.GetImplementationsOfInterface(typeof(IProxy))) { var proxy = (IProxy)ObjectUtils.CreateGameObjectWithComponent(proxyType, VRView.cameraRig, false); - interfaceModule.ConnectInterfaces(proxy); + this.ConnectInterfaces(proxy); proxy.trackedObjectInput = deviceInputModule.trackedObjectInput; proxy.activeChanged += () => OnProxyActiveChanged(proxy); proxy.hidden = true; @@ -201,10 +201,9 @@ void OnProxyActiveChanged(IProxy proxy) deviceData.node = node; deviceData.rayOrigin = rayOrigin; deviceData.inputDevice = device; - deviceData.uiInput = deviceInputModule.CreateActionMapInput(actionMap, device); // Add RayOrigin transform, proxy and ActionMapInput references to input module list of sources - inputModule.AddRaycastSource(proxy, node, deviceData.uiInput, rayOrigin, source => + inputModule.AddRaycastSource(proxy, node, rayOrigin, source => { // Do not invalidate UI raycasts in the middle of a drag operation if (!source.draggedObject) @@ -278,7 +277,7 @@ void OnProxyActiveChanged(IProxy proxy) } } - Tools.SpawnDefaultTools(proxy); + evr.GetNestedModule().SpawnDefaultTools(proxy); } } } diff --git a/Scripts/Core/EditorVR.Tools.cs b/Scripts/Core/EditorVR.Tools.cs index 3378e1349..b20b664d2 100644 --- a/Scripts/Core/EditorVR.Tools.cs +++ b/Scripts/Core/EditorVR.Tools.cs @@ -13,7 +13,7 @@ namespace UnityEditor.Experimental.EditorVR.Core { partial class EditorVR { - class Tools : Nested, IInterfaceConnector + class Tools : Nested, IInterfaceConnector, IConnectInterfaces { internal class ToolData { @@ -26,6 +26,8 @@ internal class ToolData readonly Dictionary> m_LinkedObjects = new Dictionary>(); + public event Action updatePlayerHandleMaps; + public Tools() { allTools = ObjectUtils.GetImplementationsOfInterface(typeof(ITool)).ToList(); @@ -35,12 +37,12 @@ public Tools() ISelectToolMethods.isToolActive = IsToolActive; } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { - var linkedObject = obj as ILinkedObject; + var linkedObject = @object as ILinkedObject; if (linkedObject != null) { - var type = obj.GetType(); + var type = @object.GetType(); List linkedObjectList; if (!m_LinkedObjects.TryGetValue(type, out linkedObjectList)) { @@ -53,12 +55,12 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) } } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var linkedObject = obj as ILinkedObject; + var linkedObject = @object as ILinkedObject; if (linkedObject != null) { - var type = obj.GetType(); + var type = @object.GetType(); List linkedObjectList; if (!m_LinkedObjects.TryGetValue(type, out linkedObjectList)) return; @@ -82,7 +84,7 @@ internal static bool IsDefaultTool(Type type) return evr.m_DefaultTools.Contains(type); } - internal static void SpawnDefaultTools(IProxy proxy) + internal void SpawnDefaultTools(IProxy proxy) { var vacuumables = evr.GetNestedModule(); var lockModule = evr.GetModule(); @@ -119,20 +121,22 @@ internal static void SpawnDefaultTools(IProxy proxy) } } + var menus = evr.GetNestedModule(); var menuHideData = deviceData.menuHideData; - var mainMenu = Menus.SpawnMainMenu(typeof(MainMenu), inputDevice, false, out deviceData.mainMenuInput); + var rayOrigin = deviceData.rayOrigin; + var mainMenu = menus.SpawnMainMenu(typeof(MainMenu), rayOrigin); deviceData.mainMenu = mainMenu; menuHideData[mainMenu] = new Menus.MenuHideData(); - var alternateMenu = Menus.SpawnAlternateMenu(typeof(RadialMenu), inputDevice, out deviceData.alternateMenuInput); + var alternateMenu = menus.SpawnAlternateMenu(typeof(RadialMenu), rayOrigin); deviceData.alternateMenu = alternateMenu; menuHideData[alternateMenu] = new Menus.MenuHideData(); alternateMenu.itemWasSelected += Menus.UpdateAlternateMenuOnSelectionChanged; // Setup ToolsMenu - var toolsMenu = Menus.SpawnToolsMenu(typeof(Experimental.EditorVR.Menus.ToolsMenu), inputDevice, out deviceData.toolsMenuInput); - deviceData.ToolsMenu = toolsMenu; - toolsMenu.rayOrigin = deviceData.rayOrigin; + var toolsMenu = menus.SpawnToolsMenu(typeof(Experimental.EditorVR.Menus.ToolsMenu), rayOrigin); + deviceData.toolsMenu = toolsMenu; + toolsMenu.rayOrigin = rayOrigin; toolsMenu.setButtonForType(typeof(IMainMenu), null); toolsMenu.setButtonForType(typeof(SelectionTool), selectionToolData != null ? selectionToolData.icon : null); } @@ -148,7 +152,7 @@ internal static void SpawnDefaultTools(IProxy proxy) /// The input device whose tool stack the tool should be spawned on (optional). If not /// specified, then it uses the action map to determine which devices the tool should be spawned on. /// Returns tool that was spawned or null if the spawn failed. - static ToolData SpawnTool(Type toolType, out HashSet usedDevices, InputDevice device = null) + ToolData SpawnTool(Type toolType, out HashSet usedDevices, InputDevice device = null) { usedDevices = new HashSet(); if (!typeof(ITool).IsAssignableFrom(toolType)) @@ -167,7 +171,7 @@ static ToolData SpawnTool(Type toolType, out HashSet usedDevices, I if (usedDevices.Count == 0) usedDevices.Add(device); - evr.m_Interfaces.ConnectInterfaces(tool, device); + this.ConnectInterfaces(tool, device); var icon = tool as IMenuIcon; return new ToolData { tool = tool, input = actionMapInput, icon = icon != null ? icon.icon : null}; @@ -193,7 +197,7 @@ static bool IsToolActive(Transform targetRayOrigin, Type toolType) return result; } - internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnReselect = true) + internal bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnReselect = true) { var result = false; var deviceInputModule = evr.GetModule(); @@ -206,7 +210,7 @@ internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawn var currentToolType = currentTool.GetType(); var currentToolIsSelect = currentToolType == typeof(SelectionTool); var setSelectAsCurrentTool = toolType == typeof(SelectionTool) && !currentToolIsSelect; - var toolsMenu = deviceData.ToolsMenu; + var toolsMenu = deviceData.toolsMenu; // If this tool was on the current device already, remove it, if it is selected while already being the current tool var despawn = (!currentToolIsSelect && currentToolType == toolType && despawnOnReselect) || setSelectAsCurrentTool;// || setSelectAsCurrentTool || toolType == typeof(IMainMenu); if (currentTool != null && despawn) @@ -293,7 +297,7 @@ internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawn return result; } - static void DespawnTool(DeviceData deviceData, ITool tool) + void DespawnTool(DeviceData deviceData, ITool tool) { var toolType = tool.GetType(); if (!IsDefaultTool(toolType)) @@ -340,7 +344,7 @@ static void DespawnTool(DeviceData deviceData, ITool tool) if (otherToolData != null) { otherDeviceData.currentTool = otherToolData.tool; - evr.m_Interfaces.DisconnectInterfaces(otherTool, otherDeviceData.rayOrigin); + this.DisconnectInterfaces(otherTool, otherDeviceData.rayOrigin); ObjectUtils.Destroy(otherTool as MonoBehaviour); } } @@ -356,7 +360,7 @@ static void DespawnTool(DeviceData deviceData, ITool tool) } } } - evr.m_Interfaces.DisconnectInterfaces(tool, deviceData.rayOrigin); + this.DisconnectInterfaces(tool, deviceData.rayOrigin); // Exclusive tools disable other tools underneath, so restore those if (tool is IExclusiveMode) @@ -389,51 +393,12 @@ static void AddToolToStack(DeviceData deviceData, ToolData toolData) } } - internal static void UpdatePlayerHandleMaps(List maps) + internal void UpdatePlayerHandleMaps(List maps) { - foreach (var input in evr.GetModule().workspaceInputs) - { - maps.Add(input); - } - - var evrDeviceData = evr.m_DeviceData; - foreach (var deviceData in evrDeviceData) - { - var mainMenu = deviceData.mainMenu; - var mainMenuInput = deviceData.mainMenuInput; - if (mainMenu != null && mainMenuInput != null) - { - mainMenuInput.active = mainMenu.menuHideFlags == 0; - - if (!maps.Contains(mainMenuInput)) - maps.Add(mainMenuInput); - } - - var alternateMenu = deviceData.alternateMenu; - var alternateMenuInput = deviceData.alternateMenuInput; - if (alternateMenu != null && alternateMenuInput != null) - { - alternateMenuInput.active = alternateMenu.menuHideFlags == 0; + if (updatePlayerHandleMaps != null) + updatePlayerHandleMaps(); - if (!maps.Contains(alternateMenuInput)) - maps.Add(alternateMenuInput); - } - - var toolsMenu = deviceData.ToolsMenu; - var toolsMenuInput = deviceData.toolsMenuInput; - if (toolsMenu != null && toolsMenuInput != null) - { - // Tools Menu visibility is handled internally, not via hide flags - if (!maps.Contains(toolsMenuInput)) - maps.Add(toolsMenuInput); - } - - maps.Add(deviceData.uiInput); - } - - maps.Add(evr.GetModule().trackedObjectInput); - - foreach (var deviceData in evrDeviceData) + foreach (var deviceData in evr.m_DeviceData) { foreach (var td in deviceData.toolData) { diff --git a/Scripts/Core/EditorVR.ToolsMenu.cs b/Scripts/Core/EditorVR.ToolsMenu.cs index 259ac8928..aea426c73 100644 --- a/Scripts/Core/EditorVR.ToolsMenu.cs +++ b/Scripts/Core/EditorVR.ToolsMenu.cs @@ -28,7 +28,7 @@ static void PreviewToolInToolMenuButton (Transform rayOrigin, Type toolType, str { if (deviceData.rayOrigin == rayOrigin) // Enable Tools Menu preview on the opposite (handed) device { - var previewToolMenuButton = deviceData.ToolsMenu.PreviewToolsMenuButton; + var previewToolMenuButton = deviceData.toolsMenu.PreviewToolsMenuButton; previewToolMenuButton.previewToolType = toolType; previewToolMenuButton.previewToolDescription = toolDescription; } @@ -39,7 +39,7 @@ static void ClearToolMenuButtonPreview() { Rays.ForEachProxyDevice((deviceData) => { - deviceData.ToolsMenu.PreviewToolsMenuButton.previewToolType = null; + deviceData.toolsMenu.PreviewToolsMenuButton.previewToolType = null; }); } @@ -48,7 +48,7 @@ static void OnToolButtonClicked(Transform rayOrigin, Type toolType) if (toolType == typeof(IMainMenu)) OnMainMenuActivatorSelected(rayOrigin); else - Tools.SelectTool(rayOrigin, toolType); + evr.GetNestedModule().SelectTool(rayOrigin, toolType); } static void OnMainMenuActivatorSelected(Transform rayOrigin) diff --git a/Scripts/Core/EditorVR.UI.cs b/Scripts/Core/EditorVR.UI.cs index b32883e93..c036e423b 100644 --- a/Scripts/Core/EditorVR.UI.cs +++ b/Scripts/Core/EditorVR.UI.cs @@ -14,7 +14,7 @@ partial class EditorVR [SerializeField] Camera m_EventCameraPrefab; - class UI : Nested, IInterfaceConnector + class UI : Nested, IInterfaceConnector, IConnectInterfaces { const byte k_MinStencilRef = 2; @@ -45,18 +45,18 @@ public UI() IGetManipulatorDragStateMethods.getManipulatorDragState = GetManipulatorDragState; } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { - var manipulatorController = obj as IManipulatorController; + var manipulatorController = @object as IManipulatorController; if (manipulatorController != null) m_ManipulatorControllers.Add(manipulatorController); - var usesStencilRef = obj as IUsesStencilRef; + var usesStencilRef = @object as IUsesStencilRef; if (usesStencilRef != null) { byte? stencilRef = null; - var mb = obj as MonoBehaviour; + var mb = @object as MonoBehaviour; if (mb) { var parent = mb.transform.parent; @@ -73,9 +73,9 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) } } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var manipulatorController = obj as IManipulatorController; + var manipulatorController = @object as IManipulatorController; if (manipulatorController != null) m_ManipulatorControllers.Remove(manipulatorController); } @@ -114,7 +114,7 @@ internal GameObject InstantiateUI(GameObject prefab, Transform parent = null, bo } foreach (var mb in go.GetComponentsInChildren(true)) - evr.m_Interfaces.ConnectInterfaces(mb, connectInterfacesOverride); + this.ConnectInterfaces(mb, connectInterfacesOverride); return go; } diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index 3a3dab5dd..96e523b56 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -18,7 +18,7 @@ partial class EditorVR [SerializeField] GameObject m_PreviewCameraPrefab; - class Viewer : Nested, IInterfaceConnector, ISerializePreferences + class Viewer : Nested, IInterfaceConnector, ISerializePreferences, IConnectInterfaces { [Serializable] class Preferences @@ -79,14 +79,14 @@ internal override void OnDestroy() ObjectUtils.Destroy(((MonoBehaviour)customPreviewCamera).gameObject); } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { - var usesCameraRig = obj as IUsesCameraRig; + var usesCameraRig = @object as IUsesCameraRig; if (usesCameraRig != null) usesCameraRig.cameraRig = CameraUtils.GetCameraRig(); } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { } @@ -164,7 +164,7 @@ internal void InitializeCamera() VRView.customPreviewCamera = customPreviewCamera.previewCamera; customPreviewCamera.vrCamera = VRView.viewerCamera; hmdOnlyLayerMask = customPreviewCamera.hmdOnlyLayerMask; - evr.m_Interfaces.ConnectInterfaces(customPreviewCamera); + this.ConnectInterfaces(customPreviewCamera); } } VRView.cullingMask = UnityEditor.Tools.visibleLayers | hmdOnlyLayerMask; diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index dd2fd8d2f..6256cb0f9 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -14,7 +14,7 @@ namespace UnityEditor.Experimental.EditorVR.Core { #if UNITY_EDITORVR [RequiresTag(k_VRPlayerTag)] - sealed partial class EditorVR : MonoBehaviour + sealed partial class EditorVR : MonoBehaviour, IConnectInterfaces { const string k_ShowGameObjects = "EditorVR.ShowGameObjects"; const string k_PreserveLayout = "EditorVR.PreserveLayout"; @@ -69,15 +69,11 @@ class DeviceData public Node node; public Transform rayOrigin; public readonly Stack toolData = new Stack(); - public ActionMapInput uiInput; public IMainMenu mainMenu; - public ActionMapInput mainMenuInput; public IAlternateMenu alternateMenu; - public ActionMapInput alternateMenuInput; public ITool currentTool; public IMenu customMenu; - public IToolsMenu ToolsMenu; - public ActionMapInput toolsMenuInput; + public IToolsMenu toolsMenu; public readonly Dictionary menuHideData = new Dictionary(); } @@ -155,7 +151,7 @@ void Awake() deviceInputModule.InitializePlayerHandle(); deviceInputModule.CreateDefaultActionMapInputs(); deviceInputModule.processInput = ProcessInput; - deviceInputModule.updatePlayerHandleMaps = Tools.UpdatePlayerHandleMaps; + deviceInputModule.updatePlayerHandleMaps = GetNestedModule().UpdatePlayerHandleMaps; GetNestedModule().Initialize(); @@ -170,7 +166,7 @@ void Awake() multipleRayInputModule.dragEnded += dragAndDropModule.OnDragEnded; var tooltipModule = AddModule(); - m_Interfaces.ConnectInterfaces(tooltipModule); + this.ConnectInterfaces(tooltipModule); multipleRayInputModule.rayEntered += tooltipModule.OnRayEntered; multipleRayInputModule.rayHovering += tooltipModule.OnRayHovering; multipleRayInputModule.rayExited += tooltipModule.OnRayExited; @@ -188,7 +184,7 @@ void Awake() spatialHashModule.Setup(); var intersectionModule = AddModule(); - m_Interfaces.ConnectInterfaces(intersectionModule); + this.ConnectInterfaces(intersectionModule); intersectionModule.Setup(spatialHashModule.spatialHash); AddModule(); @@ -202,7 +198,6 @@ void Awake() workspaceModule.workspaceCreated += miniWorlds.OnWorkspaceCreated; workspaceModule.workspaceCreated += workspace => { - workspaceModule.workspaceInputs.Add((WorkspaceInput)deviceInputModule.CreateActionMapInputForObject(workspace, null)); deviceInputModule.UpdatePlayerHandleMaps(); }; workspaceModule.workspaceDestroyed += vacuumables.OnWorkspaceDestroyed; @@ -362,32 +357,13 @@ void Update() void ProcessInput(HashSet processedInputs, ConsumeControlDelegate consumeControl) { - GetModule().ProcessInput(consumeControl); - GetNestedModule().UpdateMiniWorlds(); - GetModule().ProcessInput(null, consumeControl); - foreach (var deviceData in m_DeviceData) { if (!deviceData.proxy.active) continue; - var mainMenu = deviceData.mainMenu; - var menuInput = mainMenu as IProcessInput; - if (menuInput != null && mainMenu.menuHideFlags == 0) - menuInput.ProcessInput(deviceData.mainMenuInput, consumeControl); - - var altMenu = deviceData.alternateMenu; - var altMenuInput = altMenu as IProcessInput; - if (altMenuInput != null && altMenu.menuHideFlags == 0) - altMenuInput.ProcessInput(deviceData.alternateMenuInput, consumeControl); - - var toolsMenu = deviceData.ToolsMenu; - var toolsMenuInput = toolsMenu as IProcessInput; - if (toolsMenuInput != null) - toolsMenuInput.ProcessInput(deviceData.toolsMenuInput, consumeControl); - foreach (var toolData in deviceData.toolData) { var process = toolData.tool as IProcessInput; @@ -421,7 +397,7 @@ T AddModule() where T : MonoBehaviour lateBinding.LateBindInterfaceMethods((T)module); } - m_Interfaces.ConnectInterfaces(module); + this.ConnectInterfaces(module); m_Interfaces.AttachInterfaceConnectors(module); } @@ -443,7 +419,7 @@ Nested AddNestedModule(Type type) if (m_Interfaces != null) { - m_Interfaces.ConnectInterfaces(nested); + this.ConnectInterfaces(nested); m_Interfaces.AttachInterfaceConnectors(nested); } } diff --git a/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs b/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs index d2e06d26b..8d31eee59 100644 --- a/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs @@ -1,6 +1,5 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_EDITORVR using UnityEditor.Experimental.EditorVR.Modules; -using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Core { @@ -8,14 +7,14 @@ partial class EditorVR { class ActionsModuleConnector : Nested, IInterfaceConnector { - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { var actionsModule = evr.GetModule(); if (actionsModule) { var menuActions = actionsModule.menuActions; - var toolActions = obj as IActions; + var toolActions = @object as IActions; if (toolActions != null) { // Delay connecting actions to allow tool / module to initialize first @@ -40,15 +39,15 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) }; } - var alternateMenu = obj as IAlternateMenu; + var alternateMenu = @object as IAlternateMenu; if (alternateMenu != null) alternateMenu.menuActions = menuActions; } } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var toolActions = obj as IActions; + var toolActions = @object as IActions; if (toolActions != null) { var evrActionsModule = evr.GetModule(); diff --git a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs deleted file mode 100644 index 8c6f5a60d..000000000 --- a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs +++ /dev/null @@ -1,25 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; -using UnityEngine; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class DeviceInputModuleConnector : Nested, IInterfaceConnector - { - public void ConnectInterface(object obj, Transform rayOrigin = null) - { - // Tracked Object action maps shouldn't block each other so we share an instance - var trackedObjectMap = obj as ITrackedObjectActionMap; - if (trackedObjectMap != null) - trackedObjectMap.trackedObjectInput = evr.GetModule().trackedObjectInput; - } - - public void DisconnectInterface(object obj, Transform rayOrigin = null) - { - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta deleted file mode 100644 index 6d58a7589..000000000 --- a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: a798606e983e34f40bf82eb817fbcc34 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs deleted file mode 100644 index b55dc3e66..000000000 --- a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs +++ /dev/null @@ -1,18 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class HapticsModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(HapticsModule provider) - { - IControlHapticsMethods.pulse = provider.Pulse; - IControlHapticsMethods.stopPulses = provider.StopPulses; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta deleted file mode 100644 index 1c8b80936..000000000 --- a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 9fd9027b505d0c244b1bb5c586615e8d -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs deleted file mode 100644 index 9bae7284e..000000000 --- a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs +++ /dev/null @@ -1,41 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; -using UnityEngine; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class HierarchyModuleConnector : Nested, IInterfaceConnector - { - public void ConnectInterface(object obj, Transform rayOrigin = null) - { - var usesHierarchyData = obj as IUsesHierarchyData; - if (usesHierarchyData != null) - { - var evrHierarchyModule = evr.GetModule(); - evrHierarchyModule.AddConsumer(usesHierarchyData); - - var filterUI = obj as IFilterUI; - if (filterUI != null) - evrHierarchyModule.AddConsumer(filterUI); - } - } - - public void DisconnectInterface(object obj, Transform rayOrigin = null) - { - var usesHierarchy = obj as IUsesHierarchyData; - if (usesHierarchy != null) - { - var evrHierarchyModule = evr.GetModule(); - evrHierarchyModule.RemoveConsumer(usesHierarchy); - - var filterUI = obj as IFilterUI; - if (filterUI != null) - evrHierarchyModule.RemoveConsumer(filterUI); - } - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta deleted file mode 100644 index 91b52569d..000000000 --- a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5853c284ea4ca5d4492cbb8506758cc0 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs deleted file mode 100644 index ba30ee83e..000000000 --- a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs +++ /dev/null @@ -1,38 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; -using UnityEngine; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class HighlightModuleConnector : Nested, IInterfaceConnector, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(HighlightModule provider) - { - ISetHighlightMethods.setHighlight = provider.SetHighlight; - } - - public void ConnectInterface(object obj, Transform rayOrigin = null) - { - var customHighlight = obj as ICustomHighlight; - if (customHighlight != null) - { - var evrHighlightModule = evr.GetModule(); - evrHighlightModule.customHighlight += customHighlight.OnHighlight; - } - } - - public void DisconnectInterface(object obj, Transform rayOrigin = null) - { - var customHighlight = obj as ICustomHighlight; - if (customHighlight != null) - { - var evrHighlightModule = evr.GetModule(); - evrHighlightModule.customHighlight -= customHighlight.OnHighlight; - } - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta deleted file mode 100644 index 5564522c6..000000000 --- a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 39b5983bf5da6da41a2a512df83ccb33 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs deleted file mode 100644 index eba893c4b..000000000 --- a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs +++ /dev/null @@ -1,18 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class LockModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(LockModule provider) - { - IUsesGameObjectLockingMethods.setLocked = provider.SetLocked; - IUsesGameObjectLockingMethods.isLocked = provider.IsLocked; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta deleted file mode 100644 index c24ed627d..000000000 --- a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: cd6ca3d67dbdb944b9613c75d5b6a279 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs deleted file mode 100644 index d1d5b6c5c..000000000 --- a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs +++ /dev/null @@ -1,17 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class MultipleRayInputModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(MultipleRayInputModule provider) - { - IIsHoveringOverUIMethods.isHoveringOverUI = provider.IsHoveringOverUI; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta deleted file mode 100644 index bcce847ba..000000000 --- a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: c4acdc0d1cb343b43bdb533e7b69ba9c -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs deleted file mode 100644 index bc032ab6a..000000000 --- a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs +++ /dev/null @@ -1,41 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; -using UnityEngine; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class ProjectFolderModuleConnector : Nested, IInterfaceConnector - { - public void ConnectInterface(object obj, Transform rayOrigin = null) - { - var usesProjectFolderData = obj as IUsesProjectFolderData; - if (usesProjectFolderData != null) - { - var evrProjectFolderModule = evr.GetModule(); - evrProjectFolderModule.AddConsumer(usesProjectFolderData); - - var filterUI = obj as IFilterUI; - if (filterUI != null) - evrProjectFolderModule.AddConsumer(filterUI); - } - } - - public void DisconnectInterface(object obj, Transform rayOrigin = null) - { - var usesProjectFolderData = obj as IUsesProjectFolderData; - if (usesProjectFolderData != null) - { - var evrProjectFolderModule = evr.GetModule(); - evrProjectFolderModule.RemoveConsumer(usesProjectFolderData); - - var filterUI = obj as IFilterUI; - if (filterUI != null) - evrProjectFolderModule.RemoveConsumer(filterUI); - } - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta deleted file mode 100644 index c5dd2d691..000000000 --- a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: f7604b6b3be4c8c4cbf7e94687e61208 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs deleted file mode 100644 index 90d16a0e1..000000000 --- a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs +++ /dev/null @@ -1,19 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class SceneObjectModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(SceneObjectModule provider) - { - IDeleteSceneObjectMethods.deleteSceneObject = provider.DeleteSceneObject; - IPlaceSceneObjectMethods.placeSceneObject = provider.PlaceSceneObject; - IPlaceSceneObjectsMethods.placeSceneObjects = provider.PlaceSceneObjects; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta deleted file mode 100644 index 22bfbe1e6..000000000 --- a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: ff22862caceb1ef46bb59493da621d60 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs index a92581eec..3d20bd41e 100644 --- a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs @@ -1,29 +1,21 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; -using UnityEngine; +#if UNITY_EDITOR && UNITY_EDITORVR namespace UnityEditor.Experimental.EditorVR.Core { partial class EditorVR { - class SelectionModuleConnector : Nested, IInterfaceConnector, ILateBindInterfaceMethods + class SelectionModuleConnector : Nested, IInterfaceConnector { - public void LateBindInterfaceMethods(SelectionModule provider) + public void ConnectInterface(object @object, object userData = null) { - ISelectObjectMethods.getSelectionCandidate = provider.GetSelectionCandidate; - ISelectObjectMethods.selectObject = provider.SelectObject; - } - - public void ConnectInterface(object obj, Transform rayOrigin = null) - { - var selectionChanged = obj as ISelectionChanged; + var selectionChanged = @object as ISelectionChanged; if (selectionChanged != null) evr.selectionChanged += selectionChanged.OnSelectionChanged; } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var selectionChanged = obj as ISelectionChanged; + var selectionChanged = @object as ISelectionChanged; if (selectionChanged != null) evr.selectionChanged -= selectionChanged.OnSelectionChanged; } diff --git a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs deleted file mode 100644 index bf754e19e..000000000 --- a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs +++ /dev/null @@ -1,19 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class SnappingModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(SnappingModule provider) - { - IUsesSnappingMethods.manipulatorSnap = provider.ManipulatorSnap; - IUsesSnappingMethods.directSnap = provider.DirectSnap; - IUsesSnappingMethods.clearSnappingState = provider.ClearSnappingState; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta deleted file mode 100644 index b2aa98340..000000000 --- a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 87ee9909fd766c5448c4533fefa2618a -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs deleted file mode 100644 index 6845f7971..000000000 --- a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs +++ /dev/null @@ -1,18 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class SpatialHashModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(SpatialHashModule provider) - { - IUsesSpatialHashMethods.addToSpatialHash = provider.AddObject; - IUsesSpatialHashMethods.removeFromSpatialHash = provider.RemoveObject; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta deleted file mode 100644 index 5f9f7e1ca..000000000 --- a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 6cef8b3f6b78f314d916ec481e5e6429 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs deleted file mode 100644 index 59b212f3c..000000000 --- a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs +++ /dev/null @@ -1,24 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class SpatialHintModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(SpatialHintModule provider) - { - IControlSpatialHintingMethods.setSpatialHintState = provider.SetState; - IControlSpatialHintingMethods.setSpatialHintPosition = provider.SetPosition; - IControlSpatialHintingMethods.setSpatialHintContainerRotation = provider.SetContainerRotation; - IControlSpatialHintingMethods.setSpatialHintShowHideRotationTarget = provider.SetShowHideRotationTarget; - IControlSpatialHintingMethods.setSpatialHintLookAtRotation = provider.LookAt; - IControlSpatialHintingMethods.setSpatialHintDragThresholdTriggerPosition = provider.SetDragThresholdTriggerPosition; - IControlSpatialHintingMethods.pulseSpatialHintScrollArrows = provider.PulseScrollArrows; - IControlSpatialHintingMethods.setSpatialHintControlNode = provider.SetSpatialHintControlNode; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta deleted file mode 100644 index 0ce5544e0..000000000 --- a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 160f2053e594df84993a7f20d25165e1 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs deleted file mode 100644 index a4b58ac9f..000000000 --- a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs +++ /dev/null @@ -1,18 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class SpatialScrollModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(SpatialScrollModule provider) - { - IControlSpatialScrollingMethods.performSpatialScroll = provider.PerformScroll; - IControlSpatialScrollingMethods.endSpatialScroll = provider.EndScroll; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta deleted file mode 100644 index e158f9b30..000000000 --- a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: b2adf9dd694035a45b24f0ecb7d37ebe -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs deleted file mode 100644 index 3221a284e..000000000 --- a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs +++ /dev/null @@ -1,18 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class TooltipModuleConnector : Nested, ILateBindInterfaceMethods - { - public void LateBindInterfaceMethods(TooltipModule provider) - { - ISetTooltipVisibilityMethods.showTooltip = provider.ShowTooltip; - ISetTooltipVisibilityMethods.hideTooltip = provider.HideTooltip; - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta deleted file mode 100644 index 130011c87..000000000 --- a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 0d7b646c9de7fa040b51d1854cc836c8 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs deleted file mode 100644 index c1119e043..000000000 --- a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs +++ /dev/null @@ -1,32 +0,0 @@ -#if UNITY_EDITOR && UNITY_EDITORVR -using UnityEditor.Experimental.EditorVR.Modules; -using UnityEngine; - -namespace UnityEditor.Experimental.EditorVR.Core -{ - partial class EditorVR - { - class WorkspaceModuleConnector : Nested, ILateBindInterfaceMethods, IInterfaceConnector - { - public void LateBindInterfaceMethods(WorkspaceModule provider) - { - ICreateWorkspaceMethods.createWorkspace = provider.CreateWorkspace; - IResetWorkspacesMethods.resetWorkspaceRotations = provider.ResetWorkspaceRotations; - } - - public void ConnectInterface(object obj, Transform rayOrigin = null) - { - var workspaceModule = evr.GetModule(); - - var allWorkspaces = obj as IAllWorkspaces; - if (allWorkspaces != null) - allWorkspaces.allWorkspaces = workspaceModule.workspaces; - } - - public void DisconnectInterface(object obj, Transform rayOrigin = null) - { - } - } - } -} -#endif diff --git a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta deleted file mode 100644 index 642a42670..000000000 --- a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 5d6163cac077bbd4ca5405744d1a5b52 -timeCreated: 1489520545 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Scripts/Core/Interfaces/IInterfaceConnector.cs b/Scripts/Core/Interfaces/IInterfaceConnector.cs index cfefcf148..fc841fa4f 100644 --- a/Scripts/Core/Interfaces/IInterfaceConnector.cs +++ b/Scripts/Core/Interfaces/IInterfaceConnector.cs @@ -1,12 +1,10 @@ -#if UNITY_EDITOR -using UnityEngine; - +#if UNITY_EDITOR namespace UnityEditor.Experimental.EditorVR.Core { interface IInterfaceConnector { - void ConnectInterface(object obj, Transform rayOrigin = null); - void DisconnectInterface(object obj, Transform rayOrigin = null); + void ConnectInterface(object @object, object userData = null); + void DisconnectInterface(object @object, object userData = null); } } #endif diff --git a/Scripts/Interfaces/Entity/IMenu.cs b/Scripts/Interfaces/Entity/IMenu.cs index c230cd92a..715238db0 100644 --- a/Scripts/Interfaces/Entity/IMenu.cs +++ b/Scripts/Interfaces/Entity/IMenu.cs @@ -1,6 +1,6 @@ #if UNITY_EDITOR -using UnityEngine; using UnityEditor.Experimental.EditorVR.Menus; +using UnityEngine; namespace UnityEditor.Experimental.EditorVR { diff --git a/Scripts/Interfaces/Entity/IWorkspace.cs b/Scripts/Interfaces/Entity/IWorkspace.cs index 9dce752e3..32251a116 100644 --- a/Scripts/Interfaces/Entity/IWorkspace.cs +++ b/Scripts/Interfaces/Entity/IWorkspace.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using UnityEngine; diff --git a/Scripts/Interfaces/FunctionalityInjection/IConnectInterfaces.cs b/Scripts/Interfaces/FunctionalityInjection/IConnectInterfaces.cs index 6eaddda0b..5aa39f417 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IConnectInterfaces.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IConnectInterfaces.cs @@ -1,5 +1,5 @@ -#if UNITY_EDITOR -using UnityEngine; +#if UNITY_EDITOR +using System; namespace UnityEditor.Experimental.EditorVR { @@ -12,30 +12,27 @@ interface IConnectInterfaces static class IConnectInterfacesMethods { - internal delegate void ConnectInterfacesDelegate(object obj, Transform rayOrigin = null); - internal delegate void DisonnectInterfacesDelegate(object obj, Transform rayOrigin = null); - - internal static ConnectInterfacesDelegate connectInterfaces { get; set; } - internal static DisonnectInterfacesDelegate disconnectInterfaces { get; set; } + internal static Action connectInterfaces { get; set; } + internal static Action disconnectInterfaces { get; set; } /// /// Method provided by the system for connecting interfaces /// - /// Object to connect interfaces on - /// (Optional) ray origin (needed for connecting ray-based interfaces) - public static void ConnectInterfaces(this IConnectInterfaces ci, object obj, Transform rayOrigin = null) + /// Object to connect interfaces on + /// (Optional) extra data needed to connect interfaces on this object + public static void ConnectInterfaces(this IConnectInterfaces @this, object @object, object userData = null) { - connectInterfaces(obj, rayOrigin); + connectInterfaces(@object, userData); } /// /// Method provided by the system for disconnecting interfaces /// - /// Object to disconnect interfaces on - /// /// (Optional) ray origin (needed for disconnecting ray-based interfaces) - public static void DisonnectInterfaces(this IConnectInterfaces ci, object obj, Transform rayOrigin = null) + /// Object to disconnect interfaces on + /// (Optional) extra data needed to connect interfaces on this object + public static void DisconnectInterfaces(this IConnectInterfaces @this, object @object, object userData = null) { - disconnectInterfaces(obj, rayOrigin); + disconnectInterfaces(@object, userData); } } diff --git a/Scripts/Interfaces/FunctionalityInjection/IProcessInput.cs b/Scripts/Interfaces/FunctionalityInjection/IProcessInput.cs index 39ef23151..b84ba60f7 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IProcessInput.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IProcessInput.cs @@ -1,5 +1,4 @@ -#if UNITY_EDITOR -using System; +#if UNITY_EDITOR using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR diff --git a/Scripts/Modules/ActionsModule.cs b/Scripts/Modules/ActionsModule.cs index 6e917a596..5379b1198 100644 --- a/Scripts/Modules/ActionsModule.cs +++ b/Scripts/Modules/ActionsModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_EDITORVR using System; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 9432012d1..bfe800ff6 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -1,14 +1,21 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_EDITORVR using System; using System.Collections.Generic; +using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class DeviceInputModule : MonoBehaviour + sealed class DeviceInputModule : MonoBehaviour, IInterfaceConnector { + class InputProcessor + { + public IProcessInput processor; + public ActionMapInput input; + } + public TrackedObject trackedObjectInput { get; private set; } [SerializeField] ActionMap m_TrackedObjectActionMap; @@ -26,6 +33,8 @@ sealed class DeviceInputModule : MonoBehaviour { "Right", Node.RightHand } }; + readonly List m_InputProcessors = new List(); + // Local method use only -- created here to reduce garbage collection readonly HashSet m_ProcessedInputs = new HashSet(); readonly List m_SystemDevices = new List(); @@ -61,6 +70,29 @@ void OnDestroy() PlayerHandleManager.RemovePlayerHandle(m_PlayerHandle); } + public void ConnectInterface(object @object, object userData = null) + { + var inputDevice = userData as InputDevice; + var processInput = @object as IProcessInput; + if (processInput != null && !(@object is ITool)) // Tools have their input processed separately + { + m_InputProcessors.Add(new InputProcessor + { + processor = processInput, + input = CreateActionMapInputForObject(@object, inputDevice) + }); + } + + // Tracked Object action maps shouldn't block each other so we share an instance + var trackedObjectMap = @object as ITrackedObjectActionMap; + if (trackedObjectMap != null) + trackedObjectMap.trackedObjectInput = trackedObjectInput; + } + + public void DisconnectInterface(object @object, object userData = null) + { + } + public void ProcessInput() { // Maintain a consumed control, so that other AMIs don't pick up the input, until it's no longer used @@ -81,6 +113,11 @@ public void ProcessInput() m_ProcessedInputs.Clear(); + foreach (var processor in m_InputProcessors) + { + processor.processor.ProcessInput(processor.input, ConsumeControl); + } + // TODO: Replace this with a map of ActionMap,IProcessInput and go through those if (processInput != null) processInput(m_ProcessedInputs, ConsumeControl); @@ -155,6 +192,13 @@ public void UpdatePlayerHandleMaps() var maps = m_PlayerHandle.maps; maps.Clear(); + foreach (var processor in m_InputProcessors) + { + maps.Add(processor.input); + } + + maps.Add(trackedObjectInput); + if (updatePlayerHandleMaps != null) updatePlayerHandleMaps(maps); } diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index bd59e406a..304da0f30 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Core; @@ -80,16 +80,16 @@ void Start() m_Preferences = new Preferences(); } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { - var feedbackReceiver = obj as IFeedbackReceiver; + var feedbackReceiver = @object as IFeedbackReceiver; if (feedbackReceiver != null) m_FeedbackReceivers.Add(feedbackReceiver); } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var feedbackReceiver = obj as IFeedbackReceiver; + var feedbackReceiver = @object as IFeedbackReceiver; if (feedbackReceiver != null) m_FeedbackReceivers.Remove(feedbackReceiver); } diff --git a/Scripts/Modules/HapticsModule/HapticsModule.cs b/Scripts/Modules/HapticsModule/HapticsModule.cs index d155f1c93..abe69a95d 100644 --- a/Scripts/Modules/HapticsModule/HapticsModule.cs +++ b/Scripts/Modules/HapticsModule/HapticsModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using UnityEditor.Experimental.EditorVR.Core; using UnityEngine; @@ -30,6 +30,12 @@ sealed class HapticsModule : MonoBehaviour /// bool m_SampleLengthWarningShown; + void Awake() + { + IControlHapticsMethods.pulse = Pulse; + IControlHapticsMethods.stopPulses = StopPulses; + } + void Start() { #if ENABLE_OVR_INPUT diff --git a/Scripts/Modules/HierarchyModule.cs b/Scripts/Modules/HierarchyModule.cs index 74fc61fdd..d02a4ba8f 100644 --- a/Scripts/Modules/HierarchyModule.cs +++ b/Scripts/Modules/HierarchyModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Core; @@ -6,7 +6,7 @@ namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class HierarchyModule : MonoBehaviour, ISelectionChanged + sealed class HierarchyModule : MonoBehaviour, ISelectionChanged, IInterfaceConnector { readonly List m_HierarchyLists = new List(); readonly List m_HierarchyData = new List(); @@ -47,6 +47,32 @@ void OnDisable() EditorApplication.hierarchyWindowChanged -= UpdateHierarchyData; } + public void ConnectInterface(object @object, object userData = null) + { + var usesHierarchyData = @object as IUsesHierarchyData; + if (usesHierarchyData != null) + { + AddConsumer(usesHierarchyData); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + AddConsumer(filterUI); + } + } + + public void DisconnectInterface(object @object, object userData = null) + { + var usesHierarchy = @object as IUsesHierarchyData; + if (usesHierarchy != null) + { + RemoveConsumer(usesHierarchy); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + RemoveConsumer(filterUI); + } + } + public void OnSelectionChanged() { UpdateHierarchyData(); diff --git a/Scripts/Modules/HighlightModule/HighlightModule.cs b/Scripts/Modules/HighlightModule/HighlightModule.cs index 456f31387..49c7b2447 100644 --- a/Scripts/Modules/HighlightModule/HighlightModule.cs +++ b/Scripts/Modules/HighlightModule/HighlightModule.cs @@ -1,13 +1,14 @@ #if UNITY_EDITOR using System; using System.Collections.Generic; +using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class HighlightModule : MonoBehaviour, IUsesGameObjectLocking + sealed class HighlightModule : MonoBehaviour, IUsesGameObjectLocking, IInterfaceConnector { class HighlightData { @@ -46,6 +47,8 @@ public Color highlightColor void Awake() { + ISetHighlightMethods.setHighlight = SetHighlight; + m_RayHighlightMaterial = Instantiate(m_RayHighlightMaterial); if (EditorPrefs.HasKey(k_SelectionOutlinePrefsKey)) { @@ -55,6 +58,20 @@ void Awake() } } + public void ConnectInterface(object @object, object userData = null) + { + var customHighlight = @object as ICustomHighlight; + if (customHighlight != null) + this.customHighlight += customHighlight.OnHighlight; + } + + public void DisconnectInterface(object @object, object userData = null) + { + var customHighlight = @object as ICustomHighlight; + if (customHighlight != null) + this.customHighlight -= customHighlight.OnHighlight; + } + void LateUpdate() { m_HighlightsToRemove.Clear(); diff --git a/Scripts/Modules/LockModule/LockModule.cs b/Scripts/Modules/LockModule/LockModule.cs index da405d2f3..5e506ddee 100644 --- a/Scripts/Modules/LockModule/LockModule.cs +++ b/Scripts/Modules/LockModule/LockModule.cs @@ -39,6 +39,9 @@ public void ExecuteAction() void Awake() { + IUsesGameObjectLockingMethods.setLocked = SetLocked; + IUsesGameObjectLockingMethods.isLocked = IsLocked; + m_LockModuleAction.execute = ToggleLocked; UpdateAction(null); diff --git a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs index dde424972..9bb7c3b10 100644 --- a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs +++ b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs @@ -10,34 +10,115 @@ namespace UnityEditor.Experimental.EditorVR.Modules { // Based in part on code provided by VREAL at https://github.com/VREALITY/ViveUGUIModule/, which is licensed under the MIT License - sealed class MultipleRayInputModule : BaseInputModule, IProcessInput, IGetPointerLength + sealed class MultipleRayInputModule : BaseInputModule, IGetPointerLength { - public class RaycastSource + public class RaycastSource : ICustomActionMap { public IProxy proxy; // Needed for checking if proxy is active public Transform rayOrigin; public Node node; - public UIActions actionMapInput; public RayEventData eventData; public GameObject hoveredObject; public GameObject draggedObject; public bool blocked; public Func isValid; + MultipleRayInputModule owner; + public GameObject currentObject { get { return hoveredObject ? hoveredObject : draggedObject; } } public bool hasObject { get { return currentObject != null && (s_LayerMask & (1 << currentObject.layer)) != 0; } } - public RaycastSource(IProxy proxy, Transform rayOrigin, Node node, UIActions actionMapInput, Func validationCallback) + public ActionMap actionMap { get; private set; } + + public RaycastSource(IProxy proxy, Transform rayOrigin, Node node, MultipleRayInputModule owner, Func validationCallback) { - UIActions actions = (UIActions)actionMapInput; - actions.active = false; this.proxy = proxy; this.rayOrigin = rayOrigin; this.node = node; - this.actionMapInput = actionMapInput; + this.owner = owner; isValid = validationCallback; } + + public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) + { + if (!(rayOrigin.gameObject.activeSelf || draggedObject) || !proxy.active) + return; + + var preProcessRaycastSource = owner.preProcessRaycastSource; + if (preProcessRaycastSource != null) + preProcessRaycastSource(rayOrigin); + + if (eventData == null) + eventData = new RayEventData(owner.eventSystem); + + hoveredObject = owner.GetRayIntersection(this); // Check all currently running raycasters + + eventData.node = node; + eventData.rayOrigin = rayOrigin; + eventData.pointerLength = owner.GetPointerLength(eventData.rayOrigin); + + if (isValid != null && !isValid(this)) + { + var currentRaycast = eventData.pointerCurrentRaycast; + currentRaycast.gameObject = null; + eventData.pointerCurrentRaycast = currentRaycast; + hoveredObject = null; + owner.HandlePointerExitAndEnter(eventData, null, true); // Send only exit events + return; + } + + owner.HandlePointerExitAndEnter(eventData, hoveredObject); // Send enter and exit events + + var hasScrollHandler = false; + input.active = hasObject && ShouldActivateInput(eventData, currentObject, out hasScrollHandler); + + var uiActions = (UIActions)input; + var select = uiActions.select; + + // Proceed only if pointer is interacting with something + if (!input.active) + { + // If we have an object, the ray is blocked--input should not bleed through + if (hasObject && select.wasJustPressed) + consumeControl(select); + + return; + } + + // Send select pressed and released events + if (select.wasJustPressed) + { + owner.OnSelectPressed(this); + consumeControl(select); + } + + if (select.wasJustReleased) + owner.OnSelectReleased(this); + + // Send Drag Events + if (draggedObject != null) + { + ExecuteEvents.Execute(draggedObject, eventData, ExecuteEvents.dragHandler); + ExecuteEvents.Execute(draggedObject, eventData, ExecuteRayEvents.dragHandler); + } + + // Send scroll events + if (currentObject && hasScrollHandler) + { + var verticalScroll = uiActions.verticalScroll; + var horizontalScroll = uiActions.horizontalScroll; + var verticalScrollValue = verticalScroll.value; + var horizontalScrollValue = horizontalScroll.value; + if (!Mathf.Approximately(verticalScrollValue, 0f) || !Mathf.Approximately(horizontalScrollValue, 0f)) + { + consumeControl(verticalScroll); + consumeControl(horizontalScroll); + eventData.scrollDelta = new Vector2(horizontalScrollValue, verticalScrollValue); + ExecuteEvents.ExecuteHierarchy(currentObject, eventData, ExecuteEvents.scrollHandler); + } + } + } } private readonly Dictionary m_RaycastSources = new Dictionary(); @@ -62,23 +143,22 @@ public RaycastSource(IProxy proxy, Transform rayOrigin, Node node, UIActions act // Local method use only -- created here to reduce garbage collection RayEventData m_TempRayEvent; - List m_RaycastSourcesCopy = new List(); + //List m_RaycastSourcesCopy = new List(); protected override void Awake() { + IBlockUIInteractionMethods.setUIBlockedForRayOrigin = SetUIBlockedForRayOrigin; + IIsHoveringOverUIMethods.isHoveringOverUI = IsHoveringOverUI; base.Awake(); s_LayerMask = LayerMask.GetMask("UI"); m_TempRayEvent = new RayEventData(eventSystem); - IBlockUIInteractionMethods.setUIBlockedForRayOrigin = SetUIBlockedForRayOrigin; } - public void AddRaycastSource(IProxy proxy, Node node, ActionMapInput actionMapInput, Transform rayOrigin, Func validationCallback = null) + public void AddRaycastSource(IProxy proxy, Node node, Transform rayOrigin, Func validationCallback = null) { - UIActions actions = (UIActions)actionMapInput; - actions.active = false; - m_RaycastSources.Add(rayOrigin, new RaycastSource(proxy, rayOrigin, node, actions, validationCallback)); + m_RaycastSources.Add(rayOrigin, new RaycastSource(proxy, rayOrigin, node, this, validationCallback)); } public void RemoveRaycastSource(Transform rayOrigin) @@ -96,11 +176,6 @@ public RayEventData GetPointerEventData(Transform rayOrigin) } public override void Process() - { - // We don't process with all other input modules because we need fine-grained control to consume input - } - - public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { ExecuteUpdateOnSelectedObject(); @@ -111,99 +186,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon var camera = CameraUtils.GetMainCamera(); m_EventCamera.nearClipPlane = camera.nearClipPlane; m_EventCamera.farClipPlane = camera.farClipPlane; - - // The sources dictionary can change during iteration, so cache it before iterating - m_RaycastSourcesCopy.Clear(); - foreach (var kvp in m_RaycastSources) - { - m_RaycastSourcesCopy.Add(kvp.Value); - } - - //Process events for all different transforms in RayOrigins - foreach (var source in m_RaycastSourcesCopy) - { - var draggedObject = source.draggedObject; - var rayOrigin = source.rayOrigin; - if (!(rayOrigin.gameObject.activeSelf || draggedObject) || !source.proxy.active) - continue; - - if (preProcessRaycastSource != null) - preProcessRaycastSource(rayOrigin); - - if (source.eventData == null) - source.eventData = new RayEventData(base.eventSystem); - - var hoveredObject = GetRayIntersection(source); // Check all currently running raycasters - source.hoveredObject = hoveredObject; - - var eventData = source.eventData; - eventData.node = source.node; - eventData.rayOrigin = rayOrigin; - eventData.pointerLength = this.GetPointerLength(eventData.rayOrigin); - - if (source.isValid != null && !source.isValid(source)) - { - var currentRaycast = eventData.pointerCurrentRaycast; - currentRaycast.gameObject = null; - eventData.pointerCurrentRaycast = currentRaycast; - source.hoveredObject = null; - HandlePointerExitAndEnter(eventData, null, true); // Send only exit events - continue; - } - - HandlePointerExitAndEnter(eventData, hoveredObject); // Send enter and exit events - - var hasObject = source.hasObject; - var hasScrollHandler = false; - var sourceAMI = source.actionMapInput; - sourceAMI.active = hasObject && ShouldActivateInput(eventData, source.currentObject, out hasScrollHandler); - - var select = sourceAMI.select; - - // Proceed only if pointer is interacting with something - if (!sourceAMI.active) - { - // If we have an object, the ray is blocked--input should not bleed through - if (hasObject && select.wasJustPressed) - consumeControl(select); - - continue; - } - - // Send select pressed and released events - if (select.wasJustPressed) - { - OnSelectPressed(source); - consumeControl(select); - } - - if (select.wasJustReleased) - OnSelectReleased(source); - - // Send Drag Events - if (draggedObject != null) - { - ExecuteEvents.Execute(draggedObject, eventData, ExecuteEvents.dragHandler); - ExecuteEvents.Execute(draggedObject, eventData, ExecuteRayEvents.dragHandler); - } - - // Send scroll events - var scrollObject = source.currentObject; - if (scrollObject && hasScrollHandler) - { - var verticalScroll = sourceAMI.verticalScroll; - var horizontalScroll = sourceAMI.horizontalScroll; - var verticalScrollValue = verticalScroll.value; - var horizontalScrollValue = horizontalScroll.value; - if (!Mathf.Approximately(verticalScrollValue, 0f) || !Mathf.Approximately(horizontalScrollValue, 0f)) - { - consumeControl(verticalScroll); - consumeControl(horizontalScroll); - eventData.scrollDelta = new Vector2(horizontalScrollValue, verticalScrollValue); - ExecuteEvents.ExecuteHierarchy(scrollObject, eventData, ExecuteEvents.scrollHandler); - } - } - } } static bool ShouldActivateInput(RayEventData eventData, GameObject currentObject, out bool hasScrollHandler) @@ -288,7 +270,7 @@ void HandlePointerExitAndEnter(RayEventData eventData, GameObject newEnterTarget } } - GameObject commonRoot = FindCommonRoot(pointerEnter, newEnterTarget); + var commonRoot = FindCommonRoot(pointerEnter, newEnterTarget); // and we already an entered object from last time if (pointerEnter != null) @@ -340,7 +322,7 @@ void OnSelectPressed(RaycastSource source) if (hoveredObject != null) // Pressed when pointer is over something { var draggedObject = hoveredObject; - GameObject newPressed = ExecuteEvents.ExecuteHierarchy(draggedObject, eventData, ExecuteEvents.pointerDownHandler); + var newPressed = ExecuteEvents.ExecuteHierarchy(draggedObject, eventData, ExecuteEvents.pointerDownHandler); if (newPressed == null) // Gameobject does not have pointerDownHandler in hierarchy, but may still have click handler newPressed = ExecuteEvents.GetEventHandler(draggedObject); @@ -427,7 +409,7 @@ private void Select(GameObject go) base.eventSystem.SetSelectedGameObject(go); } - private GameObject GetRayIntersection(RaycastSource source) + GameObject GetRayIntersection(RaycastSource source) { // Move camera to position and rotation for the ray origin m_EventCamera.transform.position = source.rayOrigin.position; diff --git a/Scripts/Modules/ProjectFolderModule.cs b/Scripts/Modules/ProjectFolderModule.cs index d9e3e728b..026e6fcfd 100644 --- a/Scripts/Modules/ProjectFolderModule.cs +++ b/Scripts/Modules/ProjectFolderModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections; using System.Collections.Generic; @@ -8,7 +8,7 @@ namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class ProjectFolderModule : MonoBehaviour + sealed class ProjectFolderModule : MonoBehaviour, IConnectInterfaces { // Maximum time (in ms) before yielding in CreateFolderData: should be target frame time const float k_MaxFrameTime = 0.01f; @@ -35,6 +35,32 @@ void OnDisable() EditorApplication.projectWindowChanged -= UpdateProjectFolders; } + public void ConnectInterface(object @object, object userData = null) + { + var usesProjectFolderData = @object as IUsesProjectFolderData; + if (usesProjectFolderData != null) + { + AddConsumer(usesProjectFolderData); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + AddConsumer(filterUI); + } + } + + public void DisconnectInterface(object @object, object userData = null) + { + var usesProjectFolderData = @object as IUsesProjectFolderData; + if (usesProjectFolderData != null) + { + RemoveConsumer(usesProjectFolderData); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + RemoveConsumer(filterUI); + } + } + public void AddConsumer(IUsesProjectFolderData consumer) { consumer.folderData = GetFolderData(); diff --git a/Scripts/Modules/SceneObjectModule.cs b/Scripts/Modules/SceneObjectModule.cs index 806d6251f..e676b2481 100644 --- a/Scripts/Modules/SceneObjectModule.cs +++ b/Scripts/Modules/SceneObjectModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_EDITORVR using System; using System.Collections; using UnityEditor.Experimental.EditorVR.Utilities; @@ -13,6 +13,13 @@ sealed class SceneObjectModule : MonoBehaviour, IUsesSpatialHash public Func tryPlaceObject; + void Awake() + { + IDeleteSceneObjectMethods.deleteSceneObject = DeleteSceneObject; + IPlaceSceneObjectMethods.placeSceneObject = PlaceSceneObject; + IPlaceSceneObjectsMethods.placeSceneObjects = PlaceSceneObjects; + } + public void PlaceSceneObject(Transform obj, Vector3 targetScale) { if (tryPlaceObject == null || !tryPlaceObject(obj, targetScale)) diff --git a/Scripts/Modules/SelectionModule/SelectionModule.cs b/Scripts/Modules/SelectionModule/SelectionModule.cs index e3663c832..68d5da0ab 100644 --- a/Scripts/Modules/SelectionModule/SelectionModule.cs +++ b/Scripts/Modules/SelectionModule/SelectionModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Core; @@ -20,6 +20,12 @@ sealed class SelectionModule : MonoBehaviour, IUsesGameObjectLocking, ISelection public event Action selected; + void Awake() + { + ISelectObjectMethods.getSelectionCandidate = GetSelectionCandidate; + ISelectObjectMethods.selectObject = SelectObject; + } + public GameObject GetSelectionCandidate(GameObject hoveredObject, bool useGrouping = false) { // If we can't even select the object we're starting with, then skip any further logic diff --git a/Scripts/Modules/SerializedPreferencesModule.cs b/Scripts/Modules/SerializedPreferencesModule.cs index 42bfee2c4..ed0251332 100644 --- a/Scripts/Modules/SerializedPreferencesModule.cs +++ b/Scripts/Modules/SerializedPreferencesModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; @@ -58,9 +58,9 @@ class SerializedPreferenceItem public string payload { get { return m_Payload; } set { m_Payload = value; } } } - public void ConnectInterface(object obj, Transform rayOrigin = null) + public void ConnectInterface(object @object, object userData = null) { - var serializer = obj as ISerializePreferences; + var serializer = @object as ISerializePreferences; if (serializer != null) { if (m_Preferences != null) @@ -70,9 +70,9 @@ public void ConnectInterface(object obj, Transform rayOrigin = null) } } - public void DisconnectInterface(object obj, Transform rayOrigin = null) + public void DisconnectInterface(object @object, object userData = null) { - var serializer = obj as ISerializePreferences; + var serializer = @object as ISerializePreferences; if (serializer != null) { // TODO: Support serializing one type at a time diff --git a/Scripts/Modules/SnappingModule/SnappingModule.cs b/Scripts/Modules/SnappingModule/SnappingModule.cs index 908c609d8..05949817a 100644 --- a/Scripts/Modules/SnappingModule/SnappingModule.cs +++ b/Scripts/Modules/SnappingModule/SnappingModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Core; @@ -370,6 +370,10 @@ public bool directSnappingEnabled void Awake() { + IUsesSnappingMethods.manipulatorSnap = ManipulatorSnap; + IUsesSnappingMethods.directSnap = DirectSnap; + IUsesSnappingMethods.clearSnappingState = ClearSnappingState; + m_GroundPlane = ObjectUtils.Instantiate(m_GroundPlane, transform); m_GroundPlane.SetActive(false); diff --git a/Scripts/Modules/SpatialHashModule.cs b/Scripts/Modules/SpatialHashModule.cs index 53645d0cb..3afead776 100644 --- a/Scripts/Modules/SpatialHashModule.cs +++ b/Scripts/Modules/SpatialHashModule.cs @@ -1,7 +1,7 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; -using System.Collections.Generic; using System.Collections; +using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Data; using UnityEngine; @@ -16,6 +16,8 @@ sealed class SpatialHashModule : MonoBehaviour void Awake() { + IUsesSpatialHashMethods.addToSpatialHash = AddObject; + IUsesSpatialHashMethods.removeFromSpatialHash = RemoveObject; spatialHash = new SpatialHash(); } diff --git a/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs b/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs index a09b9fdd6..6a6e3e8ef 100644 --- a/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs +++ b/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs @@ -1,5 +1,4 @@ -#if UNITY_EDITOR -using System; +#if UNITY_EDITOR using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Menus; using UnityEngine; @@ -83,6 +82,15 @@ private Node? controllingNode void Awake() { + IControlSpatialHintingMethods.setSpatialHintState = SetState; + IControlSpatialHintingMethods.setSpatialHintPosition = SetPosition; + IControlSpatialHintingMethods.setSpatialHintContainerRotation = SetContainerRotation; + IControlSpatialHintingMethods.setSpatialHintShowHideRotationTarget = SetShowHideRotationTarget; + IControlSpatialHintingMethods.setSpatialHintLookAtRotation = LookAt; + IControlSpatialHintingMethods.setSpatialHintDragThresholdTriggerPosition = SetDragThresholdTriggerPosition; + IControlSpatialHintingMethods.pulseSpatialHintScrollArrows = PulseScrollArrows; + IControlSpatialHintingMethods.setSpatialHintControlNode = SetSpatialHintControlNode; + m_SpatialHintUI = this.InstantiateUI(m_SpatialHintUI.gameObject).GetComponent(); this.ConnectInterfaces(m_SpatialHintUI); } diff --git a/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs b/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs index 4cf5f9545..329cffeae 100644 --- a/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs +++ b/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Core; using UnityEngine; @@ -104,6 +104,12 @@ public void UpdateExistingScrollData(Vector3 newPosition) } } + void Awake() + { + IControlSpatialScrollingMethods.performSpatialScroll = PerformScroll; + IControlSpatialScrollingMethods.endSpatialScroll = EndScroll; + } + internal SpatialScrollData PerformScroll(IControlSpatialScrolling caller, Node? node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerScrollVisuals = true) { // Continue processing of spatial scrolling for a given caller, diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index 2c7d2a869..128d209c1 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System.Collections; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Utilities; @@ -48,6 +48,12 @@ class TooltipData // Local method use only -- created here to reduce garbage collection readonly List m_TooltipsToHide = new List(); + void Awake() + { + ISetTooltipVisibilityMethods.showTooltip = ShowTooltip; + ISetTooltipVisibilityMethods.hideTooltip = HideTooltip; + } + void Start() { m_TooltipCanvas = Instantiate(m_TooltipCanvasPrefab).transform; diff --git a/Scripts/Modules/WorkspaceModule.cs b/Scripts/Modules/WorkspaceModule.cs index 65056c0cf..9dc740ebc 100644 --- a/Scripts/Modules/WorkspaceModule.cs +++ b/Scripts/Modules/WorkspaceModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; @@ -6,11 +6,10 @@ using UnityEditor.Experimental.EditorVR.Utilities; using UnityEditor.Experimental.EditorVR.Workspaces; using UnityEngine; -using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class WorkspaceModule : MonoBehaviour, IConnectInterfaces, ISerializePreferences + sealed class WorkspaceModule : MonoBehaviour, IConnectInterfaces, ISerializePreferences, IInterfaceConnector { [Serializable] class Preferences @@ -52,9 +51,6 @@ class WorkspaceLayout internal List workspaces { get { return m_Workspaces; } } readonly List m_Workspaces = new List(); - internal List workspaceInputs { get { return m_WorkspaceInputs; } } - readonly List m_WorkspaceInputs = new List(); - internal event Action workspaceCreated; internal event Action workspaceDestroyed; @@ -70,8 +66,10 @@ static WorkspaceModule() workspaceTypes = ObjectUtils.GetImplementationsOfInterface(typeof(IWorkspace)).ToList(); } - public WorkspaceModule() + void Awake() { + ICreateWorkspaceMethods.createWorkspace = CreateWorkspace; + IResetWorkspacesMethods.resetWorkspaceRotations = ResetWorkspaceRotations; preserveWorkspaces = true; } @@ -180,19 +178,11 @@ internal void CreateWorkspace(Type t, Action createdCallback = null) workspaceCreated(workspace); } - internal void ProcessInput(ConsumeControlDelegate consumeControl) - { - for (int i = 0; i < m_Workspaces.Count; i++) - { - m_Workspaces[i].ProcessInput(m_WorkspaceInputs[i], consumeControl); - } - } - void OnWorkspaceDestroyed(IWorkspace workspace) { m_Workspaces.Remove(workspace); - this.DisonnectInterfaces(workspace); + this.DisconnectInterfaces(workspace); if (workspaceDestroyed != null) workspaceDestroyed(workspace); @@ -212,6 +202,17 @@ static void ResetRotation(IWorkspace workspace, Vector3 forward) { workspace.transform.rotation = Quaternion.LookRotation(forward) * DefaultWorkspaceTilt; } + + public void ConnectInterface(object @object, object userData = null) + { + var allWorkspaces = @object as IAllWorkspaces; + if (allWorkspaces != null) + allWorkspaces.allWorkspaces = workspaces; + } + + public void DisconnectInterface(object @object, object userData = null) + { + } } } #endif From 8c8587f0004f297619148710f81a995ed8f2fea6 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 29 Sep 2017 02:16:35 -0700 Subject: [PATCH 049/457] Fix issues caused by IProcessInput refactor --- Menus/MainMenu/MainMenu.cs | 7 +- Menus/MainMenu/Scripts/MainMenuUI.cs | 2 +- Menus/RadialMenu/RadialMenu.cs | 2 +- Menus/ToolsMenu/ToolsMenu.cs | 2 +- Scripts/Core/EditorVR.MiniWorlds.cs | 2 +- Scripts/Core/EditorVR.Rays.cs | 36 ++++------ Scripts/Core/EditorVR.Tools.cs | 19 ++--- Scripts/Core/EditorVR.UI.cs | 4 +- Scripts/Core/EditorVR.cs | 6 +- Scripts/Core/Interfaces/INodeToRay.cs | 4 +- Scripts/Core/Interfaces/IRayToNode.cs | 4 +- Scripts/Data/Node.cs | 1 + .../FunctionalityInjection/IControlHaptics.cs | 8 +-- .../IControlSpatialHinting.cs | 4 +- .../IControlSpatialScrolling.cs | 4 +- .../FunctionalityInjection/IUsesNode.cs | 2 +- Scripts/ListView/ListViewControllerBase.cs | 2 +- Scripts/Modules/DeviceInputModule.cs | 62 ++++++++-------- .../Modules/HapticsModule/HapticsModule.cs | 8 +-- .../MultipleRayInputModule.cs | 72 ++++++++++--------- .../SpatialHintModule/SpatialHintModule.cs | 19 ++--- .../SpatialHintModule/SpatialHintUI.cs | 6 +- .../SpatialScrollModule.cs | 6 +- Tools/AnnotationTool/AnnotationTool.cs | 4 +- .../CreatePrimitiveTool.cs | 4 +- Tools/LocomotionTool/LocomotionTool.cs | 16 ++--- Tools/SelectionTool/SelectionTool.cs | 4 +- Tools/TransformTool/TransformTool.cs | 6 +- Tools/VacuumTool/VacuumTool.cs | 4 +- Workspaces/Base/WorkspaceUI.cs | 5 +- 30 files changed, 163 insertions(+), 162 deletions(-) diff --git a/Menus/MainMenu/MainMenu.cs b/Menus/MainMenu/MainMenu.cs index 2cf72fa6e..af044194b 100644 --- a/Menus/MainMenu/MainMenu.cs +++ b/Menus/MainMenu/MainMenu.cs @@ -53,7 +53,7 @@ sealed class MainMenu : MonoBehaviour, IMainMenu, IConnectInterfaces, IInstantia public List menuActions { get; set; } public Transform targetRayOrigin { private get; set; } public Type proxyType { private get; set; } - public Node? node { get; set; } + public Node node { get; set; } public GameObject menuContent { get { return m_MainMenuUI.gameObject; } } public Transform rayOrigin { private get; set; } @@ -106,14 +106,17 @@ public MenuHideFlags menuHideFlags } } - void Start() + void Awake() { m_MainMenuUI = this.InstantiateUI(m_MainMenuPrefab.gameObject).GetComponent(); this.ConnectInterfaces(m_MainMenuUI); m_MainMenuUI.alternateMenuOrigin = alternateMenuOrigin; m_MainMenuUI.menuOrigin = menuOrigin; m_MainMenuUI.Setup(); + } + void Start() + { CreateFaceButtons(); UpdateToolButtons(); } diff --git a/Menus/MainMenu/Scripts/MainMenuUI.cs b/Menus/MainMenu/Scripts/MainMenuUI.cs index c200b90b9..0b610dee7 100644 --- a/Menus/MainMenu/Scripts/MainMenuUI.cs +++ b/Menus/MainMenu/Scripts/MainMenuUI.cs @@ -121,7 +121,7 @@ public Transform alternateMenuOrigin public float targetRotation { get; set; } - public Node? node { get; set; } + public Node node { get; set; } public bool visible { diff --git a/Menus/RadialMenu/RadialMenu.cs b/Menus/RadialMenu/RadialMenu.cs index 4c182b5c2..602984973 100644 --- a/Menus/RadialMenu/RadialMenu.cs +++ b/Menus/RadialMenu/RadialMenu.cs @@ -41,7 +41,7 @@ sealed class RadialMenu : MonoBehaviour, IInstantiateUI, IAlternateMenu, IUsesMe public GameObject menuContent { get { return m_RadialMenuUI.gameObject; } } - public Node? node { get; set; } + public Node node { get; set; } public Bounds localBounds { get { return default(Bounds); } } diff --git a/Menus/ToolsMenu/ToolsMenu.cs b/Menus/ToolsMenu/ToolsMenu.cs index 665a3103f..353f6b747 100644 --- a/Menus/ToolsMenu/ToolsMenu.cs +++ b/Menus/ToolsMenu/ToolsMenu.cs @@ -49,7 +49,7 @@ sealed class ToolsMenu : MonoBehaviour, IToolsMenu, IConnectInterfaces, IInstant public Action selectHighlightedButton { get; set; } public Action setButtonForType { get; set; } public Action deleteToolsMenuButton { get; set; } - public Node? node { get; set; } + public Node node { get; set; } public IToolsMenuButton PreviewToolsMenuButton { get; private set; } public Transform alternateMenuOrigin { get; set; } public SpatialScrollModule.SpatialScrollData spatialScrollData { get; set; } diff --git a/Scripts/Core/EditorVR.MiniWorlds.cs b/Scripts/Core/EditorVR.MiniWorlds.cs index 172be524f..7bf4dacdc 100644 --- a/Scripts/Core/EditorVR.MiniWorlds.cs +++ b/Scripts/Core/EditorVR.MiniWorlds.cs @@ -567,7 +567,7 @@ void OnObjectsGrabbed(Transform rayOrigin, HashSet grabbedObjects) void OnObjectsDropped(Transform rayOrigin, Transform[] grabbedObjects) { - Node? node = null; + var node = Node.None; foreach (var ray in m_Rays) { var miniWorldRay = ray.Value; diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 2d8d0f629..8ae898e92 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -186,14 +186,13 @@ void OnProxyActiveChanged(IProxy proxy) var rayOrigin = rayOriginPair.Value; var systemDevices = deviceInputModule.GetSystemDevices(); - var actionMap = inputModule.actionMap; for (int j = 0; j < systemDevices.Count; j++) { var device = systemDevices[j]; // Find device tagged with the node that matches this RayOrigin node var deviceNode = deviceInputModule.GetDeviceNode(device); - if (deviceNode.HasValue && deviceNode.Value == node) + if (deviceNode == node) { var deviceData = new DeviceData(); evrDeviceData.Add(deviceData); @@ -467,8 +466,11 @@ internal void PreProcessRaycastSource(Transform rayOrigin) m_ScaleManipulator.AdjustScale(cameraPosition, matrix); } - static Node? RequestNodeFromRayOrigin(Transform rayOrigin) + static Node RequestNodeFromRayOrigin(Transform rayOrigin) { + if (rayOrigin == null) + return Node.None; + foreach (var deviceData in evr.m_DeviceData) { if (!deviceData.proxy.active) @@ -484,14 +486,13 @@ internal void PreProcessRaycastSource(Transform rayOrigin) return kvp.Value.node; } - return null; + return Node.None; } - static Transform RequestRayOriginFromNode(Node? node) + static Transform RequestRayOriginFromNode(Node node) { - Transform rayOrigin = null; - if (node == null) - return rayOrigin; + if (node == Node.None) + return null; foreach (var deviceData in evr.m_DeviceData) { @@ -499,25 +500,16 @@ static Transform RequestRayOriginFromNode(Node? node) continue; if (deviceData.node == node) - { - rayOrigin = deviceData.rayOrigin; - break; - } + return deviceData.rayOrigin; } - if (!rayOrigin) + foreach (var kvp in evr.GetNestedModule().rays) { - foreach (var kvp in evr.GetNestedModule().rays) - { - if (kvp.Value.node == node) - { - rayOrigin = kvp.Value.originalRayOrigin; - break; - } - } + if (kvp.Value.node == node) + return kvp.Value.originalRayOrigin; } - return rayOrigin; + return null; } static void SetDefaultRayColor(Transform rayOrigin, Color color) diff --git a/Scripts/Core/EditorVR.Tools.cs b/Scripts/Core/EditorVR.Tools.cs index b20b664d2..c86dd7774 100644 --- a/Scripts/Core/EditorVR.Tools.cs +++ b/Scripts/Core/EditorVR.Tools.cs @@ -26,8 +26,6 @@ internal class ToolData readonly Dictionary> m_LinkedObjects = new Dictionary>(); - public event Action updatePlayerHandleMaps; - public Tools() { allTools = ObjectUtils.GetImplementationsOfInterface(typeof(ITool)).ToList(); @@ -98,10 +96,11 @@ internal void SpawnDefaultTools(IProxy proxy) if (deviceData.proxy != proxy) continue; + var rayOrigin = deviceData.rayOrigin; foreach (var toolType in defaultTools) { HashSet devices; - var toolData = SpawnTool(toolType, out devices, inputDevice); + var toolData = SpawnTool(toolType, out devices, inputDevice, rayOrigin); AddToolToDeviceData(toolData, devices); var tool = toolData.tool; @@ -123,7 +122,6 @@ internal void SpawnDefaultTools(IProxy proxy) var menus = evr.GetNestedModule(); var menuHideData = deviceData.menuHideData; - var rayOrigin = deviceData.rayOrigin; var mainMenu = menus.SpawnMainMenu(typeof(MainMenu), rayOrigin); deviceData.mainMenu = mainMenu; menuHideData[mainMenu] = new Menus.MenuHideData(); @@ -152,7 +150,7 @@ internal void SpawnDefaultTools(IProxy proxy) /// The input device whose tool stack the tool should be spawned on (optional). If not /// specified, then it uses the action map to determine which devices the tool should be spawned on. /// Returns tool that was spawned or null if the spawn failed. - ToolData SpawnTool(Type toolType, out HashSet usedDevices, InputDevice device = null) + ToolData SpawnTool(Type toolType, out HashSet usedDevices, InputDevice device, Transform rayOrigin) { usedDevices = new HashSet(); if (!typeof(ITool).IsAssignableFrom(toolType)) @@ -171,7 +169,7 @@ ToolData SpawnTool(Type toolType, out HashSet usedDevices, InputDev if (usedDevices.Count == 0) usedDevices.Add(device); - this.ConnectInterfaces(tool, device); + this.ConnectInterfaces(tool, rayOrigin); var icon = tool as IMenuIcon; return new ToolData { tool = tool, input = actionMapInput, icon = icon != null ? icon.icon : null}; @@ -240,7 +238,7 @@ internal bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnResel // Spawn tool and collect all devices that this tool will need HashSet usedDevices; var device = deviceData.inputDevice; - var newTool = SpawnTool(toolType, out usedDevices, device); + var newTool = SpawnTool(toolType, out usedDevices, device, rayOrigin); var multiTool = newTool.tool as IMultiDeviceTool; if (multiTool != null) { @@ -250,7 +248,7 @@ internal bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnResel if (otherDeviceData != deviceData) { HashSet otherUsedDevices; - var otherToolData = SpawnTool(toolType, out otherUsedDevices, otherDeviceData.inputDevice); + var otherToolData = SpawnTool(toolType, out otherUsedDevices, otherDeviceData.inputDevice, otherDeviceData.rayOrigin); foreach (var dd in evrDeviceData) { if (!otherUsedDevices.Contains(dd.inputDevice)) @@ -393,11 +391,8 @@ static void AddToolToStack(DeviceData deviceData, ToolData toolData) } } - internal void UpdatePlayerHandleMaps(List maps) + internal static void UpdatePlayerHandleMaps(List maps) { - if (updatePlayerHandleMaps != null) - updatePlayerHandleMaps(); - foreach (var deviceData in evr.m_DeviceData) { foreach (var td in deviceData.toolData) diff --git a/Scripts/Core/EditorVR.UI.cs b/Scripts/Core/EditorVR.UI.cs index c036e423b..e4cadb57b 100644 --- a/Scripts/Core/EditorVR.UI.cs +++ b/Scripts/Core/EditorVR.UI.cs @@ -98,7 +98,7 @@ internal void Initialize() inputModule.preProcessRaycastSource = evr.GetNestedModule().PreProcessRaycastSource; } - internal GameObject InstantiateUI(GameObject prefab, Transform parent = null, bool worldPositionStays = true, Transform connectInterfacesOverride = null) + internal GameObject InstantiateUI(GameObject prefab, Transform parent = null, bool worldPositionStays = true, Transform rayOrigin = null) { var go = ObjectUtils.Instantiate(prefab, parent ? parent : evr.transform, worldPositionStays); foreach (var canvas in go.GetComponentsInChildren()) @@ -114,7 +114,7 @@ internal GameObject InstantiateUI(GameObject prefab, Transform parent = null, bo } foreach (var mb in go.GetComponentsInChildren(true)) - this.ConnectInterfaces(mb, connectInterfacesOverride); + this.ConnectInterfaces(mb, rayOrigin); return go; } diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index 6256cb0f9..87f043fc4 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -151,7 +151,11 @@ void Awake() deviceInputModule.InitializePlayerHandle(); deviceInputModule.CreateDefaultActionMapInputs(); deviceInputModule.processInput = ProcessInput; - deviceInputModule.updatePlayerHandleMaps = GetNestedModule().UpdatePlayerHandleMaps; + deviceInputModule.updatePlayerHandleMaps = Tools.UpdatePlayerHandleMaps; + deviceInputModule.inputDeviceForRayOrigin = rayOrigin => + (from deviceData in m_DeviceData + where deviceData.rayOrigin == rayOrigin + select deviceData.inputDevice).FirstOrDefault(); GetNestedModule().Initialize(); diff --git a/Scripts/Core/Interfaces/INodeToRay.cs b/Scripts/Core/Interfaces/INodeToRay.cs index 4d26f32c6..4f906346a 100644 --- a/Scripts/Core/Interfaces/INodeToRay.cs +++ b/Scripts/Core/Interfaces/INodeToRay.cs @@ -13,13 +13,13 @@ interface INodeToRay static class INodeToRayMethods { - internal static Func requestRayOriginFromNode { private get; set; } + internal static Func requestRayOriginFromNode { private get; set; } /// /// Get the corresponding ray origin for a given node /// /// The node to request a ray origin for - internal static Transform RequestRayOriginFromNode(this INodeToRay obj, Node? node) + internal static Transform RequestRayOriginFromNode(this INodeToRay obj, Node node) { return requestRayOriginFromNode(node); } diff --git a/Scripts/Core/Interfaces/IRayToNode.cs b/Scripts/Core/Interfaces/IRayToNode.cs index 4e6bbdec0..51321a472 100644 --- a/Scripts/Core/Interfaces/IRayToNode.cs +++ b/Scripts/Core/Interfaces/IRayToNode.cs @@ -13,13 +13,13 @@ interface IRayToNode static class IRayToNodeMethods { - internal static Func requestNodeFromRayOrigin { private get; set; } + internal static Func requestNodeFromRayOrigin { private get; set; } /// /// Get the corresponding node for a given ray origin /// /// The ray origin to request a node for - internal static Node? RequestNodeFromRayOrigin(this IRayToNode obj, Transform rayOrigin) + internal static Node RequestNodeFromRayOrigin(this IRayToNode obj, Transform rayOrigin) { return requestNodeFromRayOrigin(rayOrigin); } diff --git a/Scripts/Data/Node.cs b/Scripts/Data/Node.cs index 04dd4f2fa..a10464e33 100644 --- a/Scripts/Data/Node.cs +++ b/Scripts/Data/Node.cs @@ -6,6 +6,7 @@ namespace UnityEditor.Experimental.EditorVR /// public enum Node { + None, LeftHand, RightHand } diff --git a/Scripts/Interfaces/FunctionalityInjection/IControlHaptics.cs b/Scripts/Interfaces/FunctionalityInjection/IControlHaptics.cs index 00ecc6442..b94e939cd 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IControlHaptics.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IControlHaptics.cs @@ -12,7 +12,7 @@ public interface IControlHaptics public static class IControlHapticsMethods { - internal delegate void PulseDelegate(Node? node, HapticPulse hapticPulse, float durationMultiplier = 1f, float intensityMultiplier = 1f); + internal delegate void PulseDelegate(Node node, HapticPulse hapticPulse, float durationMultiplier = 1f, float intensityMultiplier = 1f); internal static PulseDelegate pulse { get; set; } @@ -23,12 +23,12 @@ public static class IControlHapticsMethods /// Haptic pulse to perform /// (Optional) Multiplier value applied to the hapticPulse duration /// (Optional) Multiplier value applied to the hapticPulse intensity - public static void Pulse(this IControlHaptics obj, Node? node, HapticPulse hapticPulse, float durationMultiplier = 1f, float intensityMultiplier = 1f) + public static void Pulse(this IControlHaptics obj, Node node, HapticPulse hapticPulse, float durationMultiplier = 1f, float intensityMultiplier = 1f) { pulse(node, hapticPulse, durationMultiplier, intensityMultiplier); } - internal delegate void StopPulsesDelegate(Node? node); + internal delegate void StopPulsesDelegate(Node node); internal static StopPulsesDelegate stopPulses { get; set; } @@ -36,7 +36,7 @@ public static void Pulse(this IControlHaptics obj, Node? node, HapticPulse hapti /// Stop all haptic feedback on a specific device, or all devices /// /// Device RayOrigin/Transform on which to stop all pulses. A NULL value will stop pulses on all devices - public static void StopPulses(this IControlHaptics obj, Node? node) + public static void StopPulses(this IControlHaptics obj, Node node) { stopPulses(node); } diff --git a/Scripts/Interfaces/FunctionalityInjection/IControlSpatialHinting.cs b/Scripts/Interfaces/FunctionalityInjection/IControlSpatialHinting.cs index b6d689c30..29083a96b 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IControlSpatialHinting.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IControlSpatialHinting.cs @@ -25,7 +25,7 @@ public static class IControlSpatialHintingMethods internal static Action setSpatialHintLookAtRotation { get; set; } internal static Action pulseSpatialHintScrollArrows { get; set; } internal static Action setSpatialHintDragThresholdTriggerPosition { get; set; } - internal static Action setSpatialHintControlNode { get; set; } + internal static Action setSpatialHintControlNode { get; set; } /// /// Set the spatial hint state @@ -94,7 +94,7 @@ public static void SetSpatialHintDragThresholdTriggerPosition(this IControlSpati /// Each control-object has it's spatial scrolling processed independently /// /// Node on which spatial scrolling will be processed independently - public static void SetSpatialHintControlNode(this IControlSpatialHinting obj, Node? controlNode) + public static void SetSpatialHintControlNode(this IControlSpatialHinting obj, Node controlNode) { setSpatialHintControlNode(controlNode); } diff --git a/Scripts/Interfaces/FunctionalityInjection/IControlSpatialScrolling.cs b/Scripts/Interfaces/FunctionalityInjection/IControlSpatialScrolling.cs index d37f72a69..e8fd0641b 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IControlSpatialScrolling.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IControlSpatialScrolling.cs @@ -21,7 +21,7 @@ public interface IControlSpatialScrolling public static class IControlSpatialScrollingMethods { - internal delegate SpatialScrollModule.SpatialScrollData PerformSpatialScrollDelegate (IControlSpatialScrolling caller, Node? node, Vector3 startingPosition, + internal delegate SpatialScrollModule.SpatialScrollData PerformSpatialScrollDelegate (IControlSpatialScrolling caller, Node node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerVisuals = true); internal static PerformSpatialScrollDelegate performSpatialScroll { private get; set; } @@ -39,7 +39,7 @@ internal delegate SpatialScrollModule.SpatialScrollData PerformSpatialScrollDele /// The maximum number of items that can be scrolled through for this action /// If true, expand the scroll line visuals outward in both directions from the scroll start position /// The spatial scroll data for a single scroll action, but an individual caller object - public static SpatialScrollModule.SpatialScrollData PerformSpatialScroll(this IControlSpatialScrolling obj, Node? node, + public static SpatialScrollModule.SpatialScrollData PerformSpatialScroll(this IControlSpatialScrolling obj, Node node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerVisuals = true) { return performSpatialScroll(obj, node, startingPosition, currentPosition, repeatingScrollLengthRange, scrollableItemCount, maxItemCount, centerVisuals); diff --git a/Scripts/Interfaces/FunctionalityInjection/IUsesNode.cs b/Scripts/Interfaces/FunctionalityInjection/IUsesNode.cs index 6fc67ed72..035db4125 100644 --- a/Scripts/Interfaces/FunctionalityInjection/IUsesNode.cs +++ b/Scripts/Interfaces/FunctionalityInjection/IUsesNode.cs @@ -9,7 +9,7 @@ public interface IUsesNode /// /// The node associated with this tool /// - Node? node { set; } + Node node { set; } } } #endif diff --git a/Scripts/ListView/ListViewControllerBase.cs b/Scripts/ListView/ListViewControllerBase.cs index 81de78243..5990770a8 100644 --- a/Scripts/ListView/ListViewControllerBase.cs +++ b/Scripts/ListView/ListViewControllerBase.cs @@ -87,7 +87,7 @@ void Update() UpdateView(); if (m_Scrolling) - this.Pulse(null, m_ScrollPulse); + this.Pulse(Node.None, m_ScrollPulse); } protected abstract void Setup(); diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index bfe800ff6..631a6f1b3 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -10,13 +10,6 @@ namespace UnityEditor.Experimental.EditorVR.Modules { sealed class DeviceInputModule : MonoBehaviour, IInterfaceConnector { - class InputProcessor - { - public IProcessInput processor; - public ActionMapInput input; - } - - public TrackedObject trackedObjectInput { get; private set; } [SerializeField] ActionMap m_TrackedObjectActionMap; @@ -33,15 +26,18 @@ class InputProcessor { "Right", Node.RightHand } }; - readonly List m_InputProcessors = new List(); + readonly Dictionary m_InputProcessors = new Dictionary(); + + public TrackedObject trackedObjectInput { get; private set; } + public Action, ConsumeControlDelegate> processInput; + public Action> updatePlayerHandleMaps; + public Func inputDeviceForRayOrigin; // Local method use only -- created here to reduce garbage collection readonly HashSet m_ProcessedInputs = new HashSet(); readonly List m_SystemDevices = new List(); readonly Dictionary m_DeviceTypeTags = new Dictionary(); - - public Action, ConsumeControlDelegate> processInput; - public Action> updatePlayerHandleMaps; + readonly Dictionary m_InputProcessorsCopy = new Dictionary(); public List GetSystemDevices() { @@ -72,25 +68,25 @@ void OnDestroy() public void ConnectInterface(object @object, object userData = null) { - var inputDevice = userData as InputDevice; + var trackedObjectMap = @object as ITrackedObjectActionMap; + if (trackedObjectMap != null) + trackedObjectMap.trackedObjectInput = trackedObjectInput; + + var rayOrigin = userData as Transform; var processInput = @object as IProcessInput; if (processInput != null && !(@object is ITool)) // Tools have their input processed separately { - m_InputProcessors.Add(new InputProcessor - { - processor = processInput, - input = CreateActionMapInputForObject(@object, inputDevice) - }); + var inputDevice = inputDeviceForRayOrigin(rayOrigin); + var input = CreateActionMapInputForObject(@object, inputDevice); + m_InputProcessors.Add(processInput, input); } - - // Tracked Object action maps shouldn't block each other so we share an instance - var trackedObjectMap = @object as ITrackedObjectActionMap; - if (trackedObjectMap != null) - trackedObjectMap.trackedObjectInput = trackedObjectInput; } public void DisconnectInterface(object @object, object userData = null) { + var processInput = @object as IProcessInput; + if (processInput != null) + m_InputProcessors.Remove(processInput); } public void ProcessInput() @@ -113,9 +109,15 @@ public void ProcessInput() m_ProcessedInputs.Clear(); - foreach (var processor in m_InputProcessors) + m_InputProcessorsCopy.Clear(); + foreach (var kvp in m_InputProcessors) + { + m_InputProcessorsCopy[kvp.Key] = kvp.Value; + } + + foreach (var kvp in m_InputProcessorsCopy) { - processor.processor.ProcessInput(processor.input, ConsumeControl); + kvp.Key.ProcessInput(kvp.Value, ConsumeControl); } // TODO: Replace this with a map of ActionMap,IProcessInput and go through those @@ -165,7 +167,7 @@ public ActionMapInput CreateActionMapInput(ActionMap map, InputDevice device) return actionMapInput; } - public ActionMapInput CreateActionMapInputForObject(object obj, InputDevice device) + internal ActionMapInput CreateActionMapInputForObject(object obj, InputDevice device) { var customMap = obj as ICustomActionMap; if (customMap != null) @@ -192,9 +194,11 @@ public void UpdatePlayerHandleMaps() var maps = m_PlayerHandle.maps; maps.Clear(); - foreach (var processor in m_InputProcessors) + foreach (var kvp in m_InputProcessors) { - maps.Add(processor.input); + var input = kvp.Value; + if (input != null) + maps.Add(input); } maps.Add(trackedObjectInput); @@ -269,7 +273,7 @@ void ConsumeControl(InputControl control) } } - public Node? GetDeviceNode(InputDevice device) + public Node GetDeviceNode(InputDevice device) { string[] tags; @@ -288,7 +292,7 @@ void ConsumeControl(InputControl control) return node; } - return null; + return Node.None; } } } diff --git a/Scripts/Modules/HapticsModule/HapticsModule.cs b/Scripts/Modules/HapticsModule/HapticsModule.cs index abe69a95d..4af17f24e 100644 --- a/Scripts/Modules/HapticsModule/HapticsModule.cs +++ b/Scripts/Modules/HapticsModule/HapticsModule.cs @@ -60,7 +60,7 @@ void LateUpdate() /// Haptic pulse /// (Optional) Multiplier value applied to the hapticPulse duration /// (Optional) Multiplier value applied to the hapticPulse intensity - public void Pulse(Node? node, HapticPulse hapticPulse, float durationMultiplier = 1f, float intensityMultiplier = 1f) + public void Pulse(Node node, HapticPulse hapticPulse, float durationMultiplier = 1f, float intensityMultiplier = 1f) { // Clip buffer can hold up to 800 milliseconds of samples // At 320Hz, each sample is 3.125f milliseconds @@ -137,7 +137,7 @@ public void Pulse(Node? node, HapticPulse hapticPulse, float durationMultiplier #endif } - public void StopPulses(Node? node) + public void StopPulses(Node node) { #if ENABLE_OVR_INPUT var channel = GetTargetChannel(node); @@ -157,10 +157,10 @@ public void StopPulses() } #if ENABLE_OVR_INPUT - OVRHaptics.OVRHapticsChannel GetTargetChannel(Node? node) + OVRHaptics.OVRHapticsChannel GetTargetChannel(Node node) { OVRHaptics.OVRHapticsChannel channel = null; - if (node == null) + if (node == Node.None) return channel; switch (node) diff --git a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs index 9bb7c3b10..abf6bab25 100644 --- a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs +++ b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs @@ -10,7 +10,7 @@ namespace UnityEditor.Experimental.EditorVR.Modules { // Based in part on code provided by VREAL at https://github.com/VREALITY/ViveUGUIModule/, which is licensed under the MIT License - sealed class MultipleRayInputModule : BaseInputModule, IGetPointerLength + sealed class MultipleRayInputModule : BaseInputModule, IGetPointerLength, IConnectInterfaces { public class RaycastSource : ICustomActionMap { @@ -23,20 +23,20 @@ public class RaycastSource : ICustomActionMap public bool blocked; public Func isValid; - MultipleRayInputModule owner; + MultipleRayInputModule m_Owner; public GameObject currentObject { get { return hoveredObject ? hoveredObject : draggedObject; } } public bool hasObject { get { return currentObject != null && (s_LayerMask & (1 << currentObject.layer)) != 0; } } - public ActionMap actionMap { get; private set; } + public ActionMap actionMap { get { return m_Owner.m_UIActionMap; } } public RaycastSource(IProxy proxy, Transform rayOrigin, Node node, MultipleRayInputModule owner, Func validationCallback) { this.proxy = proxy; this.rayOrigin = rayOrigin; this.node = node; - this.owner = owner; + m_Owner = owner; isValid = validationCallback; } @@ -45,18 +45,18 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (!(rayOrigin.gameObject.activeSelf || draggedObject) || !proxy.active) return; - var preProcessRaycastSource = owner.preProcessRaycastSource; + var preProcessRaycastSource = m_Owner.preProcessRaycastSource; if (preProcessRaycastSource != null) preProcessRaycastSource(rayOrigin); if (eventData == null) - eventData = new RayEventData(owner.eventSystem); + eventData = new RayEventData(m_Owner.eventSystem); - hoveredObject = owner.GetRayIntersection(this); // Check all currently running raycasters + hoveredObject = m_Owner.GetRayIntersection(this); // Check all currently running raycasters eventData.node = node; eventData.rayOrigin = rayOrigin; - eventData.pointerLength = owner.GetPointerLength(eventData.rayOrigin); + eventData.pointerLength = m_Owner.GetPointerLength(eventData.rayOrigin); if (isValid != null && !isValid(this)) { @@ -64,11 +64,11 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon currentRaycast.gameObject = null; eventData.pointerCurrentRaycast = currentRaycast; hoveredObject = null; - owner.HandlePointerExitAndEnter(eventData, null, true); // Send only exit events + m_Owner.HandlePointerExitAndEnter(eventData, null, true); // Send only exit events return; } - owner.HandlePointerExitAndEnter(eventData, hoveredObject); // Send enter and exit events + m_Owner.HandlePointerExitAndEnter(eventData, hoveredObject); // Send enter and exit events var hasScrollHandler = false; input.active = hasObject && ShouldActivateInput(eventData, currentObject, out hasScrollHandler); @@ -89,12 +89,12 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon // Send select pressed and released events if (select.wasJustPressed) { - owner.OnSelectPressed(this); + m_Owner.OnSelectPressed(this); consumeControl(select); } if (select.wasJustReleased) - owner.OnSelectReleased(this); + m_Owner.OnSelectReleased(this); // Send Drag Events if (draggedObject != null) @@ -121,17 +121,18 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } } - private readonly Dictionary m_RaycastSources = new Dictionary(); + static LayerMask s_LayerMask; - public Camera eventCamera { get { return m_EventCamera; } set { m_EventCamera = value; } } - private Camera m_EventCamera; + readonly Dictionary m_RaycastSources = new Dictionary(); - public LayerMask layerMask { get { return s_LayerMask; } set { s_LayerMask = value; } } - private static LayerMask s_LayerMask; + Camera m_EventCamera; - public ActionMap actionMap { get { return m_UIActionMap; } } [SerializeField] - private ActionMap m_UIActionMap; + ActionMap m_UIActionMap; + + public Camera eventCamera { get { return m_EventCamera; } set { m_EventCamera = value; } } + public LayerMask layerMask { get { return s_LayerMask; } set { s_LayerMask = value; } } + public ActionMap actionMap { get { return m_UIActionMap; } } public event Action rayEntered; public event Action rayHovering; @@ -143,7 +144,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon // Local method use only -- created here to reduce garbage collection RayEventData m_TempRayEvent; - //List m_RaycastSourcesCopy = new List(); protected override void Awake() { @@ -153,17 +153,21 @@ protected override void Awake() s_LayerMask = LayerMask.GetMask("UI"); m_TempRayEvent = new RayEventData(eventSystem); - } - public void AddRaycastSource(IProxy proxy, Node node, Transform rayOrigin, Func validationCallback = null) + protected override void OnDestroy() { - m_RaycastSources.Add(rayOrigin, new RaycastSource(proxy, rayOrigin, node, this, validationCallback)); + foreach (var source in m_RaycastSources) + { + this.DisconnectInterfaces(source); + } } - public void RemoveRaycastSource(Transform rayOrigin) + public void AddRaycastSource(IProxy proxy, Node node, Transform rayOrigin, Func validationCallback = null) { - m_RaycastSources.Remove(rayOrigin); + var source = new RaycastSource(proxy, rayOrigin, node, this, validationCallback); + this.ConnectInterfaces(source, rayOrigin); + m_RaycastSources.Add(rayOrigin, source); } public RayEventData GetPointerEventData(Transform rayOrigin) @@ -361,7 +365,7 @@ void OnSelectPressed(RaycastSource source) } } - private void OnSelectReleased(RaycastSource source) + void OnSelectReleased(RaycastSource source) { var eventData = source.eventData; var hoveredObject = source.hoveredObject; @@ -397,16 +401,16 @@ private void OnSelectReleased(RaycastSource source) public void Deselect() { - if (base.eventSystem.currentSelectedGameObject) - base.eventSystem.SetSelectedGameObject(null); + if (eventSystem.currentSelectedGameObject) + eventSystem.SetSelectedGameObject(null); } - private void Select(GameObject go) + void Select(GameObject go) { Deselect(); if (ExecuteEvents.GetEventHandler(go)) - base.eventSystem.SetSelectedGameObject(go); + eventSystem.SetSelectedGameObject(go); } GameObject GetRayIntersection(RaycastSource source) @@ -429,13 +433,13 @@ GameObject GetRayIntersection(RaycastSource source) return hit; } - private bool ExecuteUpdateOnSelectedObject() + bool ExecuteUpdateOnSelectedObject() { - if (base.eventSystem.currentSelectedGameObject == null) + if (eventSystem.currentSelectedGameObject == null) return false; - BaseEventData eventData = GetBaseEventData(); - ExecuteEvents.Execute(base.eventSystem.currentSelectedGameObject, eventData, ExecuteEvents.updateSelectedHandler); + var eventData = GetBaseEventData(); + ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, eventData, ExecuteEvents.updateSelectedHandler); return eventData.used; } diff --git a/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs b/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs index 6a6e3e8ef..b81889dd8 100644 --- a/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs +++ b/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs @@ -19,7 +19,7 @@ public enum SpatialHintStateFlags SpatialHintUI m_SpatialHintUI; SpatialHintStateFlags m_State; - Node? m_ControllingNode; + Node m_ControllingNode; public SpatialHintStateFlags state { @@ -34,7 +34,7 @@ public SpatialHintStateFlags state m_SpatialHintUI.preScrollArrowsVisible = false; m_SpatialHintUI.secondaryArrowsVisible = false; this.RemoveRayVisibilitySettings(this.RequestRayOriginFromNode(m_ControllingNode), this); - controllingNode = null; + controllingNode = Node.None; break; case SpatialHintStateFlags.PreDragReveal: m_SpatialHintUI.centeredScrolling = false; @@ -55,7 +55,7 @@ public SpatialHintStateFlags state } } - private Node? controllingNode + Node controllingNode { set { @@ -64,15 +64,10 @@ private Node? controllingNode return; m_ControllingNode = value; - if (m_ControllingNode == null) - { - m_SpatialHintUI.controllingNode = null; - } - else - { + if (m_ControllingNode != Node.None) state = SpatialHintStateFlags.PreDragReveal; - m_SpatialHintUI.controllingNode = value; - } + + m_SpatialHintUI.controllingNode = value; } } @@ -135,7 +130,7 @@ internal void SetDragThresholdTriggerPosition (Vector3 position) m_SpatialHintUI.scrollVisualsDragThresholdTriggerPosition = position; } - internal void SetSpatialHintControlNode(Node? controlNode) + internal void SetSpatialHintControlNode(Node controlNode) { controllingNode = controlNode; this.AddRayVisibilitySettings(this.RequestRayOriginFromNode(m_ControllingNode), this, false, false); diff --git a/Scripts/Modules/SpatialHintModule/SpatialHintUI.cs b/Scripts/Modules/SpatialHintModule/SpatialHintUI.cs index e4889c2a5..ac808ae4b 100644 --- a/Scripts/Modules/SpatialHintModule/SpatialHintUI.cs +++ b/Scripts/Modules/SpatialHintModule/SpatialHintUI.cs @@ -40,7 +40,7 @@ public class SpatialHintUI : MonoBehaviour, IUsesViewerScale, IControlHaptics, I Transform m_ScrollVisualsTransform; Coroutine m_ScrollVisualsVisibilityCoroutine; Transform m_ScrollVisualsDragTargetArrowTransform; - Node? m_ControllingNode; + Node m_ControllingNode; /// /// Bool denoting the visibility of the Spatial Hint UI elements @@ -150,14 +150,14 @@ bool scrollArrowsVisible /// /// The node currently controlling the spatial hint visuals /// - public Node? controllingNode + public Node controllingNode { get { return m_ControllingNode; } set { m_ControllingNode = value; - if (m_ControllingNode == null) + if (m_ControllingNode == Node.None) { scrollVisualsRotation = Vector3.zero; this.RestartCoroutine(ref m_ScrollVisualsVisibilityCoroutine, HideScrollVisuals()); diff --git a/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs b/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs index 329cffeae..83c4f9731 100644 --- a/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs +++ b/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs @@ -15,7 +15,7 @@ public sealed class SpatialScrollModule : MonoBehaviour, IUsesViewerScale, ICont public class SpatialScrollData : INodeToRay { - public SpatialScrollData(IControlSpatialScrolling caller, Node? node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerVisuals = true) + public SpatialScrollData(IControlSpatialScrolling caller, Node node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerVisuals = true) { this.caller = caller; this.node = node; @@ -39,7 +39,7 @@ public SpatialScrollData(IControlSpatialScrolling caller, Node? node, Vector3 st /// /// The node on which this spatial scroll is being processed /// - public Node? node { get; set; } + public Node node { get; set; } /// /// The ray origin on which this spatial scroll is being processed @@ -110,7 +110,7 @@ void Awake() IControlSpatialScrollingMethods.endSpatialScroll = EndScroll; } - internal SpatialScrollData PerformScroll(IControlSpatialScrolling caller, Node? node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerScrollVisuals = true) + internal SpatialScrollData PerformScroll(IControlSpatialScrolling caller, Node node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerScrollVisuals = true) { // Continue processing of spatial scrolling for a given caller, // Or create new instance of scroll data for new callers. (Initial structure for support of simultaneous callers) diff --git a/Tools/AnnotationTool/AnnotationTool.cs b/Tools/AnnotationTool/AnnotationTool.cs index 760c0c151..54f05c5d2 100644 --- a/Tools/AnnotationTool/AnnotationTool.cs +++ b/Tools/AnnotationTool/AnnotationTool.cs @@ -103,7 +103,7 @@ class Preferences public ActionMap actionMap { get { return m_ActionMap; } } public List linkedObjects { private get; set; } - public Node? node { private get; set; } + public Node node { private get; set; } public GameObject settingsMenuItemPrefab { get { return m_SettingsMenuItemPrefab; } } public GameObject settingsMenuItemInstance @@ -223,7 +223,7 @@ void Start() m_ColorPicker.onColorPicked = OnColorPickerValueChanged; OnColorPickerValueChanged(m_Preferences.annotationColor); - activator.node = node.Value; + activator.node = node; activator.rayOrigin = otherRayOrigin; activator.showColorPicker = ShowColorPicker; activator.hideColorPicker = HideColorPicker; diff --git a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs index 6ecf47e72..661f9dcdb 100644 --- a/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs +++ b/Tools/CreatePrimitiveTool/CreatePrimitiveTool.cs @@ -35,7 +35,7 @@ sealed class CreatePrimitiveTool : MonoBehaviour, ITool, IStandardActionMap, ICo readonly Dictionary> m_Controls = new Dictionary>(); public Transform rayOrigin { get; set; } - public Node? node { get; set; } + public Node node { get; set; } public Sprite icon { get { return m_Icon; } } @@ -65,7 +65,7 @@ void Start() { this.AddFeedbackRequest(new ProxyFeedbackRequest { - node = node.Value, + node = node, control = id, tooltipText = "Draw" }); diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 904aabf3a..665cb9207 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -173,7 +173,7 @@ public GameObject settingsMenuItemInstance public Type proxyType { get; set; } - public Node? node { private get; set; } + public Node node { private get; set; } void Start() { @@ -798,7 +798,7 @@ void ShowCrawlFeedback() { var request = new ProxyFeedbackRequest { - node = node.Value, + node = node, control = id, tooltipText = "Crawl" }; @@ -818,7 +818,7 @@ void ShowMainButtonFeedback() { var request = new ProxyFeedbackRequest { - node = node.Value, + node = node, control = id, tooltipText = m_Preferences.blinkMode ? "Blink" : "Fly" }; @@ -839,7 +839,7 @@ void ShowRotateFeedback() var request = new ProxyFeedbackRequest { control = id, - node = node.Value, + node = node, tooltipText = "Rotate" }; @@ -859,7 +859,7 @@ void ShowAltRotateFeedback() var request = new ProxyFeedbackRequest { control = id, - node = node.Value, + node = node, tooltipText = "Rotate" }; @@ -899,7 +899,7 @@ void ShowResetScaleFeedback() var request = new ProxyFeedbackRequest { control = id, - node = node.Value, + node = node, tooltipText = "Reset scale" }; @@ -915,7 +915,7 @@ void ShowResetScaleFeedback() var request = new ProxyFeedbackRequest { control = id, - node = node.Value, + node = node, tooltipText = "Reset position rotation and scale" }; @@ -934,7 +934,7 @@ void ShowSpeedFeedback() { var request = new ProxyFeedbackRequest { - node = node.Value, + node = node, control = id, tooltipText = m_Preferences.blinkMode ? "Extra distance" : "Extra speed" }; diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index eb4a5f2bc..712a9a8c3 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -45,7 +45,7 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR public ActionMap actionMap { get { return m_ActionMap; } } public Transform rayOrigin { private get; set; } - public Node? node { private get; set; } + public Node node { private get; set; } public Sprite icon { get { return m_Icon; } } @@ -319,7 +319,7 @@ void ShowSelectFeedback() { var request = new ProxyFeedbackRequest { - node = node.Value, + node = node, control = id, tooltipText = "Select" }; diff --git a/Tools/TransformTool/TransformTool.cs b/Tools/TransformTool/TransformTool.cs index 02a0125b2..56ba3248a 100644 --- a/Tools/TransformTool/TransformTool.cs +++ b/Tools/TransformTool/TransformTool.cs @@ -239,7 +239,7 @@ public bool manipulatorDragging public List linkedObjects { private get; set; } public Transform rayOrigin { private get; set; } - public Node? node { private get; set; } + public Node node { private get; set; } public ActionMap actionMap { get { return m_ActionMap; } } @@ -368,7 +368,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (objectsGrabbed != null && !m_Scaling) objectsGrabbed(directRayOrigin, grabbedObjects); - m_GrabData[grabbingNode.Value] = new GrabData(directRayOrigin, transformInput, grabbedObjects.ToArray()); + m_GrabData[grabbingNode] = new GrabData(directRayOrigin, transformInput, grabbedObjects.ToArray()); // A direct selection has been made. Hide the manipulator until the selection changes m_DirectSelected = true; @@ -477,7 +477,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon { var transformTool = (TransformTool)linkedObject; var rayOrigin = transformTool.rayOrigin; - if (!(m_Scaling || directSelection.ContainsKey(rayOrigin) || m_GrabData.ContainsKey(transformTool.node.Value))) + if (!(m_Scaling || directSelection.ContainsKey(rayOrigin) || m_GrabData.ContainsKey(transformTool.node))) { this.RemoveRayVisibilitySettings(rayOrigin, this); } diff --git a/Tools/VacuumTool/VacuumTool.cs b/Tools/VacuumTool/VacuumTool.cs index 7b6865ac3..0d406404e 100644 --- a/Tools/VacuumTool/VacuumTool.cs +++ b/Tools/VacuumTool/VacuumTool.cs @@ -28,7 +28,7 @@ sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin public Vector3 defaultOffset { private get; set; } public Quaternion defaultTilt { private get; set; } - public Node? node { private get; set; } + public Node node { private get; set; } void Start() { @@ -77,7 +77,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon var request = new ProxyFeedbackRequest { control = id, - node = node.Value, + node = node, tooltipText = "Double-tap to summon workspace" }; diff --git a/Workspaces/Base/WorkspaceUI.cs b/Workspaces/Base/WorkspaceUI.cs index 4969b086f..2d9907b9f 100644 --- a/Workspaces/Base/WorkspaceUI.cs +++ b/Workspaces/Base/WorkspaceUI.cs @@ -134,6 +134,9 @@ sealed class WorkspaceUI : MonoBehaviour, IUsesStencilRef, IUsesViewerScale, IGe [SerializeField] WorkspaceButton m_ResizeButton; + [SerializeField] + ActionMap m_ActionMap; + BoxCollider m_FrameCollider; Bounds m_Bounds; float? m_TopPanelDividerOffset; @@ -348,7 +351,7 @@ public bool preventResize public Transform leftRayOrigin { private get; set; } public Transform rightRayOrigin { private get; set; } - public Node? node { get; set; } + public Node node { get; set; } public event Action resize; From 4a4dac22396bfd64df90a0126d7f2745bf5dcfc7 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 29 Sep 2017 03:35:36 -0700 Subject: [PATCH 050/457] Finish ProxyAnimator implementation; Add ProcessInputAttribute to set order on ProcessInputs --- Prefabs/Proxies/LeftTouch.prefab | 10 ++--- Prefabs/Proxies/RightTouch.prefab | 10 ++--- Scripts/Core/EditorVR.Rays.cs | 8 +++- Scripts/Helpers/ProcessInputAttribute.cs | 17 +++++++ Scripts/Helpers/ProcessInputAttribute.cs.meta | 12 +++++ Scripts/Modules/DeviceInputModule.cs | 45 +++++++++++++------ Scripts/Proxies/ProxyAnimator.cs | 33 +++++++++----- Scripts/Proxies/ProxyAnimator.cs.meta | 5 ++- 8 files changed, 102 insertions(+), 38 deletions(-) create mode 100644 Scripts/Helpers/ProcessInputAttribute.cs create mode 100644 Scripts/Helpers/ProcessInputAttribute.cs.meta diff --git a/Prefabs/Proxies/LeftTouch.prefab b/Prefabs/Proxies/LeftTouch.prefab index 6e5134255..42c764c23 100644 --- a/Prefabs/Proxies/LeftTouch.prefab +++ b/Prefabs/Proxies/LeftTouch.prefab @@ -1395,26 +1395,26 @@ MonoBehaviour: m_Renderer: {fileID: 13767942} m_TranslateAxes: 1 m_RotateAxes: 0 - m_Min: 0.00455765 - m_Max: -0.00455765 + m_Min: -0.00455765 + m_Max: 0.00455765 - m_Control: 17 m_Transform: {fileID: 442622} m_Renderer: {fileID: 13771122} - m_TranslateAxes: 2 + m_TranslateAxes: 4 m_RotateAxes: 0 m_Min: 0.001793736 m_Max: -0.001793736 - m_Control: 18 m_Transform: {fileID: 447250} m_Renderer: {fileID: 13791068} - m_TranslateAxes: 2 + m_TranslateAxes: 4 m_RotateAxes: 0 m_Min: 0.001793736 m_Max: -0.001793736 - m_Control: 22 m_Transform: {fileID: 407362} m_Renderer: {fileID: 13758356} - m_TranslateAxes: 2 + m_TranslateAxes: 1 m_RotateAxes: 0 m_Min: 0.0002774392 m_Max: -0.0002774392 diff --git a/Prefabs/Proxies/RightTouch.prefab b/Prefabs/Proxies/RightTouch.prefab index a8426767e..92856801e 100644 --- a/Prefabs/Proxies/RightTouch.prefab +++ b/Prefabs/Proxies/RightTouch.prefab @@ -1369,26 +1369,26 @@ MonoBehaviour: m_Renderer: {fileID: 13791512} m_TranslateAxes: 1 m_RotateAxes: 0 - m_Min: -0.00455765 - m_Max: 0.00455765 + m_Min: 0.00455765 + m_Max: -0.00455765 - m_Control: 17 m_Transform: {fileID: 412818} m_Renderer: {fileID: 13757144} - m_TranslateAxes: 2 + m_TranslateAxes: 4 m_RotateAxes: 0 m_Min: 0.001793736 m_Max: -0.001793736 - m_Control: 18 m_Transform: {fileID: 437054} m_Renderer: {fileID: 13724278} - m_TranslateAxes: 2 + m_TranslateAxes: 4 m_RotateAxes: 0 m_Min: 0.001793736 m_Max: -0.001793736 - m_Control: 22 m_Transform: {fileID: 451284} m_Renderer: {fileID: 13768278} - m_TranslateAxes: 2 + m_TranslateAxes: 1 m_RotateAxes: 0 m_Min: 0.0002774392 m_Max: -0.0002774392 diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index 8ae898e92..b00d7e461 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -153,7 +153,8 @@ internal void CreateAllProxies() var deviceInputModule = evr.GetModule(); foreach (var proxyType in ObjectUtils.GetImplementationsOfInterface(typeof(IProxy))) { - var proxy = (IProxy)ObjectUtils.CreateGameObjectWithComponent(proxyType, VRView.cameraRig, false); + var component = ObjectUtils.CreateGameObjectWithComponent(proxyType, VRView.cameraRig, false);; + var proxy = (IProxy)component; this.ConnectInterfaces(proxy); proxy.trackedObjectInput = deviceInputModule.trackedObjectInput; proxy.activeChanged += () => OnProxyActiveChanged(proxy); @@ -277,6 +278,11 @@ void OnProxyActiveChanged(IProxy proxy) } evr.GetNestedModule().SpawnDefaultTools(proxy); + + foreach (var helper in ((Component)proxy).GetComponentsInChildren(true)) + { + this.ConnectInterfaces(ObjectUtils.AddComponent(helper.gameObject), helper.rayOrigin); + } } } } diff --git a/Scripts/Helpers/ProcessInputAttribute.cs b/Scripts/Helpers/ProcessInputAttribute.cs new file mode 100644 index 000000000..2ab2dbe3e --- /dev/null +++ b/Scripts/Helpers/ProcessInputAttribute.cs @@ -0,0 +1,17 @@ +#if UNITY_EDITOR +using System; + +namespace UnityEditor.Experimental.EditorVR +{ + [AttributeUsage(AttributeTargets.Class)] + sealed class ProcessInputAttribute : Attribute + { + public int order; + + public ProcessInputAttribute(int order) + { + this.order = order; + } + } +} +#endif diff --git a/Scripts/Helpers/ProcessInputAttribute.cs.meta b/Scripts/Helpers/ProcessInputAttribute.cs.meta new file mode 100644 index 000000000..ea2d8193b --- /dev/null +++ b/Scripts/Helpers/ProcessInputAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 17aba4cd6323b8f449bd702f964df0d9 +timeCreated: 1506680411 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 631a6f1b3..9e3f2660a 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -1,6 +1,7 @@ #if UNITY_EDITOR && UNITY_EDITORVR using System; using System.Collections.Generic; +using System.Linq; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -10,6 +11,13 @@ namespace UnityEditor.Experimental.EditorVR.Modules { sealed class DeviceInputModule : MonoBehaviour, IInterfaceConnector { + class InputProcessor + { + public IProcessInput processor; + public ActionMapInput input; + public int order; + } + [SerializeField] ActionMap m_TrackedObjectActionMap; @@ -26,7 +34,7 @@ sealed class DeviceInputModule : MonoBehaviour, IInterfaceConnector { "Right", Node.RightHand } }; - readonly Dictionary m_InputProcessors = new Dictionary(); + readonly List m_InputProcessors = new List(); public TrackedObject trackedObjectInput { get; private set; } public Action, ConsumeControlDelegate> processInput; @@ -37,7 +45,7 @@ sealed class DeviceInputModule : MonoBehaviour, IInterfaceConnector readonly HashSet m_ProcessedInputs = new HashSet(); readonly List m_SystemDevices = new List(); readonly Dictionary m_DeviceTypeTags = new Dictionary(); - readonly Dictionary m_InputProcessorsCopy = new Dictionary(); + readonly List m_InputProcessorsCopy = new List(); public List GetSystemDevices() { @@ -78,7 +86,14 @@ public void ConnectInterface(object @object, object userData = null) { var inputDevice = inputDeviceForRayOrigin(rayOrigin); var input = CreateActionMapInputForObject(@object, inputDevice); - m_InputProcessors.Add(processInput, input); + + var order = 0; + var processInputAttribute = (ProcessInputAttribute)@object.GetType().GetCustomAttributes(typeof(ProcessInputAttribute), true).FirstOrDefault(); + if (processInputAttribute != null) + order = processInputAttribute.order; + + m_InputProcessors.Add(new InputProcessor { processor = processInput, input = input, order = order }); + m_InputProcessors.Sort((a, b) => b.order.CompareTo(a.order)); } } @@ -86,7 +101,15 @@ public void DisconnectInterface(object @object, object userData = null) { var processInput = @object as IProcessInput; if (processInput != null) - m_InputProcessors.Remove(processInput); + { + m_InputProcessorsCopy.Clear(); + m_InputProcessorsCopy.AddRange(m_InputProcessors); + foreach (var processor in m_InputProcessorsCopy) + { + if (processor.processor == @object) + m_InputProcessors.Remove(processor); + } + } } public void ProcessInput() @@ -110,14 +133,10 @@ public void ProcessInput() m_ProcessedInputs.Clear(); m_InputProcessorsCopy.Clear(); - foreach (var kvp in m_InputProcessors) - { - m_InputProcessorsCopy[kvp.Key] = kvp.Value; - } - - foreach (var kvp in m_InputProcessorsCopy) + m_InputProcessorsCopy.AddRange(m_InputProcessors); + foreach (var processor in m_InputProcessorsCopy) { - kvp.Key.ProcessInput(kvp.Value, ConsumeControl); + processor.processor.ProcessInput(processor.input, ConsumeControl); } // TODO: Replace this with a map of ActionMap,IProcessInput and go through those @@ -194,9 +213,9 @@ public void UpdatePlayerHandleMaps() var maps = m_PlayerHandle.maps; maps.Clear(); - foreach (var kvp in m_InputProcessors) + foreach (var processor in m_InputProcessors) { - var input = kvp.Value; + var input = processor.input; if (input != null) maps.Add(input); } diff --git a/Scripts/Proxies/ProxyAnimator.cs b/Scripts/Proxies/ProxyAnimator.cs index c5f4cc133..2997e60ff 100644 --- a/Scripts/Proxies/ProxyAnimator.cs +++ b/Scripts/Proxies/ProxyAnimator.cs @@ -1,9 +1,9 @@ -using System.Linq; -using UnityEditor.Experimental.EditorVR; +using UnityEditor.Experimental.EditorVR; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEngine; using UnityEngine.InputNew; +[ProcessInput(1)] [RequireComponent(typeof(ProxyHelper))] public class ProxyAnimator : MonoBehaviour, ICustomActionMap { @@ -24,6 +24,9 @@ void Start() public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { + if (m_Buttons == null) + return; + var length = m_Buttons.Length; if (m_Controls == null) { @@ -31,16 +34,21 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon m_InitialPositions = new Vector3[length]; m_InitialRotations = new Vector3[length]; + var bindings = input.actionMap.controlSchemes[0].bindings; for (var i = 0; i < input.controlCount; i++) { var control = input[i]; + var binding = bindings[i]; for (var j = 0; j < length; j++) { var button = m_Buttons[j]; - if (control.data.componentControlIndices.Contains((int)button.control)) + foreach (var index in binding.sources) { - m_Controls[j] = control; - break; + if (index.controlIndex == (int)button.control) + { + m_Controls[j] = control; + break; + } } } } @@ -57,31 +65,32 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon { var button = m_Buttons[i]; var control = m_Controls[i]; + //Assume control values are [-1, 1] var min = button.min; - var offset = min + (control.rawValue + 1) * (button.max - min); + var offset = min + (control.rawValue + 1) * (button.max - min) * 0.5f; var buttonTransform = button.transform; var localPosition = m_InitialPositions[i]; var translateAxes = button.translateAxes; - if ((translateAxes | AxisFlags.X) != 0) + if ((translateAxes & AxisFlags.X) != 0) localPosition.x += offset; - if ((translateAxes | AxisFlags.Y) != 0) + if ((translateAxes & AxisFlags.Y) != 0) localPosition.y += offset; - if ((translateAxes | AxisFlags.Z) != 0) + if ((translateAxes & AxisFlags.Z) != 0) localPosition.z += offset; var localRotation = m_InitialRotations[i]; var rotateAxes = button.rotateAxes; - if ((rotateAxes | AxisFlags.X) != 0) + if ((rotateAxes & AxisFlags.X) != 0) localRotation.x += offset; - if ((rotateAxes | AxisFlags.Y) != 0) + if ((rotateAxes & AxisFlags.Y) != 0) localRotation.y += offset; - if ((rotateAxes | AxisFlags.Z) != 0) + if ((rotateAxes & AxisFlags.Z) != 0) localRotation.z += offset; buttonTransform.localPosition = localPosition; diff --git a/Scripts/Proxies/ProxyAnimator.cs.meta b/Scripts/Proxies/ProxyAnimator.cs.meta index 710886a68..7d589e066 100644 --- a/Scripts/Proxies/ProxyAnimator.cs.meta +++ b/Scripts/Proxies/ProxyAnimator.cs.meta @@ -1,10 +1,11 @@ fileFormatVersion: 2 guid: 460af9702a1fe674a932ad1a15f33bfa -timeCreated: 1506644245 +timeCreated: 1506676876 licenseType: Pro MonoImporter: serializedVersion: 2 - defaultReferences: [] + defaultReferences: + - m_ProxyActionMap: {fileID: 11400000, guid: 9fba3ce585063484a937428d7ef14426, type: 2} executionOrder: 0 icon: {instanceID: 0} userData: From e57b9f1d7144e24f21be8123bcff044d5fac67a6 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Fri, 29 Sep 2017 12:50:29 -0700 Subject: [PATCH 051/457] Replace Unity logo icon with menu hamburger icon --- Menus/ToolsMenu/Textures/MenuIcon.png | 3 +++ .../Textures/{UnityIcon.png.meta => MenuIcon.png.meta} | 0 Menus/ToolsMenu/Textures/UnityIcon.png | 3 --- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 Menus/ToolsMenu/Textures/MenuIcon.png rename Menus/ToolsMenu/Textures/{UnityIcon.png.meta => MenuIcon.png.meta} (100%) delete mode 100644 Menus/ToolsMenu/Textures/UnityIcon.png diff --git a/Menus/ToolsMenu/Textures/MenuIcon.png b/Menus/ToolsMenu/Textures/MenuIcon.png new file mode 100644 index 000000000..791a25173 --- /dev/null +++ b/Menus/ToolsMenu/Textures/MenuIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35eb9d0eea3f283a10aae75094d2df7ed2f5c1414398fd942e59bbd63942bf02 +size 1802 diff --git a/Menus/ToolsMenu/Textures/UnityIcon.png.meta b/Menus/ToolsMenu/Textures/MenuIcon.png.meta similarity index 100% rename from Menus/ToolsMenu/Textures/UnityIcon.png.meta rename to Menus/ToolsMenu/Textures/MenuIcon.png.meta diff --git a/Menus/ToolsMenu/Textures/UnityIcon.png b/Menus/ToolsMenu/Textures/UnityIcon.png deleted file mode 100644 index e5639fdc2..000000000 --- a/Menus/ToolsMenu/Textures/UnityIcon.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e84e553e4a6e78eafdea2d5422af8d235041f8267abc10b1bf93ba6db12c0439 -size 18354 From b72a1b2f061b25cdc488eed662ea1e8d2033df92 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Fri, 29 Sep 2017 19:42:07 -0700 Subject: [PATCH 052/457] Remove toolTip collection references from TwoHandedProxyBase; no longer needed --- Scripts/Proxies/TwoHandedProxyBase.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 9f4e7713b..7e7ba9083 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -149,10 +149,6 @@ public virtual void Awake() { m_LeftProxyHelper.rayOrigin, m_LeftProxyHelper.fieldGrabOrigin }, { m_RightProxyHelper.rayOrigin, m_RightProxyHelper.fieldGrabOrigin } }; - - var m_LeftTooltips = new List(); - var m_RightTooltips = new List(); - } public virtual IEnumerator Start() From 18140fd7c749427c2dc7a6429dad78c06b24cf41 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Fri, 29 Sep 2017 19:42:55 -0700 Subject: [PATCH 053/457] Remove System.IO using from ProxyExtras --- Scripts/Helpers/ProxyExtras.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Scripts/Helpers/ProxyExtras.cs b/Scripts/Helpers/ProxyExtras.cs index a776b6874..f32f8458d 100644 --- a/Scripts/Helpers/ProxyExtras.cs +++ b/Scripts/Helpers/ProxyExtras.cs @@ -1,7 +1,6 @@ #if UNITY_EDITOR using System; using System.Collections.Generic; -using System.IO; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Helpers From fb184ab8a98825d057e37aee1f5cf15b1eeaba18 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Fri, 29 Sep 2017 19:43:37 -0700 Subject: [PATCH 054/457] Remove UnityEngine.Serialization from ProxyHelper, no longer needed --- Scripts/Helpers/ProxyHelper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index 47223aec8..d23fbc68d 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.InputNew; -using UnityEngine.Serialization; using VisibilityControlType = UnityEditor.Experimental.EditorVR.Core.ProxyAffordanceMap.VisibilityControlType; namespace UnityEditor.Experimental.EditorVR.Proxies From ff12f41ac7a0441796e96f00740815071a00438b Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Fri, 29 Sep 2017 19:46:14 -0700 Subject: [PATCH 055/457] Refine support for handling color blending, alpha fading, and material swaps for when setting proxy visibility in ProxyUI --- Scripts/Helpers/ProxyUI.cs | 134 ++++++++++++++++++++++++++++--------- 1 file changed, 103 insertions(+), 31 deletions(-) diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index 709b82e32..97ae0bffa 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -1,5 +1,4 @@ #if UNITY_EDITOR -using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -8,6 +7,7 @@ using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; +using VisibilityControlType = UnityEditor.Experimental.EditorVR.Core.ProxyAffordanceMap.VisibilityControlType; namespace UnityEditor.Experimental.EditorVR.Proxies { @@ -16,12 +16,13 @@ public class ProxyUI : MonoBehaviour List m_BodyRenderers; // Renderers not associated with controls, & will be hidden when displaying feedback/tooltips bool m_BodyRenderersVisible = true; // Renderers default to visible/true AffordanceObject[] m_Affordances; - List m_BodyMaterials; // Collection of unique body MeshRenderer materials + //List m_BodyMaterials; // Collection of unique body MeshRenderer materials // TODO : delete, no longer used? Coroutine m_BodyVisibilityCoroutine; // Map of unique body materials to their original Colors (used for affordances with the "color" visibility control type) // The second param, ColorPair, houses the original cached color, and a value, representing the color to lerp FROM when animating visibility - Dictionary m_BodyMaterialOriginalColorMap = new Dictionary(); + Dictionary> m_BodyMaterialOriginalColorMap = new Dictionary>(); + Dictionary> m_BodyMaterialOriginalAlphaMap = new Dictionary>(); // Used to draw visual attention to individual affordances Dictionary> m_AffordanceMaterialOriginalColorMap = new Dictionary>(); @@ -29,22 +30,21 @@ public class ProxyUI : MonoBehaviour [SerializeField] ProxyAffordanceMap m_AffordanceMap; - private class ColorPair + /// + /// Model containing original value, and values to "animate from", unique to each body MeshRenderer material. + /// Visibility of all objects in the proxy body are driven by a single AffordanceVisibilityDefinition, + /// as opposed to individual interactable affordances, which each have their own AffordanceVisibilityDefinition, which contains their unique value data. + /// This is a lightweight class to store that data, alleviating the need to duplicate an affordance definition for each body renderer as well. + /// + private class affordancePropertyTuple { - /// - /// The original/cached color of the material - /// - public Color originalColor { get; set; } - - /// - /// The color to lerp FROM as the current color when animating visibility - /// - public Color animateFromColor { get; set; } + public T originalValue { get; private set; } + public T animateFromValue { get; set; } - public ColorPair(Color originalColor, Color animateFromColor) + public affordancePropertyTuple(T originalValue, T animateFromValue) { - this.originalColor = originalColor; - this.animateFromColor = animateFromColor; + this.originalValue = originalValue; + this.animateFromValue = animateFromValue; } } @@ -89,16 +89,36 @@ public AffordanceObject[] Affordances } // Collect renderers not associated with affordances + // Material swaps don't need to cache original values, only alpha & color + var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; m_BodyRenderers = GetComponentsInChildren(true).Where(x => !affordanceRenderers.Contains(x)).ToList(); - foreach (var renderer in m_BodyRenderers) + Debug.LogWarning("Don't collect renderers from the menu origins!!!"); + switch (m_AffordanceMap.bodyVisibilityDefinition.visibilityType) { - // TODO: support for skipping the cloning of materials in the body that are shared between objects, to reduce draw calls - var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials per-renderer - if (materialClone != null) - { - var originalColor = materialClone.color; - m_BodyMaterialOriginalColorMap[materialClone] = new ColorPair(originalColor, originalColor); - } + case VisibilityControlType.colorProperty: + foreach (var renderer in m_BodyRenderers) + { + // TODO: support for skipping the cloning of materials in the body that are shared between objects, to reduce draw calls + var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials per-renderer + if (materialClone != null) + { + var originalColor = materialClone.color; + m_BodyMaterialOriginalColorMap[materialClone] = new affordancePropertyTuple(originalColor, originalColor); + } + } + break; + case VisibilityControlType.alphaProperty: + string shaderAlphaPropety = bodyVisibilityDefinition.alphaProperty; + foreach (var renderer in m_BodyRenderers) + { + var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials per-renderer + if (materialClone != null) + { + var originalAlpha = materialClone.GetFloat(shaderAlphaPropety); + m_BodyMaterialOriginalAlphaMap[materialClone] = new affordancePropertyTuple(originalAlpha, originalAlpha); + } + } + break; } } } @@ -114,20 +134,33 @@ public bool bodyRenderersVisible return; m_BodyRenderersVisible = value; - this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateBodyVisibility(value)); + var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; + switch (bodyVisibilityDefinition.visibilityType) + { + case VisibilityControlType.colorProperty: + this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateColorBodyVisibility(value)); + break; + case VisibilityControlType.alphaProperty: + this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateAlphaBodyVisibility(value)); + break; + case VisibilityControlType.materialSwap: + SwapToHiddenMaterial(value); + break; + } } } - IEnumerator AnimateBodyVisibility(bool isVisible) + IEnumerator AnimateColorBodyVisibility(bool isVisible) { - // Cache current "from" colors + var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; foreach (var kvp in m_BodyMaterialOriginalColorMap) { - kvp.Value.animateFromColor = kvp.Key.GetColor("_Color"); + kvp.Value.animateFromValue = kvp.Key.GetColor(bodyVisibilityDefinition.colorProperty); } const float kSpeedScalar = 2f; const float kTargetAmount = 1f; + const float kHiddenValue = 0.25f; var currentAmount = 0f; while (currentAmount < kTargetAmount) { @@ -136,15 +169,54 @@ IEnumerator AnimateBodyVisibility(bool isVisible) foreach (var kvp in m_BodyMaterialOriginalColorMap) { // Set original cached color when visible, transparent when hidden - var colorFrom = kvp.Value.animateFromColor; - var colorTo = isVisible ? kvp.Value.originalColor : new Color(colorFrom.r, colorFrom.g, colorFrom.b, 0.25f); - var currentColor = Color.Lerp(colorFrom, colorTo, smoothedAmount); + var valueFrom = kvp.Value.animateFromValue; + var valueTo = isVisible ? kvp.Value.originalValue : new Color(valueFrom.r, valueFrom.g, valueFrom.b, kHiddenValue); + var currentColor = Color.Lerp(valueFrom, valueTo, smoothedAmount); kvp.Key.color = currentColor; } yield return null; } } + + IEnumerator AnimateAlphaBodyVisibility(bool isVisible) + { + var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; + foreach (var kvp in m_BodyMaterialOriginalAlphaMap) + { + kvp.Value.animateFromValue = kvp.Key.GetFloat(bodyVisibilityDefinition.alphaProperty); + } + + const float kSpeedScalar = 2f; + const float kTargetAmount = 1f; + const float kHiddenValue = 0.25f; + string shaderAlphaPropety = bodyVisibilityDefinition.alphaProperty; + var currentAmount = 0f; + while (currentAmount < kTargetAmount) + { + currentAmount += Time.unscaledDeltaTime * kSpeedScalar; + var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount); + foreach (var kvp in m_BodyMaterialOriginalAlphaMap) + { + var valueFrom = kvp.Value.animateFromValue; + var valueTo = isVisible ? kvp.Value.originalValue : kHiddenValue; + var currentAlpha = Mathf.Lerp(valueFrom, valueTo, smoothedAmount); + kvp.Key.SetFloat(shaderAlphaPropety, currentAlpha); + } + + yield return null; + } + } + + void SwapToHiddenMaterial(bool swapToHiddenMaterial) + { + var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; + var swapMaterial = swapToHiddenMaterial ? bodyVisibilityDefinition.hiddenMaterial : bodyVisibilityDefinition.originalMaterial; + foreach (var renderer in m_BodyRenderers) + { + renderer.material = swapMaterial; + } + } } } #endif From 385beea032ce265f9daaaeaaf9c33a6e8f2a70ce Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Fri, 29 Sep 2017 19:49:07 -0700 Subject: [PATCH 056/457] Add alpha & material visibility support to the ProxyAffordanceMap --- Scripts/Helpers/ProxyAffordanceMap.cs | 98 ++++++++++++++++++++------- 1 file changed, 75 insertions(+), 23 deletions(-) diff --git a/Scripts/Helpers/ProxyAffordanceMap.cs b/Scripts/Helpers/ProxyAffordanceMap.cs index 93fca5515..7764fec7f 100644 --- a/Scripts/Helpers/ProxyAffordanceMap.cs +++ b/Scripts/Helpers/ProxyAffordanceMap.cs @@ -32,49 +32,101 @@ public static void Create() public enum VisibilityControlType { colorProperty, - //alphaProperty, // TODO: Support - //materialSwap // TODO: Support + alphaProperty, + materialSwap } [Serializable] - public class ButtonObject + public class AffordanceVisibilityDefinition { - [SerializeField] - VRInputDevice.VRControl m_Control; - [SerializeField] VisibilityControlType m_VisibilityType; - //TODO Expose each visibility control type field set based on the selected visibility control type - + //TODO: Add support for alpha/float, & material swapping. Expose each visibility control type field set based on the selected visibility control type [SerializeField] // colorProperty field - string m_ColorVisibilityProperty; // Consider custom inspector that only displays this if "shaderProperty" is chosen + string m_ColorProperty; // Consider custom inspector that only displays this if this visibility type is chosen + + [SerializeField] // alphaProperty field + string m_AlphaProperty; // Consider custom inspector that only displays this if this visibility type is chosen + + [SerializeField] + Color m_HiddenColor = new Color(1f, 1f, 1f, 0f); + + [SerializeField] + float m_HiddenAlpha; - //[SerializeField] // alphaProperty field - //string m_AlphaVisibilityProperty; // Consider custom inspector that only displays this if "shaderProperty" is chosen + [SerializeField] + Material m_HiddenMaterial; + + /// + /// The original/cached color of the material + /// + public Color originalColor { get; set; } + + /// + /// The hidden color of the material + /// + public Color hiddenColor { get { return m_HiddenColor; } set { m_HiddenColor = value; } } + + /// + /// The color to lerp FROM as the current/starting color when animating visibility + /// + public Color animateFromColor { get; set; } + + /// + /// The original/cached alpha value of the material + /// + public float originalAlpha { get; set; } + + /// + /// The hidden alpha value of the material + /// + public float hiddenAlpha { get { return m_HiddenAlpha; } set { m_HiddenAlpha = value; } } + + /// + /// The alpha value to lerp FROM as the current/starting alpha when animating visibility + /// + public float animateFromAlpha { get; set; } + + /// + /// The original/cached material + /// + public Material originalMaterial { get; set; } + + /// + /// The material to with which to swap instead of animating visibility (material blending is not supported) + /// + public Material hiddenMaterial { get { return m_HiddenMaterial; } set { m_HiddenMaterial = value; } } + + public VisibilityControlType visibilityType { get { return m_VisibilityType; } } + public string colorProperty { get { return m_ColorProperty; } } + public string alphaProperty { get { return m_AlphaProperty; } } + } - //[SerializeField] // materialSwap field - //Material m_SwapMaterial; + [Serializable] + public class AffordanceDefinition + { + [SerializeField] + VRInputDevice.VRControl m_Control; - //[SerializeField] - //float m_PropertyHiddenValue; + [SerializeField] + AffordanceVisibilityDefinition m_VisibilityDefinition; public VRInputDevice.VRControl control { get { return m_Control; } } - public VisibilityControlType visibilityControlType { get { return m_VisibilityType; } } - public string colorVisibilityProperty { get { return m_ColorVisibilityProperty; } } - //public string alphaVisibilityProperty { get { return m_AlphaVisibilityProperty; } } - //public Material swapMaterial { get { return m_SwapMaterial; } } } + [Header("Non-Interactive Input-Device Body Elements")] [SerializeField] - VisibilityControlType m_BodyVisibilityType; + AffordanceVisibilityDefinition m_BodyVisibilityDefinition; + [Space(20)] + [Header("Affordances / Interactive Input-Device Elements")] [SerializeField] [FormerlySerializedAs("m_Buttons")] - ButtonObject[] m_AffordanceDefinitions; + AffordanceDefinition[] m_AffordanceDefinitions; - public ButtonObject[] AffordanceDefinitions { get { return m_AffordanceDefinitions; } } - public VisibilityControlType BodyVisibilityControlType { get { return m_BodyVisibilityType; } } + public AffordanceDefinition[] AffordanceDefinitions { get { return m_AffordanceDefinitions; } } + public AffordanceVisibilityDefinition bodyVisibilityDefinition { get { return m_BodyVisibilityDefinition; } } } } #endif From 8d4ed5c483bae3cb3a1f3213c3ba9527c2abdac9 Mon Sep 17 00:00:00 2001 From: AndrewTHEManeri Date: Sat, 30 Sep 2017 15:51:23 -0700 Subject: [PATCH 057/457] Revert "Updated readme to reference new getting started doc" --- Menus/MainMenu/MainMenu.cs | 8 +- Menus/MainMenu/Scripts/MainMenuFace.cs | 8 -- Menus/MainMenu/Scripts/MainMenuUI.cs | 4 +- Menus/ToolsMenu/ToolsMenu.cs | 2 +- .../ToolsMenuButton/ToolsMenuButton.cs | 4 - README.md | 86 +++++++++---------- Scripts/Core/EditorVR.Menus.cs | 1 + Scripts/Core/EditorVR.Tools.cs | 16 ++-- .../FunctionalityInjection/ISelectTool.cs | 7 +- Scripts/Modules/DeviceInputModule.cs | 10 +-- .../MultipleRayInputModule.cs | 10 +-- Tools/AnnotationTool/AnnotationTool.cs | 1 + Tools/LocomotionTool/LocomotionTool.cs | 5 -- 13 files changed, 60 insertions(+), 102 deletions(-) diff --git a/Menus/MainMenu/MainMenu.cs b/Menus/MainMenu/MainMenu.cs index aecebb20b..2cf72fa6e 100644 --- a/Menus/MainMenu/MainMenu.cs +++ b/Menus/MainMenu/MainMenu.cs @@ -157,9 +157,6 @@ void CreateFaceButtons() foreach (var type in types) { var customMenuAttribute = (MainMenuItemAttribute)type.GetCustomAttributes(typeof(MainMenuItemAttribute), false).FirstOrDefault(); - if (customMenuAttribute != null && !customMenuAttribute.shown) - continue; - var isTool = typeof(ITool).IsAssignableFrom(type) && menuTools.Contains(type); var isWorkspace = typeof(Workspace).IsAssignableFrom(type); var isSettingsProvider = typeof(ISettingsMenuProvider).IsAssignableFrom(type); @@ -189,14 +186,11 @@ void CreateFaceButtons() { if (targetRayOrigin) { - this.SelectTool(targetRayOrigin, selectedType, - hideMenu: typeof(IInstantiateMenuUI).IsAssignableFrom(selectedType)); + this.SelectTool(targetRayOrigin, selectedType); UpdateToolButtons(); } }); - m_ToolButtons[type] = mainMenuButton; - // Assign Tools Menu button preview properties if (mainMenuButton != null) mainMenuButton.toolType = selectedType; diff --git a/Menus/MainMenu/Scripts/MainMenuFace.cs b/Menus/MainMenu/Scripts/MainMenuFace.cs index 459c99cf6..17a80d4a5 100644 --- a/Menus/MainMenu/Scripts/MainMenuFace.cs +++ b/Menus/MainMenu/Scripts/MainMenuFace.cs @@ -181,14 +181,6 @@ public void RemoveSubmenu() else visible = true; } - - public void ClearSubmenus() - { - foreach (var submenu in m_Submenus) - { - ObjectUtils.Destroy(submenu); - } - } } } #endif diff --git a/Menus/MainMenu/Scripts/MainMenuUI.cs b/Menus/MainMenu/Scripts/MainMenuUI.cs index 32a2ef263..ba5ddb2f3 100644 --- a/Menus/MainMenu/Scripts/MainMenuUI.cs +++ b/Menus/MainMenu/Scripts/MainMenuUI.cs @@ -378,9 +378,7 @@ IEnumerator AnimateHide() foreach (var kvp in m_Faces) { - var face = kvp.Value; - face.visible = false; - face.ClearSubmenus(); + kvp.Value.visible = false; } this.RestartCoroutine(ref m_FrameRevealCoroutine, AnimateFrameReveal(m_VisibilityState)); diff --git a/Menus/ToolsMenu/ToolsMenu.cs b/Menus/ToolsMenu/ToolsMenu.cs index 86633948d..665a3103f 100644 --- a/Menus/ToolsMenu/ToolsMenu.cs +++ b/Menus/ToolsMenu/ToolsMenu.cs @@ -200,7 +200,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon m_ToolsMenuUI.HighlightSingleButtonWithoutMenu((int)(buttonCount * normalizedRepeatingPosition) + 1); } } - else if (spatialScrollData != null && !toolslMenuInput.show.isHeld && !toolslMenuInput.select.isHeld) + else if (toolslMenuInput.show.wasJustReleased) { consumeControl(toolslMenuInput.show); consumeControl(toolslMenuInput.select); diff --git a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs index 658508b4c..0518bca6d 100644 --- a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs +++ b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs @@ -519,10 +519,6 @@ void OnBackgroundButtonClick() void OnSecondaryButtonClicked() { - if (!implementsSecondaryButton) - { - return; - } this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHideAndDestroy()); closeButton(); ActionButtonHoverExit(); diff --git a/README.md b/README.md index 747c11a02..cc9bee4e2 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,43 @@ -# EditorVR -Author VR in VR - Initial public release was on December 15, 2016 via [blogpost](https://blogs.unity3d.com/2016/12/15/editorvr-experimental-build-available-today/) - -## Experimental Status -It’s important to note that EditorVR is an experimental feature. As such, there is no formal support (e.g. FogBugz, support@unity3d.com, Premium Support, etc.) offered, so please do not use these channels. Instead, take your questions, suggestions, comments to our dedicated [forum](https://forum.unity3d.com/forums/editorvr.126/). - -To help ensure you have a good experience, and to help us answer your questions (hey, we’re a small team!), we encourage you to try it out first with a small VR-ready scene. Please use life-sized objects, nothing too big or small. Dive in and have fun just playing around, instead of trying to use your existing project. - -**As with any experimental/preview/alpha/beta build, it is always a good idea to make a backup of your project before using the build.** - -Experimental means this: -- We're still adding features! -- The current menus, tools, workspaces, actions, etc. are not the end-all-be-all. Each of these have individual designs that will change as we experiment with what works best for UX. EditorVR was designed in such a way that we plan on you being able to replace all of these defaults, too, if you so desire. -- Namespaces, classes, software architecture, prefabs, etc. can change at any point. If you are writing your own tools, then you might need to update them as these things change. -- There won’t always be an upgrade path from one release to the next, so you might need to fix things manually, which leads to the next point... -- Stuff can and will break (!) -- There’s **no guarantee** that this project will move out of experimental status within any specific timeframe. -- As such, there is no guarantee that this will remain an actively supported project. - -## Getting Started -If you've made it here, but aren't accustomed to using GitHub, cloning repositories, etc. and are simply looking to give EditorVR a spin, then take a look at the [Getting Started Guide](https://docs.google.com/document/d/13Md9Z5sXNy96qyivpLOakFU-CJ5Uhpm1bS-WJp2SkWE). Once you're up and running we recommend you join the discussion on the [EditorVR forum](https://forum.unity3d.com/forums/editorvr.126/). - -## For Software Developers -If you're a developer, we recommend that you take a look at the [Getting Started Guide](https://docs.google.com/document/d/13Md9Z5sXNy96qyivpLOakFU-CJ5Uhpm1bS-WJp2SkWE) *and* the companion document [Extending EditorVR](https://docs.google.com/document/d/1EGi9hKXAujfBMI2spErojdqRc0giqEnOu0NpwgBxtpg). You'll need to clone the repository into an existing project using the instructions below. - -### Git Dependencies -- [git-lfs](https://git-lfs.github.com/) -- [git-submodule](https://git-scm.com/docs/git-submodule) - -### Cloning -1. Create a new Unity project or use an existing one -2. From the command line change directory to your project's `Assets` directory. -3. Run `git lfs clone --recursive -b development https://github.com/Unity-Technologies/EditorVR` **(Use HTTPS!)** - -### Updating -Because this project uses [git-submodule](https://git-scm.com/docs/git-submodule), you'll need to execute `git submodule update` after pulling whenever a submodule is updated. You could execute this command always just to be safe or if you notice that a submodule is showing as modified after pulling changes. - -Optionally, you could add a [git hook for post-checkout](https://ttboj.wordpress.com/2014/05/06/keeping-git-submodules-in-sync-with-your-branches/) or use a GUI (e.g. SourceTree) that does this automatically for you. - -### Project Settings -If you plan on making changes to EditorVR and/or contributing back, then you'll need to set the `Asset Serialization` property under Edit->Project Settings->Editor to `Force Text`. - -We're using `#if UNITY_EDITOR` for now in order to keep our code out of your player builds. We will eventually explore a possible overlap between EditorVR and player builds. We recommend you do the same for your tools if you plan to distribute them to others. +# EditorVR +Author VR in VR - Initial public release was on December 15, 2016 via [blogpost](https://blogs.unity3d.com/2016/12/15/editorvr-experimental-build-available-today/) + +## Experimental Status +It’s important to note that EditorVR is an experimental feature. As such, there is no formal support (e.g. FogBugz, support@unity3d.com, Premium Support, etc.) offered, so please do not use these channels. Instead, take your questions, suggestions, comments to our dedicated [forum](https://forum.unity3d.com/forums/editorvr.126/). + +To help ensure you have a good experience, and to help us answer your questions (hey, we’re a small team!), we encourage you to try it out first with a small VR-ready scene. Please use life-sized objects, nothing too big or small. Dive in and have fun just playing around, instead of trying to use your existing project. + +**As with any experimental/preview/alpha/beta build, it is always a good idea to make a backup of your project before using the build.** + +Experimental means this: +- We're still adding features! +- The current menus, tools, workspaces, actions, etc. are not the end-all-be-all. Each of these have individual designs that will change as we experiment with what works best for UX. EditorVR was designed in such a way that we plan on you being able to replace all of these defaults, too, if you so desire. +- Namespaces, classes, software architecture, prefabs, etc. can change at any point. If you are writing your own tools, then you might need to update them as these things change. +- There won’t always be an upgrade path from one release to the next, so you might need to fix things manually, which leads to the next point... +- Stuff can and will break (!) +- There’s **no guarantee** that this project will move out of experimental status within any specific timeframe. +- As such, there is no guarantee that this will remain an actively supported project. + +## Getting Started +If you've made it here, but aren't accustomed to using GitHub, cloning repositories, etc. and are simply looking to give EditorVR a spin, then take a look at the [Getting Started Guide](https://docs.google.com/document/d/1IFQve5gAOb1gQzIhhtEr3WLrctJhsoJxl6j07pg2DYA/edit). Once you're up and running we recommend you join the discussion on the [EditorVR forum](https://forum.unity3d.com/forums/editorvr.126/). + +## For Software Developers +If you're a developer, we recommend that you take a look at the [Getting Started Guide](https://docs.google.com/document/d/1IFQve5gAOb1gQzIhhtEr3WLrctJhsoJxl6j07pg2DYA) *and* the companion document [Extending EditorVR](https://docs.google.com/document/d/1EGi9hKXAujfBMI2spErojdqRc0giqEnOu0NpwgBxtpg). You'll need to clone the repository into an existing project using the instructions below. + +### Git Dependencies +- [git-lfs](https://git-lfs.github.com/) +- [git-submodule](https://git-scm.com/docs/git-submodule) + +### Cloning +1. Create a new Unity project or use an existing one +2. From the command line change directory to your project's `Assets` directory. +3. Run `git lfs clone --recursive -b development https://github.com/Unity-Technologies/EditorVR` **(Use HTTPS!)** + +### Updating +Because this project uses [git-submodule](https://git-scm.com/docs/git-submodule), you'll need to execute `git submodule update` after pulling whenever a submodule is updated. You could execute this command always just to be safe or if you notice that a submodule is showing as modified after pulling changes. + +Optionally, you could add a [git hook for post-checkout](https://ttboj.wordpress.com/2014/05/06/keeping-git-submodules-in-sync-with-your-branches/) or use a GUI (e.g. SourceTree) that does this automatically for you. + +### Project Settings +If you plan on making changes to EditorVR and/or contributing back, then you'll need to set the `Asset Serialization` property under Edit->Project Settings->Editor to `Force Text`. + +We're using `#if UNITY_EDITOR` for now in order to keep our code out of your player builds. We will eventually explore a possible overlap between EditorVR and player builds. We recommend you do the same for your tools if you plan to distribute them to others. diff --git a/Scripts/Core/EditorVR.Menus.cs b/Scripts/Core/EditorVR.Menus.cs index 28fae9d47..86e0a490e 100644 --- a/Scripts/Core/EditorVR.Menus.cs +++ b/Scripts/Core/EditorVR.Menus.cs @@ -5,6 +5,7 @@ using UnityEditor.Experimental.EditorVR.Menus; using UnityEditor.Experimental.EditorVR.Modules; using UnityEditor.Experimental.EditorVR.Utilities; +using UnityEditor.Experimental.EditorVR.Workspaces; using UnityEngine; using UnityEngine.InputNew; diff --git a/Scripts/Core/EditorVR.Tools.cs b/Scripts/Core/EditorVR.Tools.cs index d2604eb06..3378e1349 100644 --- a/Scripts/Core/EditorVR.Tools.cs +++ b/Scripts/Core/EditorVR.Tools.cs @@ -162,8 +162,6 @@ static ToolData SpawnTool(Type toolType, out HashSet usedDevices, I { usedDevices.UnionWith(actionMapInput.GetCurrentlyUsedDevices()); InputUtils.CollectDeviceSlotsFromActionMapInput(actionMapInput, ref deviceSlots); - - actionMapInput.Reset(false); } if (usedDevices.Count == 0) @@ -195,7 +193,7 @@ static bool IsToolActive(Transform targetRayOrigin, Type toolType) return result; } - internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnReselect = true, bool hideMenu = false) + internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnReselect = true) { var result = false; var deviceInputModule = evr.GetModule(); @@ -289,8 +287,7 @@ internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawn deviceInputModule.UpdatePlayerHandleMaps(); result = spawnTool; - } else if (hideMenu) - deviceData.menuHideData[deviceData.mainMenu].hideFlags |= MenuHideFlags.Hidden; + } }); return result; @@ -311,8 +308,7 @@ static void DespawnTool(DeviceData deviceData, ITool tool) return; } - var oldTool = deviceData.toolData.Pop(); - oldTool.input.active = false; + deviceData.toolData.Pop(); topTool = deviceData.toolData.Peek(); deviceData.currentTool = topTool.tool; @@ -325,8 +321,7 @@ static void DespawnTool(DeviceData deviceData, ITool tool) var otherTool = otherDeviceData.currentTool; if (otherTool == tool) { - oldTool = otherDeviceData.toolData.Pop(); - oldTool.input.active = false; + otherDeviceData.toolData.Pop(); var otherToolData = otherDeviceData.toolData.Peek(); if (otherToolData != null) otherDeviceData.currentTool = otherToolData.tool; @@ -340,8 +335,7 @@ static void DespawnTool(DeviceData deviceData, ITool tool) { if (otherTool.GetType() == toolType) { - oldTool = otherDeviceData.toolData.Pop(); - oldTool.input.active = false; + otherDeviceData.toolData.Pop(); var otherToolData = otherDeviceData.toolData.Peek(); if (otherToolData != null) { diff --git a/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs b/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs index fe77e4b39..31e098583 100644 --- a/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs +++ b/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs @@ -13,7 +13,7 @@ public interface ISelectTool public static class ISelectToolMethods { - internal static Func selectTool { get; set; } + internal static Func selectTool { get; set; } internal static Func isToolActive { get; set; } /// @@ -23,10 +23,9 @@ public static class ISelectToolMethods /// The rayOrigin that the tool should spawn under /// Type of tool to spawn/select /// Despawn the tool, if re-selected while already the current tool - /// Whether to hide the menu after selecting this tool - public static bool SelectTool(this ISelectTool obj, Transform rayOrigin, Type toolType, bool despawnOnReselect = true, bool hideMenu = false) + public static bool SelectTool(this ISelectTool obj, Transform rayOrigin, Type toolType, bool despawnOnReselect = true) { - return selectTool(rayOrigin, toolType, despawnOnReselect, hideMenu); + return selectTool(rayOrigin, toolType, despawnOnReselect); } /// diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index d3e3e97a5..2676f8989 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -67,8 +67,7 @@ public void ProcessInput() var removeList = new List(); foreach (var lockedControl in m_LockedControls) { - if (!lockedControl.provider.active || Mathf.Approximately(lockedControl.rawValue, - lockedControl.provider.GetControlData(lockedControl.index).defaultValue)) + if (Mathf.Approximately(lockedControl.rawValue, lockedControl.provider.GetControlData(lockedControl.index).defaultValue)) removeList.Add(lockedControl); else ConsumeControl(lockedControl); @@ -77,9 +76,6 @@ public void ProcessInput() // Remove separately, since we cannot remove while iterating foreach (var inputControl in removeList) { - if (!inputControl.provider.active) - ResetControl(inputControl); - m_LockedControls.Remove(inputControl); } @@ -215,11 +211,7 @@ void ConsumeControl(InputControl control) // another AMI to pick up a wasPressed the next frame, since it's own input would have been cleared. The // control is released when it returns to it's default value m_LockedControls.Add(control); - ResetControl(control); - } - void ResetControl(InputControl control) - { var ami = control.provider as ActionMapInput; var playerHandleMaps = m_PlayerHandle.maps; for (int i = 0; i < playerHandleMaps.Count; i++) diff --git a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs index c33000220..dde424972 100644 --- a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs +++ b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs @@ -141,9 +141,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon eventData.rayOrigin = rayOrigin; eventData.pointerLength = this.GetPointerLength(eventData.rayOrigin); - var sourceAMI = source.actionMapInput; - var select = sourceAMI.select; - if (source.isValid != null && !source.isValid(source)) { var currentRaycast = eventData.pointerCurrentRaycast; @@ -151,9 +148,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon eventData.pointerCurrentRaycast = currentRaycast; source.hoveredObject = null; HandlePointerExitAndEnter(eventData, null, true); // Send only exit events - - if (select.wasJustReleased) - OnSelectReleased(source); continue; } @@ -161,9 +155,11 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon var hasObject = source.hasObject; var hasScrollHandler = false; - + var sourceAMI = source.actionMapInput; sourceAMI.active = hasObject && ShouldActivateInput(eventData, source.currentObject, out hasScrollHandler); + var select = sourceAMI.select; + // Proceed only if pointer is interacting with something if (!sourceAMI.active) { diff --git a/Tools/AnnotationTool/AnnotationTool.cs b/Tools/AnnotationTool/AnnotationTool.cs index a72c5362c..760c0c151 100644 --- a/Tools/AnnotationTool/AnnotationTool.cs +++ b/Tools/AnnotationTool/AnnotationTool.cs @@ -7,6 +7,7 @@ using UnityEditor.Experimental.EditorVR; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Extensions; +using UnityEditor.Experimental.EditorVR.Menus; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 91a1a0332..96b68cd51 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -199,12 +199,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon this.SetUIBlockedForRayOrigin(rayOrigin, true); if (DoTwoHandedScaling(consumeControl)) - { - if (m_Preferences.blinkMode) - if (m_LocomotionInput.blink.isHeld) - m_BlinkVisuals.visible = false; return; - } if (DoRotating(consumeControl)) return; From 32a5fe7fc38d60f180cb69a4b24582da6d2a2c65 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Sun, 1 Oct 2017 21:11:56 -0700 Subject: [PATCH 058/457] Add renderer property to ProxyAffordanceMap; cleanup naming and attributes --- Scripts/Helpers/ProxyAffordanceMap.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Scripts/Helpers/ProxyAffordanceMap.cs b/Scripts/Helpers/ProxyAffordanceMap.cs index 7764fec7f..e0ba1a815 100644 --- a/Scripts/Helpers/ProxyAffordanceMap.cs +++ b/Scripts/Helpers/ProxyAffordanceMap.cs @@ -58,6 +58,11 @@ public class AffordanceVisibilityDefinition [SerializeField] Material m_HiddenMaterial; + /// + /// The renderer associated with this affordance + /// + public Renderer renderer { get; set; } + /// /// The original/cached color of the material /// @@ -89,9 +94,9 @@ public class AffordanceVisibilityDefinition public float animateFromAlpha { get; set; } /// - /// The original/cached material + /// The (cloned) material that will have its properties animated /// - public Material originalMaterial { get; set; } + public Material material { get; set; } /// /// The material to with which to swap instead of animating visibility (material blending is not supported) @@ -113,6 +118,7 @@ public class AffordanceDefinition AffordanceVisibilityDefinition m_VisibilityDefinition; public VRInputDevice.VRControl control { get { return m_Control; } } + public AffordanceVisibilityDefinition visibilityDefinition { get { return m_VisibilityDefinition; } } } [Header("Non-Interactive Input-Device Body Elements")] @@ -122,7 +128,6 @@ public class AffordanceDefinition [Space(20)] [Header("Affordances / Interactive Input-Device Elements")] [SerializeField] - [FormerlySerializedAs("m_Buttons")] AffordanceDefinition[] m_AffordanceDefinitions; public AffordanceDefinition[] AffordanceDefinitions { get { return m_AffordanceDefinitions; } } From 77cf5af4738eba3bae33133df8ae926c5c47ec54 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Sun, 1 Oct 2017 21:12:47 -0700 Subject: [PATCH 059/457] Update TouchAffordanceMap with new VisibilityDefinition inspector-set values --- .../AffordanceMaps/TouchAffordanceMap.asset | 85 ++++++++++++------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset b/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset index 57eb7ece9..80cfb0eae 100644 --- a/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset +++ b/Scripts/Proxies/Touch/AffordanceMaps/TouchAffordanceMap.asset @@ -11,40 +11,67 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d08c49347620dd64bbecec4a7432ed62, type: 3} m_Name: TouchAffordanceMap m_EditorClassIdentifier: - m_BodyVisibilityType: 0 + m_BodyVisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} m_AffordanceDefinitions: - m_Control: 2 - m_VisibilityType: 0 - m_ColorVisibilityProperty: _Color - m_AlphaVisibilityProperty: - m_PropertyHiddenValue: 0 + m_VisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} - m_Control: 3 - m_VisibilityType: 0 - m_ColorVisibilityProperty: - m_AlphaVisibilityProperty: - m_PropertyHiddenValue: 0 + m_VisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} - m_Control: 17 - m_VisibilityType: 0 - m_ColorVisibilityProperty: - m_AlphaVisibilityProperty: - m_PropertyHiddenValue: 0 + m_VisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} - m_Control: 18 - m_VisibilityType: 0 - m_ColorVisibilityProperty: - m_AlphaVisibilityProperty: - m_PropertyHiddenValue: 0 + m_VisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} - m_Control: 22 - m_VisibilityType: 0 - m_ColorVisibilityProperty: - m_AlphaVisibilityProperty: - m_PropertyHiddenValue: 0 + m_VisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} - m_Control: 0 - m_VisibilityType: 0 - m_ColorVisibilityProperty: - m_AlphaVisibilityProperty: - m_PropertyHiddenValue: 0 + m_VisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} - m_Control: 1 - m_VisibilityType: 0 - m_ColorVisibilityProperty: - m_AlphaVisibilityProperty: - m_PropertyHiddenValue: 0 + m_VisibilityDefinition: + m_VisibilityType: 0 + m_ColorProperty: _Color + m_AlphaProperty: + m_HiddenColor: {r: 1, g: 1, b: 1, a: 0} + m_HiddenAlpha: 0 + m_HiddenMaterial: {fileID: 0} From 38c3482003037e3d89379f0f47caf411846b94da Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Sun, 1 Oct 2017 21:14:06 -0700 Subject: [PATCH 060/457] Add affordance visibility setting, and population of ProxyUI origins, in ProxyHelper --- Scripts/Helpers/ProxyHelper.cs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index d23fbc68d..de307488f 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -109,27 +109,29 @@ public Transform meshRoot [SerializeField] VisibilityControlType m_BodyVisibilityControlType; + /// + /// Set the visibility of the renderers associated with affordances(controls/input) + /// + /// Null checking before setting, as upon EXR setup, in Awake(), m_ProxyUI is null, even though it has been assigned in the inspector + public bool affordanceRenderersVisible { set { if (m_ProxyUI != null) m_ProxyUI.affordancesVisible = value; } } + /// /// Set the visibility of the renderers not associated with controls/input /// - public bool bodyRenderersVisible { set { if (m_ProxyUI != null) m_ProxyUI.bodyRenderersVisible = value; } } + public bool bodyRenderersVisible { set { if (m_ProxyUI != null) m_ProxyUI.bodyVisible = value; } } void Start() { + // Setup ProxyUI m_ProxyUI.Affordances = m_Affordances; - } - public void ShowAllControls() - { - foreach (var button in m_Affordances) - { - button.renderer.enabled = true; - } - } - - public void HideAffordances(AffordanceObject[] affordanceObjects) - { - // HIDE specific affordances + List origins = new List(); + origins.Add(rayOrigin); + origins.Add(menuOrigin); + origins.Add(alternateMenuOrigin); + origins.Add(previewOrigin); + origins.Add(fieldGrabOrigin); + m_ProxyUI.proxyOrigins = origins; } } } From 1168bbdf96fc870a791ce9c5ec1e81a443dd3f71 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Sun, 1 Oct 2017 21:15:28 -0700 Subject: [PATCH 061/457] Add affordance visibility setting support to TwoHandedProxyBase --- Scripts/Proxies/TwoHandedProxyBase.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 7e7ba9083..db5deb911 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -87,8 +87,10 @@ public virtual bool hidden public Dictionary previewOrigins { get; set; } public Dictionary fieldGrabOrigins { get; set; } - private bool leftBodyRenderersVisible { set { m_LeftProxyHelper.bodyRenderersVisible = value; } } - private bool rightBodyRenderersVisible { set { m_RightProxyHelper.bodyRenderersVisible = value; } } + bool leftAffordanceRenderersVisible { set { m_LeftProxyHelper.affordanceRenderersVisible = value; } } + bool rightAffordanceRenderersVisible { set { m_RightProxyHelper.affordanceRenderersVisible = value; } } + bool leftBodyRenderersVisible { set { m_LeftProxyHelper.bodyRenderersVisible = value; } } + bool rightBodyRenderersVisible { set { m_RightProxyHelper.bodyRenderersVisible = value; } } public virtual void Awake() { @@ -261,7 +263,7 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) } } - UpdateBodyTransparency(); + UpdateTransparency(); } public void RemoveFeedbackRequest(FeedbackRequest request) @@ -330,7 +332,7 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) ExecuteFeedback(request); - UpdateBodyTransparency(); + UpdateTransparency(); } public void ClearFeedbackRequests(IRequestFeedback caller) @@ -346,7 +348,7 @@ public void ClearFeedbackRequests(IRequestFeedback caller) } } - void UpdateBodyTransparency() + void UpdateTransparency() { //Debug.LogError("" + m_FeedbackRequests.Count + ""); if (m_ActiveFeedbackRequests.Count > 0) @@ -355,8 +357,11 @@ void UpdateBodyTransparency() //var rightProxyRequestsExist = m_ActiveFeedbackRequests.Where(x => x.Value.node == Node.RightHand).Any(); var leftProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.LeftHand).Any(); var rightProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.RightHand).Any(); - leftBodyRenderersVisible = !leftProxyRequestsExist; - rightBodyRenderersVisible = !rightProxyRequestsExist; + + leftAffordanceRenderersVisible = leftProxyRequestsExist; + rightAffordanceRenderersVisible = rightProxyRequestsExist; + leftBodyRenderersVisible = leftProxyRequestsExist; + rightBodyRenderersVisible = rightProxyRequestsExist; } } } From d44ac77f436a701587d72a77030c238d01da5eb8 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 00:24:09 -0700 Subject: [PATCH 062/457] Add affordanceVisibilityCoroutine to the VisibilityDefinition in ProxyAffordanceMap --- Scripts/Helpers/ProxyAffordanceMap.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/Helpers/ProxyAffordanceMap.cs b/Scripts/Helpers/ProxyAffordanceMap.cs index e0ba1a815..ed10b8be2 100644 --- a/Scripts/Helpers/ProxyAffordanceMap.cs +++ b/Scripts/Helpers/ProxyAffordanceMap.cs @@ -103,6 +103,7 @@ public class AffordanceVisibilityDefinition /// public Material hiddenMaterial { get { return m_HiddenMaterial; } set { m_HiddenMaterial = value; } } + public Coroutine affordanceVisibilityCoroutine; public VisibilityControlType visibilityType { get { return m_VisibilityType; } } public string colorProperty { get { return m_ColorProperty; } } public string alphaProperty { get { return m_AlphaProperty; } } From bfd288a9e63e4fa335cdd497616c0b22431d1ee1 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 00:25:14 -0700 Subject: [PATCH 063/457] Add new ProxyUI setup requirements to ProxyHelper --- Scripts/Helpers/ProxyHelper.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index de307488f..c08416e8e 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -123,15 +123,14 @@ public Transform meshRoot void Start() { // Setup ProxyUI - m_ProxyUI.Affordances = m_Affordances; - List origins = new List(); origins.Add(rayOrigin); origins.Add(menuOrigin); origins.Add(alternateMenuOrigin); origins.Add(previewOrigin); origins.Add(fieldGrabOrigin); - m_ProxyUI.proxyOrigins = origins; + + m_ProxyUI.Setup(m_Affordances, origins); } } } From 2fe182f2af500e56b6f6328a03c2887d2bf8d4d5 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 00:29:21 -0700 Subject: [PATCH 064/457] Cleanup visibility implementation in TwoHandedProxyBase --- Scripts/Proxies/TwoHandedProxyBase.cs | 55 +++------------------------ 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index db5deb911..90438113e 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -74,8 +74,8 @@ public virtual bool hidden m_Hidden = value; m_LeftHand.gameObject.SetActive(!value); m_RightHand.gameObject.SetActive(!value); - leftBodyRenderersVisible = !value; // TODO support checking for existing feedback requests and handling body visibility when hiding/unHiding - rightBodyRenderersVisible = !value; + + UpdateVisibility(); } } } @@ -112,7 +112,6 @@ public virtual void Awake() leftButtons[button.control] = button; } m_Affordances[Node.LeftHand] = leftButtons; - //m_LeftProxyHelper.controlToAffordanceMap = leftButtons; var rightButtons = new Dictionary(); foreach (var button in m_RightProxyHelper.Affordances) @@ -120,7 +119,6 @@ public virtual void Awake() rightButtons[button.control] = button; } m_Affordances[Node.RightHand] = rightButtons; - //m_RightProxyHelper.controlToAffordanceMap = rightButtons; m_RayOrigins = new Dictionary { @@ -248,14 +246,6 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) { tooltip.tooltipText = tooltipText; this.ShowTooltip(tooltip, true, k_FeedbackDuration); - - /* - var existingFeedback = m_ActiveFeedbackRequests.ContainsKey(tooltip); - if (existingFeedback) - m_ActiveFeedbackRequests[tooltip] = request; // Tooltips will hide themselves, replace the last existing reference - else - m_ActiveFeedbackRequests.Add(tooltip, request); - */ } } @@ -263,48 +253,20 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) } } - UpdateTransparency(); + UpdateVisibility(); } public void RemoveFeedbackRequest(FeedbackRequest request) { - Debug.LogError("RequestRemoved - PUBLIC"); m_ActiveFeedbackRequests[Node.LeftHand] -= 1; // Increase feedback request count for this hand/node var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) RemoveFeedbackRequest(proxyRequest); - - /* - var existingFeedback = m_ActiveFeedbackRequests.ContainsValue(proxyRequest); - if (existingFeedback) - { - //m_ActiveFeedbackRequests.Remove()[tooltip] = request; // Tooltips will hide themselves, remove the last existing reference - var tooltip = m_ActiveFeedbackRequests.FirstOrDefault(x => x.Value == proxyRequest).Key; - if (tooltip != null) - m_ActiveFeedbackRequests.Remove(tooltip); - } - - foreach (var proxyNode in m_Buttons) - { - foreach (var kvp in proxyNode.Value) - { - var button = kvp.Value; - foreach (var x in m_ActiveFeedbackRequests.Values) - { - - } - } - - var existingFeedback = m_ActiveFeedbackRequests.ContainsKey(tooltip); - if (existingFeedback) - m_ActiveFeedbackRequests.Remove(tooltip); // Tooltips will hide themselves, remove the last existing reference - */ } void RemoveFeedbackRequest(ProxyFeedbackRequest request) { - Debug.LogError("RequestRemoved - PRIVATE"); Dictionary buttons; if (m_Affordances.TryGetValue(request.node, out buttons)) { @@ -321,18 +283,16 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) { tooltip.tooltipText = string.Empty; this.HideTooltip(tooltip, true); - //m_ActiveFeedbackRequests.Remove(tooltip); } } } } - //m_ActiveFeedbackRequests[Node.LeftHand] -= 1; // Increase feedback request count for this hand/node m_FeedbackRequests.Remove(request); ExecuteFeedback(request); - UpdateTransparency(); + UpdateVisibility(); } public void ClearFeedbackRequests(IRequestFeedback caller) @@ -344,17 +304,14 @@ public void ClearFeedbackRequests(IRequestFeedback caller) foreach (var feedbackRequest in requests) { RemoveFeedbackRequest(feedbackRequest); - //m_ActiveFeedbackRequests.Remove(feedbackRequest.tooltipText); } } - void UpdateTransparency() + void UpdateVisibility() { - //Debug.LogError("" + m_FeedbackRequests.Count + ""); + Debug.LogError("" + m_FeedbackRequests.Count + ""); if (m_ActiveFeedbackRequests.Count > 0) { - //var leftProxyRequestsExist = m_ActiveFeedbackRequests.Where(x => x.Value.node == Node.LeftHand).Any(); - //var rightProxyRequestsExist = m_ActiveFeedbackRequests.Where(x => x.Value.node == Node.RightHand).Any(); var leftProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.LeftHand).Any(); var rightProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.RightHand).Any(); From 932f9af5084163efbc78999994cc7ef2237f7cf0 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 00:40:36 -0700 Subject: [PATCH 065/457] Add affordance color, alpha, and material funcitonality to ProxyUI; Prevent control of content under any ProxyOrigins --- Scripts/Helpers/ProxyUI.cs | 209 +++++++++++++++++++++++++++++++------ 1 file changed, 177 insertions(+), 32 deletions(-) diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index 97ae0bffa..1b34c3aa8 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -6,27 +6,32 @@ using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; -using UnityEngine.InputNew; using VisibilityControlType = UnityEditor.Experimental.EditorVR.Core.ProxyAffordanceMap.VisibilityControlType; +using AffordanceDefinition = UnityEditor.Experimental.EditorVR.Core.ProxyAffordanceMap.AffordanceDefinition; namespace UnityEditor.Experimental.EditorVR.Proxies { public class ProxyUI : MonoBehaviour { - List m_BodyRenderers; // Renderers not associated with controls, & will be hidden when displaying feedback/tooltips - bool m_BodyRenderersVisible = true; // Renderers default to visible/true + private const string k_ZWritePropertyName = "_ZWrite"; + + List m_BodyRenderers; // Renderers not associated with affordances/controls, & will be HIDDEN when displaying feedback/tooltips + List m_AffordanceRenderers; // Renderers associated with affordances/controls, & will be SHOWN when displaying feedback/tooltips + bool m_BodyRenderersVisible = true; // Body renderers default to visible/true + bool m_AffordanceRenderersVisible = true; // Affordance renderers default to visible/true AffordanceObject[] m_Affordances; - //List m_BodyMaterials; // Collection of unique body MeshRenderer materials // TODO : delete, no longer used? Coroutine m_BodyVisibilityCoroutine; + /// + /// Collection of proxy origins under which not to perform any affordance/body visibility changes + /// + List m_ProxyOrigins; + // Map of unique body materials to their original Colors (used for affordances with the "color" visibility control type) // The second param, ColorPair, houses the original cached color, and a value, representing the color to lerp FROM when animating visibility Dictionary> m_BodyMaterialOriginalColorMap = new Dictionary>(); Dictionary> m_BodyMaterialOriginalAlphaMap = new Dictionary>(); - // Used to draw visual attention to individual affordances - Dictionary> m_AffordanceMaterialOriginalColorMap = new Dictionary>(); - [SerializeField] ProxyAffordanceMap m_AffordanceMap; @@ -36,7 +41,7 @@ public class ProxyUI : MonoBehaviour /// as opposed to individual interactable affordances, which each have their own AffordanceVisibilityDefinition, which contains their unique value data. /// This is a lightweight class to store that data, alleviating the need to duplicate an affordance definition for each body renderer as well. /// - private class affordancePropertyTuple + class affordancePropertyTuple { public T originalValue { get; private set; } public T animateFromValue { get; set; } @@ -51,7 +56,7 @@ public affordancePropertyTuple(T originalValue, T animateFromValue) /// /// Set ProxyHelper affordances in this ProxyUI /// - public AffordanceObject[] Affordances + AffordanceObject[] affordances { set { @@ -65,7 +70,7 @@ public AffordanceObject[] Affordances } m_Affordances = value; - var affordanceRenderers = new List(); + m_AffordanceRenderers = new List(); foreach (var affordanceDefinition in m_AffordanceMap.AffordanceDefinitions) { var control = affordanceDefinition.control; @@ -78,11 +83,17 @@ public AffordanceObject[] Affordances var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials if (materialClone != null) { + var visualDefinition = affordanceDefinition.visibilityDefinition; var originalColor = materialClone.color; - var materialToOriginalColorMap = new Dictionary(); - affordanceRenderers.Add(renderer); // Add to collection for later comparison against body renderers - materialToOriginalColorMap[materialClone] = originalColor; - m_AffordanceMaterialOriginalColorMap[control] = materialToOriginalColorMap; + m_AffordanceRenderers.Add(renderer); // Add to collection for later optimized comparison against body renderers + visualDefinition.renderer = renderer; + visualDefinition.originalColor = originalColor; + visualDefinition.material = materialClone; + + // Clone that utilize the standard can be cloned and lose their ZWrite value (1), if it was enabled on the material + // Set it again, to avoid ZWrite + transparency visual issues + if (materialClone.HasProperty(k_ZWritePropertyName)) + materialClone.SetFloat(k_ZWritePropertyName, 1); } } } @@ -91,18 +102,20 @@ public AffordanceObject[] Affordances // Collect renderers not associated with affordances // Material swaps don't need to cache original values, only alpha & color var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; - m_BodyRenderers = GetComponentsInChildren(true).Where(x => !affordanceRenderers.Contains(x)).ToList(); - Debug.LogWarning("Don't collect renderers from the menu origins!!!"); + m_BodyRenderers = GetComponentsInChildren(true).Where(x => !m_AffordanceRenderers.Contains(x) && !IsChildOfProxyOrigin(x.transform)).ToList(); switch (m_AffordanceMap.bodyVisibilityDefinition.visibilityType) { case VisibilityControlType.colorProperty: foreach (var renderer in m_BodyRenderers) { - // TODO: support for skipping the cloning of materials in the body that are shared between objects, to reduce draw calls + // TODO: support for skipping the cloning of materials in the body that are shared between objects, in order to reduce draw calls var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials per-renderer if (materialClone != null) { var originalColor = materialClone.color; + if (materialClone.HasProperty(k_ZWritePropertyName)) + materialClone.SetFloat(k_ZWritePropertyName, 1); + m_BodyMaterialOriginalColorMap[materialClone] = new affordancePropertyTuple(originalColor, originalColor); } } @@ -115,6 +128,9 @@ public AffordanceObject[] Affordances if (materialClone != null) { var originalAlpha = materialClone.GetFloat(shaderAlphaPropety); + if (materialClone.HasProperty(k_ZWritePropertyName)) + materialClone.SetFloat(k_ZWritePropertyName, 1); + m_BodyMaterialOriginalAlphaMap[materialClone] = new affordancePropertyTuple(originalAlpha, originalAlpha); } } @@ -123,34 +139,124 @@ public AffordanceObject[] Affordances } } + /// + /// Set the visibility of the affordance renderers that are associated with controls/input + /// + public bool affordancesVisible + { + set + { + if (m_ProxyOrigins == null || !gameObject.activeInHierarchy || m_AffordanceRenderersVisible == value) + return; + + m_AffordanceRenderersVisible = value; + foreach (var affordanceDefinition in m_AffordanceMap.AffordanceDefinitions) + { + var visibilityDefinition = affordanceDefinition.visibilityDefinition; + switch (visibilityDefinition.visibilityType) + { + case VisibilityControlType.colorProperty: + this.RestartCoroutine(ref visibilityDefinition.affordanceVisibilityCoroutine, AnimateAffordanceColorVisibility(value, affordanceDefinition)); + break; + case VisibilityControlType.alphaProperty: + this.RestartCoroutine(ref visibilityDefinition.affordanceVisibilityCoroutine, AnimateAffordanceAlphaVisibility(value, affordanceDefinition)); + break; + case VisibilityControlType.materialSwap: + SwapAffordanceToHiddenMaterial(value, affordanceDefinition); + break; + } + } + } + } + /// /// Set the visibility of the renderers not associated with controls/input /// - public bool bodyRenderersVisible + public bool bodyVisible { set { - if (!gameObject.activeInHierarchy || m_BodyRenderersVisible == value) + if (m_ProxyOrigins == null || !gameObject.activeInHierarchy || m_BodyRenderersVisible == value) return; m_BodyRenderersVisible = value; - var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; - switch (bodyVisibilityDefinition.visibilityType) + var visibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; + switch (visibilityDefinition.visibilityType) { case VisibilityControlType.colorProperty: - this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateColorBodyVisibility(value)); + this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateBodyColorVisibility(value)); break; case VisibilityControlType.alphaProperty: - this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateAlphaBodyVisibility(value)); + this.RestartCoroutine(ref m_BodyVisibilityCoroutine, AnimateBodyAlphaVisibility(value)); break; case VisibilityControlType.materialSwap: - SwapToHiddenMaterial(value); + SwapBodyToHiddenMaterial(value); break; } } } - IEnumerator AnimateColorBodyVisibility(bool isVisible) + /// + /// Setup this ProxyUI + /// + /// The ProxyHelper affordances that drive visual changes in the ProxyUI + /// ProxyOrigins whose child renderers will not be controlled by the PRoxyUI + public void Setup(AffordanceObject[] affordances, List proxyOrigins) + { + // Set affordances AFTER setting origins, as the origins are referenced when setting up affordances + m_ProxyOrigins = proxyOrigins; + this.affordances = affordances; + affordancesVisible = false; + bodyVisible = false; + } + + IEnumerator AnimateAffordanceColorVisibility(bool isVisible, AffordanceDefinition definition) + { + // Set original cached color when visible, transparent when hidden + const float kSpeedScalar = 2f; + const float kTargetAmount = 1f; + const float kHiddenValue = 0.25f; + var currentAmount = 0f; + var visibilityDefinition = definition.visibilityDefinition; + var material = visibilityDefinition.material; + var shaderColorPropety = visibilityDefinition.colorProperty; + var animateFromColor = material.GetColor(shaderColorPropety); + var animateToColor = isVisible ? visibilityDefinition.originalColor : new Color(animateFromColor.r, animateFromColor.g, animateFromColor.b, kHiddenValue); + while (currentAmount < kTargetAmount) + { + var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount += Time.unscaledDeltaTime * kSpeedScalar); + var currentColor = Color.Lerp(animateFromColor, animateToColor, smoothedAmount); + material.SetColor(shaderColorPropety, currentColor); + + yield return null; + } + } + + IEnumerator AnimateAffordanceAlphaVisibility(bool isVisible, AffordanceDefinition definition) + { + const float kSpeedScalar = 2f; + const float kTargetAmount = 1f; + const float kHiddenValue = 0.25f; + var visibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; + var material = visibilityDefinition.material; + string shaderAlphaPropety = visibilityDefinition.alphaProperty; + var animateFromAlpha = material.GetFloat(shaderAlphaPropety); + var animateToAlpha = isVisible ? visibilityDefinition.originalAlpha : kHiddenValue; + var currentAmount = 0f; + while (currentAmount < kTargetAmount) + { + var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount += Time.unscaledDeltaTime * kSpeedScalar); + var currentAlpha = Mathf.Lerp(animateFromAlpha, animateToAlpha, smoothedAmount); + material.SetFloat(shaderAlphaPropety, currentAlpha); + + yield return null; + } + + // Mandate target value has been set + material.SetFloat(shaderAlphaPropety, animateToAlpha); + } + + IEnumerator AnimateBodyColorVisibility(bool isVisible) { var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; foreach (var kvp in m_BodyMaterialOriginalColorMap) @@ -164,8 +270,7 @@ IEnumerator AnimateColorBodyVisibility(bool isVisible) var currentAmount = 0f; while (currentAmount < kTargetAmount) { - currentAmount += Time.unscaledDeltaTime * kSpeedScalar; - var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount); + var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount += Time.unscaledDeltaTime * kSpeedScalar); foreach (var kvp in m_BodyMaterialOriginalColorMap) { // Set original cached color when visible, transparent when hidden @@ -177,9 +282,16 @@ IEnumerator AnimateColorBodyVisibility(bool isVisible) yield return null; } + + // Mandate target values have been set + foreach (var kvp in m_BodyMaterialOriginalColorMap) + { + var originalColor = kvp.Value.originalValue; + kvp.Key.color = isVisible ? originalColor : new Color(originalColor.r, originalColor.g, originalColor.b, kHiddenValue); + } } - IEnumerator AnimateAlphaBodyVisibility(bool isVisible) + IEnumerator AnimateBodyAlphaVisibility(bool isVisible) { var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; foreach (var kvp in m_BodyMaterialOriginalAlphaMap) @@ -194,8 +306,7 @@ IEnumerator AnimateAlphaBodyVisibility(bool isVisible) var currentAmount = 0f; while (currentAmount < kTargetAmount) { - currentAmount += Time.unscaledDeltaTime * kSpeedScalar; - var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount); + var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount += Time.unscaledDeltaTime * kSpeedScalar); foreach (var kvp in m_BodyMaterialOriginalAlphaMap) { var valueFrom = kvp.Value.animateFromValue; @@ -206,17 +317,51 @@ IEnumerator AnimateAlphaBodyVisibility(bool isVisible) yield return null; } + + // Mandate target values have been set + foreach (var kvp in m_BodyMaterialOriginalAlphaMap) + { + kvp.Key.SetFloat(shaderAlphaPropety, isVisible ? kvp.Value.originalValue : kHiddenValue); + } + } + + void SwapAffordanceToHiddenMaterial(bool swapToHiddenMaterial, AffordanceDefinition definition) + { + var visibilityDefinition = definition.visibilityDefinition; + var swapMaterial = swapToHiddenMaterial ? visibilityDefinition.hiddenMaterial : visibilityDefinition.material; + var renderer = visibilityDefinition.renderer; + renderer.material = swapMaterial; } - void SwapToHiddenMaterial(bool swapToHiddenMaterial) + void SwapBodyToHiddenMaterial(bool swapToHiddenMaterial) { var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; - var swapMaterial = swapToHiddenMaterial ? bodyVisibilityDefinition.hiddenMaterial : bodyVisibilityDefinition.originalMaterial; + var swapMaterial = swapToHiddenMaterial ? bodyVisibilityDefinition.hiddenMaterial : bodyVisibilityDefinition.material; foreach (var renderer in m_BodyRenderers) { renderer.material = swapMaterial; } } + + bool IsChildOfProxyOrigin(Transform transform) + { + // Prevent any menu/origin content from having its visibility changed + var isChild = false; + foreach (var origin in m_ProxyOrigins) + { + // m_ProxyOrgins is populated by ProxyHelper + // Validate that the transform param is not a child of any proxy origins + // Those objects shouldn't have their visibility changed by the ProxyUI + // Their individual controllers should handle their visibility + if (transform.IsChildOf(origin)) + { + isChild = true; + break; + } + } + + return isChild; + } } } #endif From 2fe7bbe0fa6e5f5c84b324db74a903ef63d4c9d8 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 00:43:26 -0700 Subject: [PATCH 066/457] Arrange affordance & body renderer visibility setting order in UpdateVisibility --- Scripts/Proxies/TwoHandedProxyBase.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 90438113e..de2c81e73 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -312,13 +312,14 @@ void UpdateVisibility() Debug.LogError("" + m_FeedbackRequests.Count + ""); if (m_ActiveFeedbackRequests.Count > 0) { - var leftProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.LeftHand).Any(); var rightProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.RightHand).Any(); + var leftProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.LeftHand).Any(); - leftAffordanceRenderersVisible = leftProxyRequestsExist; rightAffordanceRenderersVisible = rightProxyRequestsExist; - leftBodyRenderersVisible = leftProxyRequestsExist; rightBodyRenderersVisible = rightProxyRequestsExist; + + leftAffordanceRenderersVisible = leftProxyRequestsExist; + leftBodyRenderersVisible = leftProxyRequestsExist; } } } From e6e1515f5d8f837dd523a487ff06694364f7126f Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 01:06:14 -0700 Subject: [PATCH 067/457] Clone ProxyAffordanceMaps in ProxyUI, allowing a single map to drive many proxies that share a common visual definition --- Scripts/Helpers/ProxyUI.cs | 4 ++++ Scripts/Proxies/TwoHandedProxyBase.cs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index 1b34c3aa8..a7f86a17c 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -69,6 +69,10 @@ AffordanceObject[] affordances return; } + // Clone the affordance map, in order to allow a single map to drive the visuals of many duplicate + // This also allows coroutine sets in the ProxyAffordanceMap to be performed simultaneously for n-number of devices in a proxy + m_AffordanceMap = Instantiate(m_AffordanceMap); + m_Affordances = value; m_AffordanceRenderers = new List(); foreach (var affordanceDefinition in m_AffordanceMap.AffordanceDefinitions) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index de2c81e73..7e01b9c5d 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -183,7 +183,9 @@ public virtual IEnumerator Start() public virtual void OnDestroy() { foreach (var m in m_Materials) + { ObjectUtils.Destroy(m); + } } public virtual void Update() From ff6eeb6d1f899de34b07f9477a9eb659f9abd5ee Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 01:53:29 -0700 Subject: [PATCH 068/457] Remove ActiveFeedbackRequests collection in TwoHandedProxyBase, no longer needed --- Scripts/Proxies/TwoHandedProxyBase.cs | 39 +++++++++++---------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 7e01b9c5d..7a1003ddb 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -39,13 +39,11 @@ abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, IS protected Transform m_RightHand; readonly List m_Materials = new List(); readonly List m_FeedbackRequests = new List(); - readonly Dictionary m_ActiveFeedbackRequests = new Dictionary(); protected Dictionary m_RayOrigins; ProxyHelper m_LeftProxyHelper; ProxyHelper m_RightProxyHelper; - int m_ElementsHighlighted; List m_ProxyMeshRoots = new List(); readonly Dictionary> m_Affordances = new Dictionary>(); @@ -103,9 +101,6 @@ public virtual void Awake() m_ProxyMeshRoots.Add(m_LeftProxyHelper.meshRoot); m_ProxyMeshRoots.Add(m_RightProxyHelper.meshRoot); - m_ActiveFeedbackRequests.Add(Node.LeftHand, 0); - m_ActiveFeedbackRequests.Add(Node.RightHand, 0); - var leftButtons = new Dictionary(); foreach (var button in m_LeftProxyHelper.Affordances) { @@ -199,20 +194,19 @@ public virtual void Update() m_RightHand.localRotation = trackedObjectInput.rightRotation.quaternion; Debug.LogError("FeedbackRequests: " + m_FeedbackRequests.Count + ""); - Debug.LogError("ACTIVE LEFT FeedbackRequests: " + m_ActiveFeedbackRequests[Node.LeftHand] + ""); } } public void AddFeedbackRequest(FeedbackRequest request) { - //validate requests for duplicates - Debug.LogError("RequestAdded"); var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) { - m_FeedbackRequests.Add(proxyRequest); // TODO delete after dictionary addition? + m_FeedbackRequests.Add(proxyRequest); ExecuteFeedback(proxyRequest); } + + UpdateVisibility(); } void ExecuteFeedback(ProxyFeedbackRequest changedRequest) @@ -242,7 +236,7 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) if (button.transform) { - var tooltip = button.transform.GetComponent(); // TODO optimize GetComponent calls on buttons via cacheing + var tooltip = button.transform.GetComponent(); var tooltipText = request.tooltipText; if (!string.IsNullOrEmpty(tooltipText) && tooltip) { @@ -251,20 +245,17 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) } } - m_ActiveFeedbackRequests[Node.LeftHand] += 1; // Increase feedback request count for this hand/node } } - - UpdateVisibility(); } public void RemoveFeedbackRequest(FeedbackRequest request) { - m_ActiveFeedbackRequests[Node.LeftHand] -= 1; // Increase feedback request count for this hand/node - var proxyRequest = request as ProxyFeedbackRequest; if (proxyRequest != null) + { RemoveFeedbackRequest(proxyRequest); + } } void RemoveFeedbackRequest(ProxyFeedbackRequest request) @@ -312,17 +303,19 @@ public void ClearFeedbackRequests(IRequestFeedback caller) void UpdateVisibility() { Debug.LogError("" + m_FeedbackRequests.Count + ""); - if (m_ActiveFeedbackRequests.Count > 0) + var rightProxyRequestsExist = false; + var leftProxyRequestsExist = false; + if (m_FeedbackRequests.Count > 0) { - var rightProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.RightHand).Any(); - var leftProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.LeftHand).Any(); + rightProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.RightHand).Any(); + leftProxyRequestsExist = m_FeedbackRequests.Where(x => x.node == Node.LeftHand).Any(); + } - rightAffordanceRenderersVisible = rightProxyRequestsExist; - rightBodyRenderersVisible = rightProxyRequestsExist; + rightAffordanceRenderersVisible = rightProxyRequestsExist; + rightBodyRenderersVisible = rightProxyRequestsExist; - leftAffordanceRenderersVisible = leftProxyRequestsExist; - leftBodyRenderersVisible = leftProxyRequestsExist; - } + leftAffordanceRenderersVisible = leftProxyRequestsExist; + leftBodyRenderersVisible = leftProxyRequestsExist; } } } From c1a139fa03b6709cc51ea444634b97f3910f6743 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 02:08:04 -0700 Subject: [PATCH 069/457] Remove extra visibility updates from TwoHandedProxyBase --- Scripts/Proxies/TwoHandedProxyBase.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 7a1003ddb..e98bc2e17 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -205,8 +205,6 @@ public void AddFeedbackRequest(FeedbackRequest request) m_FeedbackRequests.Add(proxyRequest); ExecuteFeedback(proxyRequest); } - - UpdateVisibility(); } void ExecuteFeedback(ProxyFeedbackRequest changedRequest) @@ -244,9 +242,10 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) this.ShowTooltip(tooltip, true, k_FeedbackDuration); } } - } } + + UpdateVisibility(); } public void RemoveFeedbackRequest(FeedbackRequest request) @@ -284,8 +283,6 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) m_FeedbackRequests.Remove(request); ExecuteFeedback(request); - - UpdateVisibility(); } public void ClearFeedbackRequests(IRequestFeedback caller) From fbf1461828e08e8782d8ec77956410cb657edf8e Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 02:17:10 -0700 Subject: [PATCH 070/457] Force-set the target affordance color at the end of AnimateAffordanceColorVisibility coroutine --- Scripts/Helpers/ProxyUI.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index a7f86a17c..c7644fd2f 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -217,7 +217,7 @@ public void Setup(AffordanceObject[] affordances, List proxyOrigins) IEnumerator AnimateAffordanceColorVisibility(bool isVisible, AffordanceDefinition definition) { // Set original cached color when visible, transparent when hidden - const float kSpeedScalar = 2f; + const float kSpeedScalar = 3f; const float kTargetAmount = 1f; const float kHiddenValue = 0.25f; var currentAmount = 0f; @@ -234,11 +234,13 @@ IEnumerator AnimateAffordanceColorVisibility(bool isVisible, AffordanceDefinitio yield return null; } + + material.SetColor(shaderColorPropety, animateToColor); } IEnumerator AnimateAffordanceAlphaVisibility(bool isVisible, AffordanceDefinition definition) { - const float kSpeedScalar = 2f; + const float kSpeedScalar = 3f; const float kTargetAmount = 1f; const float kHiddenValue = 0.25f; var visibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; From 10828f5afc01f4665aaef4176ce4b43b6a5e0327 Mon Sep 17 00:00:00 2001 From: AndrewTHEManeri Date: Mon, 2 Oct 2017 11:43:53 -0700 Subject: [PATCH 071/457] Revert "*ignore* re-syncing staging and dev" --- Menus/MainMenu/MainMenu.cs | 8 +- Menus/MainMenu/Scripts/MainMenuFace.cs | 8 ++ Menus/MainMenu/Scripts/MainMenuUI.cs | 4 +- Menus/ToolsMenu/ToolsMenu.cs | 2 +- .../ToolsMenuButton/ToolsMenuButton.cs | 4 + README.md | 86 +++++++++---------- Scripts/Core/EditorVR.Menus.cs | 1 - Scripts/Core/EditorVR.Tools.cs | 16 ++-- .../FunctionalityInjection/ISelectTool.cs | 7 +- Scripts/Modules/DeviceInputModule.cs | 10 ++- .../MultipleRayInputModule.cs | 10 ++- Tools/AnnotationTool/AnnotationTool.cs | 1 - Tools/LocomotionTool/LocomotionTool.cs | 5 ++ 13 files changed, 102 insertions(+), 60 deletions(-) diff --git a/Menus/MainMenu/MainMenu.cs b/Menus/MainMenu/MainMenu.cs index 2cf72fa6e..aecebb20b 100644 --- a/Menus/MainMenu/MainMenu.cs +++ b/Menus/MainMenu/MainMenu.cs @@ -157,6 +157,9 @@ void CreateFaceButtons() foreach (var type in types) { var customMenuAttribute = (MainMenuItemAttribute)type.GetCustomAttributes(typeof(MainMenuItemAttribute), false).FirstOrDefault(); + if (customMenuAttribute != null && !customMenuAttribute.shown) + continue; + var isTool = typeof(ITool).IsAssignableFrom(type) && menuTools.Contains(type); var isWorkspace = typeof(Workspace).IsAssignableFrom(type); var isSettingsProvider = typeof(ISettingsMenuProvider).IsAssignableFrom(type); @@ -186,11 +189,14 @@ void CreateFaceButtons() { if (targetRayOrigin) { - this.SelectTool(targetRayOrigin, selectedType); + this.SelectTool(targetRayOrigin, selectedType, + hideMenu: typeof(IInstantiateMenuUI).IsAssignableFrom(selectedType)); UpdateToolButtons(); } }); + m_ToolButtons[type] = mainMenuButton; + // Assign Tools Menu button preview properties if (mainMenuButton != null) mainMenuButton.toolType = selectedType; diff --git a/Menus/MainMenu/Scripts/MainMenuFace.cs b/Menus/MainMenu/Scripts/MainMenuFace.cs index 17a80d4a5..459c99cf6 100644 --- a/Menus/MainMenu/Scripts/MainMenuFace.cs +++ b/Menus/MainMenu/Scripts/MainMenuFace.cs @@ -181,6 +181,14 @@ public void RemoveSubmenu() else visible = true; } + + public void ClearSubmenus() + { + foreach (var submenu in m_Submenus) + { + ObjectUtils.Destroy(submenu); + } + } } } #endif diff --git a/Menus/MainMenu/Scripts/MainMenuUI.cs b/Menus/MainMenu/Scripts/MainMenuUI.cs index ba5ddb2f3..32a2ef263 100644 --- a/Menus/MainMenu/Scripts/MainMenuUI.cs +++ b/Menus/MainMenu/Scripts/MainMenuUI.cs @@ -378,7 +378,9 @@ IEnumerator AnimateHide() foreach (var kvp in m_Faces) { - kvp.Value.visible = false; + var face = kvp.Value; + face.visible = false; + face.ClearSubmenus(); } this.RestartCoroutine(ref m_FrameRevealCoroutine, AnimateFrameReveal(m_VisibilityState)); diff --git a/Menus/ToolsMenu/ToolsMenu.cs b/Menus/ToolsMenu/ToolsMenu.cs index 665a3103f..86633948d 100644 --- a/Menus/ToolsMenu/ToolsMenu.cs +++ b/Menus/ToolsMenu/ToolsMenu.cs @@ -200,7 +200,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon m_ToolsMenuUI.HighlightSingleButtonWithoutMenu((int)(buttonCount * normalizedRepeatingPosition) + 1); } } - else if (toolslMenuInput.show.wasJustReleased) + else if (spatialScrollData != null && !toolslMenuInput.show.isHeld && !toolslMenuInput.select.isHeld) { consumeControl(toolslMenuInput.show); consumeControl(toolslMenuInput.select); diff --git a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs index 0518bca6d..658508b4c 100644 --- a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs +++ b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs @@ -519,6 +519,10 @@ void OnBackgroundButtonClick() void OnSecondaryButtonClicked() { + if (!implementsSecondaryButton) + { + return; + } this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHideAndDestroy()); closeButton(); ActionButtonHoverExit(); diff --git a/README.md b/README.md index cc9bee4e2..747c11a02 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,43 @@ -# EditorVR -Author VR in VR - Initial public release was on December 15, 2016 via [blogpost](https://blogs.unity3d.com/2016/12/15/editorvr-experimental-build-available-today/) - -## Experimental Status -It’s important to note that EditorVR is an experimental feature. As such, there is no formal support (e.g. FogBugz, support@unity3d.com, Premium Support, etc.) offered, so please do not use these channels. Instead, take your questions, suggestions, comments to our dedicated [forum](https://forum.unity3d.com/forums/editorvr.126/). - -To help ensure you have a good experience, and to help us answer your questions (hey, we’re a small team!), we encourage you to try it out first with a small VR-ready scene. Please use life-sized objects, nothing too big or small. Dive in and have fun just playing around, instead of trying to use your existing project. - -**As with any experimental/preview/alpha/beta build, it is always a good idea to make a backup of your project before using the build.** - -Experimental means this: -- We're still adding features! -- The current menus, tools, workspaces, actions, etc. are not the end-all-be-all. Each of these have individual designs that will change as we experiment with what works best for UX. EditorVR was designed in such a way that we plan on you being able to replace all of these defaults, too, if you so desire. -- Namespaces, classes, software architecture, prefabs, etc. can change at any point. If you are writing your own tools, then you might need to update them as these things change. -- There won’t always be an upgrade path from one release to the next, so you might need to fix things manually, which leads to the next point... -- Stuff can and will break (!) -- There’s **no guarantee** that this project will move out of experimental status within any specific timeframe. -- As such, there is no guarantee that this will remain an actively supported project. - -## Getting Started -If you've made it here, but aren't accustomed to using GitHub, cloning repositories, etc. and are simply looking to give EditorVR a spin, then take a look at the [Getting Started Guide](https://docs.google.com/document/d/1IFQve5gAOb1gQzIhhtEr3WLrctJhsoJxl6j07pg2DYA/edit). Once you're up and running we recommend you join the discussion on the [EditorVR forum](https://forum.unity3d.com/forums/editorvr.126/). - -## For Software Developers -If you're a developer, we recommend that you take a look at the [Getting Started Guide](https://docs.google.com/document/d/1IFQve5gAOb1gQzIhhtEr3WLrctJhsoJxl6j07pg2DYA) *and* the companion document [Extending EditorVR](https://docs.google.com/document/d/1EGi9hKXAujfBMI2spErojdqRc0giqEnOu0NpwgBxtpg). You'll need to clone the repository into an existing project using the instructions below. - -### Git Dependencies -- [git-lfs](https://git-lfs.github.com/) -- [git-submodule](https://git-scm.com/docs/git-submodule) - -### Cloning -1. Create a new Unity project or use an existing one -2. From the command line change directory to your project's `Assets` directory. -3. Run `git lfs clone --recursive -b development https://github.com/Unity-Technologies/EditorVR` **(Use HTTPS!)** - -### Updating -Because this project uses [git-submodule](https://git-scm.com/docs/git-submodule), you'll need to execute `git submodule update` after pulling whenever a submodule is updated. You could execute this command always just to be safe or if you notice that a submodule is showing as modified after pulling changes. - -Optionally, you could add a [git hook for post-checkout](https://ttboj.wordpress.com/2014/05/06/keeping-git-submodules-in-sync-with-your-branches/) or use a GUI (e.g. SourceTree) that does this automatically for you. - -### Project Settings -If you plan on making changes to EditorVR and/or contributing back, then you'll need to set the `Asset Serialization` property under Edit->Project Settings->Editor to `Force Text`. - -We're using `#if UNITY_EDITOR` for now in order to keep our code out of your player builds. We will eventually explore a possible overlap between EditorVR and player builds. We recommend you do the same for your tools if you plan to distribute them to others. +# EditorVR +Author VR in VR - Initial public release was on December 15, 2016 via [blogpost](https://blogs.unity3d.com/2016/12/15/editorvr-experimental-build-available-today/) + +## Experimental Status +It’s important to note that EditorVR is an experimental feature. As such, there is no formal support (e.g. FogBugz, support@unity3d.com, Premium Support, etc.) offered, so please do not use these channels. Instead, take your questions, suggestions, comments to our dedicated [forum](https://forum.unity3d.com/forums/editorvr.126/). + +To help ensure you have a good experience, and to help us answer your questions (hey, we’re a small team!), we encourage you to try it out first with a small VR-ready scene. Please use life-sized objects, nothing too big or small. Dive in and have fun just playing around, instead of trying to use your existing project. + +**As with any experimental/preview/alpha/beta build, it is always a good idea to make a backup of your project before using the build.** + +Experimental means this: +- We're still adding features! +- The current menus, tools, workspaces, actions, etc. are not the end-all-be-all. Each of these have individual designs that will change as we experiment with what works best for UX. EditorVR was designed in such a way that we plan on you being able to replace all of these defaults, too, if you so desire. +- Namespaces, classes, software architecture, prefabs, etc. can change at any point. If you are writing your own tools, then you might need to update them as these things change. +- There won’t always be an upgrade path from one release to the next, so you might need to fix things manually, which leads to the next point... +- Stuff can and will break (!) +- There’s **no guarantee** that this project will move out of experimental status within any specific timeframe. +- As such, there is no guarantee that this will remain an actively supported project. + +## Getting Started +If you've made it here, but aren't accustomed to using GitHub, cloning repositories, etc. and are simply looking to give EditorVR a spin, then take a look at the [Getting Started Guide](https://docs.google.com/document/d/13Md9Z5sXNy96qyivpLOakFU-CJ5Uhpm1bS-WJp2SkWE). Once you're up and running we recommend you join the discussion on the [EditorVR forum](https://forum.unity3d.com/forums/editorvr.126/). + +## For Software Developers +If you're a developer, we recommend that you take a look at the [Getting Started Guide](https://docs.google.com/document/d/13Md9Z5sXNy96qyivpLOakFU-CJ5Uhpm1bS-WJp2SkWE) *and* the companion document [Extending EditorVR](https://docs.google.com/document/d/1EGi9hKXAujfBMI2spErojdqRc0giqEnOu0NpwgBxtpg). You'll need to clone the repository into an existing project using the instructions below. + +### Git Dependencies +- [git-lfs](https://git-lfs.github.com/) +- [git-submodule](https://git-scm.com/docs/git-submodule) + +### Cloning +1. Create a new Unity project or use an existing one +2. From the command line change directory to your project's `Assets` directory. +3. Run `git lfs clone --recursive -b development https://github.com/Unity-Technologies/EditorVR` **(Use HTTPS!)** + +### Updating +Because this project uses [git-submodule](https://git-scm.com/docs/git-submodule), you'll need to execute `git submodule update` after pulling whenever a submodule is updated. You could execute this command always just to be safe or if you notice that a submodule is showing as modified after pulling changes. + +Optionally, you could add a [git hook for post-checkout](https://ttboj.wordpress.com/2014/05/06/keeping-git-submodules-in-sync-with-your-branches/) or use a GUI (e.g. SourceTree) that does this automatically for you. + +### Project Settings +If you plan on making changes to EditorVR and/or contributing back, then you'll need to set the `Asset Serialization` property under Edit->Project Settings->Editor to `Force Text`. + +We're using `#if UNITY_EDITOR` for now in order to keep our code out of your player builds. We will eventually explore a possible overlap between EditorVR and player builds. We recommend you do the same for your tools if you plan to distribute them to others. diff --git a/Scripts/Core/EditorVR.Menus.cs b/Scripts/Core/EditorVR.Menus.cs index 86e0a490e..28fae9d47 100644 --- a/Scripts/Core/EditorVR.Menus.cs +++ b/Scripts/Core/EditorVR.Menus.cs @@ -5,7 +5,6 @@ using UnityEditor.Experimental.EditorVR.Menus; using UnityEditor.Experimental.EditorVR.Modules; using UnityEditor.Experimental.EditorVR.Utilities; -using UnityEditor.Experimental.EditorVR.Workspaces; using UnityEngine; using UnityEngine.InputNew; diff --git a/Scripts/Core/EditorVR.Tools.cs b/Scripts/Core/EditorVR.Tools.cs index 3378e1349..d2604eb06 100644 --- a/Scripts/Core/EditorVR.Tools.cs +++ b/Scripts/Core/EditorVR.Tools.cs @@ -162,6 +162,8 @@ static ToolData SpawnTool(Type toolType, out HashSet usedDevices, I { usedDevices.UnionWith(actionMapInput.GetCurrentlyUsedDevices()); InputUtils.CollectDeviceSlotsFromActionMapInput(actionMapInput, ref deviceSlots); + + actionMapInput.Reset(false); } if (usedDevices.Count == 0) @@ -193,7 +195,7 @@ static bool IsToolActive(Transform targetRayOrigin, Type toolType) return result; } - internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnReselect = true) + internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawnOnReselect = true, bool hideMenu = false) { var result = false; var deviceInputModule = evr.GetModule(); @@ -287,7 +289,8 @@ internal static bool SelectTool(Transform rayOrigin, Type toolType, bool despawn deviceInputModule.UpdatePlayerHandleMaps(); result = spawnTool; - } + } else if (hideMenu) + deviceData.menuHideData[deviceData.mainMenu].hideFlags |= MenuHideFlags.Hidden; }); return result; @@ -308,7 +311,8 @@ static void DespawnTool(DeviceData deviceData, ITool tool) return; } - deviceData.toolData.Pop(); + var oldTool = deviceData.toolData.Pop(); + oldTool.input.active = false; topTool = deviceData.toolData.Peek(); deviceData.currentTool = topTool.tool; @@ -321,7 +325,8 @@ static void DespawnTool(DeviceData deviceData, ITool tool) var otherTool = otherDeviceData.currentTool; if (otherTool == tool) { - otherDeviceData.toolData.Pop(); + oldTool = otherDeviceData.toolData.Pop(); + oldTool.input.active = false; var otherToolData = otherDeviceData.toolData.Peek(); if (otherToolData != null) otherDeviceData.currentTool = otherToolData.tool; @@ -335,7 +340,8 @@ static void DespawnTool(DeviceData deviceData, ITool tool) { if (otherTool.GetType() == toolType) { - otherDeviceData.toolData.Pop(); + oldTool = otherDeviceData.toolData.Pop(); + oldTool.input.active = false; var otherToolData = otherDeviceData.toolData.Peek(); if (otherToolData != null) { diff --git a/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs b/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs index 31e098583..fe77e4b39 100644 --- a/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs +++ b/Scripts/Interfaces/FunctionalityInjection/ISelectTool.cs @@ -13,7 +13,7 @@ public interface ISelectTool public static class ISelectToolMethods { - internal static Func selectTool { get; set; } + internal static Func selectTool { get; set; } internal static Func isToolActive { get; set; } /// @@ -23,9 +23,10 @@ public static class ISelectToolMethods /// The rayOrigin that the tool should spawn under /// Type of tool to spawn/select /// Despawn the tool, if re-selected while already the current tool - public static bool SelectTool(this ISelectTool obj, Transform rayOrigin, Type toolType, bool despawnOnReselect = true) + /// Whether to hide the menu after selecting this tool + public static bool SelectTool(this ISelectTool obj, Transform rayOrigin, Type toolType, bool despawnOnReselect = true, bool hideMenu = false) { - return selectTool(rayOrigin, toolType, despawnOnReselect); + return selectTool(rayOrigin, toolType, despawnOnReselect, hideMenu); } /// diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 2676f8989..d3e3e97a5 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -67,7 +67,8 @@ public void ProcessInput() var removeList = new List(); foreach (var lockedControl in m_LockedControls) { - if (Mathf.Approximately(lockedControl.rawValue, lockedControl.provider.GetControlData(lockedControl.index).defaultValue)) + if (!lockedControl.provider.active || Mathf.Approximately(lockedControl.rawValue, + lockedControl.provider.GetControlData(lockedControl.index).defaultValue)) removeList.Add(lockedControl); else ConsumeControl(lockedControl); @@ -76,6 +77,9 @@ public void ProcessInput() // Remove separately, since we cannot remove while iterating foreach (var inputControl in removeList) { + if (!inputControl.provider.active) + ResetControl(inputControl); + m_LockedControls.Remove(inputControl); } @@ -211,7 +215,11 @@ void ConsumeControl(InputControl control) // another AMI to pick up a wasPressed the next frame, since it's own input would have been cleared. The // control is released when it returns to it's default value m_LockedControls.Add(control); + ResetControl(control); + } + void ResetControl(InputControl control) + { var ami = control.provider as ActionMapInput; var playerHandleMaps = m_PlayerHandle.maps; for (int i = 0; i < playerHandleMaps.Count; i++) diff --git a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs index dde424972..c33000220 100644 --- a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs +++ b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs @@ -141,6 +141,9 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon eventData.rayOrigin = rayOrigin; eventData.pointerLength = this.GetPointerLength(eventData.rayOrigin); + var sourceAMI = source.actionMapInput; + var select = sourceAMI.select; + if (source.isValid != null && !source.isValid(source)) { var currentRaycast = eventData.pointerCurrentRaycast; @@ -148,6 +151,9 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon eventData.pointerCurrentRaycast = currentRaycast; source.hoveredObject = null; HandlePointerExitAndEnter(eventData, null, true); // Send only exit events + + if (select.wasJustReleased) + OnSelectReleased(source); continue; } @@ -155,10 +161,8 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon var hasObject = source.hasObject; var hasScrollHandler = false; - var sourceAMI = source.actionMapInput; - sourceAMI.active = hasObject && ShouldActivateInput(eventData, source.currentObject, out hasScrollHandler); - var select = sourceAMI.select; + sourceAMI.active = hasObject && ShouldActivateInput(eventData, source.currentObject, out hasScrollHandler); // Proceed only if pointer is interacting with something if (!sourceAMI.active) diff --git a/Tools/AnnotationTool/AnnotationTool.cs b/Tools/AnnotationTool/AnnotationTool.cs index 760c0c151..a72c5362c 100644 --- a/Tools/AnnotationTool/AnnotationTool.cs +++ b/Tools/AnnotationTool/AnnotationTool.cs @@ -7,7 +7,6 @@ using UnityEditor.Experimental.EditorVR; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Extensions; -using UnityEditor.Experimental.EditorVR.Menus; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 96b68cd51..91a1a0332 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -199,7 +199,12 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon this.SetUIBlockedForRayOrigin(rayOrigin, true); if (DoTwoHandedScaling(consumeControl)) + { + if (m_Preferences.blinkMode) + if (m_LocomotionInput.blink.isHeld) + m_BlinkVisuals.visible = false; return; + } if (DoRotating(consumeControl)) return; From 20a02ad5fdbbee0754a4dce616fa3151f633479c Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 11:53:00 -0700 Subject: [PATCH 072/457] Cleanup all cloned body and affordance materials in ProxyUI --- Scripts/Helpers/ProxyUI.cs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index c7644fd2f..c88919f4a 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -200,6 +200,34 @@ public bool bodyVisible } } + void OnDestroy() + { + // Cleanup cloned materials + foreach (var affordanceDefinition in m_AffordanceMap.AffordanceDefinitions) + { + var visibilityDefinition = affordanceDefinition.visibilityDefinition; + var visibilityType = visibilityDefinition.visibilityType; + if (visibilityType == VisibilityControlType.colorProperty || visibilityType == VisibilityControlType.alphaProperty) + { + var material = visibilityDefinition.material; + if (material != null) + ObjectUtils.Destroy(material); + } + } + + var bodyVisibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; + var bodyVisibilityType = bodyVisibilityDefinition.visibilityType; + if (bodyVisibilityType == VisibilityControlType.colorProperty || bodyVisibilityType == VisibilityControlType.alphaProperty) + { + foreach (var kvp in m_BodyMaterialOriginalColorMap) + { + var material = kvp.Key; + if (material != null) + ObjectUtils.Destroy(material); + } + } + } + /// /// Setup this ProxyUI /// @@ -217,7 +245,7 @@ public void Setup(AffordanceObject[] affordances, List proxyOrigins) IEnumerator AnimateAffordanceColorVisibility(bool isVisible, AffordanceDefinition definition) { // Set original cached color when visible, transparent when hidden - const float kSpeedScalar = 3f; + const float kSpeedScalar = 2f; const float kTargetAmount = 1f; const float kHiddenValue = 0.25f; var currentAmount = 0f; @@ -235,12 +263,13 @@ IEnumerator AnimateAffordanceColorVisibility(bool isVisible, AffordanceDefinitio yield return null; } + // Mandate target value has been set material.SetColor(shaderColorPropety, animateToColor); } IEnumerator AnimateAffordanceAlphaVisibility(bool isVisible, AffordanceDefinition definition) { - const float kSpeedScalar = 3f; + const float kSpeedScalar = 2f; const float kTargetAmount = 1f; const float kHiddenValue = 0.25f; var visibilityDefinition = m_AffordanceMap.bodyVisibilityDefinition; From d76ce4170e7995bf4cf20e1ff5e96ff13782f441 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 12:14:44 -0700 Subject: [PATCH 073/457] Use AffordanceVisibilityDefinition color property string when setting all color properties in ProxyUI --- Scripts/Helpers/ProxyUI.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index c88919f4a..8ccd95a95 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -88,7 +88,7 @@ AffordanceObject[] affordances if (materialClone != null) { var visualDefinition = affordanceDefinition.visibilityDefinition; - var originalColor = materialClone.color; + var originalColor = materialClone.GetColor(visualDefinition.colorProperty); m_AffordanceRenderers.Add(renderer); // Add to collection for later optimized comparison against body renderers visualDefinition.renderer = renderer; visualDefinition.originalColor = originalColor; @@ -116,7 +116,7 @@ AffordanceObject[] affordances var materialClone = MaterialUtils.GetMaterialClone(renderer); // TODO: support multiple materials per-renderer if (materialClone != null) { - var originalColor = materialClone.color; + var originalColor = materialClone.GetColor(bodyVisibilityDefinition.colorProperty); if (materialClone.HasProperty(k_ZWritePropertyName)) materialClone.SetFloat(k_ZWritePropertyName, 1); @@ -303,6 +303,7 @@ IEnumerator AnimateBodyColorVisibility(bool isVisible) const float kTargetAmount = 1f; const float kHiddenValue = 0.25f; var currentAmount = 0f; + var shaderColorPropety = bodyVisibilityDefinition.colorProperty; while (currentAmount < kTargetAmount) { var smoothedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentAmount += Time.unscaledDeltaTime * kSpeedScalar); @@ -312,7 +313,7 @@ IEnumerator AnimateBodyColorVisibility(bool isVisible) var valueFrom = kvp.Value.animateFromValue; var valueTo = isVisible ? kvp.Value.originalValue : new Color(valueFrom.r, valueFrom.g, valueFrom.b, kHiddenValue); var currentColor = Color.Lerp(valueFrom, valueTo, smoothedAmount); - kvp.Key.color = currentColor; + kvp.Key.SetColor(shaderColorPropety, currentColor); } yield return null; @@ -322,7 +323,7 @@ IEnumerator AnimateBodyColorVisibility(bool isVisible) foreach (var kvp in m_BodyMaterialOriginalColorMap) { var originalColor = kvp.Value.originalValue; - kvp.Key.color = isVisible ? originalColor : new Color(originalColor.r, originalColor.g, originalColor.b, kHiddenValue); + kvp.Key.SetColor(shaderColorPropety, isVisible ? originalColor : new Color(originalColor.r, originalColor.g, originalColor.b, kHiddenValue)); } } From 5f33cf115beac273ebaa82a99b298b269bae7d02 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 12:44:35 -0700 Subject: [PATCH 074/457] Hide/remove feedbackRequests after initial displaying them in the SelectionTool; conform feedback add/remove implementation to match that which is neeeded in the ProxyUI --- Tools/SelectionTool/SelectionTool.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index eb4a5f2bc..e4dcda2c4 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -1,8 +1,10 @@ #if UNITY_EDITOR using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Core; +using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -34,6 +36,8 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR Color m_NormalRayColor; Color m_MultiselectRayColor; bool m_MultiSelect; + bool m_RayWasHidden; + Coroutine m_ShowFeedbackRequestsCoroutine; readonly Dictionary> m_Controls = new Dictionary>(); readonly List m_SelectFeedback = new List(); @@ -71,7 +75,7 @@ void Start() InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); - ShowSelectFeedback(); + this.RestartCoroutine(ref m_ShowFeedbackRequestsCoroutine, ShowThenHideFeedbackRequests()); } void OnDestroy() @@ -207,9 +211,15 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } if (!this.IsRayVisible(rayOrigin)) + { HideSelectFeedback(); - else if (m_SelectFeedback.Count == 0) - ShowSelectFeedback(); + m_RayWasHidden = true; + } + else if (m_RayWasHidden && m_SelectFeedback.Count == 0) + { + m_RayWasHidden = false; + this.RestartCoroutine(ref m_ShowFeedbackRequestsCoroutine, ShowThenHideFeedbackRequests()); + } if (!IsRayActive()) return; @@ -297,6 +307,15 @@ bool IsRayActive() return true; } + IEnumerator ShowThenHideFeedbackRequests() + { + ShowSelectFeedback(); + + yield return new WaitForSeconds(4); + + HideSelectFeedback(); + } + void OnDisable() { foreach (var kvp in m_HoverGameObjects) @@ -304,6 +323,8 @@ void OnDisable() this.SetHighlight(kvp.Value, false, kvp.Key); } m_HoverGameObjects.Clear(); + + HideSelectFeedback(); } public void OnResetDirectSelectionState() { } From 54141ca31d3b035f79e15fbe44281e296bcfd162 Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 2 Oct 2017 12:47:17 -0700 Subject: [PATCH 075/457] Add delayed ProxyUI setup, prevent setting of visibility properties before delayed setup has occurred; without the delay shader properties couldn't be reliably controlled, if cloned in awake & start --- Scripts/Helpers/ProxyUI.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Scripts/Helpers/ProxyUI.cs b/Scripts/Helpers/ProxyUI.cs index 8ccd95a95..ffb72dfc4 100644 --- a/Scripts/Helpers/ProxyUI.cs +++ b/Scripts/Helpers/ProxyUI.cs @@ -22,6 +22,11 @@ public class ProxyUI : MonoBehaviour AffordanceObject[] m_Affordances; Coroutine m_BodyVisibilityCoroutine; + /// + /// Bool that denotes the ProxyUI has been setup + /// + bool m_ProxyUISetup; + /// /// Collection of proxy origins under which not to perform any affordance/body visibility changes /// @@ -150,7 +155,7 @@ public bool affordancesVisible { set { - if (m_ProxyOrigins == null || !gameObject.activeInHierarchy || m_AffordanceRenderersVisible == value) + if (!m_ProxyUISetup || m_ProxyOrigins == null || !gameObject.activeInHierarchy || m_AffordanceRenderersVisible == value) return; m_AffordanceRenderersVisible = value; @@ -180,7 +185,7 @@ public bool bodyVisible { set { - if (m_ProxyOrigins == null || !gameObject.activeInHierarchy || m_BodyRenderersVisible == value) + if (!m_ProxyUISetup || m_ProxyOrigins == null || !gameObject.activeInHierarchy || m_BodyRenderersVisible == value) return; m_BodyRenderersVisible = value; @@ -237,9 +242,23 @@ public void Setup(AffordanceObject[] affordances, List proxyOrigins) { // Set affordances AFTER setting origins, as the origins are referenced when setting up affordances m_ProxyOrigins = proxyOrigins; + + if (!m_ProxyUISetup) + StartCoroutine(DelayedSetup(affordances)); + } + + IEnumerator DelayedSetup(AffordanceObject[] affordances) + { + // HACK: Wait before setting up ProxyUI affordances + // Cloning affordance & body materials in Awake & Start doesn't reliably allow for the ability to change their shader properties + yield return new WaitForSeconds(1); + this.affordances = affordances; affordancesVisible = false; bodyVisible = false; + + // Allow setting of affordance & body visibility after affordance+body setup is performed in the "affordances" property + m_ProxyUISetup = true; } IEnumerator AnimateAffordanceColorVisibility(bool isVisible, AffordanceDefinition definition) From 6c4cb97ee258e63aea48ca71892e87983210b025 Mon Sep 17 00:00:00 2001 From: andrewm Date: Mon, 2 Oct 2017 16:00:19 -0700 Subject: [PATCH 076/457] remove unicode characters --- LICENSE | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/LICENSE b/LICENSE index a75c47d1f..ed90c1006 100644 --- a/LICENSE +++ b/LICENSE @@ -1,24 +1,24 @@ -Unity Companion License 1.0 (“License”) -Copyright © 2017 Unity Technologies ApS (“Unity”) +Unity Companion License 1.0 ("License") +Copyright (C) 2017 Unity Technologies ApS ("Unity") -Unity hereby grants to you a worldwide, non-exclusive, no-charge, and royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the software that is made available with this License (“Software”), subject to the following terms and conditions: +Unity hereby grants to you a worldwide, non-exclusive, no-charge, and royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute the software that is made available with this License ("Software"), subject to the following terms and conditions: -1. Unity Companion Use Only. Exercise of the license granted herein is limited to exercise for the creation, use, and/or distribution of applications, software, or other content pursuant to a valid Unity development engine software license (“Engine License”). That means while use of the Software is not limited to use in the software licensed under the Engine License, the Software may not be used for any purpose other than the creation, use, and/or distribution of Engine License-dependent applications, software, or other content. No other exercise of the license granted herein is permitted. +1. Unity Companion Use Only. Exercise of the license granted herein is limited to exercise for the creation, use, and/or distribution of applications, software, or other content pursuant to a valid Unity development engine software license ("Engine License"). That means while use of the Software is not limited to use in the software licensed under the Engine License, the Software may not be used for any purpose other than the creation, use, and/or distribution of Engine License-dependent applications, software, or other content. No other exercise of the license granted herein is permitted. 2. No Modification of Engine License. Neither this License nor any exercise of the license granted herein modifies the Engine License in any way. 3. Ownership & Grant Back to You. -3.1 You own your content. In this License, “derivative works” means derivatives of the Software itself--works derived only from the Software by you under this License (for example, modifying the code of the Software itself to improve its efficacy); “derivative works” of the Software do not include, for example, games, apps, or content that you create using the Software. You keep all right, title, and interest to your own content. +3.1 You own your content. In this License, "derivative works" means derivatives of the Software itself--works derived only from the Software by you under this License (for example, modifying the code of the Software itself to improve its efficacy); "derivative works" of the Software do not include, for example, games, apps, or content that you create using the Software. You keep all right, title, and interest to your own content. 3.2 Unity owns its content. While you keep all right, title, and interest to your own content per the above, as between Unity and you, Unity will own all right, title, and interest to all intellectual property rights (including patent, trademark, and copyright) in the Software and derivative works of the Software, and you hereby assign and agree to assign all such rights in those derivative works to Unity. 3.3 You have a license to those derivative works. Subject to this License, Unity grants to you the same worldwide, non-exclusive, no-charge, and royalty-free copyright license to derivative works of the Software you create as is granted to you for the Software under this License. -4. Trademarks. You are not granted any right or license under this License to use any trademarks, service marks, trade names, products names, or branding of Unity or its affiliates (“Trademarks”). Descriptive uses of Trademarks are permitted; see, for example, Unity’s Branding Usage Guidelines at https://unity3d.com/public-relations/brand. +4. Trademarks. You are not granted any right or license under this License to use any trademarks, service marks, trade names, products names, or branding of Unity or its affiliates ("Trademarks"). Descriptive uses of Trademarks are permitted; see, for example, Unity's Branding Usage Guidelines at https://unity3d.com/public-relations/brand. -5. Notices & Third-Party Rights. This License, including the copyright notice above, must be provided in all substantial portions of the Software and derivative works thereof (or, if that is impracticable, in any other location where such notices are customarily placed). Further, if the Software is accompanied by a Unity “third-party notices” or similar file, you acknowledge and agree that software identified in that file is governed by those separate license terms. +5. Notices & Third-Party Rights. This License, including the copyright notice above, must be provided in all substantial portions of the Software and derivative works thereof (or, if that is impracticable, in any other location where such notices are customarily placed). Further, if the Software is accompanied by a Unity "third-party notices" or similar file, you acknowledge and agree that software identified in that file is governed by those separate license terms. 6. DISCLAIMER, LIMITATION OF LIABILITY. THE SOFTWARE AND ANY DERIVATIVE WORKS THEREOF IS PROVIDED ON AN "AS IS" BASIS, AND IS PROVIDED WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR NONINFRINGEMENT. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES (WHETHER DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL, INCLUDING PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR PROFITS, AND BUSINESS INTERRUPTION), OR OTHER LIABILITY WHATSOEVER, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM OR OUT OF, OR IN CONNECTION WITH, THE SOFTWARE OR ANY DERIVATIVE WORKS THEREOF OR THE USE OF OR OTHER DEALINGS IN SAME, EVEN WHERE ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -28,5 +28,5 @@ Unity hereby grants to you a worldwide, non-exclusive, no-charge, and royalty-fr 9. Severability. If any provision of this License is held to be unenforceable or invalid, that provision will be enforced to the maximum extent possible and the other provisions will remain in full force and effect. -10. Governing Law and Venue. This License is governed by and construed in accordance with the laws of Denmark, except for its conflict of laws rules; the United Nations Convention on Contracts for the International Sale of Goods will not apply. If you reside (or your principal place of business is) within the United States, you and Unity agree to submit to the personal and exclusive jurisdiction of and venue in the state and federal courts located in San Francisco County, California concerning any dispute arising out of this License (“Dispute”). If you reside (or your principal place of business is) outside the United States, you and Unity agree to submit to the personal and exclusive jurisdiction of and venue in the courts located in Copenhagen, Denmark concerning any Dispute. +10. Governing Law and Venue. This License is governed by and construed in accordance with the laws of Denmark, except for its conflict of laws rules; the United Nations Convention on Contracts for the International Sale of Goods will not apply. If you reside (or your principal place of business is) within the United States, you and Unity agree to submit to the personal and exclusive jurisdiction of and venue in the state and federal courts located in San Francisco County, California concerning any dispute arising out of this License ("Dispute"). If you reside (or your principal place of business is) outside the United States, you and Unity agree to submit to the personal and exclusive jurisdiction of and venue in the courts located in Copenhagen, Denmark concerning any Dispute. From ad08a9fdaa83c220b9e685eeb48bc9e42541f72e Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 3 Oct 2017 14:16:22 -0700 Subject: [PATCH 077/457] Fix input blocking issue with ProxyAnimator --- Menus/MainMenu/MainMenu.cs | 1 + Menus/RadialMenu/RadialMenu.cs | 4 +- Menus/ToolsMenu/ToolsMenu.cs | 1 + .../ICustomActionMap.cs | 5 ++ Scripts/Modules/DeviceInputModule.cs | 15 +++- .../MultipleRayInputModule.cs | 1 + Scripts/Proxies/ProxyAnimator.cs | 70 ++++++++++++++----- Tools/AnnotationTool/AnnotationTool.cs | 2 +- Tools/LocomotionTool/LocomotionTool.cs | 6 +- Tools/SelectionTool/SelectionTool.cs | 1 + Tools/TransformTool/TransformTool.cs | 1 + Tools/VacuumTool/VacuumTool.cs | 1 + Workspaces/Base/Workspace.cs | 1 + 13 files changed, 85 insertions(+), 24 deletions(-) diff --git a/Menus/MainMenu/MainMenu.cs b/Menus/MainMenu/MainMenu.cs index af044194b..e0a54a388 100644 --- a/Menus/MainMenu/MainMenu.cs +++ b/Menus/MainMenu/MainMenu.cs @@ -62,6 +62,7 @@ sealed class MainMenu : MonoBehaviour, IMainMenu, IConnectInterfaces, IInstantia public bool focus { get { return m_MainMenuUI.hovering; } } public ActionMap actionMap { get { return m_MainMenuActionMap; } } + public bool ignoreLocking { get { return false; } } public Transform menuOrigin { diff --git a/Menus/RadialMenu/RadialMenu.cs b/Menus/RadialMenu/RadialMenu.cs index 602984973..d5739f45d 100644 --- a/Menus/RadialMenu/RadialMenu.cs +++ b/Menus/RadialMenu/RadialMenu.cs @@ -12,7 +12,6 @@ sealed class RadialMenu : MonoBehaviour, IInstantiateUI, IAlternateMenu, IUsesMe { const float k_ActivationThreshold = 0.5f; // Do not consume thumbstick or activate menu if the control vector's magnitude is below this threshold - public ActionMap actionMap { get {return m_RadialMenuActionMap; } } [SerializeField] ActionMap m_RadialMenuActionMap; @@ -45,6 +44,9 @@ sealed class RadialMenu : MonoBehaviour, IInstantiateUI, IAlternateMenu, IUsesMe public Bounds localBounds { get { return default(Bounds); } } + public ActionMap actionMap { get { return m_RadialMenuActionMap; } } + public bool ignoreLocking { get { return false; } } + public List menuActions { get { return m_MenuActions; } diff --git a/Menus/ToolsMenu/ToolsMenu.cs b/Menus/ToolsMenu/ToolsMenu.cs index 353f6b747..a0297350a 100644 --- a/Menus/ToolsMenu/ToolsMenu.cs +++ b/Menus/ToolsMenu/ToolsMenu.cs @@ -54,6 +54,7 @@ sealed class ToolsMenu : MonoBehaviour, IToolsMenu, IConnectInterfaces, IInstant public Transform alternateMenuOrigin { get; set; } public SpatialScrollModule.SpatialScrollData spatialScrollData { get; set; } public ActionMap actionMap { get { return m_MainMenuActionMap; } } + public bool ignoreLocking { get { return false; } } public Transform rayOrigin { get; set; } public bool mainMenuActivatorInteractable diff --git a/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs b/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs index cb8a8511e..b572f6429 100644 --- a/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs +++ b/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs @@ -12,6 +12,11 @@ public interface ICustomActionMap : IProcessInput /// Provides access to the custom action map /// ActionMap actionMap { get; } + + /// + /// Whether the custom action map will always recieve input, regardless of locking + /// + bool ignoreLocking { get; } } } #endif diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 9e3f2660a..c6d4a634b 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -27,6 +27,7 @@ class InputProcessor PlayerHandle m_PlayerHandle; readonly HashSet m_LockedControls = new HashSet(); + readonly Dictionary m_IgnoreLocking = new Dictionary(); readonly Dictionary m_TagToNode = new Dictionary { @@ -107,7 +108,12 @@ public void DisconnectInterface(object @object, object userData = null) foreach (var processor in m_InputProcessorsCopy) { if (processor.processor == @object) + { m_InputProcessors.Remove(processor); + var customActionMap = @object as ICustomActionMap; + if (customActionMap != null) + m_IgnoreLocking.Remove(processor.input); + } } } } @@ -194,7 +200,11 @@ internal ActionMapInput CreateActionMapInputForObject(object obj, InputDevice de if (customMap is IStandardActionMap) Debug.LogWarning("Cannot use IStandardActionMap and ICustomActionMap together in " + obj.GetType()); - return CreateActionMapInput(customMap.actionMap, device); + var input = CreateActionMapInput(customMap.actionMap, device); + if (customMap.ignoreLocking) + m_IgnoreLocking[input] = customMap; + + return input; } var standardMap = obj as IStandardActionMap; @@ -287,6 +297,9 @@ void ConsumeControl(InputControl control) for (int i = 0; i < playerHandleMaps.Count; i++) { var input = playerHandleMaps[i]; + if (m_IgnoreLocking.ContainsKey(input)) + continue; + if (input != ami) input.ResetControl(control); } diff --git a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs index abf6bab25..c7c31814f 100644 --- a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs +++ b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs @@ -30,6 +30,7 @@ public class RaycastSource : ICustomActionMap public bool hasObject { get { return currentObject != null && (s_LayerMask & (1 << currentObject.layer)) != 0; } } public ActionMap actionMap { get { return m_Owner.m_UIActionMap; } } + public bool ignoreLocking { get { return false; } } public RaycastSource(IProxy proxy, Transform rayOrigin, Node node, MultipleRayInputModule owner, Func validationCallback) { diff --git a/Scripts/Proxies/ProxyAnimator.cs b/Scripts/Proxies/ProxyAnimator.cs index 2997e60ff..60a0a4b92 100644 --- a/Scripts/Proxies/ProxyAnimator.cs +++ b/Scripts/Proxies/ProxyAnimator.cs @@ -1,4 +1,5 @@ -using UnityEditor.Experimental.EditorVR; +using System.Collections.Generic; +using UnityEditor.Experimental.EditorVR; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEngine; using UnityEngine.InputNew; @@ -7,15 +8,30 @@ [RequireComponent(typeof(ProxyHelper))] public class ProxyAnimator : MonoBehaviour, ICustomActionMap { + class TransformInfo + { + public Vector3 initialPosition; + public Vector3 initialRotation; + public Vector3 positionOffset; + public Vector3 rotationOffset; + + public void Reset() + { + positionOffset = Vector3.zero; + rotationOffset = Vector3.zero; + } + } + [SerializeField] ActionMap m_ProxyActionMap; ProxyHelper.ButtonObject[] m_Buttons; InputControl[] m_Controls; - Vector3[] m_InitialPositions; - Vector3[] m_InitialRotations; + + readonly Dictionary m_TransformInfos = new Dictionary(); public ActionMap actionMap { get { return m_ProxyActionMap; } } + public bool ignoreLocking { get { return true; } } void Start() { @@ -31,8 +47,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (m_Controls == null) { m_Controls = new InputControl[length]; - m_InitialPositions = new Vector3[length]; - m_InitialRotations = new Vector3[length]; var bindings = input.actionMap.controlSchemes[0].bindings; for (var i = 0; i < input.controlCount; i++) @@ -53,36 +67,51 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } } - for (var i = 0; i < length; i++) + foreach (var button in m_Buttons) { - var buttonTransform = m_Buttons[i].transform; - m_InitialPositions[i] = buttonTransform.localPosition; - m_InitialRotations[i] = buttonTransform.localRotation.eulerAngles; + var buttonTransform = button.transform; + TransformInfo info; + if (!m_TransformInfos.TryGetValue(buttonTransform, out info)) + { + info = new TransformInfo(); + m_TransformInfos[buttonTransform] = info; + } + + info.initialPosition = buttonTransform.localPosition; + info.initialRotation = buttonTransform.localRotation.eulerAngles; + } } + foreach (var kvp in m_TransformInfos) + { + kvp.Value.Reset(); + } + for (var i = 0; i < length; i++) { var button = m_Buttons[i]; var control = m_Controls[i]; + var info = m_TransformInfos[button.transform]; //Assume control values are [-1, 1] var min = button.min; var offset = min + (control.rawValue + 1) * (button.max - min) * 0.5f; - var buttonTransform = button.transform; - var localPosition = m_InitialPositions[i]; + var positionOffset = info.positionOffset; var translateAxes = button.translateAxes; if ((translateAxes & AxisFlags.X) != 0) - localPosition.x += offset; + positionOffset.x += offset; if ((translateAxes & AxisFlags.Y) != 0) - localPosition.y += offset; + positionOffset.y += offset; if ((translateAxes & AxisFlags.Z) != 0) - localPosition.z += offset; + positionOffset.z += offset; - var localRotation = m_InitialRotations[i]; + info.positionOffset = positionOffset; + + var localRotation = info.rotationOffset; var rotateAxes = button.rotateAxes; if ((rotateAxes & AxisFlags.X) != 0) localRotation.x += offset; @@ -93,8 +122,15 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if ((rotateAxes & AxisFlags.Z) != 0) localRotation.z += offset; - buttonTransform.localPosition = localPosition; - buttonTransform.localRotation = Quaternion.Euler(localRotation); + info.rotationOffset = localRotation; + } + + foreach (var kvp in m_TransformInfos) + { + var buttonTransform = kvp.Key; + var info = kvp.Value; + buttonTransform.localPosition = info.initialPosition + info.positionOffset; + buttonTransform.localRotation = Quaternion.Euler(info.initialRotation + info.rotationOffset); } } } diff --git a/Tools/AnnotationTool/AnnotationTool.cs b/Tools/AnnotationTool/AnnotationTool.cs index 54f05c5d2..6ce21ac5f 100644 --- a/Tools/AnnotationTool/AnnotationTool.cs +++ b/Tools/AnnotationTool/AnnotationTool.cs @@ -7,7 +7,6 @@ using UnityEditor.Experimental.EditorVR; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Extensions; -using UnityEditor.Experimental.EditorVR.Menus; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.UI; using UnityEditor.Experimental.EditorVR.Utilities; @@ -101,6 +100,7 @@ class Preferences public Transform alternateMenuOrigin { private get; set; } public ActionMap actionMap { get { return m_ActionMap; } } + public bool ignoreLocking { get { return false; } } public List linkedObjects { private get; set; } public Node node { private get; set; } diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 665cb9207..ad52bf88b 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -107,10 +107,8 @@ public bool blinkMode readonly List m_ResetScaleFeedback = new List(); - public ActionMap actionMap - { - get { return m_ActionMap; } - } + public ActionMap actionMap { get { return m_ActionMap; } } + public bool ignoreLocking { get { return false; } } public Transform rayOrigin { get; set; } diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 712a9a8c3..e54f45275 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -43,6 +43,7 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR readonly Dictionary m_SelectionHoverGameObjects = new Dictionary(); public ActionMap actionMap { get { return m_ActionMap; } } + public bool ignoreLocking { get { return false; } } public Transform rayOrigin { private get; set; } public Node node { private get; set; } diff --git a/Tools/TransformTool/TransformTool.cs b/Tools/TransformTool/TransformTool.cs index 56ba3248a..d9d2c7369 100644 --- a/Tools/TransformTool/TransformTool.cs +++ b/Tools/TransformTool/TransformTool.cs @@ -242,6 +242,7 @@ public bool manipulatorDragging public Node node { private get; set; } public ActionMap actionMap { get { return m_ActionMap; } } + public bool ignoreLocking { get { return false; } } void Start() { diff --git a/Tools/VacuumTool/VacuumTool.cs b/Tools/VacuumTool/VacuumTool.cs index 0d406404e..2b4d6e81c 100644 --- a/Tools/VacuumTool/VacuumTool.cs +++ b/Tools/VacuumTool/VacuumTool.cs @@ -21,6 +21,7 @@ sealed class VacuumTool : MonoBehaviour, ITool, ICustomActionMap, IUsesRayOrigin readonly List m_Feedback = new List(); public ActionMap actionMap { get { return m_ActionMap; } } + public bool ignoreLocking { get { return false; } } public List vacuumables { private get; set; } diff --git a/Workspaces/Base/Workspace.cs b/Workspaces/Base/Workspace.cs index 01712f4fb..36f3f9326 100644 --- a/Workspaces/Base/Workspace.cs +++ b/Workspaces/Base/Workspace.cs @@ -126,6 +126,7 @@ public float topPanelDividerOffset public Transform frontPanel { get { return m_WorkspaceUI.frontPanel; } } public ActionMap actionMap { get { return m_ActionMap; } } + public bool ignoreLocking { get { return false; } } public Transform leftRayOrigin { protected get; set; } public Transform rightRayOrigin { protected get; set; } From 382b6c407af9937578a2e0193d8d7ed87510302c Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 3 Oct 2017 14:29:57 -0700 Subject: [PATCH 078/457] Clean up code --- Editor/FlagsPropertyDrawer.cs | 4 +- .../SelectionModuleConnector.cs | 1 - Scripts/Helpers/ProxyHelper.cs | 75 ++++++++----------- 3 files changed, 32 insertions(+), 48 deletions(-) diff --git a/Editor/FlagsPropertyDrawer.cs b/Editor/FlagsPropertyDrawer.cs index 9068bf22d..a57cf5ae5 100644 --- a/Editor/FlagsPropertyDrawer.cs +++ b/Editor/FlagsPropertyDrawer.cs @@ -1,4 +1,4 @@ -using UnityEditor.Experimental.EditorVR.Utilities; +using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.UI @@ -11,4 +11,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten property.intValue = UIUtils.MaskField(position, label, property.intValue, property.enumNames, UIUtils.SerializedPropertyToType(property)); } } -} +} \ No newline at end of file diff --git a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs index 3d20bd41e..fa195e7a2 100644 --- a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs @@ -1,5 +1,4 @@ #if UNITY_EDITOR && UNITY_EDITORVR - namespace UnityEditor.Experimental.EditorVR.Core { partial class EditorVR diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index 7c57b424b..ec44ff1ec 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -46,75 +46,60 @@ public class ButtonObject public float max { get { return m_Max; } } } + [SerializeField] + Transform m_RayOrigin; + + [SerializeField] + Transform m_MenuOrigin; + + [SerializeField] + Transform m_AlternateMenuOrigin; + + [SerializeField] + Transform m_PreviewOrigin; + + [SerializeField] + Transform m_FieldGrabOrigin; + + [SerializeField] + Transform m_MeshRoot; + + [SerializeField] + ButtonObject[] m_Buttons; + /// /// The transform that the device's ray contents (default ray, custom ray, etc) will be parented under /// - public Transform rayOrigin - { - get { return m_RayOrigin; } - } - - [SerializeField] - private Transform m_RayOrigin; + public Transform rayOrigin { get { return m_RayOrigin; } } /// /// The transform that the menu content will be parented under /// - public Transform menuOrigin - { - get { return m_MenuOrigin; } - } - - [SerializeField] - private Transform m_MenuOrigin; + public Transform menuOrigin { get { return m_MenuOrigin; } } /// /// The transform that the alternate-menu content will be parented under /// - public Transform alternateMenuOrigin - { - get { return m_AlternateMenuOrigin; } - } - - [SerializeField] - private Transform m_AlternateMenuOrigin; + public Transform alternateMenuOrigin { get { return m_AlternateMenuOrigin; } } /// /// The transform that the display/preview objects will be parented under /// - public Transform previewOrigin - { - get { return m_PreviewOrigin; } - } - - [SerializeField] - private Transform m_PreviewOrigin; + public Transform previewOrigin { get { return m_PreviewOrigin; } } /// /// The transform that the display/preview objects will be parented under /// - public Transform fieldGrabOrigin - { - get { return m_FieldGrabOrigin; } - } - - [SerializeField] - private Transform m_FieldGrabOrigin; + public Transform fieldGrabOrigin { get { return m_FieldGrabOrigin; } } /// /// The root transform of the device/controller mesh-renderers/geometry /// - public Transform meshRoot - { - get { return m_MeshRoot; } - } - - [SerializeField] - private Transform m_MeshRoot; - - [SerializeField] - ButtonObject[] m_Buttons; + public Transform meshRoot { get { return m_MeshRoot; } } + /// + /// Button objects to store transform and renderer references + /// public ButtonObject[] buttons { get { return m_Buttons; } } } } From dcdaf0cb2c30331b0147b72ddcd61722d223a9dc Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 3 Oct 2017 14:33:50 -0700 Subject: [PATCH 079/457] Fix spelling of "receive" --- Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs | 2 +- .../HierarchyWorkspace/Scripts/HierarchyListViewController.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs b/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs index b572f6429..f542cbc77 100644 --- a/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs +++ b/Scripts/Interfaces/FunctionalityInjection/ICustomActionMap.cs @@ -14,7 +14,7 @@ public interface ICustomActionMap : IProcessInput ActionMap actionMap { get; } /// - /// Whether the custom action map will always recieve input, regardless of locking + /// Whether the custom action map will always receive input, regardless of locking /// bool ignoreLocking { get; } } diff --git a/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs b/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs index 515a27ff1..1b503d7a4 100644 --- a/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs +++ b/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs @@ -102,7 +102,7 @@ protected override void Setup() foreach (var dropZone in dropZones) { dropZone.canDrop = CanDrop; - dropZone.receiveDrop = RecieveDrop; + dropZone.receiveDrop = ReceiveDrop; dropZone.dropHoverStarted += DropHoverStarted; dropZone.dropHoverEnded += DropHoverEnded; } @@ -373,7 +373,7 @@ static bool CanDrop(BaseHandle handle, object dropObject) return dropObject is HierarchyData; } - void RecieveDrop(BaseHandle handle, object dropObject) + void ReceiveDrop(BaseHandle handle, object dropObject) { if (handle == m_TopDropZone) { From ae695d0de6aea21045040b813fd4a2ae4a14e492 Mon Sep 17 00:00:00 2001 From: andrewm Date: Tue, 3 Oct 2017 15:58:30 -0700 Subject: [PATCH 080/457] Bracket fix --- Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs index 658508b4c..5c39ff91f 100644 --- a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs +++ b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs @@ -520,9 +520,7 @@ void OnBackgroundButtonClick() void OnSecondaryButtonClicked() { if (!implementsSecondaryButton) - { return; - } this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHideAndDestroy()); closeButton(); ActionButtonHoverExit(); From 0ccdbccc8512adf376990cef859b642d353cb65a Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 3 Oct 2017 16:03:46 -0700 Subject: [PATCH 081/457] Switch UNITY_EDITORVRs to UNITY_2017_2_OR_NEWER --- Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat | 3 ++- Scripts/Core/EditorVR.ToolsMenu.cs | 2 +- Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs | 2 +- .../Core/InterfaceConnectors/SpatialScrollModuleConnector.cs | 2 +- Tools/AnnotationTool/AnnotationTool.cs | 2 +- Tools/LocomotionTool/LocomotionTool.cs | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat b/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat index 3b88ca4bf..8be614de4 100644 --- a/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat +++ b/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat @@ -6,11 +6,12 @@ Material: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_Name: MenuFaceTitleIcon + m_Name: PrimitiveMenuFaceTitleIcon m_Shader: {fileID: 4800000, guid: 269bee83d6b662e489c098a4f0d9af32, type: 3} m_ShaderKeywords: _EMISSION _METALLICGLOSSMAP _NORMALMAP m_LightmapFlags: 1 m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 m_CustomRenderQueue: 9001 stringTagMap: {} disabledShaderPasses: [] diff --git a/Scripts/Core/EditorVR.ToolsMenu.cs b/Scripts/Core/EditorVR.ToolsMenu.cs index 259ac8928..5728d0e24 100644 --- a/Scripts/Core/EditorVR.ToolsMenu.cs +++ b/Scripts/Core/EditorVR.ToolsMenu.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using System; using System.Linq; using UnityEngine; diff --git a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs index 59b212f3c..4becb8b97 100644 --- a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs index a4b58ac9f..0f59719af 100644 --- a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Tools/AnnotationTool/AnnotationTool.cs b/Tools/AnnotationTool/AnnotationTool.cs index a72c5362c..efb784084 100644 --- a/Tools/AnnotationTool/AnnotationTool.cs +++ b/Tools/AnnotationTool/AnnotationTool.cs @@ -313,7 +313,7 @@ void HandleBrushSize(float value) if (m_AnnotationPointer != null) { var brushSize = m_Preferences.brushSize; - if (VRSettings.loadedDeviceName == "OpenVR") // For vive controllers, use 1:1 touchpad setting. + if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR") // For vive controllers, use 1:1 touchpad setting. { brushSize = Mathf.Lerp(MinBrushSize, MaxBrushSize, (value + 1) / 2f); } diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index 1774a10b2..d96a3a874 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -567,7 +567,7 @@ IEnumerator MoveTowardTarget(Vector3 targetPosition) var offset = cameraRig.position - CameraUtils.GetMainCamera().transform.position; offset.y = 0; -#if UNITY_EDITORVR +#if UNITY_2017_2_OR_NEWER offset += VRView.HeadHeight * Vector3.up * this.GetViewerScale(); #endif targetPosition += offset; From c1e29dff7192b721a78439d72ffaf52c56ec69b0 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Tue, 3 Oct 2017 17:37:11 -0700 Subject: [PATCH 082/457] Fix refactor issue that broke ProjectFolderModule --- Scripts/Modules/ProjectFolderModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Scripts/Modules/ProjectFolderModule.cs b/Scripts/Modules/ProjectFolderModule.cs index 026e6fcfd..13e3e8dac 100644 --- a/Scripts/Modules/ProjectFolderModule.cs +++ b/Scripts/Modules/ProjectFolderModule.cs @@ -3,12 +3,13 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Data; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class ProjectFolderModule : MonoBehaviour, IConnectInterfaces + sealed class ProjectFolderModule : MonoBehaviour, IInterfaceConnector { // Maximum time (in ms) before yielding in CreateFolderData: should be target frame time const float k_MaxFrameTime = 0.01f; From 57a4000fc1272bc06cecd3bf1d4c2d604a9745fa Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 4 Oct 2017 16:02:50 -0700 Subject: [PATCH 083/457] Remove unnecessary UNITY_2017_2_OR_NEWER; Update NoEditorVR copy to refer to 2017.2; Remove reference to VRDevice in AnnotationTool; Wrap tests that need it in UNITY_5_6_OR_NEWER --- Editor/EditingContextManagerEditor.cs | 4 +--- .../Core/Contexts/EditingContextManager.cs | 8 +++++++- Scripts/Core/EditorVR.cs | 6 +++--- Scripts/Core/VRView.cs | 19 +++++++++++++++++-- Scripts/Helpers/VRSmoothCamera.cs | 2 +- Scripts/Input/SixenseInputToEvents.cs | 3 --- Scripts/Modules/ActionsModule.cs | 2 +- Scripts/Modules/DeviceInputModule.cs | 6 +++++- Scripts/Modules/HierarchyModule.cs | 2 -- Scripts/Modules/SceneObjectModule.cs | 6 +++++- Scripts/Proxies/ViveProxy.cs | 3 ++- Scripts/UI/NumericInputField.cs | 8 ++++++++ Scripts/Utilities/CameraUtils.cs | 4 ++-- Scripts/Utilities/ObjectUtils.cs | 2 +- .../MonoBehaviourExtensionsTests.cs | 6 ++++-- .../TransformExtensionsTests.cs | 4 +++- .../Unit/Utilities/GradientPairTests.cs | 4 +++- .../Unit/Utilities/MaterialUtilsTests.cs | 4 +++- .../Unit/Utilities/MathUtilsExtTests.cs | 4 +++- .../Editor/Unit/Utilities/ObjectUtilsTests.cs | 4 ++++ Tools/AnnotationTool/AnnotationTool.cs | 2 +- Tools/LocomotionTool/LocomotionTool.cs | 5 +---- Tools/SelectionTool/SelectionTool.cs | 2 +- libs/input-prototype | 2 +- 24 files changed, 77 insertions(+), 35 deletions(-) diff --git a/Editor/EditingContextManagerEditor.cs b/Editor/EditingContextManagerEditor.cs index 308caf0dd..d68b5a586 100644 --- a/Editor/EditingContextManagerEditor.cs +++ b/Editor/EditingContextManagerEditor.cs @@ -1,5 +1,4 @@ -#if UNITY_2017_2_OR_NEWER -using System; +using System; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Core @@ -49,4 +48,3 @@ public override void OnInspectorGUI() } } } -#endif diff --git a/Scripts/Core/Contexts/EditingContextManager.cs b/Scripts/Core/Contexts/EditingContextManager.cs index a38200768..b93f0ef35 100644 --- a/Scripts/Core/Contexts/EditingContextManager.cs +++ b/Scripts/Core/Contexts/EditingContextManager.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; @@ -109,6 +109,7 @@ static void ReopenOnExitPlaymode() } } +#if UNITY_2017_2_OR_NEWER static void OnPlayModeStateChanged(PlayModeStateChange stateChange) { if (stateChange == PlayModeStateChange.ExitingEditMode) @@ -119,6 +120,7 @@ static void OnPlayModeStateChanged(PlayModeStateChange stateChange) view.Close(); } } +#endif void OnEnable() { @@ -139,16 +141,20 @@ void OnEnable() // Force the window to repaint every tick, since we need live updating // This also allows scripts with [ExecuteInEditMode] to run +#if UNITY_2017_2_OR_NEWER EditorApplication.update += EditorApplication.QueuePlayerLoopUpdate; EditorApplication.playModeStateChanged += OnPlayModeStateChanged; +#endif } void OnDisable() { +#if UNITY_2017_2_OR_NEWER EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; EditorApplication.update -= EditorApplication.QueuePlayerLoopUpdate; +#endif VRView.afterOnGUI -= OnVRViewGUI; diff --git a/Scripts/Core/EditorVR.cs b/Scripts/Core/EditorVR.cs index 955029090..255c61564 100644 --- a/Scripts/Core/EditorVR.cs +++ b/Scripts/Core/EditorVR.cs @@ -540,12 +540,12 @@ static NoEditorVR() { if (EditorPrefs.GetBool(k_ShowCustomEditorWarning, true)) { - var message = "EditorVR requires a custom editor build. Please see https://blogs.unity3d.com/2016/12/15/editorvr-experimental-build-available-today/"; - var result = EditorUtility.DisplayDialogComplex("Custom Editor Build Required", message, "Download", "Ignore", "Remind Me Again"); + var message = "EditorVR requires Unity 2017.2 or above."; + var result = EditorUtility.DisplayDialogComplex("Update Unity", message, "Download", "Ignore", "Remind Me Again"); switch (result) { case 0: - Application.OpenURL("http://rebrand.ly/EditorVR-build"); + Application.OpenURL("https://unity3d.com/get-unity/download"); break; case 1: EditorPrefs.SetBool(k_ShowCustomEditorWarning, false); diff --git a/Scripts/Core/VRView.cs b/Scripts/Core/VRView.cs index f44a98312..f43dc27b1 100644 --- a/Scripts/Core/VRView.cs +++ b/Scripts/Core/VRView.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR using System; using UnityEngine; using UnityEngine.Assertions; @@ -98,7 +98,11 @@ public static Vector3 headCenteredOrigin { get { +#if UNITY_2017_2_OR_NEWER return UnityEngine.XR.XRDevice.GetTrackingSpaceType() == UnityEngine.XR.TrackingSpaceType.Stationary ? Vector3.up * HeadHeight : Vector3.zero; +#else + return Vector3.zero; +#endif } } @@ -151,8 +155,9 @@ public void OnEnable() // VRSettings.enabled latches the reference pose for the current camera var currentCamera = Camera.current; Camera.SetupCurrent(m_Camera); +#if UNITY_2017_2_OR_NEWER UnityEngine.XR.XRSettings.enabled = true; - UnityEngine.XR.InputTracking.Recenter(); +#endif Camera.SetupCurrent(currentCamera); if (viewEnabled != null) @@ -164,7 +169,9 @@ public void OnDisable() if (viewDisabled != null) viewDisabled(); +#if UNITY_2017_2_OR_NEWER UnityEngine.XR.XRSettings.enabled = false; +#endif EditorPrefs.SetBool(k_ShowDeviceView, m_ShowDeviceView); EditorPrefs.SetBool(k_UseCustomPreviewCamera, m_UseCustomPreviewCamera); @@ -181,8 +188,10 @@ public void OnDisable() void UpdateCameraTransform() { var cameraTransform = m_Camera.transform; +#if UNITY_2017_2_OR_NEWER cameraTransform.localPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.Head); cameraTransform.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.Head); +#endif } public void CreateCameraTargetTexture(ref RenderTexture renderTexture, Rect cameraRect, bool hdr) @@ -228,7 +237,9 @@ void PrepareCameraTargetTexture(Rect cameraRect) // Always render camera into a RT CreateCameraTargetTexture(ref m_TargetTexture, cameraRect, false); m_Camera.targetTexture = m_ShowDeviceView ? m_TargetTexture : null; +#if UNITY_2017_2_OR_NEWER UnityEngine.XR.XRSettings.showDeviceView = !customPreviewCamera && m_ShowDeviceView; +#endif } void OnGUI() @@ -290,8 +301,10 @@ void DoDrawCamera(Rect rect) if (!m_Camera.gameObject.activeInHierarchy) return; +#if UNITY_2017_2_OR_NEWER if (!UnityEngine.XR.XRDevice.isPresent) return; +#endif UnityEditor.Handles.DrawCamera(rect, m_Camera, m_RenderMode); if (Event.current.type == EventType.Repaint) @@ -333,6 +346,7 @@ void UpdateHMDStatus() static bool GetIsUserPresent() { +#if UNITY_2017_2_OR_NEWER #if ENABLE_OVR_INPUT if (UnityEngine.XR.XRSettings.loadedDeviceName == "Oculus") return OVRPlugin.userPresent; @@ -340,6 +354,7 @@ static bool GetIsUserPresent() #if ENABLE_STEAMVR_INPUT if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR") return OpenVR.System.GetTrackedDeviceActivityLevel(0) == EDeviceActivityLevel.k_EDeviceActivityLevel_UserInteraction; +#endif #endif return true; } diff --git a/Scripts/Helpers/VRSmoothCamera.cs b/Scripts/Helpers/VRSmoothCamera.cs index bbd249157..4cdd5c0ee 100644 --- a/Scripts/Helpers/VRSmoothCamera.cs +++ b/Scripts/Helpers/VRSmoothCamera.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR using UnityEditor.Experimental.EditorVR.Core; using UnityEngine; diff --git a/Scripts/Input/SixenseInputToEvents.cs b/Scripts/Input/SixenseInputToEvents.cs index 116c09076..65c9ad050 100644 --- a/Scripts/Input/SixenseInputToEvents.cs +++ b/Scripts/Input/SixenseInputToEvents.cs @@ -182,8 +182,6 @@ private void SendTrackingEvents(int sixenseDeviceIndex, int deviceIndex) void CalibrateControllers() { -#if UNITY_2017_2_OR_NEWER - // Assume controllers are on the side of the HMD and facing forward (aligned with base) var span = (SixenseInput.Controllers[1].Position * k_HydraUnits - SixenseInput.Controllers[0].Position * k_HydraUnits).magnitude; @@ -198,7 +196,6 @@ void CalibrateControllers() (m_RotationOffset * SixenseInput.Controllers[0].Position * k_HydraUnits); m_ControllerOffsets[1] = VRView.cameraRig.InverseTransformPoint(headPivot.position + (headPivot.right * span * 0.5f)) - (m_RotationOffset * SixenseInput.Controllers[1].Position * k_HydraUnits); -#endif } #endif } diff --git a/Scripts/Modules/ActionsModule.cs b/Scripts/Modules/ActionsModule.cs index 38bf231fc..2c1fe5c09 100644 --- a/Scripts/Modules/ActionsModule.cs +++ b/Scripts/Modules/ActionsModule.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 6128be2b1..8503579d9 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -1,4 +1,8 @@ -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR +#if !UNITY_2017_2_OR_NEWER +#pragma warning disable 649 // "never assigned to" warning +#endif + using System; using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Utilities; diff --git a/Scripts/Modules/HierarchyModule.cs b/Scripts/Modules/HierarchyModule.cs index 9c7cefd19..50d5c0f09 100644 --- a/Scripts/Modules/HierarchyModule.cs +++ b/Scripts/Modules/HierarchyModule.cs @@ -28,12 +28,10 @@ void Awake() m_IgnoreList.Add(manager.gameObject); } -#if UNITY_2017_2_OR_NEWER foreach (var manager in Resources.FindObjectsOfTypeAll()) { m_IgnoreList.Add(manager.gameObject); } -#endif } void OnEnable() diff --git a/Scripts/Modules/SceneObjectModule.cs b/Scripts/Modules/SceneObjectModule.cs index d8fb8eedf..e8279cc16 100644 --- a/Scripts/Modules/SceneObjectModule.cs +++ b/Scripts/Modules/SceneObjectModule.cs @@ -1,4 +1,8 @@ -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR +#if !UNITY_2017_2_OR_NEWER +#pragma warning disable 649 // "never assigned to" warning +#endif + using System; using System.Collections; using UnityEditor.Experimental.EditorVR.Utilities; diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 1af2a424d..42fb39df9 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -4,7 +4,6 @@ using UnityEditor.Experimental.EditorVR.Input; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; -using UnityEngine.VR; namespace UnityEditor.Experimental.EditorVR.Proxies { @@ -23,6 +22,7 @@ sealed class ViveProxy : TwoHandedProxyBase public override void Awake() { +#if UNITY_2017_2_OR_NEWER if (UnityEngine.XR.XRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0) { m_LeftHandProxyPrefab = m_LeftHandTouchProxyPrefab; @@ -34,6 +34,7 @@ public override void Awake() #if !ENABLE_STEAMVR_INPUT enabled = false; +#endif #endif } diff --git a/Scripts/UI/NumericInputField.cs b/Scripts/UI/NumericInputField.cs index 03245bad5..bc0021257 100644 --- a/Scripts/UI/NumericInputField.cs +++ b/Scripts/UI/NumericInputField.cs @@ -247,7 +247,11 @@ void ParseNumberField() m_Text = m_Text.Replace(',', '.'); if (!float.TryParse(m_Text, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture.NumberFormat, out floatVal)) + { +#if UNITY_2017_2_OR_NEWER floatVal = ExpressionEvaluator.Evaluate(m_Text); +#endif + } if (float.IsNaN(floatVal)) floatVal = 0; @@ -258,7 +262,11 @@ void ParseNumberField() { int intVal; if (!int.TryParse(m_Text, out intVal)) + { +#if UNITY_2017_2_OR_NEWER m_Text = ExpressionEvaluator.Evaluate(m_Text).ToString(k_IntFieldFormatString); +#endif + } } m_OperandCount = 0; diff --git a/Scripts/Utilities/CameraUtils.cs b/Scripts/Utilities/CameraUtils.cs index b42104918..4b4e1454f 100644 --- a/Scripts/Utilities/CameraUtils.cs +++ b/Scripts/Utilities/CameraUtils.cs @@ -36,7 +36,7 @@ public static Camera GetMainCamera() { var camera = Camera.main; -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR if (!Application.isPlaying && VRView.viewerCamera) { camera = VRView.viewerCamera; @@ -50,7 +50,7 @@ public static Transform GetCameraRig() { var rig = Camera.main ? Camera.main.transform.parent : null; -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR if (!Application.isPlaying) { if (VRView.cameraRig) diff --git a/Scripts/Utilities/ObjectUtils.cs b/Scripts/Utilities/ObjectUtils.cs index 75fb29d8c..5c7248bd0 100644 --- a/Scripts/Utilities/ObjectUtils.cs +++ b/Scripts/Utilities/ObjectUtils.cs @@ -239,7 +239,7 @@ public static void Destroy(UnityObject o, float t = 0f) { UnityObject.Destroy(o, t); } -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR else { if (Mathf.Approximately(t, 0f)) diff --git a/Tests/Editor/Unit/Extension Methods/MonoBehaviourExtensionsTests.cs b/Tests/Editor/Unit/Extension Methods/MonoBehaviourExtensionsTests.cs index 6c857ad64..88c3b49ab 100644 --- a/Tests/Editor/Unit/Extension Methods/MonoBehaviourExtensionsTests.cs +++ b/Tests/Editor/Unit/Extension Methods/MonoBehaviourExtensionsTests.cs @@ -1,4 +1,5 @@ -using System.Collections; +#if UNITY_5_6_OR_NEWER +using System.Collections; using NUnit.Framework; using UnityEngine; using UnityEditor.Experimental.EditorVR.Extensions; @@ -12,7 +13,7 @@ public class MonoBehaviourExtensionsTests int coIndex = 0; IEnumerator routine() { yield return coIndex++; } - [OneTimeSetUp] + [OneTimeSetUp] public void Setup() { mb = new GameObject().AddComponent(); @@ -28,3 +29,4 @@ public void StopCoroutineOverload_NullifiesCoroutine() } } } +#endif diff --git a/Tests/Editor/Unit/Extension Methods/TransformExtensionsTests.cs b/Tests/Editor/Unit/Extension Methods/TransformExtensionsTests.cs index 5f080f9df..c1c803281 100644 --- a/Tests/Editor/Unit/Extension Methods/TransformExtensionsTests.cs +++ b/Tests/Editor/Unit/Extension Methods/TransformExtensionsTests.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if UNITY_5_6_OR_NEWER +using NUnit.Framework; using UnityEngine; using UnityEditor.Experimental.EditorVR.Extensions; @@ -30,3 +31,4 @@ public void TransformBounds_TranslatesLocalBoundsToWorld() } } } +#endif diff --git a/Tests/Editor/Unit/Utilities/GradientPairTests.cs b/Tests/Editor/Unit/Utilities/GradientPairTests.cs index 20087a6fa..2af0fb198 100644 --- a/Tests/Editor/Unit/Utilities/GradientPairTests.cs +++ b/Tests/Editor/Unit/Utilities/GradientPairTests.cs @@ -1,4 +1,5 @@ -using UnityEngine; +#if UNITY_5_6_OR_NEWER +using UnityEngine; using NUnit.Framework; using UnityEditor.Experimental.EditorVR.Helpers; @@ -53,3 +54,4 @@ public void Lerp_Interpolates_StartAndEndColors() public void Cleanup() { } } } +#endif diff --git a/Tests/Editor/Unit/Utilities/MaterialUtilsTests.cs b/Tests/Editor/Unit/Utilities/MaterialUtilsTests.cs index dd72d3153..e0117a931 100644 --- a/Tests/Editor/Unit/Utilities/MaterialUtilsTests.cs +++ b/Tests/Editor/Unit/Utilities/MaterialUtilsTests.cs @@ -1,4 +1,5 @@ -using UnityEngine; +#if UNITY_5_6_OR_NEWER +using UnityEngine; using UnityEngine.UI; using NUnit.Framework; using UnityEditor.Experimental.EditorVR.Utilities; @@ -65,3 +66,4 @@ public void HextoColor_DoesValidConversion(string hex, float r, float g, float b public void Cleanup() { } } } +#endif diff --git a/Tests/Editor/Unit/Utilities/MathUtilsExtTests.cs b/Tests/Editor/Unit/Utilities/MathUtilsExtTests.cs index f9e603478..e51513e15 100644 --- a/Tests/Editor/Unit/Utilities/MathUtilsExtTests.cs +++ b/Tests/Editor/Unit/Utilities/MathUtilsExtTests.cs @@ -1,4 +1,5 @@ -using NUnit.Framework; +#if UNITY_5_6_OR_NEWER +using NUnit.Framework; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -46,3 +47,4 @@ public void ConstrainYawRotation() public void Cleanup() { } } } +#endif diff --git a/Tests/Editor/Unit/Utilities/ObjectUtilsTests.cs b/Tests/Editor/Unit/Utilities/ObjectUtilsTests.cs index 166bd5a0b..8d607e586 100644 --- a/Tests/Editor/Unit/Utilities/ObjectUtilsTests.cs +++ b/Tests/Editor/Unit/Utilities/ObjectUtilsTests.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; +#if UNITY_5_6_OR_NEWER using UnityEngine.TestTools; +#endif namespace UnityEditor.Experimental.EditorVR.Tests.Utilities { @@ -73,6 +75,7 @@ public void Instantiate_SetRunInEditMode(bool expected) m_ToCleanupAfterEach.Add(clone); } +#if UNITY_5_6_OR_NEWER [UnityTest] public IEnumerator Destroy_OneArg_DestroysImmediately_InEditMode() { @@ -81,6 +84,7 @@ public IEnumerator Destroy_OneArg_DestroysImmediately_InEditMode() yield return null; // skip frame to allow destruction to run Assert.IsTrue(m_Other == null); } +#endif // here, we could test the other types of calls to Destroy / Instantiate, but that // would require refactor / making some things "internal" instead of private, diff --git a/Tools/AnnotationTool/AnnotationTool.cs b/Tools/AnnotationTool/AnnotationTool.cs index efb784084..0668fd6a9 100644 --- a/Tools/AnnotationTool/AnnotationTool.cs +++ b/Tools/AnnotationTool/AnnotationTool.cs @@ -313,7 +313,7 @@ void HandleBrushSize(float value) if (m_AnnotationPointer != null) { var brushSize = m_Preferences.brushSize; - if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR") // For vive controllers, use 1:1 touchpad setting. + if (proxyType == typeof(ViveProxy)) // For vive controllers, use 1:1 touchpad setting. { brushSize = Mathf.Lerp(MinBrushSize, MaxBrushSize, (value + 1) / 2f); } diff --git a/Tools/LocomotionTool/LocomotionTool.cs b/Tools/LocomotionTool/LocomotionTool.cs index d96a3a874..1f96cf897 100644 --- a/Tools/LocomotionTool/LocomotionTool.cs +++ b/Tools/LocomotionTool/LocomotionTool.cs @@ -491,9 +491,7 @@ bool DoTwoHandedScaling(ConsumeControlDelegate consumeControl) if (worldResetHeld && otherWorldResetHeld) { m_AllowScaling = false; -#if UNITY_2017_2_OR_NEWER cameraRig.position = VRView.headCenteredOrigin; -#endif cameraRig.rotation = Quaternion.identity; ResetViewerScale(); @@ -567,9 +565,8 @@ IEnumerator MoveTowardTarget(Vector3 targetPosition) var offset = cameraRig.position - CameraUtils.GetMainCamera().transform.position; offset.y = 0; -#if UNITY_2017_2_OR_NEWER offset += VRView.HeadHeight * Vector3.up * this.GetViewerScale(); -#endif + targetPosition += offset; const float kTargetDuration = 0.05f; var currentPosition = cameraRig.position; diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index f2807ba59..48a529592 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_2017_2_OR_NEWER +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; diff --git a/libs/input-prototype b/libs/input-prototype index b671b868a..92aa26f22 160000 --- a/libs/input-prototype +++ b/libs/input-prototype @@ -1 +1 @@ -Subproject commit b671b868a5c458f2ce194da5bd6808f401a914c5 +Subproject commit 92aa26f2202380cfca037b450f16a67f4796caa3 From 2818af7239324b0c01170cddfc67e953999283e4 Mon Sep 17 00:00:00 2001 From: andrewm Date: Wed, 4 Oct 2017 17:17:13 -0700 Subject: [PATCH 084/457] fixed spacing --- Scripts/Utilities/ObjectUtils.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Scripts/Utilities/ObjectUtils.cs b/Scripts/Utilities/ObjectUtils.cs index 5c7248bd0..3dbc9af31 100644 --- a/Scripts/Utilities/ObjectUtils.cs +++ b/Scripts/Utilities/ObjectUtils.cs @@ -286,9 +286,7 @@ public static Type TypeNameToType(string name) foreach (var type in assembly.GetTypes()) { if (type.Name.Equals(name) && typeof(UnityObject).IsAssignableFrom(type)) - { return type; - } } } catch (ReflectionTypeLoadException) From dd617a6f12857870c640fa5e2b8c497797be5ccb Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 4 Oct 2017 17:52:00 -0700 Subject: [PATCH 085/457] Add using for UnityEngine.XR --- Scripts/Core/EditorVR.Viewer.cs | 4 ++-- Scripts/Core/VRView.cs | 23 +++++++++++------------ Scripts/Input/ViveInputToEvents.cs | 6 +++--- Scripts/Proxies/ViveProxy.cs | 5 +++-- libs/input-prototype | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index 885e67dba..8d8f750b1 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -6,7 +6,7 @@ using UnityEditor.Experimental.EditorVR.Modules; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; -using UnityEngine.VR; +using UnityEngine.XR; namespace UnityEditor.Experimental.EditorVR.Core { @@ -146,7 +146,7 @@ internal void InitializeCamera() viewerCamera.gameObject.hideFlags = defaultHideFlags; m_OriginalNearClipPlane = viewerCamera.nearClipPlane; m_OriginalFarClipPlane = viewerCamera.farClipPlane; - if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR") + if (XRSettings.loadedDeviceName == "OpenVR") { // Steam's reference position should be at the feet and not at the head as we do with Oculus cameraRig.localPosition = Vector3.zero; diff --git a/Scripts/Core/VRView.cs b/Scripts/Core/VRView.cs index f43dc27b1..03fac24ab 100644 --- a/Scripts/Core/VRView.cs +++ b/Scripts/Core/VRView.cs @@ -5,11 +5,10 @@ using System.Collections; using UnityEditor.Experimental.EditorVR.Helpers; using System.Reflection; -using UnityEngine.VR; +using UnityEngine.XR; #if ENABLE_STEAMVR_INPUT using Valve.VR; #endif -using UnityObject = UnityEngine.Object; namespace UnityEditor.Experimental.EditorVR.Core { @@ -99,7 +98,7 @@ public static Vector3 headCenteredOrigin get { #if UNITY_2017_2_OR_NEWER - return UnityEngine.XR.XRDevice.GetTrackingSpaceType() == UnityEngine.XR.TrackingSpaceType.Stationary ? Vector3.up * HeadHeight : Vector3.zero; + return XRDevice.GetTrackingSpaceType() == TrackingSpaceType.Stationary ? Vector3.up * HeadHeight : Vector3.zero; #else return Vector3.zero; #endif @@ -156,7 +155,7 @@ public void OnEnable() var currentCamera = Camera.current; Camera.SetupCurrent(m_Camera); #if UNITY_2017_2_OR_NEWER - UnityEngine.XR.XRSettings.enabled = true; + XRSettings.enabled = true; #endif Camera.SetupCurrent(currentCamera); @@ -170,7 +169,7 @@ public void OnDisable() viewDisabled(); #if UNITY_2017_2_OR_NEWER - UnityEngine.XR.XRSettings.enabled = false; + XRSettings.enabled = false; #endif EditorPrefs.SetBool(k_ShowDeviceView, m_ShowDeviceView); @@ -189,8 +188,8 @@ void UpdateCameraTransform() { var cameraTransform = m_Camera.transform; #if UNITY_2017_2_OR_NEWER - cameraTransform.localPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.Head); - cameraTransform.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.Head); + cameraTransform.localPosition = InputTracking.GetLocalPosition(XRNode.Head); + cameraTransform.localRotation = InputTracking.GetLocalRotation(XRNode.Head); #endif } @@ -238,7 +237,7 @@ void PrepareCameraTargetTexture(Rect cameraRect) CreateCameraTargetTexture(ref m_TargetTexture, cameraRect, false); m_Camera.targetTexture = m_ShowDeviceView ? m_TargetTexture : null; #if UNITY_2017_2_OR_NEWER - UnityEngine.XR.XRSettings.showDeviceView = !customPreviewCamera && m_ShowDeviceView; + XRSettings.showDeviceView = !customPreviewCamera && m_ShowDeviceView; #endif } @@ -302,7 +301,7 @@ void DoDrawCamera(Rect rect) return; #if UNITY_2017_2_OR_NEWER - if (!UnityEngine.XR.XRDevice.isPresent) + if (!XRDevice.isPresent) return; #endif @@ -348,11 +347,11 @@ static bool GetIsUserPresent() { #if UNITY_2017_2_OR_NEWER #if ENABLE_OVR_INPUT - if (UnityEngine.XR.XRSettings.loadedDeviceName == "Oculus") + if (XRSettings.loadedDeviceName == "Oculus") return OVRPlugin.userPresent; #endif #if ENABLE_STEAMVR_INPUT - if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR") + if (XRSettings.loadedDeviceName == "OpenVR") return OpenVR.System.GetTrackedDeviceActivityLevel(0) == EDeviceActivityLevel.k_EDeviceActivityLevel_UserInteraction; #endif #endif @@ -394,4 +393,4 @@ void SetAutoRepaintOnSceneChanged(Type viewType, bool enabled) } } } -#endif \ No newline at end of file +#endif diff --git a/Scripts/Input/ViveInputToEvents.cs b/Scripts/Input/ViveInputToEvents.cs index 40fe05235..f477446f4 100644 --- a/Scripts/Input/ViveInputToEvents.cs +++ b/Scripts/Input/ViveInputToEvents.cs @@ -1,8 +1,8 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using UnityEditor.Experimental.EditorVR; using UnityEngine; using UnityEngine.InputNew; -using UnityEngine.VR; +using UnityEngine.XR; #if ENABLE_STEAMVR_INPUT using System; using Valve.VR; @@ -65,7 +65,7 @@ public void Update() return; // Oculus Touch on OpenVR should have fixed left/right hand device indices - if (UnityEngine.XR.XRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0 + if (XRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0 && leftSteamDeviceIndex > rightSteamDeviceIndex) { var swap = rightSteamDeviceIndex; diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 42fb39df9..4bd45e987 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -1,9 +1,10 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections; using UnityEditor.Experimental.EditorVR.Input; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; +using UnityEngine.XR; namespace UnityEditor.Experimental.EditorVR.Proxies { @@ -23,7 +24,7 @@ sealed class ViveProxy : TwoHandedProxyBase public override void Awake() { #if UNITY_2017_2_OR_NEWER - if (UnityEngine.XR.XRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0) + if (XRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0) { m_LeftHandProxyPrefab = m_LeftHandTouchProxyPrefab; m_RightHandProxyPrefab = m_RightHandTouchProxyPrefab; diff --git a/libs/input-prototype b/libs/input-prototype index 92aa26f22..ced8f334a 160000 --- a/libs/input-prototype +++ b/libs/input-prototype @@ -1 +1 @@ -Subproject commit 92aa26f2202380cfca037b450f16a67f4796caa3 +Subproject commit ced8f334ad608aa77348820a4430ea450d71e37c From d170afa37a1c1b1c6347d826d872a836cb73931e Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Wed, 4 Oct 2017 19:55:22 -0700 Subject: [PATCH 086/457] Group UNITY_2017_2_OR_NEWER defines --- Scripts/Core/Contexts/EditingContextManager.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Scripts/Core/Contexts/EditingContextManager.cs b/Scripts/Core/Contexts/EditingContextManager.cs index b93f0ef35..ef84bf794 100644 --- a/Scripts/Core/Contexts/EditingContextManager.cs +++ b/Scripts/Core/Contexts/EditingContextManager.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR +#if UNITY_EDITOR using System; using System.Collections.Generic; using System.Linq; @@ -120,7 +120,6 @@ static void OnPlayModeStateChanged(PlayModeStateChange stateChange) view.Close(); } } -#endif void OnEnable() { @@ -141,20 +140,16 @@ void OnEnable() // Force the window to repaint every tick, since we need live updating // This also allows scripts with [ExecuteInEditMode] to run -#if UNITY_2017_2_OR_NEWER EditorApplication.update += EditorApplication.QueuePlayerLoopUpdate; EditorApplication.playModeStateChanged += OnPlayModeStateChanged; -#endif } void OnDisable() { -#if UNITY_2017_2_OR_NEWER EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; EditorApplication.update -= EditorApplication.QueuePlayerLoopUpdate; -#endif VRView.afterOnGUI -= OnVRViewGUI; @@ -170,6 +165,7 @@ void OnDisable() SaveUserSettings(m_Settings); } +#endif void OnVRViewGUI(EditorWindow window) { From d848ae8f8c16d477d0e9e816f8ea95a25ddb18b0 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 5 Oct 2017 13:47:46 -0700 Subject: [PATCH 087/457] Begin implementing Vive controller prefab --- Models/Vive.meta | 9 + Models/Vive/Materials.meta | 9 + Models/Vive/Materials/body.mtl | 15 + Models/Vive/Materials/body.mtl.meta | 8 + Models/Vive/Materials/button.mtl | 15 + Models/Vive/Materials/button.mtl.meta | 8 + Models/Vive/Materials/initialShadingGroup.mat | 75 + .../Materials/initialShadingGroup.mat.meta | 5 +- Models/Vive/Materials/l_grip.mtl | 15 + Models/Vive/Materials/l_grip.mtl.meta | 8 + Models/Vive/Materials/lambert4SG.mat | 80 + .../Vive/Materials/lambert4SG.mat.meta | 5 +- Models/Vive/Materials/led.mtl | 15 + Models/Vive/Materials/led.mtl.meta | 8 + Models/Vive/Materials/r_grip.mtl | 15 + Models/Vive/Materials/r_grip.mtl.meta | 8 + Models/Vive/Materials/scroll_wheel.mtl | 15 + Models/Vive/Materials/scroll_wheel.mtl.meta | 8 + Models/Vive/Materials/status.mtl | 9 + Models/Vive/Materials/status.mtl.meta | 8 + Models/Vive/Materials/sys_button.mtl | 15 + Models/Vive/Materials/sys_button.mtl.meta | 8 + Models/Vive/Materials/trackpad.mtl | 15 + Models/Vive/Materials/trackpad.mtl.meta | 8 + Models/Vive/Materials/trackpad_scroll_cut.mtl | 15 + .../Materials/trackpad_scroll_cut.mtl.meta | 8 + Models/Vive/Materials/trackpad_touch.mtl | 15 + Models/Vive/Materials/trackpad_touch.mtl.meta | 8 + Models/Vive/Materials/trigger.mtl | 15 + Models/Vive/Materials/trigger.mtl.meta | 8 + Models/Vive/Models.meta | 9 + Models/Vive/Models/body.obj | 3 + Models/Vive/Models/body.obj.meta | 84 + Models/Vive/Models/button.obj | 3 + Models/Vive/Models/button.obj.meta | 84 + Models/Vive/Models/l_grip.obj | 3 + Models/Vive/Models/l_grip.obj.meta | 84 + Models/Vive/Models/led.obj | 3 + Models/Vive/Models/led.obj.meta | 84 + Models/Vive/Models/r_grip.obj | 3 + Models/Vive/Models/r_grip.obj.meta | 84 + Models/Vive/Models/scroll_wheel.obj | 3 + Models/Vive/Models/scroll_wheel.obj.meta | 84 + Models/Vive/Models/status.obj | 3 + Models/Vive/Models/status.obj.meta | 84 + Models/Vive/Models/sys_button.obj | 3 + Models/Vive/Models/sys_button.obj.meta | 84 + Models/Vive/Models/trackpad.obj | 3 + Models/Vive/Models/trackpad.obj.meta | 84 + Models/Vive/Models/trackpad_scroll_cut.obj | 3 + .../Vive/Models/trackpad_scroll_cut.obj.meta | 84 + Models/Vive/Models/trackpad_touch.obj | 3 + Models/Vive/Models/trackpad_touch.obj.meta | 84 + Models/Vive/Models/trigger.obj | 3 + Models/Vive/Models/trigger.obj.meta | 84 + Models/Vive/Textures.meta | 9 + .../Vive/Textures/onepointfive_occ_bake.tga | 3 + .../Textures/onepointfive_occ_bake.tga.meta | 68 + Models/Vive/Textures/onepointfive_spec.png | 3 + .../Vive/Textures/onepointfive_spec.png.meta | 76 + Models/Vive/Textures/onepointfive_texture.png | 3 + .../Textures/onepointfive_texture.png.meta | 68 + Models/Vive/Textures/status.png | 3 + Models/Vive/Textures/status.png.meta | 68 + Models/Vive/Vive Controller.prefab | 891 ++++++++ Models/Vive/Vive Controller.prefab.meta | 9 + Prefabs/Proxies/ViveController.prefab | 1299 +++--------- Prefabs/Proxies/ViveLeftTouch.prefab | 1793 ----------------- Prefabs/Proxies/ViveRightTouch.prefab | 1793 ----------------- Scripts/Proxies/ViveProxy.cs | 32 - Scripts/Proxies/ViveProxy.cs.meta | 8 +- 71 files changed, 3030 insertions(+), 4602 deletions(-) create mode 100644 Models/Vive.meta create mode 100644 Models/Vive/Materials.meta create mode 100644 Models/Vive/Materials/body.mtl create mode 100644 Models/Vive/Materials/body.mtl.meta create mode 100644 Models/Vive/Materials/button.mtl create mode 100644 Models/Vive/Materials/button.mtl.meta create mode 100644 Models/Vive/Materials/initialShadingGroup.mat rename Prefabs/Proxies/ViveLeftTouch.prefab.meta => Models/Vive/Materials/initialShadingGroup.mat.meta (56%) create mode 100644 Models/Vive/Materials/l_grip.mtl create mode 100644 Models/Vive/Materials/l_grip.mtl.meta create mode 100644 Models/Vive/Materials/lambert4SG.mat rename Prefabs/Proxies/ViveRightTouch.prefab.meta => Models/Vive/Materials/lambert4SG.mat.meta (56%) create mode 100644 Models/Vive/Materials/led.mtl create mode 100644 Models/Vive/Materials/led.mtl.meta create mode 100644 Models/Vive/Materials/r_grip.mtl create mode 100644 Models/Vive/Materials/r_grip.mtl.meta create mode 100644 Models/Vive/Materials/scroll_wheel.mtl create mode 100644 Models/Vive/Materials/scroll_wheel.mtl.meta create mode 100644 Models/Vive/Materials/status.mtl create mode 100644 Models/Vive/Materials/status.mtl.meta create mode 100644 Models/Vive/Materials/sys_button.mtl create mode 100644 Models/Vive/Materials/sys_button.mtl.meta create mode 100644 Models/Vive/Materials/trackpad.mtl create mode 100644 Models/Vive/Materials/trackpad.mtl.meta create mode 100644 Models/Vive/Materials/trackpad_scroll_cut.mtl create mode 100644 Models/Vive/Materials/trackpad_scroll_cut.mtl.meta create mode 100644 Models/Vive/Materials/trackpad_touch.mtl create mode 100644 Models/Vive/Materials/trackpad_touch.mtl.meta create mode 100644 Models/Vive/Materials/trigger.mtl create mode 100644 Models/Vive/Materials/trigger.mtl.meta create mode 100644 Models/Vive/Models.meta create mode 100644 Models/Vive/Models/body.obj create mode 100644 Models/Vive/Models/body.obj.meta create mode 100644 Models/Vive/Models/button.obj create mode 100644 Models/Vive/Models/button.obj.meta create mode 100644 Models/Vive/Models/l_grip.obj create mode 100644 Models/Vive/Models/l_grip.obj.meta create mode 100644 Models/Vive/Models/led.obj create mode 100644 Models/Vive/Models/led.obj.meta create mode 100644 Models/Vive/Models/r_grip.obj create mode 100644 Models/Vive/Models/r_grip.obj.meta create mode 100644 Models/Vive/Models/scroll_wheel.obj create mode 100644 Models/Vive/Models/scroll_wheel.obj.meta create mode 100644 Models/Vive/Models/status.obj create mode 100644 Models/Vive/Models/status.obj.meta create mode 100644 Models/Vive/Models/sys_button.obj create mode 100644 Models/Vive/Models/sys_button.obj.meta create mode 100644 Models/Vive/Models/trackpad.obj create mode 100644 Models/Vive/Models/trackpad.obj.meta create mode 100644 Models/Vive/Models/trackpad_scroll_cut.obj create mode 100644 Models/Vive/Models/trackpad_scroll_cut.obj.meta create mode 100644 Models/Vive/Models/trackpad_touch.obj create mode 100644 Models/Vive/Models/trackpad_touch.obj.meta create mode 100644 Models/Vive/Models/trigger.obj create mode 100644 Models/Vive/Models/trigger.obj.meta create mode 100644 Models/Vive/Textures.meta create mode 100644 Models/Vive/Textures/onepointfive_occ_bake.tga create mode 100644 Models/Vive/Textures/onepointfive_occ_bake.tga.meta create mode 100644 Models/Vive/Textures/onepointfive_spec.png create mode 100644 Models/Vive/Textures/onepointfive_spec.png.meta create mode 100644 Models/Vive/Textures/onepointfive_texture.png create mode 100644 Models/Vive/Textures/onepointfive_texture.png.meta create mode 100644 Models/Vive/Textures/status.png create mode 100644 Models/Vive/Textures/status.png.meta create mode 100644 Models/Vive/Vive Controller.prefab create mode 100644 Models/Vive/Vive Controller.prefab.meta delete mode 100644 Prefabs/Proxies/ViveLeftTouch.prefab delete mode 100644 Prefabs/Proxies/ViveRightTouch.prefab diff --git a/Models/Vive.meta b/Models/Vive.meta new file mode 100644 index 000000000..c33f6da62 --- /dev/null +++ b/Models/Vive.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ff4be2d401c7445498948d0b6918850c +folderAsset: yes +timeCreated: 1507230082 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials.meta b/Models/Vive/Materials.meta new file mode 100644 index 000000000..58319e2a1 --- /dev/null +++ b/Models/Vive/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 06abe8dbf14262c4dac0225d767cfbc0 +folderAsset: yes +timeCreated: 1507075389 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/body.mtl b/Models/Vive/Materials/body.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/body.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/body.mtl.meta b/Models/Vive/Materials/body.mtl.meta new file mode 100644 index 000000000..96e6bffb1 --- /dev/null +++ b/Models/Vive/Materials/body.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7a2d4a15a7c7a1148ac269365748a334 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/button.mtl b/Models/Vive/Materials/button.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/button.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/button.mtl.meta b/Models/Vive/Materials/button.mtl.meta new file mode 100644 index 000000000..30da8fc25 --- /dev/null +++ b/Models/Vive/Materials/button.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 539e42079f414614786f29d31d92a2b6 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/initialShadingGroup.mat b/Models/Vive/Materials/initialShadingGroup.mat new file mode 100644 index 000000000..8c4bb7d67 --- /dev/null +++ b/Models/Vive/Materials/initialShadingGroup.mat @@ -0,0 +1,75 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: initialShadingGroup + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 96adc4d51780f23449f5b583efc779fe, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Prefabs/Proxies/ViveLeftTouch.prefab.meta b/Models/Vive/Materials/initialShadingGroup.mat.meta similarity index 56% rename from Prefabs/Proxies/ViveLeftTouch.prefab.meta rename to Models/Vive/Materials/initialShadingGroup.mat.meta index c3d0eec89..5395d9cf6 100644 --- a/Prefabs/Proxies/ViveLeftTouch.prefab.meta +++ b/Models/Vive/Materials/initialShadingGroup.mat.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: daaa590e782c45c4880977eb4d91d4ee -timeCreated: 1466800271 +guid: 382a130523b88ba4fb85bf066031e25c +timeCreated: 1507075389 licenseType: Pro NativeFormatImporter: + mainObjectFileID: 2100000 userData: assetBundleName: assetBundleVariant: diff --git a/Models/Vive/Materials/l_grip.mtl b/Models/Vive/Materials/l_grip.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/l_grip.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/l_grip.mtl.meta b/Models/Vive/Materials/l_grip.mtl.meta new file mode 100644 index 000000000..fd9e15ebb --- /dev/null +++ b/Models/Vive/Materials/l_grip.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c02966373ee087e4b87648a95a463b28 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/lambert4SG.mat b/Models/Vive/Materials/lambert4SG.mat new file mode 100644 index 000000000..9a10f0f29 --- /dev/null +++ b/Models/Vive/Materials/lambert4SG.mat @@ -0,0 +1,80 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: lambert4SG + m_Shader: {fileID: 45, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _SPECGLOSSMAP + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: 24cc18b3a55e86549a28733115993260, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 2800000, guid: 8828790a51636ba44b2295163ee79217, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 2800000, guid: 027f95486327b3f4392c4563b2a13d1a, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} diff --git a/Prefabs/Proxies/ViveRightTouch.prefab.meta b/Models/Vive/Materials/lambert4SG.mat.meta similarity index 56% rename from Prefabs/Proxies/ViveRightTouch.prefab.meta rename to Models/Vive/Materials/lambert4SG.mat.meta index 28ccc1308..d1526a98a 100644 --- a/Prefabs/Proxies/ViveRightTouch.prefab.meta +++ b/Models/Vive/Materials/lambert4SG.mat.meta @@ -1,8 +1,9 @@ fileFormatVersion: 2 -guid: 687f54c4214cdf541b6809be57b26544 -timeCreated: 1466800271 +guid: b0cbe6ebb5130174ea902e4e160468b9 +timeCreated: 1507075389 licenseType: Pro NativeFormatImporter: + mainObjectFileID: 2100000 userData: assetBundleName: assetBundleVariant: diff --git a/Models/Vive/Materials/led.mtl b/Models/Vive/Materials/led.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/led.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/led.mtl.meta b/Models/Vive/Materials/led.mtl.meta new file mode 100644 index 000000000..45374f3ff --- /dev/null +++ b/Models/Vive/Materials/led.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e0da3db3a4fb87c4685dcc2ea06495e4 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/r_grip.mtl b/Models/Vive/Materials/r_grip.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/r_grip.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/r_grip.mtl.meta b/Models/Vive/Materials/r_grip.mtl.meta new file mode 100644 index 000000000..ae8bf5114 --- /dev/null +++ b/Models/Vive/Materials/r_grip.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a0f36f63db2126d408275047b6da8d3c +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/scroll_wheel.mtl b/Models/Vive/Materials/scroll_wheel.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/scroll_wheel.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/scroll_wheel.mtl.meta b/Models/Vive/Materials/scroll_wheel.mtl.meta new file mode 100644 index 000000000..25a6657d1 --- /dev/null +++ b/Models/Vive/Materials/scroll_wheel.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0c32eae4586d18f4f967987138bee9fe +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/status.mtl b/Models/Vive/Materials/status.mtl new file mode 100644 index 000000000..a4ff1f153 --- /dev/null +++ b/Models/Vive/Materials/status.mtl @@ -0,0 +1,9 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd status.png +Ni 1.00 +newmtl lambert4SG + diff --git a/Models/Vive/Materials/status.mtl.meta b/Models/Vive/Materials/status.mtl.meta new file mode 100644 index 000000000..aea121834 --- /dev/null +++ b/Models/Vive/Materials/status.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: df66281bcb5dc5048b756f26b3497de1 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/sys_button.mtl b/Models/Vive/Materials/sys_button.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/sys_button.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/sys_button.mtl.meta b/Models/Vive/Materials/sys_button.mtl.meta new file mode 100644 index 000000000..5f64fe41c --- /dev/null +++ b/Models/Vive/Materials/sys_button.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9ceb230d2af4588408c5af49aa715713 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/trackpad.mtl b/Models/Vive/Materials/trackpad.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/trackpad.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/trackpad.mtl.meta b/Models/Vive/Materials/trackpad.mtl.meta new file mode 100644 index 000000000..f00b5a19e --- /dev/null +++ b/Models/Vive/Materials/trackpad.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: db4994de10138db49bd9d2b21a814120 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/trackpad_scroll_cut.mtl b/Models/Vive/Materials/trackpad_scroll_cut.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/trackpad_scroll_cut.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/trackpad_scroll_cut.mtl.meta b/Models/Vive/Materials/trackpad_scroll_cut.mtl.meta new file mode 100644 index 000000000..68eb4de82 --- /dev/null +++ b/Models/Vive/Materials/trackpad_scroll_cut.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ba1f24fecc5ff924da77dc464c5a1fbb +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/trackpad_touch.mtl b/Models/Vive/Materials/trackpad_touch.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/trackpad_touch.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/trackpad_touch.mtl.meta b/Models/Vive/Materials/trackpad_touch.mtl.meta new file mode 100644 index 000000000..bbf8f926a --- /dev/null +++ b/Models/Vive/Materials/trackpad_touch.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb8fc38bd9541d24794cdaebcf96ac4b +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Materials/trigger.mtl b/Models/Vive/Materials/trigger.mtl new file mode 100644 index 000000000..5a6f15abf --- /dev/null +++ b/Models/Vive/Materials/trigger.mtl @@ -0,0 +1,15 @@ +newmtl initialShadingGroup +illum 4 +Kd 0.50 0.50 0.50 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +Ni 1.00 +newmtl lambert4SG +illum 4 +Kd 0.00 0.00 0.00 +Ka 0.00 0.00 0.00 +Tf 1.00 1.00 1.00 +map_Kd onepointfive_texture.png +Ni 1.00 +Ks 0.00 0.00 0.00 +map_Ks onepointfive_spec.png diff --git a/Models/Vive/Materials/trigger.mtl.meta b/Models/Vive/Materials/trigger.mtl.meta new file mode 100644 index 000000000..31025628e --- /dev/null +++ b/Models/Vive/Materials/trigger.mtl.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4112f44848fa1544d84b5465857ce524 +timeCreated: 1507075387 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models.meta b/Models/Vive/Models.meta new file mode 100644 index 000000000..90714691f --- /dev/null +++ b/Models/Vive/Models.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4224c63ff5dca0f4a89c9bfa2a898cf5 +folderAsset: yes +timeCreated: 1507233331 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/body.obj b/Models/Vive/Models/body.obj new file mode 100644 index 000000000..c410db611 --- /dev/null +++ b/Models/Vive/Models/body.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bf1f538bc76f68fbb5e3e22157157939725fc4f9ec913aa213a41a150a9246a5 +size 1125046 diff --git a/Models/Vive/Models/body.obj.meta b/Models/Vive/Models/body.obj.meta new file mode 100644 index 000000000..9a58639ef --- /dev/null +++ b/Models/Vive/Models/body.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 91923fcf53844be47a1ad1b01dc5b4d5 +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: body_group1 + 400000: //RootNode + 400002: body_group1 + 2300000: body_group1 + 3300000: body_group1 + 4300000: body_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/button.obj b/Models/Vive/Models/button.obj new file mode 100644 index 000000000..10b1fcc0f --- /dev/null +++ b/Models/Vive/Models/button.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9975d9a4bad6e47f87ff38e1361f985c438bdcc5bc9565a13343b927ce46daf9 +size 17699 diff --git a/Models/Vive/Models/button.obj.meta b/Models/Vive/Models/button.obj.meta new file mode 100644 index 000000000..f34aa26f3 --- /dev/null +++ b/Models/Vive/Models/button.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: cbd31b89c0bde684db82ff8056d3cc8e +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: menu_but_group1 + 400000: //RootNode + 400002: menu_but_group1 + 2300000: menu_but_group1 + 3300000: menu_but_group1 + 4300000: menu_but_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/l_grip.obj b/Models/Vive/Models/l_grip.obj new file mode 100644 index 000000000..d8deaaf90 --- /dev/null +++ b/Models/Vive/Models/l_grip.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2b28a4262a6029e234c73172432486cdc2d1e988a2c7867649844af445ac3ee +size 26758 diff --git a/Models/Vive/Models/l_grip.obj.meta b/Models/Vive/Models/l_grip.obj.meta new file mode 100644 index 000000000..577b7c1d5 --- /dev/null +++ b/Models/Vive/Models/l_grip.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: b32f6f3f786b1b8449a3494a98f2b6b2 +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: l_gripper_group1 + 400000: //RootNode + 400002: l_gripper_group1 + 2300000: l_gripper_group1 + 3300000: l_gripper_group1 + 4300000: l_gripper_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/led.obj b/Models/Vive/Models/led.obj new file mode 100644 index 000000000..69756a0e4 --- /dev/null +++ b/Models/Vive/Models/led.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d940ae3df78612587a1dcddd89364c110d214f39cd5031326070dd65466032e +size 4721 diff --git a/Models/Vive/Models/led.obj.meta b/Models/Vive/Models/led.obj.meta new file mode 100644 index 000000000..e134296c1 --- /dev/null +++ b/Models/Vive/Models/led.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 76a8658f8856237409616e713d02cd80 +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: LED_group1 + 400000: //RootNode + 400002: LED_group1 + 2300000: LED_group1 + 3300000: LED_group1 + 4300000: LED_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/r_grip.obj b/Models/Vive/Models/r_grip.obj new file mode 100644 index 000000000..a3ad34064 --- /dev/null +++ b/Models/Vive/Models/r_grip.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c7eae3e668b03d9ded1dbd6932245bdbbecee0935bf007e076064ddba13dede +size 26387 diff --git a/Models/Vive/Models/r_grip.obj.meta b/Models/Vive/Models/r_grip.obj.meta new file mode 100644 index 000000000..a5b63bc36 --- /dev/null +++ b/Models/Vive/Models/r_grip.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 56f79c509c890b74e906e8a5caee40ae +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: r_gripper_group1 + 400000: //RootNode + 400002: r_gripper_group1 + 2300000: r_gripper_group1 + 3300000: r_gripper_group1 + 4300000: r_gripper_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/scroll_wheel.obj b/Models/Vive/Models/scroll_wheel.obj new file mode 100644 index 000000000..e4c13c38f --- /dev/null +++ b/Models/Vive/Models/scroll_wheel.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f72f1f837cf4d0b928fbf1fafa5d6e63e2536590e6338b083d551fc605d773f2 +size 52546 diff --git a/Models/Vive/Models/scroll_wheel.obj.meta b/Models/Vive/Models/scroll_wheel.obj.meta new file mode 100644 index 000000000..3a3b59ac3 --- /dev/null +++ b/Models/Vive/Models/scroll_wheel.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 0470cc75e5d4adc4ea095278a47a03b4 +timeCreated: 1507075389 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: scroll_wheel_group1 + 400000: //RootNode + 400002: scroll_wheel_group1 + 2300000: scroll_wheel_group1 + 3300000: scroll_wheel_group1 + 4300000: scroll_wheel_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/status.obj b/Models/Vive/Models/status.obj new file mode 100644 index 000000000..2d052cc43 --- /dev/null +++ b/Models/Vive/Models/status.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:51f429ed90fdff59cbd54ae523b56731bb8ab136e9f7393447c51b46c1eb342b +size 16049 diff --git a/Models/Vive/Models/status.obj.meta b/Models/Vive/Models/status.obj.meta new file mode 100644 index 000000000..fea8bd553 --- /dev/null +++ b/Models/Vive/Models/status.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 4be9d36f561eb7c4baf693cb4a3afac0 +timeCreated: 1507075389 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: status_group1 + 400000: //RootNode + 400002: status_group1 + 2300000: status_group1 + 3300000: status_group1 + 4300000: status_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/sys_button.obj b/Models/Vive/Models/sys_button.obj new file mode 100644 index 000000000..4a6e87298 --- /dev/null +++ b/Models/Vive/Models/sys_button.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef3a4f1ec5b109a5858171f6ffbbd277c5b01732abd5da0c4d8ffdd3f1fe3278 +size 17668 diff --git a/Models/Vive/Models/sys_button.obj.meta b/Models/Vive/Models/sys_button.obj.meta new file mode 100644 index 000000000..5e3be2e4d --- /dev/null +++ b/Models/Vive/Models/sys_button.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: a522de35d424c4547bce18694eac5aea +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: sys_but_group1 + 100002: //RootNode + 400000: sys_but_group1 + 400002: //RootNode + 2300000: sys_but_group1 + 3300000: sys_but_group1 + 4300000: sys_but_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/trackpad.obj b/Models/Vive/Models/trackpad.obj new file mode 100644 index 000000000..f52e02ce3 --- /dev/null +++ b/Models/Vive/Models/trackpad.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ce84d868684c2ce7ce2b860f3e6eb68dc91a2d5d0b17d17b18738521237f13f +size 60578 diff --git a/Models/Vive/Models/trackpad.obj.meta b/Models/Vive/Models/trackpad.obj.meta new file mode 100644 index 000000000..4701e9c6c --- /dev/null +++ b/Models/Vive/Models/trackpad.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 1eb55c31fec770a4d97118edb282d8c8 +timeCreated: 1507075389 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: trackpad_group1 + 400000: //RootNode + 400002: trackpad_group1 + 2300000: trackpad_group1 + 3300000: trackpad_group1 + 4300000: trackpad_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/trackpad_scroll_cut.obj b/Models/Vive/Models/trackpad_scroll_cut.obj new file mode 100644 index 000000000..604d1421e --- /dev/null +++ b/Models/Vive/Models/trackpad_scroll_cut.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:536a1e4002d9fcdec043d8655db0abc12697976a4321fae4797c9461333e3873 +size 91475 diff --git a/Models/Vive/Models/trackpad_scroll_cut.obj.meta b/Models/Vive/Models/trackpad_scroll_cut.obj.meta new file mode 100644 index 000000000..f2a85f0f0 --- /dev/null +++ b/Models/Vive/Models/trackpad_scroll_cut.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 918f5dcc9e64cfa47ad3a7aa35fb70f2 +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: track_pad_scrollcut_group1 + 100002: //RootNode + 400000: track_pad_scrollcut_group1 + 400002: //RootNode + 2300000: track_pad_scrollcut_group1 + 3300000: track_pad_scrollcut_group1 + 4300000: track_pad_scrollcut_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/trackpad_touch.obj b/Models/Vive/Models/trackpad_touch.obj new file mode 100644 index 000000000..ae0b47bd4 --- /dev/null +++ b/Models/Vive/Models/trackpad_touch.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90b5daccc313ab8770f32b5dcdab3e3774a3893829e087dfcd09c5a01fd164ba +size 28992 diff --git a/Models/Vive/Models/trackpad_touch.obj.meta b/Models/Vive/Models/trackpad_touch.obj.meta new file mode 100644 index 000000000..94ab2097b --- /dev/null +++ b/Models/Vive/Models/trackpad_touch.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 8fca69da58fb5a44ba6d838685744c73 +timeCreated: 1507075390 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: track_pip_group1 + 100002: //RootNode + 400000: track_pip_group1 + 400002: //RootNode + 2300000: track_pip_group1 + 3300000: track_pip_group1 + 4300000: track_pip_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Models/trigger.obj b/Models/Vive/Models/trigger.obj new file mode 100644 index 000000000..c5a266ba5 --- /dev/null +++ b/Models/Vive/Models/trigger.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acb0202c0b23fb3a1ab4ae70e00acc33795fbe14a1dc452dbd7fbbd09826c348 +size 78060 diff --git a/Models/Vive/Models/trigger.obj.meta b/Models/Vive/Models/trigger.obj.meta new file mode 100644 index 000000000..39a45e475 --- /dev/null +++ b/Models/Vive/Models/trigger.obj.meta @@ -0,0 +1,84 @@ +fileFormatVersion: 2 +guid: 11be60732cf8ba74ab65779a6c6d62f2 +timeCreated: 1507075389 +licenseType: Pro +ModelImporter: + serializedVersion: 19 + fileIDToRecycleName: + 100000: //RootNode + 100002: trigger_group1 + 400000: //RootNode + 400002: trigger_group1 + 2300000: trigger_group1 + 3300000: trigger_group1 + 4300000: trigger_group1 + materials: + importMaterials: 1 + materialName: 0 + materialSearch: 1 + animations: + legacyGenerateAnimations: 4 + bakeSimulation: 0 + resampleCurves: 1 + optimizeGameObjects: 0 + motionNodeName: + rigImportErrors: + rigImportWarnings: + animationImportErrors: + animationImportWarnings: + animationRetargetingWarnings: + animationDoRetargetingWarnings: 0 + animationCompression: 1 + animationRotationError: 0.5 + animationPositionError: 0.5 + animationScaleError: 0.5 + animationWrapMode: 0 + extraExposedTransformPaths: [] + clipAnimations: [] + isReadable: 1 + meshes: + lODScreenPercentages: [] + globalScale: 1 + meshCompression: 0 + addColliders: 0 + importBlendShapes: 1 + swapUVChannels: 0 + generateSecondaryUV: 0 + useFileUnits: 1 + optimizeMeshForGPU: 1 + keepQuads: 0 + weldVertices: 1 + secondaryUVAngleDistortion: 8 + secondaryUVAreaDistortion: 15.000001 + secondaryUVHardAngle: 88 + secondaryUVPackMargin: 4 + useFileScale: 1 + tangentSpace: + normalSmoothAngle: 60 + normalImportMode: 0 + tangentImportMode: 3 + importAnimation: 1 + copyAvatar: 0 + humanDescription: + serializedVersion: 2 + human: [] + skeleton: [] + armTwist: 0.5 + foreArmTwist: 0.5 + upperLegTwist: 0.5 + legTwist: 0.5 + armStretch: 0.05 + legStretch: 0.05 + feetSpacing: 0 + rootMotionBoneName: + rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} + hasTranslationDoF: 0 + hasExtraRoot: 0 + skeletonHasParents: 1 + lastHumanDescriptionAvatarSource: {instanceID: 0} + animationType: 0 + humanoidOversampling: 1 + additionalBone: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Textures.meta b/Models/Vive/Textures.meta new file mode 100644 index 000000000..a004dfe9e --- /dev/null +++ b/Models/Vive/Textures.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 40f831edc89a7ab45af2c30ab40cbfbe +folderAsset: yes +timeCreated: 1507233385 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Textures/onepointfive_occ_bake.tga b/Models/Vive/Textures/onepointfive_occ_bake.tga new file mode 100644 index 000000000..b2f095e0e --- /dev/null +++ b/Models/Vive/Textures/onepointfive_occ_bake.tga @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7706de03631c839f0fd4843cca0a4179c69156c1c9d195431217ab87e6c391eb +size 16777755 diff --git a/Models/Vive/Textures/onepointfive_occ_bake.tga.meta b/Models/Vive/Textures/onepointfive_occ_bake.tga.meta new file mode 100644 index 000000000..9b5b7a63e --- /dev/null +++ b/Models/Vive/Textures/onepointfive_occ_bake.tga.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 8828790a51636ba44b2295163ee79217 +timeCreated: 1507232584 +licenseType: Pro +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + 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 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Textures/onepointfive_spec.png b/Models/Vive/Textures/onepointfive_spec.png new file mode 100644 index 000000000..c46de81d2 --- /dev/null +++ b/Models/Vive/Textures/onepointfive_spec.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1a8e767a3b69da8517507c0b56370ec3a6fd84b94fefd58a4f9b73561662e0da +size 806924 diff --git a/Models/Vive/Textures/onepointfive_spec.png.meta b/Models/Vive/Textures/onepointfive_spec.png.meta new file mode 100644 index 000000000..df562beb8 --- /dev/null +++ b/Models/Vive/Textures/onepointfive_spec.png.meta @@ -0,0 +1,76 @@ +fileFormatVersion: 2 +guid: 027f95486327b3f4392c4563b2a13d1a +timeCreated: 1507075387 +licenseType: Pro +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + 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 + alphaUsage: 2 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + - buildTarget: Standalone + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Textures/onepointfive_texture.png b/Models/Vive/Textures/onepointfive_texture.png new file mode 100644 index 000000000..2d1e27b9a --- /dev/null +++ b/Models/Vive/Textures/onepointfive_texture.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c628205774eab24125b481b6654685fda0a75898518c68671477aef242efb4e +size 571315 diff --git a/Models/Vive/Textures/onepointfive_texture.png.meta b/Models/Vive/Textures/onepointfive_texture.png.meta new file mode 100644 index 000000000..62c2d95b0 --- /dev/null +++ b/Models/Vive/Textures/onepointfive_texture.png.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 24cc18b3a55e86549a28733115993260 +timeCreated: 1507075388 +licenseType: Pro +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + 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 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Textures/status.png b/Models/Vive/Textures/status.png new file mode 100644 index 000000000..88c6f0851 --- /dev/null +++ b/Models/Vive/Textures/status.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f55a0531711c564935aef03bcf7cd6aac1b4c096e3355e65607af2d9853b0f2d +size 23971 diff --git a/Models/Vive/Textures/status.png.meta b/Models/Vive/Textures/status.png.meta new file mode 100644 index 000000000..da7730e2f --- /dev/null +++ b/Models/Vive/Textures/status.png.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 96adc4d51780f23449f5b583efc779fe +timeCreated: 1507075388 +licenseType: Pro +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + 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 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Models/Vive/Vive Controller.prefab b/Models/Vive/Vive Controller.prefab new file mode 100644 index 000000000..5c2325c10 --- /dev/null +++ b/Models/Vive/Vive Controller.prefab @@ -0,0 +1,891 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1209380750545250} + m_IsPrefabParent: 1 +--- !u!1 &1050972447233552 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4141614633343734} + m_Layer: 0 + m_Name: r_grip + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1060745157379764 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4178950193930848} + m_Layer: 0 + m_Name: Trigger Pivot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1080825974306186 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4733050997672564} + m_Layer: 0 + m_Name: trigger + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1158033672746100 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4628166181024904} + - component: {fileID: 33814485998625972} + - component: {fileID: 23955400649498454} + m_Layer: 0 + m_Name: body_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1161642225960158 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4969712784081516} + m_Layer: 0 + m_Name: sys_button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1185564939657662 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4473971208216750} + - component: {fileID: 33793789404428102} + - component: {fileID: 23108927844864994} + m_Layer: 0 + m_Name: trigger_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1209380750545250 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4070439039470938} + m_Layer: 0 + m_Name: Vive Controller + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1247747337006612 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4751614880040586} + m_Layer: 0 + m_Name: RotationPivot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1273110110392832 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4021288017967424} + - component: {fileID: 33929020179086686} + - component: {fileID: 23486518235351522} + m_Layer: 0 + m_Name: sys_but_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1279882147296190 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4870699379224690} + m_Layer: 0 + m_Name: trackpad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1337870186751960 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4456514911280876} + m_Layer: 0 + m_Name: body + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1496152834539938 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4286962923601822} + - component: {fileID: 33428812567342110} + - component: {fileID: 23550780355922678} + m_Layer: 0 + m_Name: l_gripper_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1543190631434974 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4379478342503068} + m_Layer: 0 + m_Name: button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1564332711776060 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4681028676750298} + - component: {fileID: 33303814144955338} + - component: {fileID: 23787027095492304} + m_Layer: 0 + m_Name: r_gripper_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1594453721519874 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4935574672116756} + - component: {fileID: 33297299078280020} + - component: {fileID: 23337155761104620} + m_Layer: 0 + m_Name: menu_but_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1652446519038126 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4847249200977864} + - component: {fileID: 33917146450602826} + - component: {fileID: 23868849647331914} + m_Layer: 0 + m_Name: track_pip_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1672968912502426 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4767014662726266} + m_Layer: 0 + m_Name: trackpad_touch + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!1 &1822768616165084 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4544892698428310} + - component: {fileID: 33584304405889436} + - component: {fileID: 23420308633838566} + m_Layer: 0 + m_Name: trackpad_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1889762995122838 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4791409254588110} + m_Layer: 0 + m_Name: l_grip + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4021288017967424 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1273110110392832} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4969712784081516} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4070439039470938 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1209380750545250} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4751614880040586} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4141614633343734 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1050972447233552} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4681028676750298} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4178950193930848 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1060745157379764} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: -0.015999973, z: 0.039} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4733050997672564} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4286962923601822 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1496152834539938} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4791409254588110} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4379478342503068 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1543190631434974} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4935574672116756} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4456514911280876 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1337870186751960} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4628166181024904} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4473971208216750 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1185564939657662} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4733050997672564} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4544892698428310 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1822768616165084} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4870699379224690} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4628166181024904 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1158033672746100} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4456514911280876} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4681028676750298 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1564332711776060} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4141614633343734} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4733050997672564 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1080825974306186} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.016, z: -0.039} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4473971208216750} + m_Father: {fileID: 4178950193930848} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4751614880040586 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1247747337006612} + m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4456514911280876} + - {fileID: 4379478342503068} + - {fileID: 4791409254588110} + - {fileID: 4141614633343734} + - {fileID: 4969712784081516} + - {fileID: 4870699379224690} + - {fileID: 4767014662726266} + - {fileID: 4178950193930848} + m_Father: {fileID: 4070439039470938} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} +--- !u!4 &4767014662726266 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1672968912502426} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4847249200977864} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4791409254588110 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1889762995122838} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4286962923601822} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4847249200977864 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1652446519038126} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4767014662726266} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4870699379224690 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1279882147296190} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4544892698428310} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4935574672116756 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1594453721519874} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4379478342503068} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4969712784081516 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1161642225960158} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4021288017967424} + m_Father: {fileID: 4751614880040586} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23108927844864994 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1185564939657662} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23337155761104620 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1594453721519874} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23420308633838566 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1822768616165084} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23486518235351522 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1273110110392832} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23550780355922678 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1496152834539938} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23787027095492304 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1564332711776060} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23868849647331914 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1652446519038126} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!23 &23955400649498454 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1158033672746100} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &33297299078280020 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1594453721519874} + m_Mesh: {fileID: 4300000, guid: cbd31b89c0bde684db82ff8056d3cc8e, type: 3} +--- !u!33 &33303814144955338 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1564332711776060} + m_Mesh: {fileID: 4300000, guid: 56f79c509c890b74e906e8a5caee40ae, type: 3} +--- !u!33 &33428812567342110 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1496152834539938} + m_Mesh: {fileID: 4300000, guid: b32f6f3f786b1b8449a3494a98f2b6b2, type: 3} +--- !u!33 &33584304405889436 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1822768616165084} + m_Mesh: {fileID: 4300000, guid: 1eb55c31fec770a4d97118edb282d8c8, type: 3} +--- !u!33 &33793789404428102 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1185564939657662} + m_Mesh: {fileID: 4300000, guid: 11be60732cf8ba74ab65779a6c6d62f2, type: 3} +--- !u!33 &33814485998625972 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1158033672746100} + m_Mesh: {fileID: 4300000, guid: 91923fcf53844be47a1ad1b01dc5b4d5, type: 3} +--- !u!33 &33917146450602826 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1652446519038126} + m_Mesh: {fileID: 4300000, guid: 8fca69da58fb5a44ba6d838685744c73, type: 3} +--- !u!33 &33929020179086686 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1273110110392832} + m_Mesh: {fileID: 4300000, guid: a522de35d424c4547bce18694eac5aea, type: 3} diff --git a/Models/Vive/Vive Controller.prefab.meta b/Models/Vive/Vive Controller.prefab.meta new file mode 100644 index 000000000..8e8b0073a --- /dev/null +++ b/Models/Vive/Vive Controller.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: e3d4b87f591a2344d91089355a332d95 +timeCreated: 1507233321 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Prefabs/Proxies/ViveController.prefab b/Prefabs/Proxies/ViveController.prefab index 8261e9ad3..e46978538 100644 --- a/Prefabs/Proxies/ViveController.prefab +++ b/Prefabs/Proxies/ViveController.prefab @@ -11,51 +11,6 @@ Prefab: m_ParentPrefab: {fileID: 0} m_RootGameObject: {fileID: 1000010426338840} m_IsPrefabParent: 1 ---- !u!1 &1000010034631710 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000010792599280} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000010213219904 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000011412644664} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000010329909022 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000014007409216} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 --- !u!1 &1000010389867652 GameObject: m_ObjectHideFlags: 0 @@ -87,150 +42,6 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000010626792842 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000011414108474} - m_Layer: 0 - m_Name: base - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000010727302888 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000014171066352} - - component: {fileID: 33000011340142794} - - component: {fileID: 23000010895685312} - m_Layer: 0 - m_Name: scroll_wheel - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1000010881321038 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000013055212058} - - component: {fileID: 33000013907030392} - - component: {fileID: 23000010767424786} - m_Layer: 0 - m_Name: trigger - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000010904668802 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000014197376536} - - component: {fileID: 33000014119514820} - - component: {fileID: 23000011674629476} - m_Layer: 0 - m_Name: status - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1000010994638552 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000011627283782} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000011000407838 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000014179470850} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000011089348306 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000010282135068} - - component: {fileID: 33000011124491924} - - component: {fileID: 23000010886298118} - m_Layer: 0 - m_Name: rgrip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000011184586376 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000011863402304} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000011264600012 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000010093119470} - - component: {fileID: 114000013615270472} - m_Layer: 0 - m_Name: ViveController - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 --- !u!1 &1000011518103352 GameObject: m_ObjectHideFlags: 0 @@ -246,503 +57,331 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000011689948654 +--- !u!1 &1000013317574938 GameObject: - m_ObjectHideFlags: 1 + m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011188626626} + - component: {fileID: 4000013650664202} m_Layer: 0 - m_Name: attach + m_Name: RayOrigin m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000011989361216 +--- !u!1 &1000013989530118 GameObject: - m_ObjectHideFlags: 1 + m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011842007162} + - component: {fileID: 4000011094092792} m_Layer: 0 - m_Name: attach + m_Name: FieldGrabOrigin m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000012027203522 +--- !u!1 &1000014283866272 GameObject: - m_ObjectHideFlags: 1 + m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000013888546616} + - component: {fileID: 4000013779846498} m_Layer: 0 - m_Name: attach + m_Name: PreviewOrigin m_TagString: ShowInMiniWorld m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000012344393068 +--- !u!1 &1022711910310728 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011925357806} - - component: {fileID: 33000012514889160} - - component: {fileID: 23000013766817786} + - component: {fileID: 4539810040550546} m_Layer: 0 - m_Name: trackpad_touch - m_TagString: ShowInMiniWorld + m_Name: trigger + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1000012637843424 + m_IsActive: 1 +--- !u!1 &1023945361284662 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011270446216} + - component: {fileID: 4851027070737694} m_Layer: 0 - m_Name: tip - m_TagString: ShowInMiniWorld + m_Name: button + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000012799287492 +--- !u!1 &1024981127734174 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000012339569106} - - component: {fileID: 33000010448505510} - - component: {fileID: 23000012255253108} + - component: {fileID: 4027072583190098} m_Layer: 0 m_Name: trackpad - m_TagString: ShowInMiniWorld + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000012816092326 +--- !u!1 &1135163918873870 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011295643006} + - component: {fileID: 4526029195024024} + - component: {fileID: 33026695381748044} + - component: {fileID: 23334373145171194} m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld + m_Name: trigger_group1 + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000012845243444 +--- !u!1 &1231645741518206 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000010563357738} - - component: {fileID: 33000011453974200} - - component: {fileID: 23000010607278970} + - component: {fileID: 4469504124180788} m_Layer: 0 - m_Name: led - m_TagString: ShowInMiniWorld + m_Name: RotationPivot + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000012931125694 +--- !u!1 &1278246946492418 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000010489751992} + - component: {fileID: 4936608528125002} + - component: {fileID: 33280749333283016} + - component: {fileID: 23366296176317488} m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld + m_Name: sys_but_group1 + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000013014963684 +--- !u!1 &1300576921832436 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000012719514568} + - component: {fileID: 4681010082850024} m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld + m_Name: Trigger Pivot + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000013110091078 +--- !u!1 &1313115655797016 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011688713980} + - component: {fileID: 4268880949599228} + - component: {fileID: 33647587406334408} + - component: {fileID: 23609183526492908} m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld + m_Name: body_group1 + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000013113560248 +--- !u!1 &1328780274993912 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000013688132212} - - component: {fileID: 33000014192999810} - - component: {fileID: 23000010506554950} + - component: {fileID: 4925654503666930} m_Layer: 0 m_Name: sys_button - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013164070732 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000012331173858} - - component: {fileID: 33000010307034400} - - component: {fileID: 23000011816873416} - m_Layer: 0 - m_Name: button - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013184390162 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000012406371646} - - component: {fileID: 33000012366328456} - - component: {fileID: 23000011076833864} - m_Layer: 0 - m_Name: body - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013317574938 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000013650664202} - m_Layer: 0 - m_Name: RayOrigin - m_TagString: ShowInMiniWorld + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000013412529190 +--- !u!1 &1409931571782782 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000010063544880} + - component: {fileID: 4233998180511522} m_Layer: 0 - m_Name: handgrip - m_TagString: ShowInMiniWorld + m_Name: r_grip + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000013557447172 +--- !u!1 &1679918130705836 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000010628809070} + - component: {fileID: 4314961011562620} + - component: {fileID: 33582950657332710} + - component: {fileID: 23366012271666804} m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld + m_Name: r_gripper_group1 + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000013978634718 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000012561956288} - - component: {fileID: 33000012641422892} - - component: {fileID: 23000013435694576} - m_Layer: 0 - m_Name: trackpad_scroll_cut - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1000013981060860 +--- !u!1 &1723382491159284 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011783740326} - - component: {fileID: 33000011677718802} - - component: {fileID: 23000010838925790} + - component: {fileID: 4788207952759710} + - component: {fileID: 33314458779764706} + - component: {fileID: 23166709740205842} m_Layer: 0 - m_Name: lgrip - m_TagString: ShowInMiniWorld + m_Name: trackpad_group1 + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000013989530118 +--- !u!1 &1778897529519236 GameObject: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000011094092792} + - component: {fileID: 4433677558257222} m_Layer: 0 - m_Name: FieldGrabOrigin - m_TagString: ShowInMiniWorld + m_Name: Vive Controller + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000014085374686 +--- !u!1 &1846282981662570 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000012954177294} + - component: {fileID: 4432114245915554} m_Layer: 0 - m_Name: gdc2015 - m_TagString: ShowInMiniWorld + m_Name: body + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000014088004772 +--- !u!1 &1863334949330014 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000013294255394} + - component: {fileID: 4064835649293204} m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld + m_Name: l_grip + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000014124141576 +--- !u!1 &1947952444214838 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000010023052306} + - component: {fileID: 4962833239565766} + - component: {fileID: 33615960404030348} + - component: {fileID: 23772360735447006} m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld + m_Name: menu_but_group1 + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1000014283866272 +--- !u!1 &1998691428341312 GameObject: - m_ObjectHideFlags: 0 + m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4000013779846498} + - component: {fileID: 4521799058005778} + - component: {fileID: 33065187397586782} + - component: {fileID: 23569124774784352} m_Layer: 0 - m_Name: PreviewOrigin - m_TagString: ShowInMiniWorld + m_Name: l_gripper_group1 + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &4000010023052306 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000014124141576} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000014171066352} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000010063544880 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013412529190} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000010489751992} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000010093119470 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011264600012} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000011414108474} - - {fileID: 4000012406371646} - - {fileID: 4000012331173858} - - {fileID: 4000012954177294} - - {fileID: 4000010063544880} - - {fileID: 4000010563357738} - - {fileID: 4000011783740326} - - {fileID: 4000010282135068} - - {fileID: 4000014171066352} - - {fileID: 4000014197376536} - - {fileID: 4000013688132212} - - {fileID: 4000011270446216} - - {fileID: 4000012339569106} - - {fileID: 4000012561956288} - - {fileID: 4000011925357806} - - {fileID: 4000013055212058} - m_Father: {fileID: 4000010742330424} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000010282135068 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011089348306} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000014007409216} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000010489751992 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012931125694} - m_LocalRotation: {x: -0.043941922, y: -0, z: -0, w: 0.9990341} - m_LocalPosition: {x: 0, y: 0.003, z: -0.097} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000010063544880} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000010563357738 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012845243444} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000014179470850} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000010628809070 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013557447172} - m_LocalRotation: {x: -0, y: -0.7327449, z: -0, w: 0.68050355} - m_LocalPosition: {x: -0.02, y: -0.015, z: -0.088} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000011783740326} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4000010742330424 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1000010426338840} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -0.0029, z: 0.0242} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.25, y: -0.775, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000010093119470} + - {fileID: 4433677558257222} - {fileID: 4000013650664202} - {fileID: 4000012662092726} - {fileID: 4000012932055730} @@ -751,19 +390,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000010792599280 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010034631710} - m_LocalRotation: {x: -0, y: -0.99997437, z: 0.0071637705, w: 0} - m_LocalPosition: {x: 0, y: -0.014, z: -0.174} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000011414108474} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4000011094092792 Transform: m_ObjectHideFlags: 1 @@ -777,562 +403,301 @@ Transform: m_Father: {fileID: 4000010742330424} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} ---- !u!4 &4000011188626626 +--- !u!4 &4000012662092726 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011689948654} - m_LocalRotation: {x: 0.6683845, y: -0, z: -0, w: 0.74381596} - m_LocalPosition: {x: 0, y: -0.039, z: -0.051} + m_GameObject: {fileID: 1000010389867652} + m_LocalRotation: {x: -0.062518746, y: -0, z: -0, w: 0.99804384} + m_LocalPosition: {x: 0, y: 0.0107, z: -0.0509} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000013055212058} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011270446216 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012637843424} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000011627283782} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 11 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011295643006 + m_Father: {fileID: 4000010742330424} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: -7.1180005, y: 0, z: 0} +--- !u!4 &4000012932055730 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012816092326} - m_LocalRotation: {x: -0.68217707, y: -0, z: -0, w: 0.73118705} - m_LocalPosition: {x: 0, y: 0.008, z: -0.019} + m_GameObject: {fileID: 1000011518103352} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: -0.0215, z: 0.0644} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000012331173858} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011412644664 + m_Father: {fileID: 4000010742330424} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!4 &4000013650664202 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010213219904} + m_GameObject: {fileID: 1000013317574938} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000012561956288} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011414108474 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010626792842} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000010792599280} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011627283782 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010994638552} - m_LocalRotation: {x: -0.011187929, y: -0, z: -0, w: 0.9999374} - m_LocalPosition: {x: 0, y: -0.01, z: 0.007} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000011270446216} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011688713980 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013110091078} - m_LocalRotation: {x: -0.74271846, y: -0, z: -0, w: 0.6696039} - m_LocalPosition: {x: 0, y: -0.002, z: -0.146} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000014197376536} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011783740326 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013981060860} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000010628809070} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011842007162 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011989361216} - m_LocalRotation: {x: -0.7368645, y: -0, z: -0, w: 0.6760405} - m_LocalPosition: {x: 0, y: 0.004, z: -0.088} + m_LocalPosition: {x: 0, y: 0, z: 0.0059} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000013688132212} - m_RootOrder: 0 + m_Father: {fileID: 4000010742330424} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011863402304 +--- !u!4 &4000013779846498 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011184586376} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} + m_GameObject: {fileID: 1000014283866272} + m_LocalRotation: {x: -0.258819, y: 0, z: 0, w: 0.9659259} + m_LocalPosition: {x: 0, y: 0, z: 0.1006} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000011925357806} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000011925357806 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012344393068} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -6.9849193e-10, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000011863402304} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 14 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000012331173858 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013164070732} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000011295643006} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000012339569106 + m_Father: {fileID: 4000010742330424} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} +--- !u!4 &4027072583190098 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012799287492} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -6.9849193e-10, z: -0} + m_GameObject: {fileID: 1024981127734174} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000012719514568} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 12 + - {fileID: 4788207952759710} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000012406371646 +--- !u!4 &4064835649293204 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013184390162} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} + m_GameObject: {fileID: 1863334949330014} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000013888546616} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 1 + - {fileID: 4521799058005778} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000012561956288 +--- !u!4 &4233998180511522 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013978634718} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} + m_GameObject: {fileID: 1409931571782782} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000011412644664} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 13 + - {fileID: 4314961011562620} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000012662092726 +--- !u!4 &4268880949599228 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010389867652} - m_LocalRotation: {x: -0.062518746, y: -0, z: -0, w: 0.99804384} - m_LocalPosition: {x: 0, y: 0.0107, z: -0.0509} + m_GameObject: {fileID: 1313115655797016} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000010742330424} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: -7.1180005, y: 0, z: 0} ---- !u!4 &4000012719514568 + m_Father: {fileID: 4432114245915554} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4314961011562620 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013014963684} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} + m_GameObject: {fileID: 1679918130705836} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000012339569106} + m_Father: {fileID: 4233998180511522} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000012932055730 +--- !u!4 &4432114245915554 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011518103352} - m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} - m_LocalPosition: {x: 0, y: -0.0215, z: 0.0644} + m_GameObject: {fileID: 1846282981662570} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000010742330424} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} ---- !u!4 &4000012954177294 + m_Children: + - {fileID: 4268880949599228} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4433677558257222 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000014085374686} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} + m_GameObject: {fileID: 1778897529519236} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000013294255394} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 3 + - {fileID: 4469504124180788} + m_Father: {fileID: 4000010742330424} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000013055212058 +--- !u!4 &4469504124180788 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010881321038} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} + m_GameObject: {fileID: 1231645741518206} + m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000011188626626} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 15 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000013294255394 + - {fileID: 4432114245915554} + - {fileID: 4851027070737694} + - {fileID: 4064835649293204} + - {fileID: 4233998180511522} + - {fileID: 4925654503666930} + - {fileID: 4027072583190098} + - {fileID: 4681010082850024} + m_Father: {fileID: 4433677558257222} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} +--- !u!4 &4521799058005778 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000014088004772} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_GameObject: {fileID: 1998691428341312} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000012954177294} + m_Father: {fileID: 4064835649293204} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000013650664202 +--- !u!4 &4526029195024024 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013317574938} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0.0059} + m_GameObject: {fileID: 1135163918873870} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000010742330424} - m_RootOrder: 1 + m_Father: {fileID: 4539810040550546} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000013688132212 +--- !u!4 &4539810040550546 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013113560248} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} + m_GameObject: {fileID: 1022711910310728} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0.016, z: -0.039} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000011842007162} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 10 + - {fileID: 4526029195024024} + m_Father: {fileID: 4681010082850024} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000013779846498 +--- !u!4 &4681010082850024 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000014283866272} - m_LocalRotation: {x: -0.258819, y: 0, z: 0, w: 0.9659259} - m_LocalPosition: {x: 0, y: 0, z: 0.1006} + m_GameObject: {fileID: 1300576921832436} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: -0.016, z: 0.039} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000010742330424} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} ---- !u!4 &4000013888546616 + m_Children: + - {fileID: 4539810040550546} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4788207952759710 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012027203522} - m_LocalRotation: {x: -0.043941922, y: -0, z: -0, w: 0.9990341} - m_LocalPosition: {x: 0, y: 0.003, z: -0.097} + m_GameObject: {fileID: 1723382491159284} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000012406371646} + m_Father: {fileID: 4027072583190098} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000014007409216 +--- !u!4 &4851027070737694 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010329909022} - m_LocalRotation: {x: -0, y: 0.7327449, z: -0, w: 0.68050355} - m_LocalPosition: {x: 0.02, y: -0.015, z: -0.088} + m_GameObject: {fileID: 1023945361284662} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: -0.0006, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4000010282135068} - m_RootOrder: 0 + m_Children: + - {fileID: 4962833239565766} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000014171066352 +--- !u!4 &4925654503666930 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010727302888} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} + m_GameObject: {fileID: 1328780274993912} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - - {fileID: 4000010023052306} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 8 + - {fileID: 4936608528125002} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000014179470850 +--- !u!4 &4936608528125002 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011000407838} - m_LocalRotation: {x: -0.73805505, y: -0, z: -0, w: 0.6747405} - m_LocalPosition: {x: 0, y: 0.003, z: -0.096} + m_GameObject: {fileID: 1278246946492418} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4000010563357738} + m_Father: {fileID: 4925654503666930} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4000014197376536 +--- !u!4 &4962833239565766 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010904668802} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} + m_GameObject: {fileID: 1947952444214838} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000011688713980} - m_Father: {fileID: 4000010093119470} - m_RootOrder: 9 + m_Children: [] + m_Father: {fileID: 4851027070737694} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &23000010506554950 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013113560248} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23000010607278970 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012845243444} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23000010767424786 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010881321038} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23000010838925790 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013981060860} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23000010886298118 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011089348306} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23000010895685312 +--- !u!23 &23166709740205842 MeshRenderer: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010727302888} + m_GameObject: {fileID: 1723382491159284} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -1340,7 +705,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 0} + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1359,12 +724,12 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!23 &23000011076833864 +--- !u!23 &23334373145171194 MeshRenderer: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013184390162} + m_GameObject: {fileID: 1135163918873870} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -1372,7 +737,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 0} + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1391,12 +756,12 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!23 &23000011674629476 +--- !u!23 &23366012271666804 MeshRenderer: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010904668802} + m_GameObject: {fileID: 1679918130705836} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -1404,7 +769,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 0} + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1423,12 +788,12 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!23 &23000011816873416 +--- !u!23 &23366296176317488 MeshRenderer: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013164070732} + m_GameObject: {fileID: 1278246946492418} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -1436,7 +801,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 0} + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1455,12 +820,12 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!23 &23000012255253108 +--- !u!23 &23569124774784352 MeshRenderer: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012799287492} + m_GameObject: {fileID: 1998691428341312} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -1468,7 +833,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 0} + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1487,12 +852,12 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!23 &23000013435694576 +--- !u!23 &23609183526492908 MeshRenderer: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013978634718} + m_GameObject: {fileID: 1313115655797016} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -1500,7 +865,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 0} + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1519,12 +884,12 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!23 &23000013766817786 +--- !u!23 &23772360735447006 MeshRenderer: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012344393068} + m_GameObject: {fileID: 1947952444214838} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -1532,7 +897,7 @@ MeshRenderer: m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 m_Materials: - - {fileID: 0} + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -1551,90 +916,55 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!33 &33000010307034400 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013164070732} - m_Mesh: {fileID: 0} ---- !u!33 &33000010448505510 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012799287492} - m_Mesh: {fileID: 0} ---- !u!33 &33000011124491924 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011089348306} - m_Mesh: {fileID: 0} ---- !u!33 &33000011340142794 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010727302888} - m_Mesh: {fileID: 0} ---- !u!33 &33000011453974200 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012845243444} - m_Mesh: {fileID: 0} ---- !u!33 &33000011677718802 +--- !u!33 &33026695381748044 MeshFilter: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013981060860} - m_Mesh: {fileID: 0} ---- !u!33 &33000012366328456 + m_GameObject: {fileID: 1135163918873870} + m_Mesh: {fileID: 4300000, guid: 11be60732cf8ba74ab65779a6c6d62f2, type: 3} +--- !u!33 &33065187397586782 MeshFilter: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013184390162} - m_Mesh: {fileID: 0} ---- !u!33 &33000012514889160 + m_GameObject: {fileID: 1998691428341312} + m_Mesh: {fileID: 4300000, guid: b32f6f3f786b1b8449a3494a98f2b6b2, type: 3} +--- !u!33 &33280749333283016 MeshFilter: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012344393068} - m_Mesh: {fileID: 0} ---- !u!33 &33000012641422892 + m_GameObject: {fileID: 1278246946492418} + m_Mesh: {fileID: 4300000, guid: a522de35d424c4547bce18694eac5aea, type: 3} +--- !u!33 &33314458779764706 MeshFilter: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013978634718} - m_Mesh: {fileID: 0} ---- !u!33 &33000013907030392 + m_GameObject: {fileID: 1723382491159284} + m_Mesh: {fileID: 4300000, guid: 1eb55c31fec770a4d97118edb282d8c8, type: 3} +--- !u!33 &33582950657332710 MeshFilter: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010881321038} - m_Mesh: {fileID: 0} ---- !u!33 &33000014119514820 + m_GameObject: {fileID: 1679918130705836} + m_Mesh: {fileID: 4300000, guid: 56f79c509c890b74e906e8a5caee40ae, type: 3} +--- !u!33 &33615960404030348 MeshFilter: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010904668802} - m_Mesh: {fileID: 0} ---- !u!33 &33000014192999810 + m_GameObject: {fileID: 1947952444214838} + m_Mesh: {fileID: 4300000, guid: cbd31b89c0bde684db82ff8056d3cc8e, type: 3} +--- !u!33 &33647587406334408 MeshFilter: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013113560248} - m_Mesh: {fileID: 0} + m_GameObject: {fileID: 1313115655797016} + m_Mesh: {fileID: 4300000, guid: 91923fcf53844be47a1ad1b01dc5b4d5, type: 3} --- !u!114 &114000011293798520 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1651,21 +981,40 @@ MonoBehaviour: m_AlternateMenuOrigin: {fileID: 4000012662092726} m_PreviewOrigin: {fileID: 4000013779846498} m_FieldGrabOrigin: {fileID: 4000011094092792} - m_MeshRoot: {fileID: 4000010093119470} ---- !u!114 &114000013615270472 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011264600012} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5890e3cad70bea64d91aef9145ba3454, type: 3} - m_Name: - m_EditorClassIdentifier: - index: -1 - modelOverride: vr_controller_vive_1_5 - shader: {fileID: 0} - verbose: 0 - createComponents: 1 - updateDynamically: 1 + m_MeshRoot: {fileID: 4433677558257222} + m_Buttons: + - m_Control: 2 + m_Transform: {fileID: 4681010082850024} + m_Renderer: {fileID: 23334373145171194} + m_TranslateAxes: 0 + m_RotateAxes: 1 + m_Min: 20 + m_Max: -20 + - m_Control: 3 + m_Transform: {fileID: 4064835649293204} + m_Renderer: {fileID: 23569124774784352} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: 0.0005 + m_Max: -0.0005 + - m_Control: 3 + m_Transform: {fileID: 4233998180511522} + m_Renderer: {fileID: 23366012271666804} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: -0.0005 + m_Max: 0.0005 + - m_Control: 18 + m_Transform: {fileID: 4851027070737694} + m_Renderer: {fileID: 23772360735447006} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.0005 + m_Max: -0.0005 + - m_Control: 22 + m_Transform: {fileID: 4027072583190098} + m_Renderer: {fileID: 23166709740205842} + m_TranslateAxes: 2 + m_RotateAxes: 0 + m_Min: 0.001 + m_Max: -0.001 diff --git a/Prefabs/Proxies/ViveLeftTouch.prefab b/Prefabs/Proxies/ViveLeftTouch.prefab deleted file mode 100644 index e67b94494..000000000 --- a/Prefabs/Proxies/ViveLeftTouch.prefab +++ /dev/null @@ -1,1793 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &118082 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 436998} - - component: {fileID: 114000013861093962} - m_Layer: 0 - m_Name: ViveLeftTouch - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &436998 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 118082} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4560682712705560} - - {fileID: 4794322518342860} - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &100100000 -Prefab: - m_ObjectHideFlags: 1 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 0} - propertyPath: m_animator - value: - objectReference: {fileID: 0} - - target: {fileID: 0} - propertyPath: m_controllerMask - value: 1 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 0} - m_RootGameObject: {fileID: 118082} - m_IsPrefabParent: 1 ---- !u!1 &1000011111799672 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000010810114962} - m_Layer: 0 - m_Name: FieldDragOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000011958545574 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000012123783760} - m_Layer: 0 - m_Name: PreviewOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000012440443120 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000012197213606} - m_Layer: 0 - m_Name: MenuOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013074843682 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000011559331518} - m_Layer: 0 - m_Name: AltMenuOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013561259994 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000011600309478} - m_Layer: 0 - m_Name: RayOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1007789260927380 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4050334673459560} - m_Layer: 0 - m_Name: tip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1035596773115294 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4530606897415404} - m_Layer: 0 - m_Name: sys_button - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1049163276494280 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4483743749631420} - m_Layer: 0 - m_Name: base - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1060698883967346 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4285027184705220} - - component: {fileID: 33469603830917590} - - component: {fileID: 23011143559282002} - m_Layer: 0 - m_Name: grip - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1104926084809440 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4337199902515864} - - component: {fileID: 33956794758310866} - - component: {fileID: 23051715092450864} - m_Layer: 0 - m_Name: x_button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1110475007587292 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4587665996471028} - m_Layer: 0 - m_Name: rgrip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1156465154805694 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4560682712705560} - - component: {fileID: 114937401967916400} - m_Layer: 0 - m_Name: ViveController - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1174060473669720 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4150248458252998} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1258117880674016 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4738112902644160} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1266831003489266 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4890536220949060} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1300265623868800 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4426836777321650} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1336837414518560 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4827942793568330} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1361187521139138 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4988814349371388} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1391981533677216 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4870480252557800} - - component: {fileID: 33178554236838322} - - component: {fileID: 23092173763119808} - m_Layer: 0 - m_Name: y_button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1393640855049194 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4367960988115872} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1399362814821872 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4633347229691846} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1420128299563268 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4539072541428752} - m_Layer: 0 - m_Name: gdc2015 - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1437228542812490 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4695993798676282} - m_Layer: 0 - m_Name: trackpad_scroll_cut - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1437418336100850 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4062986250107026} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1439211211668616 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4642943849942306} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1440919061280958 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4716886561057732} - m_Layer: 0 - m_Name: status - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1442609195633634 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4296230171978536} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1492068379737228 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4791681828321116} - m_Layer: 0 - m_Name: handgrip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1504505394622770 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4610012774413914} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1509876955685344 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4769650049049550} - - component: {fileID: 33112371956597706} - - component: {fileID: 23995618592158306} - m_Layer: 0 - m_Name: enter_button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1515052315250130 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4710379363873502} - m_Layer: 0 - m_Name: lgrip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1521131054530934 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4883595441978386} - - component: {fileID: 33916300125348632} - - component: {fileID: 23853239758501888} - m_Layer: 0 - m_Name: thumbstick - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1522899860247498 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4390317408276986} - - component: {fileID: 33785835701983434} - - component: {fileID: 23279684870724754} - m_Layer: 0 - m_Name: body - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1536059129537142 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4751982353548818} - - component: {fileID: 33249309609687366} - - component: {fileID: 23204078342171062} - m_Layer: 0 - m_Name: trigger - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1542893286125322 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4347810169859968} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1591938757829128 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4774128065012916} - m_Layer: 0 - m_Name: scroll_wheel - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1596603730712686 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4333997724612544} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1663480401225244 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4794322518342860} - m_Layer: 0 - m_Name: Pivot - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1703325721247870 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4317776395953736} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1749022349492836 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4581809795155478} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1766619086927632 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4213492642316678} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1770412470437466 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4774972711166902} - m_Layer: 0 - m_Name: trackpad - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1816339016628520 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4503428551396470} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1840772862127990 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4333883292380042} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1876384562517976 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4805665119888262} - m_Layer: 0 - m_Name: led - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1925894250920826 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4230762009131586} - m_Layer: 0 - m_Name: button - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1962360390267190 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4363050274432786} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1981557860433196 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4577270798619972} - m_Layer: 0 - m_Name: trackpad_touch - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1986466803964708 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4368742210636480} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &4000010810114962 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011111799672} - m_LocalRotation: {x: -0.258819, y: -0, z: -0, w: 0.9659259} - m_LocalPosition: {x: 0, y: 0.025, z: 0.0746} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4794322518342860} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} ---- !u!4 &4000011559331518 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013074843682} - m_LocalRotation: {x: -0, y: 0.06975647, z: -0, w: 0.9975641} - m_LocalPosition: {x: 0, y: 0.0208, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4794322518342860} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 8, z: 0} ---- !u!4 &4000011600309478 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013561259994} - m_LocalRotation: {x: -0, y: 0.06975647, z: -0, w: 0.9975641} - m_LocalPosition: {x: 0, y: -0.003, z: 0.03} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4794322518342860} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 8, z: 0} ---- !u!4 &4000012123783760 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011958545574} - m_LocalRotation: {x: -0.258819, y: -0, z: -0, w: 0.9659259} - m_LocalPosition: {x: 0, y: 0.074, z: 0.0746} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4794322518342860} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} ---- !u!4 &4000012197213606 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000012440443120} - m_LocalRotation: {x: 0.7053843, y: 0.049325276, z: -0.049325276, w: 0.7053843} - m_LocalPosition: {x: 0, y: -0.02, z: 0.05} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4794322518342860} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 90, y: 8, z: 0} ---- !u!4 &4050334673459560 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1007789260927380} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4642943849942306} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 11 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4062986250107026 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1437418336100850} - m_LocalRotation: {x: -0.73805505, y: -0, z: -0, w: 0.6747405} - m_LocalPosition: {x: 0, y: 0.003, z: -0.096} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4805665119888262} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4150248458252998 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1174060473669720} - m_LocalRotation: {x: -0.7368645, y: -0, z: -0, w: 0.6760405} - m_LocalPosition: {x: 0, y: 0.004, z: -0.088} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4530606897415404} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4213492642316678 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1766619086927632} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4774128065012916} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4230762009131586 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1925894250920826} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4367960988115872} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4285027184705220 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1060698883967346} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4426836777321650} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 17 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4296230171978536 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1442609195633634} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4539072541428752} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4317776395953736 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1703325721247870} - m_LocalRotation: {x: -0.043941922, y: -0, z: -0, w: 0.9990341} - m_LocalPosition: {x: 0, y: 0.003, z: -0.097} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4390317408276986} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4333883292380042 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1840772862127990} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: 0.01107, y: 0.0001, z: -0.05813} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4337199902515864} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4333997724612544 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1596603730712686} - m_LocalRotation: {x: -0, y: -0.7327449, z: -0, w: 0.68050355} - m_LocalPosition: {x: -0.02, y: -0.015, z: -0.088} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4710379363873502} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4337199902515864 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1104926084809440} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4333883292380042} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 19 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4347810169859968 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1542893286125322} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: 0.01732, y: -0.00897, z: -0.04806} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4870480252557800} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4363050274432786 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1962360390267190} - m_LocalRotation: {x: -0.043941922, y: -0, z: -0, w: 0.9990341} - m_LocalPosition: {x: 0, y: 0.003, z: -0.097} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4791681828321116} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4367960988115872 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1393640855049194} - m_LocalRotation: {x: -0.68217707, y: -0, z: -0, w: 0.73118705} - m_LocalPosition: {x: 0, y: 0.008, z: -0.019} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4230762009131586} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4368742210636480 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1986466803964708} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4774972711166902} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4390317408276986 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1522899860247498} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4317776395953736} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4426836777321650 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1300265623868800} - m_LocalRotation: {x: -0, y: -0.7313537, z: -0, w: 0.6819984} - m_LocalPosition: {x: 0.012, y: -0.00938, z: -0.09077} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4285027184705220} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4483743749631420 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1049163276494280} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4610012774413914} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4503428551396470 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1816339016628520} - m_LocalRotation: {x: -0, y: 0.7327449, z: -0, w: 0.68050355} - m_LocalPosition: {x: 0.02, y: -0.015, z: -0.088} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4587665996471028} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4530606897415404 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1035596773115294} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4150248458252998} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 10 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4539072541428752 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1420128299563268} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4296230171978536} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4560682712705560 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1156465154805694} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4483743749631420} - - {fileID: 4390317408276986} - - {fileID: 4230762009131586} - - {fileID: 4539072541428752} - - {fileID: 4791681828321116} - - {fileID: 4805665119888262} - - {fileID: 4710379363873502} - - {fileID: 4587665996471028} - - {fileID: 4774128065012916} - - {fileID: 4716886561057732} - - {fileID: 4530606897415404} - - {fileID: 4050334673459560} - - {fileID: 4774972711166902} - - {fileID: 4695993798676282} - - {fileID: 4577270798619972} - - {fileID: 4751982353548818} - - {fileID: 4769650049049550} - - {fileID: 4285027184705220} - - {fileID: 4883595441978386} - - {fileID: 4337199902515864} - - {fileID: 4870480252557800} - m_Father: {fileID: 436998} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4577270798619972 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1981557860433196} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -6.9849193e-10, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4633347229691846} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 14 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4581809795155478 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1749022349492836} - m_LocalRotation: {x: 0.33709526, y: -0, z: -0, w: 0.94147056} - m_LocalPosition: {x: 0.00391, y: -0.04554, z: -0.05172} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4751982353548818} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4587665996471028 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1110475007587292} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4503428551396470} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4610012774413914 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1504505394622770} - m_LocalRotation: {x: -0, y: -0.9999939, z: 0.0034912962, w: 0} - m_LocalPosition: {x: -0.00554, y: -0.00735, z: -0.139} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4483743749631420} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4633347229691846 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1399362814821872} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4577270798619972} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4642943849942306 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1439211211668616} - m_LocalRotation: {x: 0.33709526, y: -0, z: -0, w: 0.94147056} - m_LocalPosition: {x: 0.00629, y: -0.02522, z: -0.03469} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4050334673459560} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4695993798676282 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1437228542812490} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4988814349371388} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 13 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4710379363873502 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1515052315250130} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4333997724612544} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4716886561057732 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1440919061280958} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4738112902644160} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 9 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4738112902644160 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1258117880674016} - m_LocalRotation: {x: -0.74271846, y: -0, z: -0, w: 0.6696039} - m_LocalPosition: {x: 0, y: -0.002, z: -0.146} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4716886561057732} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4751982353548818 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1536059129537142} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4581809795155478} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 15 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4769650049049550 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1509876955685344} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4827942793568330} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 16 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4774128065012916 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1591938757829128} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4213492642316678} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4774972711166902 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1770412470437466} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -6.9849193e-10, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4368742210636480} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 12 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4791681828321116 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1492068379737228} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4363050274432786} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4794322518342860 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1663480401225244} - m_LocalRotation: {x: 0.3420201, y: 0, z: 0, w: 0.9396927} - m_LocalPosition: {x: -0.007, y: -0.005, z: -0.05} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000011600309478} - - {fileID: 4000012197213606} - - {fileID: 4000011559331518} - - {fileID: 4000012123783760} - - {fileID: 4000010810114962} - m_Father: {fileID: 436998} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 40, y: 0, z: 0} ---- !u!4 &4805665119888262 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1876384562517976} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4062986250107026} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4827942793568330 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1336837414518560} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: -0.00371, y: 0.00408, z: -0.06298} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4769650049049550} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4870480252557800 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1391981533677216} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4347810169859968} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 20 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4883595441978386 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1521131054530934} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4890536220949060} - m_Father: {fileID: 4560682712705560} - m_RootOrder: 18 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4890536220949060 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1266831003489266} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: -0.00149, y: -0.0012, z: -0.042} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4883595441978386} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4988814349371388 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1361187521139138} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4695993798676282} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &23011143559282002 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1060698883967346} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23051715092450864 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1104926084809440} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23092173763119808 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1391981533677216} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23204078342171062 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1536059129537142} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23279684870724754 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1522899860247498} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23853239758501888 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1521131054530934} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23995618592158306 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1509876955685344} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &33112371956597706 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1509876955685344} - m_Mesh: {fileID: 0} ---- !u!33 &33178554236838322 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1391981533677216} - m_Mesh: {fileID: 0} ---- !u!33 &33249309609687366 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1536059129537142} - m_Mesh: {fileID: 0} ---- !u!33 &33469603830917590 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1060698883967346} - m_Mesh: {fileID: 0} ---- !u!33 &33785835701983434 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1522899860247498} - m_Mesh: {fileID: 0} ---- !u!33 &33916300125348632 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1521131054530934} - m_Mesh: {fileID: 0} ---- !u!33 &33956794758310866 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1104926084809440} - m_Mesh: {fileID: 0} ---- !u!114 &114000013861093962 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 118082} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 88cb44c52683f6648b7d436e9aa51bcc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_RayOrigin: {fileID: 4000011600309478} - m_MenuOrigin: {fileID: 4000012197213606} - m_AlternateMenuOrigin: {fileID: 4000011559331518} - m_PreviewOrigin: {fileID: 4000012123783760} - m_FieldGrabOrigin: {fileID: 4000010810114962} - m_MeshRoot: {fileID: 4560682712705560} ---- !u!114 &114937401967916400 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1156465154805694} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5890e3cad70bea64d91aef9145ba3454, type: 3} - m_Name: - m_EditorClassIdentifier: - index: -1 - modelOverride: oculus_cv1_controller_left - shader: {fileID: 0} - verbose: 0 - createComponents: 1 - updateDynamically: 1 diff --git a/Prefabs/Proxies/ViveRightTouch.prefab b/Prefabs/Proxies/ViveRightTouch.prefab deleted file mode 100644 index be21f637e..000000000 --- a/Prefabs/Proxies/ViveRightTouch.prefab +++ /dev/null @@ -1,1793 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &141214 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 401760} - - component: {fileID: 114000011379258124} - m_Layer: 0 - m_Name: ViveRightTouch - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &401760 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 141214} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4114123614112124} - - {fileID: 4955629398068996} - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1001 &100100000 -Prefab: - m_ObjectHideFlags: 1 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 0} - propertyPath: m_animator - value: - objectReference: {fileID: 0} - - target: {fileID: 0} - propertyPath: m_controllerMask - value: 2 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 0} - m_RootGameObject: {fileID: 141214} - m_IsPrefabParent: 1 ---- !u!1 &1000010902826424 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000013824268610} - m_Layer: 0 - m_Name: PreviewOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000011728326988 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000014173169826} - m_Layer: 0 - m_Name: AltMenuOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013093051286 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000013278877548} - m_Layer: 0 - m_Name: MenuOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013401176380 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000010594257346} - m_Layer: 0 - m_Name: RayOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1000013806026548 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4000013218449236} - m_Layer: 0 - m_Name: FieldGrabOrigin - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1015025080107114 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4338863275766746} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1017848103554036 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4122877284945652} - m_Layer: 0 - m_Name: trackpad - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1078006834343386 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4153476044374478} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1084918560607064 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4394165137411150} - m_Layer: 0 - m_Name: lgrip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1096205118238398 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4985208446964720} - m_Layer: 0 - m_Name: gdc2015 - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1167263510738910 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4561186901587738} - m_Layer: 0 - m_Name: led - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1175562550023768 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4064421876161292} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1204407478510882 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4169102245282828} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1216001569780214 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4311070753493540} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1222108692673876 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4875182527443278} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1226461832118804 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4965564546862400} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1256313153753432 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4430884566944392} - m_Layer: 0 - m_Name: button - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1277699755885064 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4955629398068996} - m_Layer: 0 - m_Name: Pivot - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1291234185117738 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4492256861506862} - m_Layer: 0 - m_Name: sys_button - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1292403980323252 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4285528196412450} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1319750618082326 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4056063937132584} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1333329582297900 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4284541016125380} - m_Layer: 0 - m_Name: trackpad_scroll_cut - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1353490116601374 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4599338099271058} - - component: {fileID: 33213006784566536} - - component: {fileID: 23685513969778260} - m_Layer: 0 - m_Name: grip - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1365288689439810 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4729463227102552} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1370040456003826 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4035414622491038} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1383174753814500 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4446355355938954} - - component: {fileID: 33759447688285446} - - component: {fileID: 23450107420406520} - m_Layer: 0 - m_Name: home_button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1397216264146802 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4209818961789830} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1403337088170430 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4407470732880478} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1419037120550808 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4227554333722452} - m_Layer: 0 - m_Name: scroll_wheel - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1445857430169780 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4172279170361694} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1502414433327842 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4960372018300962} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1506756903305690 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4789122475774794} - m_Layer: 0 - m_Name: rgrip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1513740458129314 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4981603906608778} - - component: {fileID: 33967930094284210} - - component: {fileID: 23568579826718600} - m_Layer: 0 - m_Name: trigger - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1513766918687040 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4387113911672788} - - component: {fileID: 33819656159155084} - - component: {fileID: 23815770440904726} - m_Layer: 0 - m_Name: a_button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1519858117726124 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4736825928440594} - m_Layer: 0 - m_Name: trackpad_touch - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1538132534700554 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4317735520733896} - m_Layer: 0 - m_Name: tip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1538927158357284 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4954436683111630} - - component: {fileID: 33333166757609738} - - component: {fileID: 23861366152661854} - m_Layer: 0 - m_Name: thumbstick - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1547058690299732 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4957691913824072} - m_Layer: 0 - m_Name: attach - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1565124413751224 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4425350603751650} - m_Layer: 0 - m_Name: base - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1568059572411962 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4114123614112124} - - component: {fileID: 114864599699760286} - m_Layer: 0 - m_Name: ViveController - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1578026775671302 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4928237335952316} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1628430348274358 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4868308064664076} - - component: {fileID: 33313187326441368} - - component: {fileID: 23657970368481130} - m_Layer: 0 - m_Name: b_button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1782201578535092 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4051923300086686} - m_Layer: 0 - m_Name: status - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1789018909152748 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4238326113030232} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1847735767803450 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4948460115251384} - - component: {fileID: 33826026786099534} - - component: {fileID: 23412163262348934} - m_Layer: 0 - m_Name: body - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1849442996289906 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4563531661905232} - m_Layer: 0 - m_Name: handgrip - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1850472157921530 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4157320317652094} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1865910509741364 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4215450861154768} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1898858430087610 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4115262718920228} - m_Layer: 0 - m_Name: attach - m_TagString: ShowInMiniWorld - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &4000010594257346 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013401176380} - m_LocalRotation: {x: -0, y: -0.06975647, z: -0, w: 0.9975641} - m_LocalPosition: {x: 0, y: -0.003, z: 0.03} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4955629398068996} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: -8, z: 0} ---- !u!4 &4000013218449236 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013806026548} - m_LocalRotation: {x: -0.258819, y: -0, z: -0, w: 0.9659259} - m_LocalPosition: {x: 0, y: 0.025, z: 0.0746} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4955629398068996} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} ---- !u!4 &4000013278877548 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000013093051286} - m_LocalRotation: {x: 0.7053843, y: -0.049325276, z: 0.049325276, w: 0.7053843} - m_LocalPosition: {x: 0, y: -0.02, z: 0.05} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4955629398068996} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 90, y: -8, z: 0} ---- !u!4 &4000013824268610 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000010902826424} - m_LocalRotation: {x: -0.258819, y: -0, z: -0, w: 0.9659259} - m_LocalPosition: {x: 0, y: 0.074, z: 0.0746} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4955629398068996} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} ---- !u!4 &4000014173169826 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1000011728326988} - m_LocalRotation: {x: -0, y: -0.06975647, z: -0, w: 0.9975641} - m_LocalPosition: {x: 0, y: 0.0208, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4955629398068996} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: -8, z: 0} ---- !u!4 &4035414622491038 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1370040456003826} - m_LocalRotation: {x: 0.33709526, y: -0, z: -0, w: 0.94147056} - m_LocalPosition: {x: -0.00629, y: -0.02522, z: -0.03469} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4317735520733896} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4051923300086686 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1782201578535092} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4209818961789830} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 9 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4056063937132584 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1319750618082326} - m_LocalRotation: {x: -0.043941922, y: -0, z: -0, w: 0.9990341} - m_LocalPosition: {x: 0, y: 0.003, z: -0.097} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4563531661905232} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4064421876161292 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1175562550023768} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: 0.00371, y: 0.00408, z: -0.06298} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4446355355938954} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4114123614112124 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1568059572411962} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4425350603751650} - - {fileID: 4948460115251384} - - {fileID: 4430884566944392} - - {fileID: 4985208446964720} - - {fileID: 4563531661905232} - - {fileID: 4561186901587738} - - {fileID: 4394165137411150} - - {fileID: 4789122475774794} - - {fileID: 4227554333722452} - - {fileID: 4051923300086686} - - {fileID: 4492256861506862} - - {fileID: 4317735520733896} - - {fileID: 4122877284945652} - - {fileID: 4284541016125380} - - {fileID: 4736825928440594} - - {fileID: 4981603906608778} - - {fileID: 4387113911672788} - - {fileID: 4868308064664076} - - {fileID: 4599338099271058} - - {fileID: 4446355355938954} - - {fileID: 4954436683111630} - m_Father: {fileID: 401760} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4115262718920228 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1898858430087610} - m_LocalRotation: {x: -0, y: -0.9999939, z: 0.0034912962, w: 0} - m_LocalPosition: {x: 0.00554, y: -0.00735, z: -0.139} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4425350603751650} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4122877284945652 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1017848103554036} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -6.9849193e-10, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4965564546862400} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 12 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4153476044374478 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1078006834343386} - m_LocalRotation: {x: -0.68217707, y: -0, z: -0, w: 0.73118705} - m_LocalPosition: {x: 0, y: 0.008, z: -0.019} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4430884566944392} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4157320317652094 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1850472157921530} - m_LocalRotation: {x: -0.7368645, y: -0, z: -0, w: 0.6760405} - m_LocalPosition: {x: 0, y: 0.004, z: -0.088} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4492256861506862} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4169102245282828 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1204407478510882} - m_LocalRotation: {x: -0, y: -0.7313537, z: -0, w: 0.6819984} - m_LocalPosition: {x: -0.012, y: -0.00938, z: -0.09077} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4599338099271058} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4172279170361694 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1445857430169780} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4985208446964720} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4209818961789830 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1397216264146802} - m_LocalRotation: {x: -0.74271846, y: -0, z: -0, w: 0.6696039} - m_LocalPosition: {x: 0, y: -0.002, z: -0.146} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4051923300086686} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4215450861154768 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1865910509741364} - m_LocalRotation: {x: 0.33709526, y: -0, z: -0, w: 0.94147056} - m_LocalPosition: {x: -0.00391, y: -0.04554, z: -0.05172} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4981603906608778} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4227554333722452 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1419037120550808} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4729463227102552} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4238326113030232 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1789018909152748} - m_LocalRotation: {x: -0.73805505, y: -0, z: -0, w: 0.6747405} - m_LocalPosition: {x: 0, y: 0.003, z: -0.096} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4561186901587738} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4284541016125380 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1333329582297900} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4960372018300962} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 13 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4285528196412450 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1292403980323252} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: -0.01732, y: -0.00897, z: -0.04806} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4868308064664076} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4311070753493540 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1216001569780214} - m_LocalRotation: {x: -0.043941922, y: -0, z: -0, w: 0.9990341} - m_LocalPosition: {x: 0, y: 0.003, z: -0.097} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4948460115251384} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4317735520733896 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1538132534700554} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4035414622491038} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 11 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4338863275766746 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1015025080107114} - m_LocalRotation: {x: -0, y: 0.7327449, z: -0, w: 0.68050355} - m_LocalPosition: {x: 0.02, y: -0.015, z: -0.088} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4789122475774794} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4387113911672788 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1513766918687040} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4957691913824072} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 16 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4394165137411150 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1084918560607064} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4875182527443278} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4407470732880478 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1403337088170430} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: 0.00149, y: -0.0012, z: -0.042} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4954436683111630} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4425350603751650 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1565124413751224} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4115262718920228} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4430884566944392 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1256313153753432} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4153476044374478} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4446355355938954 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1383174753814500} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4064421876161292} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 19 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4492256861506862 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1291234185117738} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4157320317652094} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 10 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4561186901587738 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1167263510738910} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4238326113030232} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4563531661905232 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1849442996289906} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4056063937132584} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4599338099271058 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1353490116601374} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4169102245282828} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 18 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4729463227102552 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1365288689439810} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4227554333722452} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4736825928440594 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1519858117726124} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -6.9849193e-10, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4928237335952316} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 14 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4789122475774794 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1506756903305690} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4338863275766746} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4868308064664076 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1628430348274358} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4285528196412450} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 17 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4875182527443278 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1222108692673876} - m_LocalRotation: {x: -0, y: -0.7327449, z: -0, w: 0.68050355} - m_LocalPosition: {x: -0.02, y: -0.015, z: -0.088} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4394165137411150} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4928237335952316 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1578026775671302} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4736825928440594} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4948460115251384 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1847735767803450} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4311070753493540} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4954436683111630 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1538927158357284} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4407470732880478} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 20 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4955629398068996 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1277699755885064} - m_LocalRotation: {x: 0.3420201, y: 0, z: 0, w: 0.9396927} - m_LocalPosition: {x: -0.007, y: -0.005, z: -0.05} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4000010594257346} - - {fileID: 4000013278877548} - - {fileID: 4000014173169826} - - {fileID: 4000013824268610} - - {fileID: 4000013218449236} - m_Father: {fileID: 401760} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 40, y: 0, z: 0} ---- !u!4 &4957691913824072 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1547058690299732} - m_LocalRotation: {x: -0.42735785, y: -0, z: -0, w: 0.9040826} - m_LocalPosition: {x: -0.01107, y: 0.0001, z: -0.05813} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4387113911672788} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4960372018300962 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1502414433327842} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4284541016125380} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4965564546862400 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1226461832118804} - m_LocalRotation: {x: -0.52774763, y: -0.52774763, z: -0.47061923, w: 0.4706192} - m_LocalPosition: {x: 0, y: 0.002, z: -0.049} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4122877284945652} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4981603906608778 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1513740458129314} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4215450861154768} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 15 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4985208446964720 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1096205118238398} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4172279170361694} - m_Father: {fileID: 4114123614112124} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &23412163262348934 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1847735767803450} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23450107420406520 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1383174753814500} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23568579826718600 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1513740458129314} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23657970368481130 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1628430348274358} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23685513969778260 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1353490116601374} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23815770440904726 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1513766918687040} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23861366152661854 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1538927158357284} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &33213006784566536 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1353490116601374} - m_Mesh: {fileID: 0} ---- !u!33 &33313187326441368 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1628430348274358} - m_Mesh: {fileID: 0} ---- !u!33 &33333166757609738 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1538927158357284} - m_Mesh: {fileID: 0} ---- !u!33 &33759447688285446 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1383174753814500} - m_Mesh: {fileID: 0} ---- !u!33 &33819656159155084 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1513766918687040} - m_Mesh: {fileID: 0} ---- !u!33 &33826026786099534 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1847735767803450} - m_Mesh: {fileID: 0} ---- !u!33 &33967930094284210 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1513740458129314} - m_Mesh: {fileID: 0} ---- !u!114 &114000011379258124 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 141214} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 88cb44c52683f6648b7d436e9aa51bcc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_RayOrigin: {fileID: 4000010594257346} - m_MenuOrigin: {fileID: 4000013278877548} - m_AlternateMenuOrigin: {fileID: 4000014173169826} - m_PreviewOrigin: {fileID: 4000013824268610} - m_FieldGrabOrigin: {fileID: 4000013218449236} - m_MeshRoot: {fileID: 4114123614112124} ---- !u!114 &114864599699760286 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1568059572411962} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5890e3cad70bea64d91aef9145ba3454, type: 3} - m_Name: - m_EditorClassIdentifier: - index: -1 - modelOverride: oculus_cv1_controller_right - shader: {fileID: 0} - verbose: 0 - createComponents: 1 - updateDynamically: 1 diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 9580b2cb1..e0f0606b6 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -16,11 +16,6 @@ sealed class ViveProxy : TwoHandedProxyBase [SerializeField] GameObject m_RightHandTouchProxyPrefab; -#if ENABLE_STEAMVR_INPUT - SteamVR_RenderModel m_LeftModel; - SteamVR_RenderModel m_RightModel; -#endif - public override void Awake() { if (VRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0) @@ -45,35 +40,8 @@ public override IEnumerator Start() while (!active) yield return null; - m_LeftModel = m_LeftHand.GetComponentInChildren(true); - m_LeftModel.enabled = true; - m_RightModel = m_RightHand.GetComponentInChildren(true); - m_RightModel.enabled = true; - yield return base.Start(); } - - public override void Update() - { - if (active && m_LeftModel && m_RightModel) - { - var viveInputToEvents = (ViveInputToEvents)m_InputToEvents; - - //If proxy is not mapped to a physical input device, check if one has been assigned - if ((int) m_LeftModel.index == -1 && viveInputToEvents.steamDevice[0] != -1) - { - // HACK set device index individually instead of calling SetDeviceIndex because loading device mesh dynamically does not work in editor. Prefab has Model Override set and mesh generated, calling SetDeviceIndex clears the model. - m_LeftModel.index = (SteamVR_TrackedObject.EIndex)viveInputToEvents.steamDevice[0]; - } - - if ((int) m_RightModel.index == -1 && viveInputToEvents.steamDevice[1] != -1) - { - m_RightModel.index = (SteamVR_TrackedObject.EIndex)viveInputToEvents.steamDevice[1]; - } - } - - base.Update(); - } #endif } } diff --git a/Scripts/Proxies/ViveProxy.cs.meta b/Scripts/Proxies/ViveProxy.cs.meta index 8a3a3aca9..72191a514 100644 --- a/Scripts/Proxies/ViveProxy.cs.meta +++ b/Scripts/Proxies/ViveProxy.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 1dd05fa08947fc34392a98bded9b0ae0 -timeCreated: 1494831546 +timeCreated: 1507234154 licenseType: Pro MonoImporter: serializedVersion: 2 @@ -10,11 +10,9 @@ MonoImporter: - m_RightHandProxyPrefab: {fileID: 1000010426338840, guid: fbcfdb50f5e2d7a45bebae9a3a90b3fa, type: 2} - m_PlayerInput: {instanceID: 0} - - m_HighlightMaterial: {fileID: 2100000, guid: 40ce8f85e3653a84abffb13adb986781, + - m_LeftHandTouchProxyPrefab: {fileID: 118082, guid: b8cd5407792522543a52d20579ae4966, type: 2} - - m_LeftHandTouchProxyPrefab: {fileID: 118082, guid: daaa590e782c45c4880977eb4d91d4ee, - type: 2} - - m_RightHandTouchProxyPrefab: {fileID: 141214, guid: 687f54c4214cdf541b6809be57b26544, + - m_RightHandTouchProxyPrefab: {fileID: 141214, guid: d34262fb62f38944b97137c536cddf4b, type: 2} executionOrder: 0 icon: {instanceID: 0} From f81ff08677d417691e1f3678baa56a53dd919cc2 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 5 Oct 2017 15:43:36 -0700 Subject: [PATCH 088/457] Set up Vive controllers with tooltips --- .../Models/Materials/L_controller_DIF.mat | 2 +- .../Models/Materials/R_controller_DIF.mat | 2 +- Models/Vive/Materials/lambert4SG.mat | 2 +- Prefabs/Proxies/ViveController.prefab | 600 ++++++++++++++++-- Scripts/Helpers/ProxyHelper.cs | 16 + Scripts/Input/ViveInputToEvents.cs | 1 + Scripts/Proxies/TwoHandedProxyBase.cs | 78 ++- Scripts/Proxies/ViveProxy.cs | 2 - 8 files changed, 624 insertions(+), 79 deletions(-) diff --git a/Models/Touch/Models/Materials/L_controller_DIF.mat b/Models/Touch/Models/Materials/L_controller_DIF.mat index 0ac60a20e..a9baea05c 100644 --- a/Models/Touch/Models/Materials/L_controller_DIF.mat +++ b/Models/Touch/Models/Materials/L_controller_DIF.mat @@ -11,7 +11,7 @@ Material: m_ShaderKeywords: m_LightmapFlags: 5 m_EnableInstancingVariants: 0 - m_CustomRenderQueue: -1 + m_CustomRenderQueue: 9000 stringTagMap: {} disabledShaderPasses: [] m_SavedProperties: diff --git a/Models/Touch/Models/Materials/R_controller_DIF.mat b/Models/Touch/Models/Materials/R_controller_DIF.mat index 1adff4d50..eb4519702 100644 --- a/Models/Touch/Models/Materials/R_controller_DIF.mat +++ b/Models/Touch/Models/Materials/R_controller_DIF.mat @@ -11,7 +11,7 @@ Material: m_ShaderKeywords: _ALPHAPREMULTIPLY_ON m_LightmapFlags: 5 m_EnableInstancingVariants: 0 - m_CustomRenderQueue: 3000 + m_CustomRenderQueue: 9000 stringTagMap: RenderType: Transparent disabledShaderPasses: [] diff --git a/Models/Vive/Materials/lambert4SG.mat b/Models/Vive/Materials/lambert4SG.mat index 9a10f0f29..687c70692 100644 --- a/Models/Vive/Materials/lambert4SG.mat +++ b/Models/Vive/Materials/lambert4SG.mat @@ -11,7 +11,7 @@ Material: m_ShaderKeywords: _SPECGLOSSMAP m_LightmapFlags: 4 m_EnableInstancingVariants: 0 - m_CustomRenderQueue: -1 + m_CustomRenderQueue: 9000 stringTagMap: {} disabledShaderPasses: [] m_SavedProperties: diff --git a/Prefabs/Proxies/ViveController.prefab b/Prefabs/Proxies/ViveController.prefab index e46978538..7de4e7385 100644 --- a/Prefabs/Proxies/ViveController.prefab +++ b/Prefabs/Proxies/ViveController.prefab @@ -110,6 +110,10 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 4539810040550546} + - component: {fileID: 65755399496172608} + - component: {fileID: 114665279328025710} + - component: {fileID: 114185068079462814} + - component: {fileID: 114558108786776402} m_Layer: 0 m_Name: trigger m_TagString: Untagged @@ -125,6 +129,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 4851027070737694} + - component: {fileID: 65172744706328662} + - component: {fileID: 114845929221920070} + - component: {fileID: 114819021981951190} m_Layer: 0 m_Name: button m_TagString: Untagged @@ -140,6 +147,9 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 4027072583190098} + - component: {fileID: 65465404271049998} + - component: {fileID: 114585625546197374} + - component: {fileID: 114055751475063944} m_Layer: 0 m_Name: trackpad m_TagString: Untagged @@ -147,6 +157,21 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1120439927175024 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4831616359132024} + m_Layer: 0 + m_Name: TriggerTargetLeft + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1135163918873870 GameObject: m_ObjectHideFlags: 1 @@ -196,16 +221,16 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!1 &1300576921832436 +--- !u!1 &1299922452772042 GameObject: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} serializedVersion: 5 m_Component: - - component: {fileID: 4681010082850024} + - component: {fileID: 4335422725840038} m_Layer: 0 - m_Name: Trigger Pivot + m_Name: LGripTarget m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -228,6 +253,21 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1323843677921728 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4518390891298428} + m_Layer: 0 + m_Name: led + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1328780274993912 GameObject: m_ObjectHideFlags: 1 @@ -243,6 +283,23 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1406760687173922 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4815264511532942} + - component: {fileID: 33128327584385780} + - component: {fileID: 23418004637093020} + m_Layer: 0 + m_Name: LED_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1409931571782782 GameObject: m_ObjectHideFlags: 1 @@ -251,6 +308,10 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 4233998180511522} + - component: {fileID: 65911716287823276} + - component: {fileID: 114126237721642110} + - component: {fileID: 114195992931318178} + - component: {fileID: 114026251721049050} m_Layer: 0 m_Name: r_grip m_TagString: Untagged @@ -258,6 +319,36 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1497447780648672 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4393549197851336} + m_Layer: 0 + m_Name: TriggerTargetRight + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1662934685407242 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4351754754706288} + m_Layer: 0 + m_Name: RGripTarget + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1679918130705836 GameObject: m_ObjectHideFlags: 1 @@ -275,6 +366,21 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1685245103264382 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4957881420011328} + m_Layer: 0 + m_Name: TrackpadTarget + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1723382491159284 GameObject: m_ObjectHideFlags: 1 @@ -292,6 +398,21 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1759691860976830 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4662756588912008} + m_Layer: 0 + m_Name: ButtonTarget + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1778897529519236 GameObject: m_ObjectHideFlags: 0 @@ -330,6 +451,10 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 4064835649293204} + - component: {fileID: 65020282845500906} + - component: {fileID: 114585033862718108} + - component: {fileID: 114116332399531262} + - component: {fileID: 114306613819668780} m_Layer: 0 m_Name: l_grip m_TagString: Untagged @@ -461,42 +586,42 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1024981127734174} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: 0.057000216, y: -5.087612e-19, z: -0.0000000067949544, w: 0.99837416} + m_LocalPosition: {x: 0, y: 0.00379, z: 0.04921} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4788207952759710} m_Father: {fileID: 4469504124180788} m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 6.5350003, y: 0, z: 0} --- !u!4 &4064835649293204 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1863334949330014} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: 0.04776544, y: -0.020783136, z: -0.21021362, w: 0.97626674} + m_LocalPosition: {x: 0.01764, y: -0.01463, z: 0.08718} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4521799058005778} m_Father: {fileID: 4469504124180788} m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 4.8490005, y: -3.4900002, z: -24.451} --- !u!4 &4233998180511522 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1409931571782782} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: 0.047766984, y: 0.0207802, z: 0.21021305, w: 0.97626686} + m_LocalPosition: {x: -0.01764, y: -0.01463, z: 0.08718} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4314961011562620} m_Father: {fileID: 4469504124180788} m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 4.8490005, y: 3.49, z: 24.451} --- !u!4 &4268880949599228 Transform: m_ObjectHideFlags: 1 @@ -516,13 +641,52 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1679918130705836} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalRotation: {x: -0.047766984, y: -0.0207802, z: -0.21021305, w: 0.97626686} + m_LocalPosition: {x: 0.023886112, y: -0.00282767, z: -0.086873576} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4233998180511522} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4335422725840038 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1299922452772042} + m_LocalRotation: {x: -0.00000003073365, y: -0.8014793, z: 0.59802264, w: -0.000000048428777} + m_LocalPosition: {x: 0.06033203, y: -0.016862929, z: 0.08215353} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4469504124180788} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: 116.031006, y: 62.57099, z: -111.45099} +--- !u!4 &4351754754706288 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1662934685407242} + m_LocalRotation: {x: -0.0000000060535967, y: -0.8014792, z: 0.59802264, w: -0.000000013038516} + m_LocalPosition: {x: -0.06033203, y: -0.016862929, z: 0.08215353} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4469504124180788} + m_RootOrder: 10 + m_LocalEulerAnglesHint: {x: 116.031006, y: 62.57099, z: -111.45099} +--- !u!4 &4393549197851336 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1497447780648672} + m_LocalRotation: {x: 0.80147827, y: 0.000000038097546, z: 0.000000038097546, w: 0.5980239} + m_LocalPosition: {x: -0.06510001, y: -0.01986134, z: 0.041082107} + m_LocalScale: {x: 1.0000007, y: 1.0000005, z: 1.0000005} + m_Children: [] + m_Father: {fileID: 4469504124180788} + m_RootOrder: 13 + m_LocalEulerAnglesHint: {x: 106.543, y: -0.000015258789, z: -0.000015258789} --- !u!4 &4432114245915554 Transform: m_ObjectHideFlags: 1 @@ -567,19 +731,40 @@ Transform: - {fileID: 4233998180511522} - {fileID: 4925654503666930} - {fileID: 4027072583190098} - - {fileID: 4681010082850024} + - {fileID: 4539810040550546} + - {fileID: 4518390891298428} + - {fileID: 4662756588912008} + - {fileID: 4335422725840038} + - {fileID: 4351754754706288} + - {fileID: 4957881420011328} + - {fileID: 4831616359132024} + - {fileID: 4393549197851336} m_Father: {fileID: 4433677558257222} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} ---- !u!4 &4521799058005778 +--- !u!4 &4518390891298428 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1998691428341312} + m_GameObject: {fileID: 1323843677921728} m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4815264511532942} + m_Father: {fileID: 4469504124180788} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4521799058005778 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1998691428341312} + m_LocalRotation: {x: -0.04776544, y: 0.020783136, z: 0.21021362, w: 0.97626674} + m_LocalPosition: {x: -0.02388667, y: -0.002827534, z: -0.08687342} + m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4064835649293204} m_RootOrder: 0 @@ -590,8 +775,8 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1135163918873870} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalRotation: {x: -0.027226483, y: 2.2863792e-19, z: 0.0000000032456493, w: 0.9996293} + m_LocalPosition: {x: 0, y: 0.014395678, z: -0.03960231} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4539810040550546} @@ -603,90 +788,128 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1022711910310728} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0.016, z: -0.039} + m_LocalRotation: {x: 0.027226483, y: -2.2863792e-19, z: -0.0000000032456493, w: 0.9996293} + m_LocalPosition: {x: 0, y: -0.01653, z: 0.03876} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4526029195024024} - m_Father: {fileID: 4681010082850024} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4681010082850024 + m_Father: {fileID: 4469504124180788} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 3.1200001, y: 0, z: 0} +--- !u!4 &4662756588912008 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1300576921832436} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: -0.016, z: 0.039} + m_GameObject: {fileID: 1759691860976830} + m_LocalRotation: {x: 0.9483718, y: -0, z: -0, w: 0.31716076} + m_LocalPosition: {x: 0, y: 0.03160715, z: -0.049625583} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4539810040550546} + m_Children: [] m_Father: {fileID: 4469504124180788} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: 55.717003, y: 0, z: 0} --- !u!4 &4788207952759710 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1723382491159284} + m_LocalRotation: {x: -0.057000216, y: 5.087612e-19, z: 0.0000000067949544, w: 0.99837416} + m_LocalPosition: {x: 8.9541444e-11, y: -0.009366212, z: -0.048458874} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4027072583190098} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4815264511532942 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406760687173922} m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} m_LocalPosition: {x: -0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] - m_Father: {fileID: 4027072583190098} + m_Father: {fileID: 4518390891298428} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4831616359132024 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1120439927175024} + m_LocalRotation: {x: 0.80147827, y: 0.000000038097546, z: 0.000000038097546, w: 0.5980239} + m_LocalPosition: {x: 0.065100014, y: -0.01986134, z: 0.041082107} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4469504124180788} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 106.543, y: -0.000015258789, z: -0.000015258789} --- !u!4 &4851027070737694 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1023945361284662} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: -0.0006, z: 0} + m_LocalRotation: {x: 0.6902513, y: 0, z: 0, w: 0.72356975} + m_LocalPosition: {x: 0, y: 0.00765, z: 0.01978} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4962833239565766} m_Father: {fileID: 4469504124180788} m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 87.3, y: 0, z: 0} --- !u!4 &4925654503666930 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1328780274993912} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: 0.052335896, y: 0, z: 0, w: 0.9986295} + m_LocalPosition: {x: 0, y: 0.00205, z: 0.0883} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4936608528125002} m_Father: {fileID: 4469504124180788} m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 6, y: 0, z: 0} --- !u!4 &4936608528125002 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1278246946492418} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalRotation: {x: -0.052335896, y: -6.092699e-11, z: -0.0000000011625576, w: 0.9986295} + m_LocalPosition: {x: 0, y: -0.011268621, z: -0.08760199} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4925654503666930} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4957881420011328 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1685245103264382} + m_LocalRotation: {x: 0.9483718, y: -0.000000034924597, z: -0.0000000074505815, w: 0.3171608} + m_LocalPosition: {x: 0, y: 0.03161806, z: -0.005679421} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4469504124180788} + m_RootOrder: 11 + m_LocalEulerAnglesHint: {x: 55.717003, y: 0, z: 0} --- !u!4 &4962833239565766 Transform: m_ObjectHideFlags: 1 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1947952444214838} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} + m_LocalRotation: {x: -0.6902513, y: -0, z: -0, w: 0.72356975} + m_LocalPosition: {x: 0, y: -0.020118408, z: 0.0067097433} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4851027070737694} @@ -820,6 +1043,38 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 +--- !u!23 &23418004637093020 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406760687173922} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 --- !u!23 &23569124774784352 MeshRenderer: m_ObjectHideFlags: 1 @@ -930,6 +1185,13 @@ MeshFilter: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1998691428341312} m_Mesh: {fileID: 4300000, guid: b32f6f3f786b1b8449a3494a98f2b6b2, type: 3} +--- !u!33 &33128327584385780 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1406760687173922} + m_Mesh: {fileID: 4300000, guid: 76a8658f8856237409616e713d02cd80, type: 3} --- !u!33 &33280749333283016 MeshFilter: m_ObjectHideFlags: 1 @@ -965,6 +1227,66 @@ MeshFilter: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1313115655797016} m_Mesh: {fileID: 4300000, guid: 91923fcf53844be47a1ad1b01dc5b4d5, type: 3} +--- !u!65 &65020282845500906 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1863334949330014} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0049, y: 0.01356, z: 0.0297} + m_Center: {x: 0, y: 0, z: 0} +--- !u!65 &65172744706328662 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1023945361284662} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.009986, y: 0.01, z: 0.0042} + m_Center: {x: 0, y: 0, z: 0.0021} +--- !u!65 &65465404271049998 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1024981127734174} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.043, y: 0.00775, z: 0.04275} + m_Center: {x: 0, y: -0.00275, z: 0} +--- !u!65 &65755399496172608 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1022711910310728} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.01925, y: 0.0215, z: 0.019} + m_Center: {x: 0, y: -0.01075, z: 0.0095} +--- !u!65 &65911716287823276 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1409931571782782} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0049, y: 0.01356, z: 0.0297} + m_Center: {x: 0, y: 0, z: 0} --- !u!114 &114000011293798520 MonoBehaviour: m_ObjectHideFlags: 1 @@ -984,7 +1306,7 @@ MonoBehaviour: m_MeshRoot: {fileID: 4433677558257222} m_Buttons: - m_Control: 2 - m_Transform: {fileID: 4681010082850024} + m_Transform: {fileID: 4539810040550546} m_Renderer: {fileID: 23334373145171194} m_TranslateAxes: 0 m_RotateAxes: 1 @@ -1007,7 +1329,7 @@ MonoBehaviour: - m_Control: 18 m_Transform: {fileID: 4851027070737694} m_Renderer: {fileID: 23772360735447006} - m_TranslateAxes: 2 + m_TranslateAxes: 4 m_RotateAxes: 0 m_Min: 0.0005 m_Max: -0.0005 @@ -1018,3 +1340,191 @@ MonoBehaviour: m_RotateAxes: 0 m_Min: 0.001 m_Max: -0.001 + m_LeftTooltips: + - {fileID: 114116332399531262} + - {fileID: 114026251721049050} + - {fileID: 114185068079462814} + m_RightTooltips: + - {fileID: 114306613819668780} + - {fileID: 114195992931318178} + - {fileID: 114558108786776402} +--- !u!114 &114026251721049050 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1409931571782782} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4064835649293204} + m_TooltipSource: {fileID: 4335422725840038} + m_TooltipAlignment: 2 +--- !u!114 &114055751475063944 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1024981127734174} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4957881420011328} + m_TooltipSource: {fileID: 4027072583190098} + m_TooltipAlignment: 1 +--- !u!114 &114116332399531262 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1863334949330014} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4335422725840038} + m_TooltipSource: {fileID: 4064835649293204} + m_TooltipAlignment: 2 +--- !u!114 &114126237721642110 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1409931571782782} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114185068079462814 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1022711910310728} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4831616359132024} + m_TooltipSource: {fileID: 4539810040550546} + m_TooltipAlignment: 2 +--- !u!114 &114195992931318178 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1409931571782782} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4351754754706288} + m_TooltipSource: {fileID: 4233998180511522} + m_TooltipAlignment: 0 +--- !u!114 &114306613819668780 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1863334949330014} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4233998180511522} + m_TooltipSource: {fileID: 4351754754706288} + m_TooltipAlignment: 0 +--- !u!114 &114558108786776402 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1022711910310728} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4831616359132024} + m_TooltipSource: {fileID: 4539810040550546} + m_TooltipAlignment: 0 +--- !u!114 &114585033862718108 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1863334949330014} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114585625546197374 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1024981127734174} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114665279328025710 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1022711910310728} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114819021981951190 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1023945361284662} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4662756588912008} + m_TooltipSource: {fileID: 4851027070737694} + m_TooltipAlignment: 1 +--- !u!114 &114845929221920070 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1023945361284662} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index ec44ff1ec..bb06b590e 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -67,6 +67,12 @@ public class ButtonObject [SerializeField] ButtonObject[] m_Buttons; + [SerializeField] + Tooltip[] m_LeftTooltips; + + [SerializeField] + Tooltip[] m_RightTooltips; + /// /// The transform that the device's ray contents (default ray, custom ray, etc) will be parented under /// @@ -101,6 +107,16 @@ public class ButtonObject /// Button objects to store transform and renderer references /// public ButtonObject[] buttons { get { return m_Buttons; } } + + /// + /// Tooltip components to be removed from a right-handed controller + /// + public Tooltip[] leftTooltips { get { return m_LeftTooltips; } } + + /// + /// Tooltip components to be removed from a left-handed controller + /// + public Tooltip[] rightTooltips { get { return m_RightTooltips; } } } } #endif diff --git a/Scripts/Input/ViveInputToEvents.cs b/Scripts/Input/ViveInputToEvents.cs index c3a222e34..b1f4d6871 100644 --- a/Scripts/Input/ViveInputToEvents.cs +++ b/Scripts/Input/ViveInputToEvents.cs @@ -54,6 +54,7 @@ public void Update() if (compositor != null) { var render = SteamVR_Render.instance; + render.transform.parent = gameObject.transform; compositor.GetLastPoses(render.poses, render.gamePoses); poses = render.poses; } diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 981464d7f..e83293502 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -42,9 +42,12 @@ abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, IS protected Dictionary m_RayOrigins; + bool m_Hidden; + List m_ProxyMeshRoots = new List(); - readonly Dictionary> m_Buttons = new Dictionary>(); + readonly Dictionary>> m_Buttons = + new Dictionary>>(); public Transform leftHand { get { return m_LeftHand; } } public Transform rightHand { get { return m_RightHand; } } @@ -74,8 +77,6 @@ public virtual bool hidden } } - private bool m_Hidden; - public Dictionary menuOrigins { get; set; } public Dictionary alternateMenuOrigins { get; set; } public Dictionary previewOrigins { get; set; } @@ -91,17 +92,31 @@ public virtual void Awake() m_ProxyMeshRoots.Add(leftProxyHelper.meshRoot); m_ProxyMeshRoots.Add(rightProxyHelper.meshRoot); - var leftButtons = new Dictionary(); + var leftButtons = new Dictionary>(); foreach (var button in leftProxyHelper.buttons) { - leftButtons[button.control] = button; + List buttons; + if (!leftButtons.TryGetValue(button.control, out buttons)) + { + buttons = new List(); + leftButtons[button.control] = buttons; + } + + buttons.Add(button); } m_Buttons[Node.LeftHand] = leftButtons; - var rightButtons = new Dictionary(); + var rightButtons = new Dictionary>(); foreach (var button in rightProxyHelper.buttons) { - rightButtons[button.control] = button; + List buttons; + if (!rightButtons.TryGetValue(button.control, out buttons)) + { + buttons = new List(); + rightButtons[button.control] = buttons; + } + + buttons.Add(button); } m_Buttons[Node.RightHand] = rightButtons; @@ -213,18 +228,20 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) if (request == null) continue; - var button = kvp.Value; - if (button.renderer) - this.SetHighlight(button.renderer.gameObject, true, duration: k_FeedbackDuration); - - if (button.transform) + foreach (var button in kvp.Value) { - var tooltip = button.transform.GetComponent(); - var tooltipText = request.tooltipText; - if (!string.IsNullOrEmpty(tooltipText) && tooltip) + if (button.renderer) + this.SetHighlight(button.renderer.gameObject, true, duration: k_FeedbackDuration); + + if (button.transform) { - tooltip.tooltipText = tooltipText; - this.ShowTooltip(tooltip, true, k_FeedbackDuration); + var tooltip = button.transform.GetComponent(); + var tooltipText = request.tooltipText; + if (!string.IsNullOrEmpty(tooltipText) && tooltip) + { + tooltip.tooltipText = tooltipText; + this.ShowTooltip(tooltip, true, k_FeedbackDuration); + } } } } @@ -240,22 +257,25 @@ public void RemoveFeedbackRequest(FeedbackRequest request) void RemoveFeedbackRequest(ProxyFeedbackRequest request) { - Dictionary buttons; - if (m_Buttons.TryGetValue(request.node, out buttons)) + Dictionary> group; + if (m_Buttons.TryGetValue(request.node, out group)) { - ProxyHelper.ButtonObject button; - if (buttons.TryGetValue(request.control, out button)) + List buttons; + if (group.TryGetValue(request.control, out buttons)) { - if (button.renderer) - this.SetHighlight(button.renderer.gameObject, false); - - if (button.transform) + foreach (var button in buttons) { - var tooltip = button.transform.GetComponent(); - if (tooltip) + if (button.renderer) + this.SetHighlight(button.renderer.gameObject, false); + + if (button.transform) { - tooltip.tooltipText = string.Empty; - this.HideTooltip(tooltip, true); + var tooltip = button.transform.GetComponent(); + if (tooltip) + { + tooltip.tooltipText = string.Empty; + this.HideTooltip(tooltip, true); + } } } } diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index e0f0606b6..9a93a9303 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -35,8 +35,6 @@ public override void Awake() #if ENABLE_STEAMVR_INPUT public override IEnumerator Start() { - SteamVR_Render.instance.transform.parent = gameObject.transform; - while (!active) yield return null; From a94cabc82ad9a0656a9fdca443e890c5f3a5354d Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 5 Oct 2017 16:28:42 -0700 Subject: [PATCH 089/457] Finish adding tooltips to Vive controllers --- Prefabs/Proxies/ViveController.prefab | 37 +++++------ Scripts/Helpers/ProxyHelper.cs | 8 --- .../Modules/TooltipModule/TooltipModule.cs | 31 +++++---- Scripts/Proxies/TwoHandedProxyBase.cs | 66 ++++++++----------- 4 files changed, 67 insertions(+), 75 deletions(-) diff --git a/Prefabs/Proxies/ViveController.prefab b/Prefabs/Proxies/ViveController.prefab index 7de4e7385..f48107aa8 100644 --- a/Prefabs/Proxies/ViveController.prefab +++ b/Prefabs/Proxies/ViveController.prefab @@ -680,13 +680,13 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1497447780648672} - m_LocalRotation: {x: 0.80147827, y: 0.000000038097546, z: 0.000000038097546, w: 0.5980239} + m_LocalRotation: {x: -0.00000011198207, y: -0.80147827, z: 0.5980239, w: -0.00000015007961} m_LocalPosition: {x: -0.06510001, y: -0.01986134, z: 0.041082107} - m_LocalScale: {x: 1.0000007, y: 1.0000005, z: 1.0000005} + m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005} m_Children: [] m_Father: {fileID: 4469504124180788} m_RootOrder: 13 - m_LocalEulerAnglesHint: {x: 106.543, y: -0.000015258789, z: -0.000015258789} + m_LocalEulerAnglesHint: {x: 106.543, y: -0.000015258789, z: 180} --- !u!4 &4432114245915554 Transform: m_ObjectHideFlags: 1 @@ -802,13 +802,13 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1759691860976830} - m_LocalRotation: {x: 0.9483718, y: -0, z: -0, w: 0.31716076} + m_LocalRotation: {x: 0, y: -0.94837075, z: 0.317164, w: 0} m_LocalPosition: {x: 0, y: 0.03160715, z: -0.049625583} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4469504124180788} m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: 55.717003, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 143.017, y: 0, z: 180} --- !u!4 &4788207952759710 Transform: m_ObjectHideFlags: 1 @@ -841,13 +841,13 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1120439927175024} - m_LocalRotation: {x: 0.80147827, y: 0.000000038097546, z: 0.000000038097546, w: 0.5980239} + m_LocalRotation: {x: 0, y: -0.80147827, z: 0.5980239, w: 0} m_LocalPosition: {x: 0.065100014, y: -0.01986134, z: 0.041082107} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4469504124180788} m_RootOrder: 12 - m_LocalEulerAnglesHint: {x: 106.543, y: -0.000015258789, z: -0.000015258789} + m_LocalEulerAnglesHint: {x: 106.543, y: 0, z: 180} --- !u!4 &4851027070737694 Transform: m_ObjectHideFlags: 1 @@ -895,13 +895,13 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1685245103264382} - m_LocalRotation: {x: 0.9483718, y: -0.000000034924597, z: -0.0000000074505815, w: 0.3171608} + m_LocalRotation: {x: 0, y: -0.94837075, z: 0.317164, w: 0} m_LocalPosition: {x: 0, y: 0.03161806, z: -0.005679421} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4469504124180788} m_RootOrder: 11 - m_LocalEulerAnglesHint: {x: 55.717003, y: 0, z: 0} + m_LocalEulerAnglesHint: {x: 143.017, y: 0, z: 180} --- !u!4 &4962833239565766 Transform: m_ObjectHideFlags: 1 @@ -1303,7 +1303,6 @@ MonoBehaviour: m_AlternateMenuOrigin: {fileID: 4000012662092726} m_PreviewOrigin: {fileID: 4000013779846498} m_FieldGrabOrigin: {fileID: 4000011094092792} - m_MeshRoot: {fileID: 4433677558257222} m_Buttons: - m_Control: 2 m_Transform: {fileID: 4539810040550546} @@ -1341,13 +1340,13 @@ MonoBehaviour: m_Min: 0.001 m_Max: -0.001 m_LeftTooltips: - - {fileID: 114116332399531262} + - {fileID: 114558108786776402} - {fileID: 114026251721049050} - - {fileID: 114185068079462814} + - {fileID: 114116332399531262} m_RightTooltips: - - {fileID: 114306613819668780} + - {fileID: 114185068079462814} - {fileID: 114195992931318178} - - {fileID: 114558108786776402} + - {fileID: 114306613819668780} --- !u!114 &114026251721049050 MonoBehaviour: m_ObjectHideFlags: 1 @@ -1360,8 +1359,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_TooltipText: - m_TooltipTarget: {fileID: 4064835649293204} - m_TooltipSource: {fileID: 4335422725840038} + m_TooltipTarget: {fileID: 4335422725840038} + m_TooltipSource: {fileID: 4064835649293204} m_TooltipAlignment: 2 --- !u!114 &114055751475063944 MonoBehaviour: @@ -1447,8 +1446,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_TooltipText: - m_TooltipTarget: {fileID: 4233998180511522} - m_TooltipSource: {fileID: 4351754754706288} + m_TooltipTarget: {fileID: 4351754754706288} + m_TooltipSource: {fileID: 4233998180511522} m_TooltipAlignment: 0 --- !u!114 &114558108786776402 MonoBehaviour: @@ -1462,7 +1461,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_TooltipText: - m_TooltipTarget: {fileID: 4831616359132024} + m_TooltipTarget: {fileID: 4393549197851336} m_TooltipSource: {fileID: 4539810040550546} m_TooltipAlignment: 0 --- !u!114 &114585033862718108 diff --git a/Scripts/Helpers/ProxyHelper.cs b/Scripts/Helpers/ProxyHelper.cs index bb06b590e..ec95e76c8 100644 --- a/Scripts/Helpers/ProxyHelper.cs +++ b/Scripts/Helpers/ProxyHelper.cs @@ -61,9 +61,6 @@ public class ButtonObject [SerializeField] Transform m_FieldGrabOrigin; - [SerializeField] - Transform m_MeshRoot; - [SerializeField] ButtonObject[] m_Buttons; @@ -98,11 +95,6 @@ public class ButtonObject /// public Transform fieldGrabOrigin { get { return m_FieldGrabOrigin; } } - /// - /// The root transform of the device/controller mesh-renderers/geometry - /// - public Transform meshRoot { get { return m_MeshRoot; } } - /// /// Button objects to store transform and renderer references /// diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index 128d209c1..86ef047de 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -46,7 +46,7 @@ class TooltipData Color m_OriginalBackgroundColor; // Local method use only -- created here to reduce garbage collection - readonly List m_TooltipsToHide = new List(); + static readonly List k_TooltipList = new List(); void Awake() { @@ -69,7 +69,7 @@ void Start() void Update() { - m_TooltipsToHide.Clear(); + k_TooltipList.Clear(); foreach (var kvp in m_Tooltips) { var tooltip = kvp.Key; @@ -107,17 +107,17 @@ void Update() } if (!IsValidTooltip(tooltip)) - m_TooltipsToHide.Add(tooltip); + k_TooltipList.Add(tooltip); if (tooltipData.persistent) { var duration = tooltipData.duration; if (duration > 0 && Time.time - tooltipData.lastModifiedTime + k_Delay > duration) - m_TooltipsToHide.Add(tooltip); + k_TooltipList.Add(tooltip); } } - foreach (var tooltip in m_TooltipsToHide) + foreach (var tooltip in k_TooltipList) { HideTooltip(tooltip, true); } @@ -222,9 +222,12 @@ public void OnRayEntered(GameObject gameObject, RayEventData eventData) if (gameObject == this.gameObject) return; - var tooltip = gameObject.GetComponent(); - if (tooltip != null) + k_TooltipList.Clear(); + gameObject.GetComponents(k_TooltipList); + foreach (var tooltip in k_TooltipList) + { ShowTooltip(tooltip); + } } public void OnRayHovering(GameObject gameObject, RayEventData eventData) @@ -232,18 +235,24 @@ public void OnRayHovering(GameObject gameObject, RayEventData eventData) if (gameObject == this.gameObject) return; - var tooltip = gameObject.GetComponent(); - if (tooltip != null) + k_TooltipList.Clear(); + gameObject.GetComponents(k_TooltipList); + foreach (var tooltip in k_TooltipList) + { ShowTooltip(tooltip); + } } public void OnRayExited(GameObject gameObject, RayEventData eventData) { if (gameObject && gameObject != this.gameObject) { - var tooltip = gameObject.GetComponent(); - if (tooltip != null) + k_TooltipList.Clear(); + gameObject.GetComponents(k_TooltipList); + foreach (var tooltip in k_TooltipList) + { HideTooltip(tooltip); + } } } diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index e83293502..64459f9b6 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -21,8 +21,7 @@ public class ProxyFeedbackRequest : FeedbackRequest abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, ISetTooltipVisibility, ISetHighlight { - const int k_RendererQueue = 9000; - const float k_FeedbackDuration = 5f; + const float k_FeedbackDuration = 500f; [SerializeField] protected GameObject m_LeftHandProxyPrefab; @@ -37,15 +36,12 @@ abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, IS protected Transform m_LeftHand; protected Transform m_RightHand; - readonly List m_Materials = new List(); readonly List m_FeedbackRequests = new List(); protected Dictionary m_RayOrigins; bool m_Hidden; - List m_ProxyMeshRoots = new List(); - readonly Dictionary>> m_Buttons = new Dictionary>>(); @@ -82,6 +78,9 @@ public virtual bool hidden public Dictionary previewOrigins { get; set; } public Dictionary fieldGrabOrigins { get; set; } + // Local method use only -- created here to reduce garbage collection + static readonly List k_TooltipList = new List(); + public virtual void Awake() { m_LeftHand = ObjectUtils.Instantiate(m_LeftHandProxyPrefab, transform).transform; @@ -89,8 +88,15 @@ public virtual void Awake() var leftProxyHelper = m_LeftHand.GetComponent(); var rightProxyHelper = m_RightHand.GetComponent(); - m_ProxyMeshRoots.Add(leftProxyHelper.meshRoot); - m_ProxyMeshRoots.Add(rightProxyHelper.meshRoot); + foreach (var tooltip in leftProxyHelper.rightTooltips) + { + ObjectUtils.Destroy(tooltip); + } + + foreach (var tooltip in rightProxyHelper.leftTooltips) + { + ObjectUtils.Destroy(tooltip); + } var leftButtons = new Dictionary>(); foreach (var button in leftProxyHelper.buttons) @@ -153,37 +159,18 @@ public virtual void Awake() public virtual IEnumerator Start() { - // In standalone play-mode usage, attempt to get the TrackedObjectInput + // In standalone play-mode usage, attempt to get the TrackedObjectInput if (trackedObjectInput == null && m_PlayerInput) trackedObjectInput = m_PlayerInput.GetActions(); - List renderers = new List(); - while (renderers.Count == 0) - { - yield return null; - foreach (var meshRoot in m_ProxyMeshRoots) - { - // Only add models of the device and not anything else that is spawned underneath the hand (e.g. menu button, cone/ray) - renderers.AddRange(meshRoot.GetComponentsInChildren()); - } - } - - foreach (var r in renderers) - { - m_Materials.AddRange(MaterialUtils.CloneMaterials(r)); - } - - // Move controllers up into EVR range, so they render properly over our UI (e.g. manipulators) - foreach (var m in m_Materials) - { - m.renderQueue = k_RendererQueue; - } +#pragma warning disable 162 + if (false) + yield return null; //Unreachable yield to fix compiler error +#pragma warning restore 162 } public virtual void OnDestroy() { - foreach (var m in m_Materials) - ObjectUtils.Destroy(m); } public virtual void Update() @@ -235,12 +222,16 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) if (button.transform) { - var tooltip = button.transform.GetComponent(); var tooltipText = request.tooltipText; - if (!string.IsNullOrEmpty(tooltipText) && tooltip) + if (!string.IsNullOrEmpty(tooltipText)) { - tooltip.tooltipText = tooltipText; - this.ShowTooltip(tooltip, true, k_FeedbackDuration); + k_TooltipList.Clear(); + button.transform.GetComponents(k_TooltipList); + foreach (var tooltip in k_TooltipList) + { + tooltip.tooltipText = tooltipText; + this.ShowTooltip(tooltip, true, k_FeedbackDuration); + } } } } @@ -270,8 +261,9 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) if (button.transform) { - var tooltip = button.transform.GetComponent(); - if (tooltip) + k_TooltipList.Clear(); + button.transform.GetComponents(k_TooltipList); + foreach (var tooltip in k_TooltipList) { tooltip.tooltipText = string.Empty; this.HideTooltip(tooltip, true); From 566440a62d2aab3d802087d9f52de039b9bf76ba Mon Sep 17 00:00:00 2001 From: andrewm Date: Thu, 5 Oct 2017 17:03:03 -0700 Subject: [PATCH 090/457] Chipping away at our per-frame allocations. This reduces things by about 1-3kb/frame --- Scripts/Core/EditorVR.Menus.cs | 16 ++++++++- Scripts/Core/EditorVR.MiniWorlds.cs | 34 ++++++++++--------- Scripts/Core/EditorVR.UI.cs | 11 +++++- Scripts/Core/EditorVR.Viewer.cs | 12 +++++-- Scripts/Modules/DeviceInputModule.cs | 9 ++--- .../Modules/TooltipModule/TooltipModule.cs | 6 ++-- Scripts/Utilities/ComponentUtils.cs | 27 +++++++++++++++ Scripts/Utilities/ComponentUtils.cs.meta | 13 +++++++ Tools/SelectionTool/SelectionTool.cs | 7 ++-- libs/input-prototype | 2 +- 10 files changed, 106 insertions(+), 31 deletions(-) create mode 100644 Scripts/Utilities/ComponentUtils.cs create mode 100644 Scripts/Utilities/ComponentUtils.cs.meta diff --git a/Scripts/Core/EditorVR.Menus.cs b/Scripts/Core/EditorVR.Menus.cs index 2d3571484..d7c1d3c6b 100644 --- a/Scripts/Core/EditorVR.Menus.cs +++ b/Scripts/Core/EditorVR.Menus.cs @@ -382,7 +382,21 @@ internal static bool IsValidHover(MultipleRayInputModule.RaycastSource source) var eventData = source.eventData; var rayOrigin = eventData.rayOrigin; - var deviceData = evr.m_DeviceData.FirstOrDefault(dd => dd.rayOrigin == rayOrigin); + + DeviceData deviceData = null; + var deviceDataList = evr.m_DeviceData; + var dataCounter = 0; + while (dataCounter < deviceDataList.Count) + { + var currentDevice = deviceDataList[dataCounter]; + if (currentDevice.rayOrigin == rayOrigin) + { + deviceData = currentDevice; + break; + } + dataCounter++; + } + if (deviceData != null) { if (go.transform.IsChildOf(deviceData.rayOrigin)) // Don't let UI on this hand block the menu diff --git a/Scripts/Core/EditorVR.MiniWorlds.cs b/Scripts/Core/EditorVR.MiniWorlds.cs index 741790160..efaacf356 100644 --- a/Scripts/Core/EditorVR.MiniWorlds.cs +++ b/Scripts/Core/EditorVR.MiniWorlds.cs @@ -463,26 +463,28 @@ internal void UpdateMiniWorlds() } // Update ray visibilities - Rays.ForEachProxyDevice(data => - { - bool wasContained; - var rayOrigin = data.rayOrigin; - m_RayWasContained.TryGetValue(rayOrigin, out wasContained); + Rays.ForEachProxyDevice(UpdateRayContaimnent); + } - var isContained = false; - foreach (var miniWorld in m_Worlds) - { - isContained |= miniWorld.Contains(rayOrigin.position + rayOrigin.forward * DirectSelection.GetPointerLength(rayOrigin)); - } + void UpdateRayContaimnent(DeviceData data) + { + bool wasContained; + var rayOrigin = data.rayOrigin; + m_RayWasContained.TryGetValue(rayOrigin, out wasContained); + + var isContained = false; + foreach (var miniWorld in m_Worlds) + { + isContained |= miniWorld.Contains(rayOrigin.position + rayOrigin.forward * DirectSelection.GetPointerLength(rayOrigin)); + } - if (isContained && !wasContained) - Rays.AddVisibilitySettings(rayOrigin, this, false, true); + if (isContained && !wasContained) + Rays.AddVisibilitySettings(rayOrigin, this, false, true); - if (!isContained && wasContained) - Rays.RemoveVisibilitySettings(rayOrigin, this); + if (!isContained && wasContained) + Rays.RemoveVisibilitySettings(rayOrigin, this); - m_RayWasContained[rayOrigin] = isContained; - }); + m_RayWasContained[rayOrigin] = isContained; } internal void OnWorkspaceCreated(IWorkspace workspace) diff --git a/Scripts/Core/EditorVR.UI.cs b/Scripts/Core/EditorVR.UI.cs index 40c08d80f..91f2cab88 100644 --- a/Scripts/Core/EditorVR.UI.cs +++ b/Scripts/Core/EditorVR.UI.cs @@ -129,7 +129,16 @@ void SetManipulatorsVisible(ISetManipulatorsVisible setter, bool visible) bool GetManipulatorDragState() { - return m_ManipulatorControllers.Any(controller => controller.manipulatorDragging); + var controllerCounter = 0; + while (controllerCounter < m_ManipulatorControllers.Count) + { + if (m_ManipulatorControllers[controllerCounter].manipulatorDragging) + { + return true; + } + controllerCounter++; + } + return false; } internal void UpdateManipulatorVisibilites() diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index 885e67dba..ab20115b2 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -37,6 +37,8 @@ class Preferences const float k_CameraRigTransitionTime = 0.25f; + static Collider[] s_CachedColliders = new Collider[20]; + PlayerBody m_PlayerBody; float m_OriginalNearClipPlane; float m_OriginalFarClipPlane; @@ -199,11 +201,15 @@ static bool Overlaps(Transform rayOrigin, Collider trigger) { var radius = DirectSelection.GetPointerLength(rayOrigin); - var colliders = Physics.OverlapSphere(rayOrigin.position, radius, -1, QueryTriggerInteraction.Collide); - foreach (var collider in colliders) + var totalColliders = Physics.OverlapSphereNonAlloc(rayOrigin.position, radius, s_CachedColliders, -1, QueryTriggerInteraction.Collide); + var colliderIndex = 0; + + while (colliderIndex < totalColliders) { - if (collider == trigger) + if (s_CachedColliders[colliderIndex] == trigger) return true; + + colliderIndex++; } return false; diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 8503579d9..1aed46609 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -37,6 +37,7 @@ sealed class DeviceInputModule : MonoBehaviour public Action, ConsumeControlDelegate> processInput; public Action> updatePlayerHandleMaps; + List m_RemoveList = new List(); public List GetSystemDevices() { @@ -67,26 +68,26 @@ void OnDestroy() public void ProcessInput() { + m_RemoveList.Clear(); // Maintain a consumed control, so that other AMIs don't pick up the input, until it's no longer used - var removeList = new List(); foreach (var lockedControl in m_LockedControls) { if (!lockedControl.provider.active || Mathf.Approximately(lockedControl.rawValue, lockedControl.provider.GetControlData(lockedControl.index).defaultValue)) - removeList.Add(lockedControl); + m_RemoveList.Add(lockedControl); else ConsumeControl(lockedControl); } // Remove separately, since we cannot remove while iterating - foreach (var inputControl in removeList) + foreach (var inputControl in m_RemoveList) { if (!inputControl.provider.active) ResetControl(inputControl); m_LockedControls.Remove(inputControl); } - + m_RemoveList.Clear(); m_ProcessedInputs.Clear(); // TODO: Replace this with a map of ActionMap,IProcessInput and go through those diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index 8f1972f11..0399184ad 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -211,7 +211,7 @@ public void OnRayEntered(GameObject gameObject, RayEventData eventData) if (gameObject == this.gameObject) return; - var tooltip = gameObject.GetComponent(); + var tooltip = ComponentUtils.GetComponent(gameObject); if (tooltip != null) ShowTooltip(tooltip); } @@ -221,7 +221,7 @@ public void OnRayHovering(GameObject gameObject, RayEventData eventData) if (gameObject == this.gameObject) return; - var tooltip = gameObject.GetComponent(); + var tooltip = ComponentUtils.GetComponent(gameObject); if (tooltip != null) ShowTooltip(tooltip); } @@ -230,7 +230,7 @@ public void OnRayExited(GameObject gameObject, RayEventData eventData) { if (gameObject && gameObject != this.gameObject) { - var tooltip = gameObject.GetComponent(); + var tooltip = ComponentUtils.GetComponent(gameObject); if (tooltip != null) HideTooltip(tooltip); } diff --git a/Scripts/Utilities/ComponentUtils.cs b/Scripts/Utilities/ComponentUtils.cs new file mode 100644 index 000000000..9adbed776 --- /dev/null +++ b/Scripts/Utilities/ComponentUtils.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.Experimental.EditorVR.Utilities +{ + /// + /// Special utility class for getting components in the editor without allocations + /// + /// + public class ComponentUtils + { + static List s_RetrievalList = new List(); + + public static T GetComponent(GameObject go) + { + var foundComponent = default(T); + go.GetComponents(s_RetrievalList); + if (s_RetrievalList.Count > 0) + { + foundComponent = s_RetrievalList[0]; + s_RetrievalList.Clear(); + } + return foundComponent; + } + + } +} diff --git a/Scripts/Utilities/ComponentUtils.cs.meta b/Scripts/Utilities/ComponentUtils.cs.meta new file mode 100644 index 000000000..c1603cd9f --- /dev/null +++ b/Scripts/Utilities/ComponentUtils.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ded6979332e70e54e9c58387cd2cb326 +timeCreated: 1507247001 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 48a529592..7793f7898 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -39,6 +39,8 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR readonly Dictionary m_SelectionHoverGameObjects = new Dictionary(); + Dictionary m_TempHovers = new Dictionary(); + public ActionMap actionMap { get { return m_ActionMap; } } public Transform rayOrigin { private get; set; } @@ -133,8 +135,8 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } // Unset highlight old hovers - var hovers = new Dictionary(m_HoverGameObjects); - foreach (var kvp in hovers) + m_TempHovers.Clear(); + foreach (var kvp in m_TempHovers) { var directRayOrigin = kvp.Key; var hover = kvp.Value; @@ -146,6 +148,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon m_HoverGameObjects.Remove(directRayOrigin); } } + m_TempHovers.Clear(); // Find new hovers foreach (var kvp in directSelection) diff --git a/libs/input-prototype b/libs/input-prototype index 92aa26f22..b671b868a 160000 --- a/libs/input-prototype +++ b/libs/input-prototype @@ -1 +1 @@ -Subproject commit 92aa26f2202380cfca037b450f16a67f4796caa3 +Subproject commit b671b868a5c458f2ce194da5bd6808f401a914c5 From 435842e5138c98ba357b96d02b33b4af4e196f69 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 5 Oct 2017 17:22:23 -0700 Subject: [PATCH 091/457] Add postAnimate event for custom ProxyAnimator logic; Implement Vive trackpad animation --- Models/Vive/Vive Controller.prefab | 891 ------------------------ Models/Vive/Vive Controller.prefab.meta | 9 - Prefabs/Proxies/ViveController.prefab | 129 +++- Scripts/Core/EditorVR.Rays.cs | 5 - Scripts/Proxies/ProxyAnimator.cs | 34 +- Scripts/Proxies/TwoHandedProxyBase.cs | 9 +- Scripts/Proxies/ViveProxy.cs | 31 + 7 files changed, 192 insertions(+), 916 deletions(-) delete mode 100644 Models/Vive/Vive Controller.prefab delete mode 100644 Models/Vive/Vive Controller.prefab.meta diff --git a/Models/Vive/Vive Controller.prefab b/Models/Vive/Vive Controller.prefab deleted file mode 100644 index 5c2325c10..000000000 --- a/Models/Vive/Vive Controller.prefab +++ /dev/null @@ -1,891 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1001 &100100000 -Prefab: - m_ObjectHideFlags: 1 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: [] - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 0} - m_RootGameObject: {fileID: 1209380750545250} - m_IsPrefabParent: 1 ---- !u!1 &1050972447233552 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4141614633343734} - m_Layer: 0 - m_Name: r_grip - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1060745157379764 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4178950193930848} - m_Layer: 0 - m_Name: Trigger Pivot - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1080825974306186 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4733050997672564} - m_Layer: 0 - m_Name: trigger - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1158033672746100 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4628166181024904} - - component: {fileID: 33814485998625972} - - component: {fileID: 23955400649498454} - m_Layer: 0 - m_Name: body_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1161642225960158 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4969712784081516} - m_Layer: 0 - m_Name: sys_button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1185564939657662 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4473971208216750} - - component: {fileID: 33793789404428102} - - component: {fileID: 23108927844864994} - m_Layer: 0 - m_Name: trigger_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1209380750545250 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4070439039470938} - m_Layer: 0 - m_Name: Vive Controller - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1247747337006612 -GameObject: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4751614880040586} - m_Layer: 0 - m_Name: RotationPivot - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1273110110392832 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4021288017967424} - - component: {fileID: 33929020179086686} - - component: {fileID: 23486518235351522} - m_Layer: 0 - m_Name: sys_but_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1279882147296190 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4870699379224690} - m_Layer: 0 - m_Name: trackpad - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1337870186751960 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4456514911280876} - m_Layer: 0 - m_Name: body - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1496152834539938 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4286962923601822} - - component: {fileID: 33428812567342110} - - component: {fileID: 23550780355922678} - m_Layer: 0 - m_Name: l_gripper_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1543190631434974 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4379478342503068} - m_Layer: 0 - m_Name: button - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1564332711776060 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4681028676750298} - - component: {fileID: 33303814144955338} - - component: {fileID: 23787027095492304} - m_Layer: 0 - m_Name: r_gripper_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1594453721519874 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4935574672116756} - - component: {fileID: 33297299078280020} - - component: {fileID: 23337155761104620} - m_Layer: 0 - m_Name: menu_but_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1652446519038126 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4847249200977864} - - component: {fileID: 33917146450602826} - - component: {fileID: 23868849647331914} - m_Layer: 0 - m_Name: track_pip_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1672968912502426 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4767014662726266} - m_Layer: 0 - m_Name: trackpad_touch - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!1 &1822768616165084 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4544892698428310} - - component: {fileID: 33584304405889436} - - component: {fileID: 23420308633838566} - m_Layer: 0 - m_Name: trackpad_group1 - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!1 &1889762995122838 -GameObject: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 5 - m_Component: - - component: {fileID: 4791409254588110} - m_Layer: 0 - m_Name: l_grip - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &4021288017967424 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1273110110392832} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4969712784081516} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4070439039470938 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1209380750545250} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4751614880040586} - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4141614633343734 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1050972447233552} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4681028676750298} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4178950193930848 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1060745157379764} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: -0.015999973, z: 0.039} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4733050997672564} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4286962923601822 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1496152834539938} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4791409254588110} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4379478342503068 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1543190631434974} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4935574672116756} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4456514911280876 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1337870186751960} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4628166181024904} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4473971208216750 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1185564939657662} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4733050997672564} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4544892698428310 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1822768616165084} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4870699379224690} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4628166181024904 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1158033672746100} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4456514911280876} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4681028676750298 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1564332711776060} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4141614633343734} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4733050997672564 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1080825974306186} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0.016, z: -0.039} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4473971208216750} - m_Father: {fileID: 4178950193930848} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4751614880040586 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1247747337006612} - m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4456514911280876} - - {fileID: 4379478342503068} - - {fileID: 4791409254588110} - - {fileID: 4141614633343734} - - {fileID: 4969712784081516} - - {fileID: 4870699379224690} - - {fileID: 4767014662726266} - - {fileID: 4178950193930848} - m_Father: {fileID: 4070439039470938} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} ---- !u!4 &4767014662726266 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1672968912502426} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4847249200977864} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4791409254588110 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1889762995122838} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4286962923601822} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4847249200977864 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1652446519038126} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4767014662726266} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4870699379224690 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1279882147296190} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4544892698428310} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4935574672116756 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1594453721519874} - m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 4379478342503068} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &4969712784081516 -Transform: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1161642225960158} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: - - {fileID: 4021288017967424} - m_Father: {fileID: 4751614880040586} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!23 &23108927844864994 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1185564939657662} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23337155761104620 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1594453721519874} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23420308633838566 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1822768616165084} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23486518235351522 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1273110110392832} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23550780355922678 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1496152834539938} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23787027095492304 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1564332711776060} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23868849647331914 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1652446519038126} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!23 &23955400649498454 -MeshRenderer: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1158033672746100} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_Materials: - - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &33297299078280020 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1594453721519874} - m_Mesh: {fileID: 4300000, guid: cbd31b89c0bde684db82ff8056d3cc8e, type: 3} ---- !u!33 &33303814144955338 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1564332711776060} - m_Mesh: {fileID: 4300000, guid: 56f79c509c890b74e906e8a5caee40ae, type: 3} ---- !u!33 &33428812567342110 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1496152834539938} - m_Mesh: {fileID: 4300000, guid: b32f6f3f786b1b8449a3494a98f2b6b2, type: 3} ---- !u!33 &33584304405889436 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1822768616165084} - m_Mesh: {fileID: 4300000, guid: 1eb55c31fec770a4d97118edb282d8c8, type: 3} ---- !u!33 &33793789404428102 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1185564939657662} - m_Mesh: {fileID: 4300000, guid: 11be60732cf8ba74ab65779a6c6d62f2, type: 3} ---- !u!33 &33814485998625972 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1158033672746100} - m_Mesh: {fileID: 4300000, guid: 91923fcf53844be47a1ad1b01dc5b4d5, type: 3} ---- !u!33 &33917146450602826 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1652446519038126} - m_Mesh: {fileID: 4300000, guid: 8fca69da58fb5a44ba6d838685744c73, type: 3} ---- !u!33 &33929020179086686 -MeshFilter: - m_ObjectHideFlags: 1 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1273110110392832} - m_Mesh: {fileID: 4300000, guid: a522de35d424c4547bce18694eac5aea, type: 3} diff --git a/Models/Vive/Vive Controller.prefab.meta b/Models/Vive/Vive Controller.prefab.meta deleted file mode 100644 index 8e8b0073a..000000000 --- a/Models/Vive/Vive Controller.prefab.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: e3d4b87f591a2344d91089355a332d95 -timeCreated: 1507233321 -licenseType: Pro -NativeFormatImporter: - mainObjectFileID: 100100000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Prefabs/Proxies/ViveController.prefab b/Prefabs/Proxies/ViveController.prefab index f48107aa8..4b3ed8f91 100644 --- a/Prefabs/Proxies/ViveController.prefab +++ b/Prefabs/Proxies/ViveController.prefab @@ -462,6 +462,23 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1937968145898116 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4267069473354514} + - component: {fileID: 33016647632292958} + - component: {fileID: 23228397771655312} + m_Layer: 0 + m_Name: track_pip_group1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1947952444214838 GameObject: m_ObjectHideFlags: 1 @@ -479,6 +496,21 @@ GameObject: m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 +--- !u!1 &1967335880900170 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4278513193597556} + m_Layer: 0 + m_Name: trackpad_touch + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!1 &1998691428341312 GameObject: m_ObjectHideFlags: 1 @@ -586,11 +618,12 @@ Transform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1024981127734174} - m_LocalRotation: {x: 0.057000216, y: -5.087612e-19, z: -0.0000000067949544, w: 0.99837416} + m_LocalRotation: {x: 0.05699771, y: 0, z: 0, w: 0.99837434} m_LocalPosition: {x: 0, y: 0.00379, z: 0.04921} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4788207952759710} + - {fileID: 4278513193597556} m_Father: {fileID: 4469504124180788} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 6.5350003, y: 0, z: 0} @@ -622,6 +655,19 @@ Transform: m_Father: {fileID: 4469504124180788} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 4.8490005, y: 3.49, z: 24.451} +--- !u!4 &4267069473354514 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1937968145898116} + m_LocalRotation: {x: -0.05699771, y: -0, z: -0, w: 0.99837434} + m_LocalPosition: {x: 0, y: -0.009365969, z: -0.04845892} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4278513193597556} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4268880949599228 Transform: m_ObjectHideFlags: 1 @@ -635,6 +681,20 @@ Transform: m_Father: {fileID: 4432114245915554} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4278513193597556 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1967335880900170} + m_LocalRotation: {x: 0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4267069473354514} + m_Father: {fileID: 4027072583190098} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &4314961011562620 Transform: m_ObjectHideFlags: 1 @@ -947,6 +1007,38 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 +--- !u!23 &23228397771655312 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1937968145898116} + m_Enabled: 0 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: b0cbe6ebb5130174ea902e4e160468b9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 --- !u!23 &23334373145171194 MeshRenderer: m_ObjectHideFlags: 1 @@ -1171,6 +1263,13 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 +--- !u!33 &33016647632292958 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1937968145898116} + m_Mesh: {fileID: 4300000, guid: 8fca69da58fb5a44ba6d838685744c73, type: 3} --- !u!33 &33026695381748044 MeshFilter: m_ObjectHideFlags: 1 @@ -1339,6 +1438,34 @@ MonoBehaviour: m_RotateAxes: 0 m_Min: 0.001 m_Max: -0.001 + - m_Control: 0 + m_Transform: {fileID: 4027072583190098} + m_Renderer: {fileID: 23166709740205842} + m_TranslateAxes: 0 + m_RotateAxes: 4 + m_Min: -4 + m_Max: 4 + - m_Control: 1 + m_Transform: {fileID: 4027072583190098} + m_Renderer: {fileID: 23166709740205842} + m_TranslateAxes: 0 + m_RotateAxes: 1 + m_Min: 4 + m_Max: -4 + - m_Control: 0 + m_Transform: {fileID: 4278513193597556} + m_Renderer: {fileID: 23228397771655312} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: 0.018 + m_Max: -0.018 + - m_Control: 1 + m_Transform: {fileID: 4278513193597556} + m_Renderer: {fileID: 23228397771655312} + m_TranslateAxes: 4 + m_RotateAxes: 0 + m_Min: 0.018 + m_Max: -0.018 m_LeftTooltips: - {fileID: 114558108786776402} - {fileID: 114026251721049050} diff --git a/Scripts/Core/EditorVR.Rays.cs b/Scripts/Core/EditorVR.Rays.cs index b00d7e461..6c0fb4b84 100644 --- a/Scripts/Core/EditorVR.Rays.cs +++ b/Scripts/Core/EditorVR.Rays.cs @@ -278,11 +278,6 @@ void OnProxyActiveChanged(IProxy proxy) } evr.GetNestedModule().SpawnDefaultTools(proxy); - - foreach (var helper in ((Component)proxy).GetComponentsInChildren(true)) - { - this.ConnectInterfaces(ObjectUtils.AddComponent(helper.gameObject), helper.rayOrigin); - } } } } diff --git a/Scripts/Proxies/ProxyAnimator.cs b/Scripts/Proxies/ProxyAnimator.cs index 60a0a4b92..75ab637d6 100644 --- a/Scripts/Proxies/ProxyAnimator.cs +++ b/Scripts/Proxies/ProxyAnimator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using UnityEditor.Experimental.EditorVR; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEngine; @@ -8,18 +9,34 @@ [RequireComponent(typeof(ProxyHelper))] public class ProxyAnimator : MonoBehaviour, ICustomActionMap { - class TransformInfo + public class TransformInfo { public Vector3 initialPosition; public Vector3 initialRotation; public Vector3 positionOffset; public Vector3 rotationOffset; - public void Reset() + public void ResetOffsets() { positionOffset = Vector3.zero; rotationOffset = Vector3.zero; } + + public void ResetPositionOffset() + { + positionOffset = Vector3.zero; + } + + public void ResetRotationOffset() + { + rotationOffset = Vector3.zero; + } + + public void Apply(Transform transform) + { + transform.localPosition = initialPosition + positionOffset; + transform.localRotation = Quaternion.Euler(initialRotation + rotationOffset); + } } [SerializeField] @@ -32,6 +49,7 @@ public void Reset() public ActionMap actionMap { get { return m_ProxyActionMap; } } public bool ignoreLocking { get { return true; } } + internal event Action, ActionMapInput> postAnimate; void Start() { @@ -85,7 +103,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon foreach (var kvp in m_TransformInfos) { - kvp.Value.Reset(); + kvp.Value.ResetOffsets(); } for (var i = 0; i < length; i++) @@ -127,10 +145,10 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon foreach (var kvp in m_TransformInfos) { - var buttonTransform = kvp.Key; - var info = kvp.Value; - buttonTransform.localPosition = info.initialPosition + info.positionOffset; - buttonTransform.localRotation = Quaternion.Euler(info.initialRotation + info.rotationOffset); + kvp.Value.Apply(kvp.Key); } + + if (postAnimate != null) + postAnimate(m_Buttons, m_TransformInfos, input); } } diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 64459f9b6..bccd6f8d1 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -19,9 +19,9 @@ public class ProxyFeedbackRequest : FeedbackRequest public string tooltipText; } - abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, ISetTooltipVisibility, ISetHighlight + abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, ISetTooltipVisibility, ISetHighlight, IConnectInterfaces { - const float k_FeedbackDuration = 500f; + const float k_FeedbackDuration = 5f; [SerializeField] protected GameObject m_LeftHandProxyPrefab; @@ -163,6 +163,11 @@ public virtual IEnumerator Start() if (trackedObjectInput == null && m_PlayerInput) trackedObjectInput = m_PlayerInput.GetActions(); + var leftProxyHelper = m_LeftHand.GetComponent(); + var rightProxyHelper = m_RightHand.GetComponent(); + this.ConnectInterfaces(ObjectUtils.AddComponent(leftProxyHelper.gameObject), leftProxyHelper.rayOrigin); + this.ConnectInterfaces(ObjectUtils.AddComponent(rightProxyHelper.gameObject), rightProxyHelper.rayOrigin); + #pragma warning disable 162 if (false) yield return null; //Unreachable yield to fix compiler error diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 9a93a9303..61d1079a9 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -1,9 +1,11 @@ #if UNITY_EDITOR using System; using System.Collections; +using System.Collections.Generic; using UnityEditor.Experimental.EditorVR.Input; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; +using UnityEngine.InputNew; using UnityEngine.VR; namespace UnityEditor.Experimental.EditorVR.Proxies @@ -32,6 +34,32 @@ public override void Awake() #endif } + static void PostAnimate(ProxyHelper.ButtonObject[] buttons, Dictionary transformInfos, ActionMapInput input) + { + var proxyInput = (ProxyAnimatorInput)input; + + foreach (var button in buttons) + { + switch (button.control) + { + case VRInputDevice.VRControl.LeftStickButton: + if (!proxyInput.stickButton.isHeld) + { + var buttonTransform = button.transform; + var info = transformInfos[buttonTransform]; + info.ResetRotationOffset(); + info.Apply(buttonTransform); + } + break; + case VRInputDevice.VRControl.Analog0: + // Trackpad touch sphere + if (button.translateAxes != 0) + button.renderer.enabled = !Mathf.Approximately(proxyInput.stickX.value, 0) || !Mathf.Approximately(proxyInput.stickY.value, 0); + break; + } + } + } + #if ENABLE_STEAMVR_INPUT public override IEnumerator Start() { @@ -39,6 +67,9 @@ public override IEnumerator Start() yield return null; yield return base.Start(); + + m_LeftHand.GetComponent().postAnimate += PostAnimate; + m_RightHand.GetComponent().postAnimate += PostAnimate; } #endif } From c76535cbce6ec05a180e21b4ba4e06d72a76bef5 Mon Sep 17 00:00:00 2001 From: andrewm Date: Thu, 5 Oct 2017 17:23:18 -0700 Subject: [PATCH 092/457] Undo input-prototype reference change --- libs/input-prototype | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/input-prototype b/libs/input-prototype index b671b868a..ced8f334a 160000 --- a/libs/input-prototype +++ b/libs/input-prototype @@ -1 +1 @@ -Subproject commit b671b868a5c458f2ce194da5bd6808f401a914c5 +Subproject commit ced8f334ad608aa77348820a4430ea450d71e37c From e65ce06123061510c8f66f9ee65c2b10d337f70f Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 5 Oct 2017 17:36:55 -0700 Subject: [PATCH 093/457] Switch to yield break in TwoHandedProxyBase.Start --- Scripts/Proxies/TwoHandedProxyBase.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index bccd6f8d1..f13feed58 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -168,10 +168,7 @@ public virtual IEnumerator Start() this.ConnectInterfaces(ObjectUtils.AddComponent(leftProxyHelper.gameObject), leftProxyHelper.rayOrigin); this.ConnectInterfaces(ObjectUtils.AddComponent(rightProxyHelper.gameObject), rightProxyHelper.rayOrigin); -#pragma warning disable 162 - if (false) - yield return null; //Unreachable yield to fix compiler error -#pragma warning restore 162 + yield break; } public virtual void OnDestroy() From 712b23c3428c21047f8ce427d60495af1479675d Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Thu, 5 Oct 2017 18:29:11 -0700 Subject: [PATCH 094/457] Update for Touch controllers on OpenVR --- Prefabs/Proxies/LeftTouchOpenVR.prefab | 1604 ++++++++++++++++++ Prefabs/Proxies/LeftTouchOpenVR.prefab.meta | 9 + Prefabs/Proxies/RightTouchOpenVR.prefab | 1578 +++++++++++++++++ Prefabs/Proxies/RightTouchOpenVR.prefab.meta | 9 + Scripts/Input/ViveInputToEvents.cs | 2 +- Scripts/Proxies/TwoHandedProxyBase.cs | 3 + Scripts/Proxies/ViveProxy.cs | 13 +- Scripts/Proxies/ViveProxy.cs.meta | 6 +- 8 files changed, 3217 insertions(+), 7 deletions(-) create mode 100644 Prefabs/Proxies/LeftTouchOpenVR.prefab create mode 100644 Prefabs/Proxies/LeftTouchOpenVR.prefab.meta create mode 100644 Prefabs/Proxies/RightTouchOpenVR.prefab create mode 100644 Prefabs/Proxies/RightTouchOpenVR.prefab.meta diff --git a/Prefabs/Proxies/LeftTouchOpenVR.prefab b/Prefabs/Proxies/LeftTouchOpenVR.prefab new file mode 100644 index 000000000..735d4ad40 --- /dev/null +++ b/Prefabs/Proxies/LeftTouchOpenVR.prefab @@ -0,0 +1,1604 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1121674342063006} + m_IsPrefabParent: 1 +--- !u!1 &1058892736116868 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4066961127535540} + m_Layer: 0 + m_Name: RayOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1059381763870278 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4928396761936120} + m_Layer: 5 + m_Name: lctrl:left_touch_controller_world + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1114405751753674 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4493958092089210} + - component: {fileID: 137042652805398938} + m_Layer: 0 + m_Name: lctrl:controller_body_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1121674342063006 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4397591939547504} + - component: {fileID: 114752989612263042} + m_Layer: 0 + m_Name: LeftTouchOpenVR + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1136457067828312 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4469383580960808} + - component: {fileID: 137244907625904870} + m_Layer: 0 + m_Name: lctrl:ring_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1195761804429546 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4890390517630010} + - component: {fileID: 137445039977449418} + m_Layer: 0 + m_Name: lctrl:y_button_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1201644712411802 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4520968933053068} + - component: {fileID: 65017680198051446} + - component: {fileID: 114935678038053448} + - component: {fileID: 114208349049674382} + m_Layer: 5 + m_Name: lctrl:b_hold + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1221307289850582 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4749739265137154} + m_Layer: 5 + m_Name: StickTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1226206133097882 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4490380767236794} + - component: {fileID: 136527854278805382} + - component: {fileID: 114868536840748390} + - component: {fileID: 114125306406013188} + m_Layer: 5 + m_Name: lctrl:b_stick + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1240828664680790 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4674955885034900} + m_Layer: 5 + m_Name: lctrl:b_stick_IGNORE + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1280035726240652 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4298354039062494} + m_Layer: 0 + m_Name: MenuOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1312015401150000 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4739757693524634} + - component: {fileID: 65659955836085406} + - component: {fileID: 114229362539100848} + - component: {fileID: 114178244051393772} + m_Layer: 5 + m_Name: lctrl:b_trigger + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1371879058933120 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4951772808299216} + m_Layer: 5 + m_Name: YTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1499359694046320 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4377293643276708} + m_Layer: 0 + m_Name: rig:f_world + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1510159293463522 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4694679444484640} + m_Layer: 0 + m_Name: FieldDragOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1529948422914310 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4856563909459678} + m_Layer: 5 + m_Name: TriggerTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1540202087307366 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4300584506686358} + m_Layer: 0 + m_Name: lctrl:geometry_null + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1583560589394632 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4143703544839238} + - component: {fileID: 137862233404870076} + - component: {fileID: 65956258734514298} + m_Layer: 0 + m_Name: lctrl:thumbstick_ball_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1607563885409028 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4474642415084100} + m_Layer: 5 + m_Name: XTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1658267023927624 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4987518757343592} + - component: {fileID: 65342610400895034} + - component: {fileID: 114395863652273138} + - component: {fileID: 114933204733924580} + m_Layer: 5 + m_Name: lctrl:b_button02 + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1671144174825412 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4601081929867384} + m_Layer: 0 + m_Name: PreviewOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1687655920288898 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4053280757573756} + m_Layer: 5 + m_Name: GripTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1768556897632508 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4253614850656894} + m_Layer: 0 + m_Name: RotationPivot + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1771063030855162 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4023477162748282} + - component: {fileID: 137279077384400616} + - component: {fileID: 65207712253230708} + m_Layer: 0 + m_Name: lctrl:x_button_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1778209516209752 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4263165527348130} + m_Layer: 0 + m_Name: AltMenuOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1802512491026532 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4065078371109140} + - component: {fileID: 137827934778804418} + m_Layer: 0 + m_Name: lctrl:main_trigger_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1803401048987102 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4822934406098802} + - component: {fileID: 65823636635226990} + - component: {fileID: 114263728491513428} + - component: {fileID: 114474480701569528} + m_Layer: 5 + m_Name: lctrl:b_button01 + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1839881575708718 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4587486705036062} + - component: {fileID: 137643571378826982} + m_Layer: 0 + m_Name: lctrl:surface_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1860390453984564 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4155622204998586} + - component: {fileID: 137809521931614260} + m_Layer: 0 + m_Name: lctrl:side_trigger_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1940796525994132 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4725754007993800} + - component: {fileID: 95063306400865646} + m_Layer: 0 + m_Name: left_touch_controller_model_skel + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1967264639938012 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4315188598119720} + m_Layer: 0 + m_Name: rig:controller_rig_grp + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4023477162748282 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1771063030855162} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4053280757573756 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1687655920288898} + m_LocalRotation: {x: -0.036001876, y: 0.9469688, z: 0.31843576, w: -0.023508724} + m_LocalPosition: {x: -0.0319, y: -0.0291, z: -0.0264} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: -8.8810005, y: -178.727, z: -370.594} +--- !u!4 &4065078371109140 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1802512491026532} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4066961127535540 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1058892736116868} + m_LocalRotation: {x: 0, y: 0.06975647, z: 0, w: 0.9975641} + m_LocalPosition: {x: 0, y: -0.003, z: 0.03} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4253614850656894} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 8, z: 0} +--- !u!4 &4143703544839238 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1583560589394632} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4155622204998586 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1860390453984564} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4253614850656894 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1768556897632508} + m_LocalRotation: {x: 0.34028876, y: -0.0113096535, z: 0.015475078, w: 0.9401257} + m_LocalPosition: {x: 0.0040553696, y: -0.0069484636, z: -0.053190824} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4725754007993800} + - {fileID: 4066961127535540} + - {fileID: 4298354039062494} + - {fileID: 4263165527348130} + - {fileID: 4601081929867384} + - {fileID: 4694679444484640} + m_Father: {fileID: 4397591939547504} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 30, y: 0, z: 0} +--- !u!4 &4263165527348130 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1778209516209752} + m_LocalRotation: {x: -0, y: 0.06975647, z: -0, w: 0.9975641} + m_LocalPosition: {x: 0, y: 0.0208, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4253614850656894} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 8, z: 0} +--- !u!4 &4298354039062494 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1280035726240652} + m_LocalRotation: {x: 0.7053843, y: 0.049325276, z: -0.049325276, w: 0.7053843} + m_LocalPosition: {x: 0, y: -0.02, z: 0.05} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4253614850656894} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 90, y: 8, z: 0} +--- !u!4 &4300584506686358 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1540202087307366} + m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4493958092089210} + - {fileID: 4065078371109140} + - {fileID: 4469383580960808} + - {fileID: 4155622204998586} + - {fileID: 4587486705036062} + - {fileID: 4143703544839238} + - {fileID: 4023477162748282} + - {fileID: 4890390517630010} + m_Father: {fileID: 4725754007993800} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4315188598119720 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1967264639938012} + m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4377293643276708} + m_Father: {fileID: 4725754007993800} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4377293643276708 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1499359694046320} + m_LocalRotation: {x: -0, y: 0, z: 1, w: -6.123234e-17} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4315188598119720} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4397591939547504 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1121674342063006} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.25, y: -0.775, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4253614850656894} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4469383580960808 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1136457067828312} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4474642415084100 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1607563885409028} + m_LocalRotation: {x: -0.51841843, y: 0.7203171, z: 0.36884463, w: -0.27629557} + m_LocalPosition: {x: -0.07252136, y: -0.0017951168, z: 0.041165117} + m_LocalScale: {x: 1.0000007, y: 1.000001, z: 1.0000012} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -418.43} +--- !u!4 &4490380767236794 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1226206133097882} + m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068} + m_LocalPosition: {x: 0.0075226245, y: 0.0048274146, z: -0.011412583} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4674955885034900} + m_Father: {fileID: 4928396761936120} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} +--- !u!4 &4493958092089210 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1114405751753674} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4520968933053068 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1201644712411802} + m_LocalRotation: {x: -0.23833114, y: -0.083428115, z: -0.04423342, w: 0.96658236} + m_LocalPosition: {x: 0.0056325207, y: -0.02406612, z: -0.02614386} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4587486705036062 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1839881575708718} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4601081929867384 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1671144174825412} + m_LocalRotation: {x: -0.258819, y: 0, z: 0, w: 0.9659259} + m_LocalPosition: {x: 0, y: 0.074, z: 0.0746} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4253614850656894} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} +--- !u!4 &4674955885034900 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1240828664680790} + m_LocalRotation: {x: -4.5059287e-17, y: -0.70108956, z: -6.5911624e-17, w: 0.71307325} + m_LocalPosition: {x: -0.019321036, y: 0, z: 9.992007e-18} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4490380767236794} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4694679444484640 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1510159293463522} + m_LocalRotation: {x: -0.258819, y: -0, z: -0, w: 0.9659259} + m_LocalPosition: {x: 0, y: 0.025, z: 0.0746} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4253614850656894} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} +--- !u!4 &4725754007993800 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1940796525994132} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4300584506686358} + - {fileID: 4928396761936120} + - {fileID: 4315188598119720} + m_Father: {fileID: 4253614850656894} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4739757693524634 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1312015401150000} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.0006312649, y: 0.023094632, z: -0.008431792} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4749739265137154 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1221307289850582} + m_LocalRotation: {x: 0.35172954, y: 0.88359857, z: 0.3072935, w: 0.033327878} + m_LocalPosition: {x: 0.07429461, y: 0.03352204, z: 0.020555971} + m_LocalScale: {x: 0.42783472, y: 1.0000005, z: 1.0000006} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: -35.649002, y: -194.698, z: -336.566} +--- !u!4 &4822934406098802 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1803401048987102} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.009307305, y: -0.012594516, z: -0.000036243782} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4856563909459678 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1529948422914310} + m_LocalRotation: {x: -0.0037376191, y: -0.9212345, z: -0.38850796, w: 0.019355591} + m_LocalPosition: {x: -0.0009559246, y: 0.08051417, z: 0.047581732} + m_LocalScale: {x: 0.8193403, y: 1.0000005, z: 1.0000005} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: -45.722004, y: -177.311, z: -0.669} +--- !u!4 &4890390517630010 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1195761804429546} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4300584506686358} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4928396761936120 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1059381763870278} + m_LocalRotation: {x: 0, y: 0.7071068, z: 0.7071068, w: -8.659561e-17} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4822934406098802} + - {fileID: 4987518757343592} + - {fileID: 4520968933053068} + - {fileID: 4490380767236794} + - {fileID: 4739757693524634} + - {fileID: 4856563909459678} + - {fileID: 4053280757573756} + - {fileID: 4951772808299216} + - {fileID: 4474642415084100} + - {fileID: 4749739265137154} + m_Father: {fileID: 4725754007993800} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4951772808299216 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1371879058933120} + m_LocalRotation: {x: -0.2575147, y: 0.83480066, z: 0.4621716, w: -0.15228775} + m_LocalPosition: {x: -0.041980393, y: 0.05147165, z: 0.017116126} + m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1.0000006} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: -9.259001, y: -170.28401, z: -418.43} +--- !u!4 &4987518757343592 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1658267023927624} + m_LocalRotation: {x: 0, y: 0, z: 0.5321842, w: 0.8466286} + m_LocalPosition: {x: -0.016168496, y: 0.0017703404, z: -0.000036243782} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4928396761936120} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &65017680198051446 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1201644712411802} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0138321975, y: 0.023385666, z: 0.01187079} + m_Center: {x: -0.006514117, y: -0.0015480702, z: -0.00021664354} +--- !u!65 &65207712253230708 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1771063030855162} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.009820405, y: 0.009820404, z: 0.004344657} + m_Center: {x: 0.009307315, y: 0.012594526, z: -0.000050143473} +--- !u!65 &65342610400895034 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1658267023927624} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} +--- !u!65 &65659955836085406 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1312015401150000} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.027765447, y: 0.016550489, z: 0.024621258} + m_Center: {x: 0.000057838857, y: -0.003146829, z: -0.011298977} +--- !u!65 &65823636635226990 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1803401048987102} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} +--- !u!65 &65956258734514298 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1583560589394632} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.017161056, y: 0.016454693, z: 0.008820649} + m_Center: {x: -0.0075670555, y: -0.004549614, z: 0.00416026} +--- !u!95 &95063306400865646 +Animator: + serializedVersion: 3 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1940796525994132} + m_Enabled: 1 + m_Avatar: {fileID: 9000000, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Controller: {fileID: 9100000, guid: 643f2c61311b7c143952344a7a406239, type: 2} + m_CullingMode: 1 + m_UpdateMode: 0 + m_ApplyRootMotion: 0 + m_LinearVelocityBlending: 0 + m_WarningMessage: + m_HasTransformHierarchy: 1 + m_AllowConstantClipSamplingOptimization: 1 +--- !u!114 &114125306406013188 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1226206133097882} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4749739265137154} + m_TooltipSource: {fileID: 4490380767236794} + m_TooltipAlignment: 1 +--- !u!114 &114178244051393772 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1312015401150000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4856563909459678} + m_TooltipSource: {fileID: 4739757693524634} + m_TooltipAlignment: 1 +--- !u!114 &114208349049674382 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1201644712411802} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4053280757573756} + m_TooltipSource: {fileID: 4520968933053068} + m_TooltipAlignment: 0 +--- !u!114 &114229362539100848 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1312015401150000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114263728491513428 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1803401048987102} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114395863652273138 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1658267023927624} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114474480701569528 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1803401048987102} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4474642415084100} + m_TooltipSource: {fileID: 4822934406098802} + m_TooltipAlignment: 1 +--- !u!114 &114752989612263042 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1121674342063006} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 88cb44c52683f6648b7d436e9aa51bcc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RayOrigin: {fileID: 4066961127535540} + m_MenuOrigin: {fileID: 4298354039062494} + m_AlternateMenuOrigin: {fileID: 4263165527348130} + m_PreviewOrigin: {fileID: 4601081929867384} + m_FieldGrabOrigin: {fileID: 4694679444484640} + m_Buttons: + - m_Control: 2 + m_Transform: {fileID: 4739757693524634} + m_Renderer: {fileID: 137827934778804418} + m_TranslateAxes: 0 + m_RotateAxes: 1 + m_Min: 20 + m_Max: -20 + - m_Control: 3 + m_Transform: {fileID: 4520968933053068} + m_Renderer: {fileID: 137809521931614260} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: -0.00455765 + m_Max: 0.00455765 + - m_Control: 17 + m_Transform: {fileID: 4822934406098802} + m_Renderer: {fileID: 137279077384400616} + m_TranslateAxes: 4 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 + - m_Control: 18 + m_Transform: {fileID: 4987518757343592} + m_Renderer: {fileID: 137445039977449418} + m_TranslateAxes: 4 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 + - m_Control: 22 + m_Transform: {fileID: 4490380767236794} + m_Renderer: {fileID: 137862233404870076} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: 0.0002774392 + m_Max: -0.0002774392 + - m_Control: 0 + m_Transform: {fileID: 4490380767236794} + m_Renderer: {fileID: 137862233404870076} + m_TranslateAxes: 0 + m_RotateAxes: 2 + m_Min: 15 + m_Max: -15 + - m_Control: 1 + m_Transform: {fileID: 4490380767236794} + m_Renderer: {fileID: 137862233404870076} + m_TranslateAxes: 0 + m_RotateAxes: 4 + m_Min: 15 + m_Max: -15 + m_LeftTooltips: [] + m_RightTooltips: [] +--- !u!114 &114868536840748390 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1226206133097882} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114933204733924580 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1658267023927624} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4951772808299216} + m_TooltipSource: {fileID: 4987518757343592} + m_TooltipAlignment: 1 +--- !u!114 &114935678038053448 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1201644712411802} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!136 &136527854278805382 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1226206133097882} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.007829846 + m_Height: 0.020090805 + m_Direction: 0 + m_Center: {x: -0.013697198, y: 0.00020355526, z: -0.000012598241} +--- !u!137 &137042652805398938 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1114405751753674} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 0ff51c0175f4bf74a85d0a8a5718b3d8, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300000, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4928396761936120} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4928396761936120} + m_AABB: + m_Center: {x: 0.000024752691, y: -0.020011706, z: -0.0322693} + m_Extent: {x: 0.030508967, y: 0.049215406, z: 0.032041423} + m_DirtyAABB: 0 +--- !u!137 &137244907625904870 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1136457067828312} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 0ff51c0175f4bf74a85d0a8a5718b3d8, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300008, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4928396761936120} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4928396761936120} + m_AABB: + m_Center: {x: 0.016486254, y: 0.010407065, z: -0.035518706} + m_Extent: {x: 0.055269, y: 0.021764714, z: 0.049788818} + m_DirtyAABB: 0 +--- !u!137 &137279077384400616 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1771063030855162} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 165c00e6a6441ba4c928870ca72b6395, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300012, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4822934406098802} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4822934406098802} + m_AABB: + m_Center: {x: -0.000000004656613, y: -0.0000000055879354, z: -0.000013903482} + m_Extent: {x: 0.0049102013, y: 0.004910201, z: 0.002172327} + m_DirtyAABB: 0 +--- !u!137 &137445039977449418 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1195761804429546} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 165c00e6a6441ba4c928870ca72b6395, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300014, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4987518757343592} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4987518757343592} + m_AABB: + m_Center: {x: -0.0000000013969839, y: 0.0000000023283064, z: -0.000014121411} + m_Extent: {x: 0.0049718525, y: 0.004971853, z: 0.0022058291} + m_DirtyAABB: 0 +--- !u!137 &137643571378826982 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1839881575708718} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 0ff51c0175f4bf74a85d0a8a5718b3d8, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300010, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4928396761936120} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4928396761936120} + m_AABB: + m_Center: {x: -0.000035190955, y: -0.0008289404, z: -0.0013011228} + m_Extent: {x: 0.028027145, y: 0.02802688, z: 0.0013616025} + m_DirtyAABB: 0 +--- !u!137 &137809521931614260 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1860390453984564} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 0ff51c0175f4bf74a85d0a8a5718b3d8, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300004, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4520968933053068} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4520968933053068} + m_AABB: + m_Center: {x: -0.006221815, y: -0.0013287487, z: 0.00007528858} + m_Extent: {x: 0.007264071, y: 0.012129311, z: 0.007043778} + m_DirtyAABB: 0 +--- !u!137 &137827934778804418 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1802512491026532} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 165c00e6a6441ba4c928870ca72b6395, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300002, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4739757693524634} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4739757693524634} + m_AABB: + m_Center: {x: 0.00022322498, y: -0.004294172, z: -0.011436155} + m_Extent: {x: 0.013697366, y: 0.0092213, z: 0.012605751} + m_DirtyAABB: 0 +--- !u!137 &137862233404870076 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1583560589394632} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 0ff51c0175f4bf74a85d0a8a5718b3d8, type: 2} + - {fileID: 2100000, guid: 165c00e6a6441ba4c928870ca72b6395, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300006, guid: 111c043191ef2d44a8ff0233d087d59e, type: 3} + m_Bones: + - {fileID: 4490380767236794} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4490380767236794} + m_AABB: + m_Center: {x: -0.003208002, y: -0.000032193027, z: 0.000038057566} + m_Extent: {x: 0.016647747, y: 0.013635856, z: 0.013636045} + m_DirtyAABB: 0 diff --git a/Prefabs/Proxies/LeftTouchOpenVR.prefab.meta b/Prefabs/Proxies/LeftTouchOpenVR.prefab.meta new file mode 100644 index 000000000..07f8294ab --- /dev/null +++ b/Prefabs/Proxies/LeftTouchOpenVR.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6d5643096de04ca41802e2f0dd4652d8 +timeCreated: 1507252401 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Prefabs/Proxies/RightTouchOpenVR.prefab b/Prefabs/Proxies/RightTouchOpenVR.prefab new file mode 100644 index 000000000..30276745f --- /dev/null +++ b/Prefabs/Proxies/RightTouchOpenVR.prefab @@ -0,0 +1,1578 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1523256443734892} + m_IsPrefabParent: 1 +--- !u!1 &1056099179106798 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4446763199465236} + m_Layer: 5 + m_Name: TriggerTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1086842468569796 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4274382880384220} + m_Layer: 0 + m_Name: rig:f_world + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1164116263758344 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4818182269131524} + m_Layer: 0 + m_Name: rig:controller_rig_grp + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1194454412462410 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4353357426996200} + - component: {fileID: 137136063802218740} + m_Layer: 0 + m_Name: rctrl:a_button_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1223205433028314 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4935138999995796} + - component: {fileID: 137123611090237704} + m_Layer: 0 + m_Name: rctrl:thumbstick_ball_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1256076955954310 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4882697647327558} + m_Layer: 0 + m_Name: RayOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1264255518176884 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4802769266775244} + - component: {fileID: 95092237021106554} + m_Layer: 0 + m_Name: right_touch_controller_model_skel + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1306534095714824 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4979269271274180} + - component: {fileID: 137143491985645950} + m_Layer: 0 + m_Name: rctrl:surface_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1310876574352590 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4259604204601724} + m_Layer: 0 + m_Name: RotationPivot + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1311406822410160 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4670305928695856} + m_Layer: 0 + m_Name: b_stick_IGNORE + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1388939600237114 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4221126147080902} + - component: {fileID: 65135740924965490} + - component: {fileID: 114106225397066218} + - component: {fileID: 114041942050554804} + m_Layer: 0 + m_Name: rctrl:b_button01 + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1416527321095848 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4422225379807504} + m_Layer: 0 + m_Name: rctrl:right_touch_controller_world + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1417067495490614 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4095834679382798} + - component: {fileID: 137514863478410292} + m_Layer: 0 + m_Name: rctrl:ring_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1426379869996688 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4294130387479796} + - component: {fileID: 137005679053573082} + m_Layer: 0 + m_Name: rctrl:main_trigger_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1431128304040176 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4335710408679822} + m_Layer: 5 + m_Name: GripTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1473775665559764 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4199321456540786} + - component: {fileID: 65480711556455584} + - component: {fileID: 114437718840659960} + - component: {fileID: 114106734160267480} + m_Layer: 0 + m_Name: rctrl:b_trigger + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1484365269502848 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4022345611153456} + - component: {fileID: 65616315155519538} + - component: {fileID: 114743270976659912} + - component: {fileID: 114698121262855600} + m_Layer: 0 + m_Name: rctrl:b_button02 + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1500797279058346 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4010047915957694} + - component: {fileID: 65035587217273350} + - component: {fileID: 114822292473482224} + - component: {fileID: 114427722552533374} + m_Layer: 0 + m_Name: rctrl:b_hold + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1523256443734892 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4617753192742486} + - component: {fileID: 114700073176764548} + m_Layer: 0 + m_Name: RightTouchOpenVR + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1544585890443730 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4020309191218892} + m_Layer: 5 + m_Name: StickTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1609220482806210 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4670162007001066} + m_Layer: 5 + m_Name: BTarget + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1628251336023638 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4119770686273284} + m_Layer: 5 + m_Name: 'ATarget ' + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1660781032455562 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4684511478074442} + m_Layer: 0 + m_Name: rctrl:geometry_null + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1746245720813780 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4689379065830556} + - component: {fileID: 137284767618660090} + m_Layer: 0 + m_Name: rctrl:controller_body_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1792146300288516 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4572777086385804} + - component: {fileID: 137918311825069984} + m_Layer: 0 + m_Name: rctrl:b_button_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1802177967822326 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4182888507544958} + m_Layer: 0 + m_Name: MenuOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1833602971288856 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4799468984284310} + m_Layer: 0 + m_Name: AltMenuOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1863945976233890 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4217860718351282} + - component: {fileID: 137200858950391162} + m_Layer: 0 + m_Name: rctrl:side_trigger_PLY + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1886015457735076 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4662592250246964} + - component: {fileID: 136497482760722588} + - component: {fileID: 114904225304444658} + - component: {fileID: 114510401113800598} + m_Layer: 0 + m_Name: rctrl:b_stick + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1905885652100770 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4286406122114976} + m_Layer: 0 + m_Name: PreviewOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &1916842633872340 +GameObject: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4866118000331932} + m_Layer: 0 + m_Name: FieldGrabOrigin + m_TagString: ShowInMiniWorld + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4010047915957694 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1500797279058346} + m_LocalRotation: {x: -0.23419154, y: 0.094429806, z: -0.00078238576, w: 0.9675933} + m_LocalPosition: {x: -0.0056325225, y: -0.024066128, z: -0.026143856} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4020309191218892 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1544585890443730} + m_LocalRotation: {x: -0.3517295, y: 0.88359857, z: 0.30729347, w: -0.033327874} + m_LocalPosition: {x: -0.07429464, y: 0.03352204, z: 0.020555971} + m_LocalScale: {x: 0.9537753, y: 1.0450228, z: 1.0630285} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4022345611153456 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1484365269502848} + m_LocalRotation: {x: 0, y: 0, z: 0.5321842, w: 0.8466286} + m_LocalPosition: {x: 0.016168498, y: 0.0017703332, z: -0.000036240206} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4095834679382798 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1417067495490614} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4119770686273284 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1628251336023638} + m_LocalRotation: {x: 0.51841843, y: 0.7203171, z: 0.36884466, w: 0.27629554} + m_LocalPosition: {x: 0.0725214, y: -0.0017951243, z: 0.041165117} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4182888507544958 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1802177967822326} + m_LocalRotation: {x: 0.7053843, y: -0.049325276, z: 0.049325276, w: 0.7053843} + m_LocalPosition: {x: 0, y: -0.02, z: 0.05} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4259604204601724} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 90, y: -8, z: 0} +--- !u!4 &4199321456540786 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1473775665559764} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.0006312625, y: 0.023094624, z: -0.008431789} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4217860718351282 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1863945976233890} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4221126147080902 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1388939600237114} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.009307307, y: -0.012594523, z: -0.000036240206} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4259604204601724 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1310876574352590} + m_LocalRotation: {x: 0.34028774, y: 0.0113129085, z: -0.015474445, w: 0.94012594} + m_LocalPosition: {x: 0.0040553696, y: -0.0069484636, z: -0.053190824} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4802769266775244} + - {fileID: 4882697647327558} + - {fileID: 4182888507544958} + - {fileID: 4799468984284310} + - {fileID: 4286406122114976} + - {fileID: 4866118000331932} + m_Father: {fileID: 4617753192742486} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 39.805, y: 0.8010001, z: -1.596} +--- !u!4 &4274382880384220 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1086842468569796} + m_LocalRotation: {x: -0, y: 0, z: 1, w: -6.123234e-17} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4818182269131524} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4286406122114976 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1905885652100770} + m_LocalRotation: {x: -0.258819, y: 0, z: 0, w: 0.9659259} + m_LocalPosition: {x: 0, y: 0.074, z: 0.0746} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4259604204601724} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} +--- !u!4 &4294130387479796 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1426379869996688} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4335710408679822 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1431128304040176} + m_LocalRotation: {x: 0.036001876, y: 0.9469688, z: 0.31843576, w: 0.023508724} + m_LocalPosition: {x: 0.0326, y: -0.0291, z: -0.0263} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4353357426996200 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1194454412462410} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4422225379807504 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1416527321095848} + m_LocalRotation: {x: 0, y: 0.7071068, z: 0.7071068, w: -8.659561e-17} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4221126147080902} + - {fileID: 4022345611153456} + - {fileID: 4010047915957694} + - {fileID: 4662592250246964} + - {fileID: 4199321456540786} + - {fileID: 4446763199465236} + - {fileID: 4335710408679822} + - {fileID: 4670162007001066} + - {fileID: 4119770686273284} + - {fileID: 4020309191218892} + m_Father: {fileID: 4802769266775244} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4446763199465236 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1056099179106798} + m_LocalRotation: {x: 0.0037376198, y: -0.9212345, z: -0.388508, w: -0.019355595} + m_LocalPosition: {x: 0.0009559395, y: 0.08051417, z: 0.047581732} + m_LocalScale: {x: 0.9982224, y: 1.000015, z: 1.0021566} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4572777086385804 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1792146300288516} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4617753192742486 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1523256443734892} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: -0.775, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4259604204601724} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4662592250246964 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1886015457735076} + m_LocalRotation: {x: 0.002293064, y: 0.70780116, z: 0.0029638258, w: 0.7064019} + m_LocalPosition: {x: -0.007522622, y: 0.0048274077, z: -0.01141258} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4670305928695856} + m_Father: {fileID: 4422225379807504} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4670162007001066 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1609220482806210} + m_LocalRotation: {x: 0.2575147, y: 0.8348006, z: 0.4621716, w: 0.15228775} + m_LocalPosition: {x: 0.041980393, y: 0.051471658, z: 0.017116126} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4422225379807504} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4670305928695856 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1311406822410160} + m_LocalRotation: {x: -4.5059287e-17, y: -0.70108956, z: -6.5911624e-17, w: 0.71307325} + m_LocalPosition: {x: -0.019321036, y: 0, z: 9.992007e-18} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4662592250246964} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4684511478074442 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1660781032455562} + m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4353357426996200} + - {fileID: 4572777086385804} + - {fileID: 4689379065830556} + - {fileID: 4294130387479796} + - {fileID: 4095834679382798} + - {fileID: 4217860718351282} + - {fileID: 4979269271274180} + - {fileID: 4935138999995796} + m_Father: {fileID: 4802769266775244} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4689379065830556 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1746245720813780} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4799468984284310 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1833602971288856} + m_LocalRotation: {x: -0, y: -0.06975647, z: -0, w: 0.9975641} + m_LocalPosition: {x: 0, y: 0.0208, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4259604204601724} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: -8, z: 0} +--- !u!4 &4802769266775244 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1264255518176884} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4684511478074442} + - {fileID: 4422225379807504} + - {fileID: 4818182269131524} + m_Father: {fileID: 4259604204601724} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4818182269131524 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1164116263758344} + m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4274382880384220} + m_Father: {fileID: 4802769266775244} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4866118000331932 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1916842633872340} + m_LocalRotation: {x: -0.258819, y: -0, z: -0, w: 0.9659259} + m_LocalPosition: {x: 0, y: 0.025, z: 0.0746} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4259604204601724} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: -30, y: 0, z: 0} +--- !u!4 &4882697647327558 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1256076955954310} + m_LocalRotation: {x: 0, y: -0.06975647, z: 0, w: 0.9975641} + m_LocalPosition: {x: 0, y: -0.003, z: 0.03} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4259604204601724} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: -8, z: 0} +--- !u!4 &4935138999995796 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1223205433028314} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!4 &4979269271274180 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1306534095714824} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 4684511478074442} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &65035587217273350 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1500797279058346} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0138321975, y: 0.023385666, z: 0.01187079} + m_Center: {x: 0.006514117, y: -0.0015480702, z: -0.00021664354} +--- !u!65 &65135740924965490 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1388939600237114} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} +--- !u!65 &65480711556455584 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1473775665559764} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.027765447, y: 0.016550489, z: 0.024621258} + m_Center: {x: 0.000057838857, y: -0.003146829, z: -0.011298977} +--- !u!65 &65616315155519538 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1484365269502848} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.0132717155, y: 0.0132717155, z: 0.004411662} + m_Center: {x: 0, y: 0, z: 0} +--- !u!95 &95092237021106554 +Animator: + serializedVersion: 3 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1264255518176884} + m_Enabled: 1 + m_Avatar: {fileID: 9000000, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Controller: {fileID: 9100000, guid: 3bd486f67a7a98c4db3db1785ff50c29, type: 2} + m_CullingMode: 1 + m_UpdateMode: 0 + m_ApplyRootMotion: 0 + m_LinearVelocityBlending: 0 + m_WarningMessage: + m_HasTransformHierarchy: 1 + m_AllowConstantClipSamplingOptimization: 1 +--- !u!114 &114041942050554804 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1388939600237114} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4119770686273284} + m_TooltipSource: {fileID: 4221126147080902} + m_TooltipAlignment: 1 +--- !u!114 &114106225397066218 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1388939600237114} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114106734160267480 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1473775665559764} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4446763199465236} + m_TooltipSource: {fileID: 4199321456540786} + m_TooltipAlignment: 1 +--- !u!114 &114427722552533374 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1500797279058346} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4335710408679822} + m_TooltipSource: {fileID: 4010047915957694} + m_TooltipAlignment: 2 +--- !u!114 &114437718840659960 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1473775665559764} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114510401113800598 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1886015457735076} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4020309191218892} + m_TooltipSource: {fileID: 4662592250246964} + m_TooltipAlignment: 1 +--- !u!114 &114698121262855600 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1484365269502848} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 121a9b94e41e9e444af3e8069a887154, type: 3} + m_Name: + m_EditorClassIdentifier: + m_TooltipText: + m_TooltipTarget: {fileID: 4670162007001066} + m_TooltipSource: {fileID: 4022345611153456} + m_TooltipAlignment: 1 +--- !u!114 &114700073176764548 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1523256443734892} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 88cb44c52683f6648b7d436e9aa51bcc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RayOrigin: {fileID: 4882697647327558} + m_MenuOrigin: {fileID: 4182888507544958} + m_AlternateMenuOrigin: {fileID: 4799468984284310} + m_PreviewOrigin: {fileID: 4286406122114976} + m_FieldGrabOrigin: {fileID: 4866118000331932} + m_Buttons: + - m_Control: 2 + m_Transform: {fileID: 4199321456540786} + m_Renderer: {fileID: 137005679053573082} + m_TranslateAxes: 0 + m_RotateAxes: 1 + m_Min: 20 + m_Max: -20 + - m_Control: 3 + m_Transform: {fileID: 4010047915957694} + m_Renderer: {fileID: 137200858950391162} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: 0.00455765 + m_Max: -0.00455765 + - m_Control: 17 + m_Transform: {fileID: 4221126147080902} + m_Renderer: {fileID: 137136063802218740} + m_TranslateAxes: 4 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 + - m_Control: 18 + m_Transform: {fileID: 4022345611153456} + m_Renderer: {fileID: 137918311825069984} + m_TranslateAxes: 4 + m_RotateAxes: 0 + m_Min: 0.001793736 + m_Max: -0.001793736 + - m_Control: 22 + m_Transform: {fileID: 4662592250246964} + m_Renderer: {fileID: 137123611090237704} + m_TranslateAxes: 1 + m_RotateAxes: 0 + m_Min: 0.0002774392 + m_Max: -0.0002774392 + - m_Control: 0 + m_Transform: {fileID: 4662592250246964} + m_Renderer: {fileID: 137123611090237704} + m_TranslateAxes: 0 + m_RotateAxes: 2 + m_Min: 15 + m_Max: -15 + - m_Control: 1 + m_Transform: {fileID: 4662592250246964} + m_Renderer: {fileID: 137123611090237704} + m_TranslateAxes: 0 + m_RotateAxes: 4 + m_Min: 15 + m_Max: -15 + m_LeftTooltips: [] + m_RightTooltips: [] +--- !u!114 &114743270976659912 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1484365269502848} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114822292473482224 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1500797279058346} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!114 &114904225304444658 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1886015457735076} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4fb8f7696afa96048aa938286d04f96c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SelectionFlags: 3 +--- !u!136 &136497482760722588 +CapsuleCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1886015457735076} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.007829846 + m_Height: 0.020090805 + m_Direction: 0 + m_Center: {x: -0.013697198, y: 0.00020355526, z: -0.000012598241} +--- !u!137 &137005679053573082 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1426379869996688} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 6dca398ec6487b142811f0497ed47f6d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300000, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4199321456540786} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4199321456540786} + m_AABB: + m_Center: {x: -0.0002194522, y: -0.0042922553, z: -0.011436114} + m_Extent: {x: 0.013691929, y: 0.00921237, z: 0.012600293} + m_DirtyAABB: 0 +--- !u!137 &137123611090237704 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1223205433028314} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 14179725cf9421448b565469bfc84247, type: 2} + - {fileID: 2100000, guid: 6dca398ec6487b142811f0497ed47f6d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300004, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4662592250246964} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4662592250246964} + m_AABB: + m_Center: {x: -0.0032078787, y: -0.000032121316, z: -0.00003948249} + m_Extent: {x: 0.01664787, y: 0.013635859, z: 0.01363614} + m_DirtyAABB: 0 +--- !u!137 &137136063802218740 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1194454412462410} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 6dca398ec6487b142811f0497ed47f6d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300014, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4221126147080902} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4221126147080902} + m_AABB: + m_Center: {x: 0.0000000013969839, y: 0.0000000023283064, z: -0.000013906974} + m_Extent: {x: 0.0049102018, y: 0.004910201, z: 0.0021723267} + m_DirtyAABB: 0 +--- !u!137 &137143491985645950 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1306534095714824} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 14179725cf9421448b565469bfc84247, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300008, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4422225379807504} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4422225379807504} + m_AABB: + m_Center: {x: 0.000035190955, y: -0.0008289404, z: -0.0013011228} + m_Extent: {x: 0.028027145, y: 0.02802688, z: 0.0013616025} + m_DirtyAABB: 0 +--- !u!137 &137200858950391162 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1863945976233890} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 14179725cf9421448b565469bfc84247, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300002, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4010047915957694} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4010047915957694} + m_AABB: + m_Center: {x: 0.0060774516, y: -0.0012136139, z: 0.00006003538} + m_Extent: {x: 0.007926514, y: 0.012150802, z: 0.0070478776} + m_DirtyAABB: 0 +--- !u!137 &137284767618660090 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1746245720813780} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 14179725cf9421448b565469bfc84247, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300010, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4422225379807504} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4422225379807504} + m_AABB: + m_Center: {x: -0.000024748966, y: -0.020011706, z: -0.0322693} + m_Extent: {x: 0.030508965, y: 0.049215406, z: 0.032041423} + m_DirtyAABB: 0 +--- !u!137 &137514863478410292 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1417067495490614} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 14179725cf9421448b565469bfc84247, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300006, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4422225379807504} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4422225379807504} + m_AABB: + m_Center: {x: -0.016486254, y: 0.010407065, z: -0.035518706} + m_Extent: {x: 0.055269, y: 0.021764714, z: 0.049788818} + m_DirtyAABB: 0 +--- !u!137 &137918311825069984 +SkinnedMeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1792146300288516} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 6dca398ec6487b142811f0497ed47f6d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + serializedVersion: 2 + m_Quality: 0 + m_UpdateWhenOffscreen: 0 + m_SkinnedMotionVectors: 1 + m_Mesh: {fileID: 4300012, guid: 20d82fb66fc22fa40ae34d9489bd6fcd, type: 3} + m_Bones: + - {fileID: 4022345611153456} + m_BlendShapeWeights: [] + m_RootBone: {fileID: 4022345611153456} + m_AABB: + m_Center: {x: 0.000000005122274, y: 0, z: -0.000014125137} + m_Extent: {x: 0.004971852, y: 0.0049718525, z: 0.0022058291} + m_DirtyAABB: 0 diff --git a/Prefabs/Proxies/RightTouchOpenVR.prefab.meta b/Prefabs/Proxies/RightTouchOpenVR.prefab.meta new file mode 100644 index 000000000..ee24c35bc --- /dev/null +++ b/Prefabs/Proxies/RightTouchOpenVR.prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ab57bd440a8be844eb9d12bbfafe308f +timeCreated: 1507252396 +licenseType: Pro +NativeFormatImporter: + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Input/ViveInputToEvents.cs b/Scripts/Input/ViveInputToEvents.cs index b1f4d6871..c5fb0c90d 100644 --- a/Scripts/Input/ViveInputToEvents.cs +++ b/Scripts/Input/ViveInputToEvents.cs @@ -86,7 +86,7 @@ public void Update() isActive = true; - int deviceIndex = hand == VRInputDevice.Handedness.Left ? 3 : 4; // TODO change 3 and 4 based on virtual devices defined in InputDeviceManager (using actual hardware available) + int deviceIndex = hand == VRInputDevice.Handedness.Right ? 3 : 4; // TODO change 3 and 4 based on virtual devices defined in InputDeviceManager (using actual hardware available) SendButtonEvents(steamDeviceIndex, deviceIndex); SendAxisEvents(steamDeviceIndex, deviceIndex); SendTrackingEvents(steamDeviceIndex, deviceIndex, poses); diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index f13feed58..ab1222e4d 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -199,6 +199,9 @@ public void AddFeedbackRequest(FeedbackRequest request) void ExecuteFeedback(ProxyFeedbackRequest changedRequest) { + if (!active) + return; + foreach (var proxyNode in m_Buttons) { foreach (var kvp in proxyNode.Value) diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 61d1079a9..5eeeadb43 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -18,9 +18,13 @@ sealed class ViveProxy : TwoHandedProxyBase [SerializeField] GameObject m_RightHandTouchProxyPrefab; + bool m_IsOculus; + public override void Awake() { - if (VRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0) + m_IsOculus = VRDevice.model.IndexOf("oculus", StringComparison.OrdinalIgnoreCase) >= 0; + + if (m_IsOculus) { m_LeftHandProxyPrefab = m_LeftHandTouchProxyPrefab; m_RightHandProxyPrefab = m_RightHandTouchProxyPrefab; @@ -68,8 +72,11 @@ public override IEnumerator Start() yield return base.Start(); - m_LeftHand.GetComponent().postAnimate += PostAnimate; - m_RightHand.GetComponent().postAnimate += PostAnimate; + if (!m_IsOculus) + { + m_LeftHand.GetComponent().postAnimate += PostAnimate; + m_RightHand.GetComponent().postAnimate += PostAnimate; + } } #endif } diff --git a/Scripts/Proxies/ViveProxy.cs.meta b/Scripts/Proxies/ViveProxy.cs.meta index 72191a514..7d62a75ee 100644 --- a/Scripts/Proxies/ViveProxy.cs.meta +++ b/Scripts/Proxies/ViveProxy.cs.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 1dd05fa08947fc34392a98bded9b0ae0 -timeCreated: 1507234154 +timeCreated: 1507252419 licenseType: Pro MonoImporter: serializedVersion: 2 @@ -10,9 +10,9 @@ MonoImporter: - m_RightHandProxyPrefab: {fileID: 1000010426338840, guid: fbcfdb50f5e2d7a45bebae9a3a90b3fa, type: 2} - m_PlayerInput: {instanceID: 0} - - m_LeftHandTouchProxyPrefab: {fileID: 118082, guid: b8cd5407792522543a52d20579ae4966, + - m_LeftHandTouchProxyPrefab: {fileID: 1121674342063006, guid: 6d5643096de04ca41802e2f0dd4652d8, type: 2} - - m_RightHandTouchProxyPrefab: {fileID: 141214, guid: d34262fb62f38944b97137c536cddf4b, + - m_RightHandTouchProxyPrefab: {fileID: 1523256443734892, guid: ab57bd440a8be844eb9d12bbfafe308f, type: 2} executionOrder: 0 icon: {instanceID: 0} From f2523005e0d5cbba4dcd8379656e849b97f485b4 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 6 Oct 2017 10:48:24 -0700 Subject: [PATCH 095/457] Promote wait on active to TwoHandedProxyBase to fix TouchProxy input setup; Block MainMenu.ProcessInput if UI is not visible This prevents MainMenu from sending haptic pulses and consuming input unnecessarily Move .mtl files back next to .obj files to prevent generating materials on import --- Menus/MainMenu/MainMenu.cs | 3 +++ Models/Vive/{Materials => Models}/body.mtl | 0 Models/Vive/{Materials => Models}/body.mtl.meta | 0 Models/Vive/{Materials => Models}/button.mtl | 0 Models/Vive/{Materials => Models}/button.mtl.meta | 0 Models/Vive/{Materials => Models}/l_grip.mtl | 0 Models/Vive/{Materials => Models}/l_grip.mtl.meta | 0 Models/Vive/{Materials => Models}/led.mtl | 0 Models/Vive/{Materials => Models}/led.mtl.meta | 0 Models/Vive/{Materials => Models}/r_grip.mtl | 0 Models/Vive/{Materials => Models}/r_grip.mtl.meta | 0 Models/Vive/{Materials => Models}/scroll_wheel.mtl | 0 Models/Vive/{Materials => Models}/scroll_wheel.mtl.meta | 0 Models/Vive/{Materials => Models}/status.mtl | 0 Models/Vive/{Materials => Models}/status.mtl.meta | 0 Models/Vive/{Materials => Models}/sys_button.mtl | 0 Models/Vive/{Materials => Models}/sys_button.mtl.meta | 0 Models/Vive/{Materials => Models}/trackpad.mtl | 0 Models/Vive/{Materials => Models}/trackpad.mtl.meta | 0 Models/Vive/{Materials => Models}/trackpad_scroll_cut.mtl | 0 .../Vive/{Materials => Models}/trackpad_scroll_cut.mtl.meta | 0 Models/Vive/{Materials => Models}/trackpad_touch.mtl | 0 Models/Vive/{Materials => Models}/trackpad_touch.mtl.meta | 0 Models/Vive/{Materials => Models}/trigger.mtl | 0 Models/Vive/{Materials => Models}/trigger.mtl.meta | 0 Scripts/Proxies/TwoHandedProxyBase.cs | 5 +++-- Scripts/Proxies/ViveProxy.cs | 3 --- 27 files changed, 6 insertions(+), 5 deletions(-) rename Models/Vive/{Materials => Models}/body.mtl (100%) rename Models/Vive/{Materials => Models}/body.mtl.meta (100%) rename Models/Vive/{Materials => Models}/button.mtl (100%) rename Models/Vive/{Materials => Models}/button.mtl.meta (100%) rename Models/Vive/{Materials => Models}/l_grip.mtl (100%) rename Models/Vive/{Materials => Models}/l_grip.mtl.meta (100%) rename Models/Vive/{Materials => Models}/led.mtl (100%) rename Models/Vive/{Materials => Models}/led.mtl.meta (100%) rename Models/Vive/{Materials => Models}/r_grip.mtl (100%) rename Models/Vive/{Materials => Models}/r_grip.mtl.meta (100%) rename Models/Vive/{Materials => Models}/scroll_wheel.mtl (100%) rename Models/Vive/{Materials => Models}/scroll_wheel.mtl.meta (100%) rename Models/Vive/{Materials => Models}/status.mtl (100%) rename Models/Vive/{Materials => Models}/status.mtl.meta (100%) rename Models/Vive/{Materials => Models}/sys_button.mtl (100%) rename Models/Vive/{Materials => Models}/sys_button.mtl.meta (100%) rename Models/Vive/{Materials => Models}/trackpad.mtl (100%) rename Models/Vive/{Materials => Models}/trackpad.mtl.meta (100%) rename Models/Vive/{Materials => Models}/trackpad_scroll_cut.mtl (100%) rename Models/Vive/{Materials => Models}/trackpad_scroll_cut.mtl.meta (100%) rename Models/Vive/{Materials => Models}/trackpad_touch.mtl (100%) rename Models/Vive/{Materials => Models}/trackpad_touch.mtl.meta (100%) rename Models/Vive/{Materials => Models}/trigger.mtl (100%) rename Models/Vive/{Materials => Models}/trigger.mtl.meta (100%) diff --git a/Menus/MainMenu/MainMenu.cs b/Menus/MainMenu/MainMenu.cs index c132d9a6c..8eef377c4 100644 --- a/Menus/MainMenu/MainMenu.cs +++ b/Menus/MainMenu/MainMenu.cs @@ -124,6 +124,9 @@ void Start() public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) { + if (!m_MainMenuUI.visible) + return; + var mainMenuInput = (MainMenuInput)input; var rotationInput = -mainMenuInput.rotate.rawValue; diff --git a/Models/Vive/Materials/body.mtl b/Models/Vive/Models/body.mtl similarity index 100% rename from Models/Vive/Materials/body.mtl rename to Models/Vive/Models/body.mtl diff --git a/Models/Vive/Materials/body.mtl.meta b/Models/Vive/Models/body.mtl.meta similarity index 100% rename from Models/Vive/Materials/body.mtl.meta rename to Models/Vive/Models/body.mtl.meta diff --git a/Models/Vive/Materials/button.mtl b/Models/Vive/Models/button.mtl similarity index 100% rename from Models/Vive/Materials/button.mtl rename to Models/Vive/Models/button.mtl diff --git a/Models/Vive/Materials/button.mtl.meta b/Models/Vive/Models/button.mtl.meta similarity index 100% rename from Models/Vive/Materials/button.mtl.meta rename to Models/Vive/Models/button.mtl.meta diff --git a/Models/Vive/Materials/l_grip.mtl b/Models/Vive/Models/l_grip.mtl similarity index 100% rename from Models/Vive/Materials/l_grip.mtl rename to Models/Vive/Models/l_grip.mtl diff --git a/Models/Vive/Materials/l_grip.mtl.meta b/Models/Vive/Models/l_grip.mtl.meta similarity index 100% rename from Models/Vive/Materials/l_grip.mtl.meta rename to Models/Vive/Models/l_grip.mtl.meta diff --git a/Models/Vive/Materials/led.mtl b/Models/Vive/Models/led.mtl similarity index 100% rename from Models/Vive/Materials/led.mtl rename to Models/Vive/Models/led.mtl diff --git a/Models/Vive/Materials/led.mtl.meta b/Models/Vive/Models/led.mtl.meta similarity index 100% rename from Models/Vive/Materials/led.mtl.meta rename to Models/Vive/Models/led.mtl.meta diff --git a/Models/Vive/Materials/r_grip.mtl b/Models/Vive/Models/r_grip.mtl similarity index 100% rename from Models/Vive/Materials/r_grip.mtl rename to Models/Vive/Models/r_grip.mtl diff --git a/Models/Vive/Materials/r_grip.mtl.meta b/Models/Vive/Models/r_grip.mtl.meta similarity index 100% rename from Models/Vive/Materials/r_grip.mtl.meta rename to Models/Vive/Models/r_grip.mtl.meta diff --git a/Models/Vive/Materials/scroll_wheel.mtl b/Models/Vive/Models/scroll_wheel.mtl similarity index 100% rename from Models/Vive/Materials/scroll_wheel.mtl rename to Models/Vive/Models/scroll_wheel.mtl diff --git a/Models/Vive/Materials/scroll_wheel.mtl.meta b/Models/Vive/Models/scroll_wheel.mtl.meta similarity index 100% rename from Models/Vive/Materials/scroll_wheel.mtl.meta rename to Models/Vive/Models/scroll_wheel.mtl.meta diff --git a/Models/Vive/Materials/status.mtl b/Models/Vive/Models/status.mtl similarity index 100% rename from Models/Vive/Materials/status.mtl rename to Models/Vive/Models/status.mtl diff --git a/Models/Vive/Materials/status.mtl.meta b/Models/Vive/Models/status.mtl.meta similarity index 100% rename from Models/Vive/Materials/status.mtl.meta rename to Models/Vive/Models/status.mtl.meta diff --git a/Models/Vive/Materials/sys_button.mtl b/Models/Vive/Models/sys_button.mtl similarity index 100% rename from Models/Vive/Materials/sys_button.mtl rename to Models/Vive/Models/sys_button.mtl diff --git a/Models/Vive/Materials/sys_button.mtl.meta b/Models/Vive/Models/sys_button.mtl.meta similarity index 100% rename from Models/Vive/Materials/sys_button.mtl.meta rename to Models/Vive/Models/sys_button.mtl.meta diff --git a/Models/Vive/Materials/trackpad.mtl b/Models/Vive/Models/trackpad.mtl similarity index 100% rename from Models/Vive/Materials/trackpad.mtl rename to Models/Vive/Models/trackpad.mtl diff --git a/Models/Vive/Materials/trackpad.mtl.meta b/Models/Vive/Models/trackpad.mtl.meta similarity index 100% rename from Models/Vive/Materials/trackpad.mtl.meta rename to Models/Vive/Models/trackpad.mtl.meta diff --git a/Models/Vive/Materials/trackpad_scroll_cut.mtl b/Models/Vive/Models/trackpad_scroll_cut.mtl similarity index 100% rename from Models/Vive/Materials/trackpad_scroll_cut.mtl rename to Models/Vive/Models/trackpad_scroll_cut.mtl diff --git a/Models/Vive/Materials/trackpad_scroll_cut.mtl.meta b/Models/Vive/Models/trackpad_scroll_cut.mtl.meta similarity index 100% rename from Models/Vive/Materials/trackpad_scroll_cut.mtl.meta rename to Models/Vive/Models/trackpad_scroll_cut.mtl.meta diff --git a/Models/Vive/Materials/trackpad_touch.mtl b/Models/Vive/Models/trackpad_touch.mtl similarity index 100% rename from Models/Vive/Materials/trackpad_touch.mtl rename to Models/Vive/Models/trackpad_touch.mtl diff --git a/Models/Vive/Materials/trackpad_touch.mtl.meta b/Models/Vive/Models/trackpad_touch.mtl.meta similarity index 100% rename from Models/Vive/Materials/trackpad_touch.mtl.meta rename to Models/Vive/Models/trackpad_touch.mtl.meta diff --git a/Models/Vive/Materials/trigger.mtl b/Models/Vive/Models/trigger.mtl similarity index 100% rename from Models/Vive/Materials/trigger.mtl rename to Models/Vive/Models/trigger.mtl diff --git a/Models/Vive/Materials/trigger.mtl.meta b/Models/Vive/Models/trigger.mtl.meta similarity index 100% rename from Models/Vive/Materials/trigger.mtl.meta rename to Models/Vive/Models/trigger.mtl.meta diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index ab1222e4d..68eb946af 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -159,6 +159,9 @@ public virtual void Awake() public virtual IEnumerator Start() { + while (!active) + yield return null; + // In standalone play-mode usage, attempt to get the TrackedObjectInput if (trackedObjectInput == null && m_PlayerInput) trackedObjectInput = m_PlayerInput.GetActions(); @@ -167,8 +170,6 @@ public virtual IEnumerator Start() var rightProxyHelper = m_RightHand.GetComponent(); this.ConnectInterfaces(ObjectUtils.AddComponent(leftProxyHelper.gameObject), leftProxyHelper.rayOrigin); this.ConnectInterfaces(ObjectUtils.AddComponent(rightProxyHelper.gameObject), rightProxyHelper.rayOrigin); - - yield break; } public virtual void OnDestroy() diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 5eeeadb43..1a466da00 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -67,9 +67,6 @@ static void PostAnimate(ProxyHelper.ButtonObject[] buttons, Dictionary Date: Fri, 6 Oct 2017 12:27:51 -0700 Subject: [PATCH 096/457] PR Feedback --- Scripts/Core/EditorVR.Menus.cs | 6 +----- Scripts/Core/EditorVR.Viewer.cs | 10 ++++++---- Scripts/Modules/DeviceInputModule.cs | 10 +++++----- Scripts/Utilities/ComponentUtils.cs | 8 ++++---- Tools/SelectionTool/SelectionTool.cs | 11 ++++++----- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Scripts/Core/EditorVR.Menus.cs b/Scripts/Core/EditorVR.Menus.cs index d7c1d3c6b..ae45a3b10 100644 --- a/Scripts/Core/EditorVR.Menus.cs +++ b/Scripts/Core/EditorVR.Menus.cs @@ -384,17 +384,13 @@ internal static bool IsValidHover(MultipleRayInputModule.RaycastSource source) var rayOrigin = eventData.rayOrigin; DeviceData deviceData = null; - var deviceDataList = evr.m_DeviceData; - var dataCounter = 0; - while (dataCounter < deviceDataList.Count) + foreach (var currentDevice in evr.m_DeviceData) { - var currentDevice = deviceDataList[dataCounter]; if (currentDevice.rayOrigin == rayOrigin) { deviceData = currentDevice; break; } - dataCounter++; } if (deviceData != null) diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index ab20115b2..4464dfaed 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -37,7 +37,9 @@ class Preferences const float k_CameraRigTransitionTime = 0.25f; - static Collider[] s_CachedColliders = new Collider[20]; + // Local method use only -- created here to reduce garbage collection + const int k_MaxCollisionCheck = 32; + static Collider[] s_CachedColliders = new Collider[k_MaxCollisionCheck]; PlayerBody m_PlayerBody; float m_OriginalNearClipPlane; @@ -201,15 +203,15 @@ static bool Overlaps(Transform rayOrigin, Collider trigger) { var radius = DirectSelection.GetPointerLength(rayOrigin); - var totalColliders = Physics.OverlapSphereNonAlloc(rayOrigin.position, radius, s_CachedColliders, -1, QueryTriggerInteraction.Collide); - var colliderIndex = 0; + var totalColliders = Physics.OverlapSphereNonAlloc(rayOrigin.position, radius, s_CachedColliders, -1, QueryTriggerInteraction.Collide); + var colliderIndex = 0; while (colliderIndex < totalColliders) { if (s_CachedColliders[colliderIndex] == trigger) return true; - colliderIndex++; + colliderIndex++; } return false; diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index 1aed46609..da6c9a192 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -34,10 +34,10 @@ sealed class DeviceInputModule : MonoBehaviour readonly HashSet m_ProcessedInputs = new HashSet(); readonly List m_SystemDevices = new List(); readonly Dictionary m_DeviceTypeTags = new Dictionary(); + static readonly List s_RemoveList = new List(); public Action, ConsumeControlDelegate> processInput; public Action> updatePlayerHandleMaps; - List m_RemoveList = new List(); public List GetSystemDevices() { @@ -68,26 +68,26 @@ void OnDestroy() public void ProcessInput() { - m_RemoveList.Clear(); + s_RemoveList.Clear(); // Maintain a consumed control, so that other AMIs don't pick up the input, until it's no longer used foreach (var lockedControl in m_LockedControls) { if (!lockedControl.provider.active || Mathf.Approximately(lockedControl.rawValue, lockedControl.provider.GetControlData(lockedControl.index).defaultValue)) - m_RemoveList.Add(lockedControl); + s_RemoveList.Add(lockedControl); else ConsumeControl(lockedControl); } // Remove separately, since we cannot remove while iterating - foreach (var inputControl in m_RemoveList) + foreach (var inputControl in s_RemoveList) { if (!inputControl.provider.active) ResetControl(inputControl); m_LockedControls.Remove(inputControl); } - m_RemoveList.Clear(); + s_RemoveList.Clear(); m_ProcessedInputs.Clear(); // TODO: Replace this with a map of ActionMap,IProcessInput and go through those diff --git a/Scripts/Utilities/ComponentUtils.cs b/Scripts/Utilities/ComponentUtils.cs index 9adbed776..1de420dde 100644 --- a/Scripts/Utilities/ComponentUtils.cs +++ b/Scripts/Utilities/ComponentUtils.cs @@ -3,11 +3,11 @@ namespace UnityEditor.Experimental.EditorVR.Utilities { - /// - /// Special utility class for getting components in the editor without allocations - /// + /// + /// Special utility class for getting components in the editor without allocations + /// /// - public class ComponentUtils + public static class ComponentUtils { static List s_RetrievalList = new List(); diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index 7793f7898..50e0f443d 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -20,6 +20,9 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR static readonly Vector3 k_TooltipPosition = new Vector3(0, 0.05f, -0.03f); static readonly Quaternion k_TooltipRotation = Quaternion.AngleAxis(90, Vector3.right); + // Local method use only -- created here to reduce garbage collection + static readonly Dictionary s_TempHovers = new Dictionary(); + [SerializeField] Sprite m_Icon; @@ -39,8 +42,6 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR readonly Dictionary m_SelectionHoverGameObjects = new Dictionary(); - Dictionary m_TempHovers = new Dictionary(); - public ActionMap actionMap { get { return m_ActionMap; } } public Transform rayOrigin { private get; set; } @@ -135,8 +136,8 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } // Unset highlight old hovers - m_TempHovers.Clear(); - foreach (var kvp in m_TempHovers) + s_TempHovers.Clear(); + foreach (var kvp in s_TempHovers) { var directRayOrigin = kvp.Key; var hover = kvp.Value; @@ -148,7 +149,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon m_HoverGameObjects.Remove(directRayOrigin); } } - m_TempHovers.Clear(); + s_TempHovers.Clear(); // Find new hovers foreach (var kvp in directSelection) From 487d8ea46bfdcb6e3445a91a8b87302fb9954e2a Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 6 Oct 2017 14:16:47 -0700 Subject: [PATCH 097/457] Bring back interface connectors and ensure no module implements IInterfaceConnector --- .../ActionsModuleConnector.cs | 2 +- .../DeviceInputModuleConnector.cs | 30 ++++++++ .../DeviceInputModuleConnector.cs.meta | 12 +++ .../HapticsModuleConnector.cs | 18 +++++ .../HapticsModuleConnector.cs.meta | 12 +++ .../HierarchyModuleConnector.cs | 40 ++++++++++ .../HierarchyModuleConnector.cs.meta | 12 +++ .../HighlightModuleConnector.cs | 31 ++++++++ .../HighlightModuleConnector.cs.meta | 12 +++ .../LockModuleConnector.cs | 18 +++++ .../LockModuleConnector.cs.meta | 12 +++ .../MultipleRayInputModuleConnector.cs | 18 +++++ .../MultipleRayInputModuleConnector.cs.meta | 12 +++ .../ProjectFolderModuleConnector.cs | 40 ++++++++++ .../ProjectFolderModuleConnector.cs.meta | 12 +++ .../SceneObjectModuleConnector.cs | 19 +++++ .../SceneObjectModuleConnector.cs.meta | 12 +++ .../SelectionModuleConnector.cs | 12 ++- .../SnappingModuleConnector.cs | 19 +++++ .../SnappingModuleConnector.cs.meta | 12 +++ .../SpatialHashModuleConnector.cs | 18 +++++ .../SpatialHashModuleConnector.cs.meta | 12 +++ .../SpatialHintModuleConnector.cs | 24 ++++++ .../SpatialHintModuleConnector.cs.meta | 12 +++ .../SpatialScrollModuleConnector.cs | 18 +++++ .../SpatialScrollModuleConnector.cs.meta | 12 +++ .../TooltipModuleConnector.cs | 18 +++++ .../TooltipModuleConnector.cs.meta | 12 +++ .../WorkspaceModuleConnector.cs | 31 ++++++++ .../WorkspaceModuleConnector.cs.meta | 12 +++ Scripts/Modules/DeviceInputModule.cs | 77 ++++++++----------- .../Modules/FeedbackModule/FeedbackModule.cs | 14 ++-- .../Modules/HapticsModule/HapticsModule.cs | 7 -- Scripts/Modules/HierarchyModule.cs | 28 +------ .../HighlightModule/HighlightModule.cs | 19 +---- Scripts/Modules/LockModule/LockModule.cs | 3 - .../MultipleRayInputModule.cs | 4 +- Scripts/Modules/ProjectFolderModule.cs | 29 +------ Scripts/Modules/SceneObjectModule.cs | 7 -- .../SelectionModule/SelectionModule.cs | 6 -- .../Modules/SerializedPreferencesModule.cs | 26 +++---- .../Modules/SnappingModule/SnappingModule.cs | 4 - Scripts/Modules/SpatialHashModule.cs | 2 - .../SpatialHintModule/SpatialHintModule.cs | 9 --- .../SpatialScrollModule.cs | 6 -- .../Modules/TooltipModule/TooltipModule.cs | 6 -- Scripts/Modules/WorkspaceModule.cs | 15 +--- 47 files changed, 572 insertions(+), 214 deletions(-) create mode 100644 Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/LockModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta diff --git a/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs b/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs index 8d31eee59..d3a1fc4e2 100644 --- a/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/ActionsModuleConnector.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_EDITORVR using UnityEditor.Experimental.EditorVR.Modules; namespace UnityEditor.Experimental.EditorVR.Core diff --git a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs new file mode 100644 index 000000000..187995ec3 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs @@ -0,0 +1,30 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class DeviceInputModuleConnector : Nested, IInterfaceConnector + { + public void ConnectInterface(object @object, object userData = null) + { + var trackedObjectMap = @object as ITrackedObjectActionMap; + if (trackedObjectMap != null) + trackedObjectMap.trackedObjectInput = evr.GetModule().trackedObjectInput; + + var processInput = @object as IProcessInput; + if (processInput != null && !(@object is ITool)) // Tools have their input processed separately + evr.GetModule().AddInputProcessor(processInput, userData); + } + + public void DisconnectInterface(object @object, object userData = null) + { + var processInput = @object as IProcessInput; + if (processInput != null) + evr.GetModule().RemoveInputProcessor(processInput); + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta new file mode 100644 index 000000000..6d58a7589 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/DeviceInputModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a798606e983e34f40bf82eb817fbcc34 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs new file mode 100644 index 000000000..b55dc3e66 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs @@ -0,0 +1,18 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class HapticsModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(HapticsModule provider) + { + IControlHapticsMethods.pulse = provider.Pulse; + IControlHapticsMethods.stopPulses = provider.StopPulses; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta new file mode 100644 index 000000000..1c8b80936 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/HapticsModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9fd9027b505d0c244b1bb5c586615e8d +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs new file mode 100644 index 000000000..28c89c173 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs @@ -0,0 +1,40 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class HierarchyModuleConnector : Nested, IInterfaceConnector + { + public void ConnectInterface(object @object, object userData = null) + { + var usesHierarchyData = @object as IUsesHierarchyData; + if (usesHierarchyData != null) + { + var evrHierarchyModule = evr.GetModule(); + evrHierarchyModule.AddConsumer(usesHierarchyData); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + evrHierarchyModule.AddConsumer(filterUI); + } + } + + public void DisconnectInterface(object @object, object userData = null) + { + var usesHierarchy = @object as IUsesHierarchyData; + if (usesHierarchy != null) + { + var evrHierarchyModule = evr.GetModule(); + evrHierarchyModule.RemoveConsumer(usesHierarchy); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + evrHierarchyModule.RemoveConsumer(filterUI); + } + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta new file mode 100644 index 000000000..91b52569d --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/HierarchyModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5853c284ea4ca5d4492cbb8506758cc0 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs new file mode 100644 index 000000000..d54b5c564 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs @@ -0,0 +1,31 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class HighlightModuleConnector : Nested, IInterfaceConnector, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(HighlightModule provider) + { + ISetHighlightMethods.setHighlight = provider.SetHighlight; + } + + public void ConnectInterface(object @object, object userData = null) + { + var customHighlight = @object as ICustomHighlight; + if (customHighlight != null) + evr.GetModule().customHighlight += customHighlight.OnHighlight; + } + + public void DisconnectInterface(object @object, object userData = null) + { + var customHighlight = @object as ICustomHighlight; + if (customHighlight != null) + evr.GetModule().customHighlight -= customHighlight.OnHighlight; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta new file mode 100644 index 000000000..5564522c6 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/HighlightModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 39b5983bf5da6da41a2a512df83ccb33 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs new file mode 100644 index 000000000..eba893c4b --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs @@ -0,0 +1,18 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class LockModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(LockModule provider) + { + IUsesGameObjectLockingMethods.setLocked = provider.SetLocked; + IUsesGameObjectLockingMethods.isLocked = provider.IsLocked; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta new file mode 100644 index 000000000..c24ed627d --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/LockModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cd6ca3d67dbdb944b9613c75d5b6a279 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs new file mode 100644 index 000000000..6302370aa --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs @@ -0,0 +1,18 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class MultipleRayInputModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(MultipleRayInputModule provider) + { + IIsHoveringOverUIMethods.isHoveringOverUI = provider.IsHoveringOverUI; + IBlockUIInteractionMethods.setUIBlockedForRayOrigin = provider.SetUIBlockedForRayOrigin; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta new file mode 100644 index 000000000..bcce847ba --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/MultipleRayInputModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c4acdc0d1cb343b43bdb533e7b69ba9c +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs new file mode 100644 index 000000000..0d4b5f009 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs @@ -0,0 +1,40 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class ProjectFolderModuleConnector : Nested, IInterfaceConnector + { + public void ConnectInterface(object @object, object userData = null) + { + var usesProjectFolderData = @object as IUsesProjectFolderData; + if (usesProjectFolderData != null) + { + var evrProjectFolderModule = evr.GetModule(); + evrProjectFolderModule.AddConsumer(usesProjectFolderData); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + evrProjectFolderModule.AddConsumer(filterUI); + } + } + + public void DisconnectInterface(object @object, object userData = null) + { + var usesProjectFolderData = @object as IUsesProjectFolderData; + if (usesProjectFolderData != null) + { + var evrProjectFolderModule = evr.GetModule(); + evrProjectFolderModule.RemoveConsumer(usesProjectFolderData); + + var filterUI = @object as IFilterUI; + if (filterUI != null) + evrProjectFolderModule.RemoveConsumer(filterUI); + } + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta new file mode 100644 index 000000000..c5dd2d691 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/ProjectFolderModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f7604b6b3be4c8c4cbf7e94687e61208 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs new file mode 100644 index 000000000..90d16a0e1 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs @@ -0,0 +1,19 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class SceneObjectModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(SceneObjectModule provider) + { + IDeleteSceneObjectMethods.deleteSceneObject = provider.DeleteSceneObject; + IPlaceSceneObjectMethods.placeSceneObject = provider.PlaceSceneObject; + IPlaceSceneObjectsMethods.placeSceneObjects = provider.PlaceSceneObjects; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta new file mode 100644 index 000000000..22bfbe1e6 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SceneObjectModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ff22862caceb1ef46bb59493da621d60 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs index fa195e7a2..d57db17c5 100644 --- a/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs +++ b/Scripts/Core/InterfaceConnectors/SelectionModuleConnector.cs @@ -1,10 +1,18 @@ -#if UNITY_EDITOR && UNITY_EDITORVR +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + namespace UnityEditor.Experimental.EditorVR.Core { partial class EditorVR { - class SelectionModuleConnector : Nested, IInterfaceConnector + class SelectionModuleConnector : Nested, IInterfaceConnector, ILateBindInterfaceMethods { + public void LateBindInterfaceMethods(SelectionModule provider) + { + ISelectObjectMethods.getSelectionCandidate = provider.GetSelectionCandidate; + ISelectObjectMethods.selectObject = provider.SelectObject; + } + public void ConnectInterface(object @object, object userData = null) { var selectionChanged = @object as ISelectionChanged; diff --git a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs new file mode 100644 index 000000000..bf754e19e --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs @@ -0,0 +1,19 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class SnappingModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(SnappingModule provider) + { + IUsesSnappingMethods.manipulatorSnap = provider.ManipulatorSnap; + IUsesSnappingMethods.directSnap = provider.DirectSnap; + IUsesSnappingMethods.clearSnappingState = provider.ClearSnappingState; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta new file mode 100644 index 000000000..b2aa98340 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SnappingModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 87ee9909fd766c5448c4533fefa2618a +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs new file mode 100644 index 000000000..6845f7971 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs @@ -0,0 +1,18 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class SpatialHashModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(SpatialHashModule provider) + { + IUsesSpatialHashMethods.addToSpatialHash = provider.AddObject; + IUsesSpatialHashMethods.removeFromSpatialHash = provider.RemoveObject; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta new file mode 100644 index 000000000..5f9f7e1ca --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SpatialHashModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6cef8b3f6b78f314d916ec481e5e6429 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs new file mode 100644 index 000000000..59b212f3c --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs @@ -0,0 +1,24 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class SpatialHintModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(SpatialHintModule provider) + { + IControlSpatialHintingMethods.setSpatialHintState = provider.SetState; + IControlSpatialHintingMethods.setSpatialHintPosition = provider.SetPosition; + IControlSpatialHintingMethods.setSpatialHintContainerRotation = provider.SetContainerRotation; + IControlSpatialHintingMethods.setSpatialHintShowHideRotationTarget = provider.SetShowHideRotationTarget; + IControlSpatialHintingMethods.setSpatialHintLookAtRotation = provider.LookAt; + IControlSpatialHintingMethods.setSpatialHintDragThresholdTriggerPosition = provider.SetDragThresholdTriggerPosition; + IControlSpatialHintingMethods.pulseSpatialHintScrollArrows = provider.PulseScrollArrows; + IControlSpatialHintingMethods.setSpatialHintControlNode = provider.SetSpatialHintControlNode; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta new file mode 100644 index 000000000..0ce5544e0 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SpatialHintModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 160f2053e594df84993a7f20d25165e1 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs new file mode 100644 index 000000000..a4b58ac9f --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs @@ -0,0 +1,18 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class SpatialScrollModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(SpatialScrollModule provider) + { + IControlSpatialScrollingMethods.performSpatialScroll = provider.PerformScroll; + IControlSpatialScrollingMethods.endSpatialScroll = provider.EndScroll; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta new file mode 100644 index 000000000..e158f9b30 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SpatialScrollModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b2adf9dd694035a45b24f0ecb7d37ebe +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs new file mode 100644 index 000000000..3221a284e --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs @@ -0,0 +1,18 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class TooltipModuleConnector : Nested, ILateBindInterfaceMethods + { + public void LateBindInterfaceMethods(TooltipModule provider) + { + ISetTooltipVisibilityMethods.showTooltip = provider.ShowTooltip; + ISetTooltipVisibilityMethods.hideTooltip = provider.HideTooltip; + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta new file mode 100644 index 000000000..130011c87 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/TooltipModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0d7b646c9de7fa040b51d1854cc836c8 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs new file mode 100644 index 000000000..5c5b5f49c --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs @@ -0,0 +1,31 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class WorkspaceModuleConnector : Nested, ILateBindInterfaceMethods, IInterfaceConnector + { + public void LateBindInterfaceMethods(WorkspaceModule provider) + { + ICreateWorkspaceMethods.createWorkspace = provider.CreateWorkspace; + IResetWorkspacesMethods.resetWorkspaceRotations = provider.ResetWorkspaceRotations; + } + + public void ConnectInterface(object @object, object userData = null) + { + var workspaceModule = evr.GetModule(); + + var allWorkspaces = @object as IAllWorkspaces; + if (allWorkspaces != null) + allWorkspaces.allWorkspaces = workspaceModule.workspaces; + } + + public void DisconnectInterface(object @object, object userData = null) + { + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta new file mode 100644 index 000000000..642a42670 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/WorkspaceModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5d6163cac077bbd4ca5405744d1a5b52 +timeCreated: 1489520545 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Modules/DeviceInputModule.cs b/Scripts/Modules/DeviceInputModule.cs index fc5e33da3..c1ee8619f 100644 --- a/Scripts/Modules/DeviceInputModule.cs +++ b/Scripts/Modules/DeviceInputModule.cs @@ -2,14 +2,13 @@ using System; using System.Collections.Generic; using System.Linq; -using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class DeviceInputModule : MonoBehaviour, IInterfaceConnector + sealed class DeviceInputModule : MonoBehaviour { class InputProcessor { @@ -75,49 +74,6 @@ void OnDestroy() PlayerHandleManager.RemovePlayerHandle(m_PlayerHandle); } - public void ConnectInterface(object @object, object userData = null) - { - var trackedObjectMap = @object as ITrackedObjectActionMap; - if (trackedObjectMap != null) - trackedObjectMap.trackedObjectInput = trackedObjectInput; - - var rayOrigin = userData as Transform; - var processInput = @object as IProcessInput; - if (processInput != null && !(@object is ITool)) // Tools have their input processed separately - { - var inputDevice = inputDeviceForRayOrigin(rayOrigin); - var input = CreateActionMapInputForObject(@object, inputDevice); - - var order = 0; - var processInputAttribute = (ProcessInputAttribute)@object.GetType().GetCustomAttributes(typeof(ProcessInputAttribute), true).FirstOrDefault(); - if (processInputAttribute != null) - order = processInputAttribute.order; - - m_InputProcessors.Add(new InputProcessor { processor = processInput, input = input, order = order }); - m_InputProcessors.Sort((a, b) => b.order.CompareTo(a.order)); - } - } - - public void DisconnectInterface(object @object, object userData = null) - { - var processInput = @object as IProcessInput; - if (processInput != null) - { - m_InputProcessorsCopy.Clear(); - m_InputProcessorsCopy.AddRange(m_InputProcessors); - foreach (var processor in m_InputProcessorsCopy) - { - if (processor.processor == @object) - { - m_InputProcessors.Remove(processor); - var customActionMap = @object as ICustomActionMap; - if (customActionMap != null) - m_IgnoreLocking.Remove(processor.input); - } - } - } - } - public void ProcessInput() { // Maintain a consumed control, so that other AMIs don't pick up the input, until it's no longer used @@ -334,6 +290,37 @@ public Node GetDeviceNode(InputDevice device) return Node.None; } + + public void AddInputProcessor(IProcessInput processInput, object userData) + { + var rayOrigin = userData as Transform; + var inputDevice = inputDeviceForRayOrigin(rayOrigin); + var input = CreateActionMapInputForObject(processInput, inputDevice); + + var order = 0; + var processInputAttribute = (ProcessInputAttribute)processInput.GetType().GetCustomAttributes(typeof(ProcessInputAttribute), true).FirstOrDefault(); + if (processInputAttribute != null) + order = processInputAttribute.order; + + m_InputProcessors.Add(new InputProcessor { processor = processInput, input = input, order = order }); + m_InputProcessors.Sort((a, b) => b.order.CompareTo(a.order)); + } + + public void RemoveInputProcessor(IProcessInput processInput) + { + m_InputProcessorsCopy.Clear(); + m_InputProcessorsCopy.AddRange(m_InputProcessors); + foreach (var processor in m_InputProcessorsCopy) + { + if (processor.processor == processInput) + { + m_InputProcessors.Remove(processor); + var customActionMap = processInput as ICustomActionMap; + if (customActionMap != null) + m_IgnoreLocking.Remove(processor.input); + } + } + } } } #endif diff --git a/Scripts/Modules/FeedbackModule/FeedbackModule.cs b/Scripts/Modules/FeedbackModule/FeedbackModule.cs index 304da0f30..4b1dc5ab1 100644 --- a/Scripts/Modules/FeedbackModule/FeedbackModule.cs +++ b/Scripts/Modules/FeedbackModule/FeedbackModule.cs @@ -15,7 +15,7 @@ public abstract class FeedbackRequest public GameObject settingsMenuItemInstance { get; set; } } - public class FeedbackModule : MonoBehaviour, IInterfaceConnector, ISettingsMenuItemProvider, ISerializePreferences + public class FeedbackModule : MonoBehaviour, ISettingsMenuItemProvider, ISerializePreferences { [Serializable] class Preferences @@ -80,18 +80,14 @@ void Start() m_Preferences = new Preferences(); } - public void ConnectInterface(object @object, object userData = null) + public void AddReceiver(IFeedbackReceiver feedbackReceiver) { - var feedbackReceiver = @object as IFeedbackReceiver; - if (feedbackReceiver != null) - m_FeedbackReceivers.Add(feedbackReceiver); + m_FeedbackReceivers.Add(feedbackReceiver); } - public void DisconnectInterface(object @object, object userData = null) + public void RemoveReceiver(IFeedbackReceiver feedbackReceiver) { - var feedbackReceiver = @object as IFeedbackReceiver; - if (feedbackReceiver != null) - m_FeedbackReceivers.Remove(feedbackReceiver); + m_FeedbackReceivers.Remove(feedbackReceiver); } void SetEnabled(bool enabled) diff --git a/Scripts/Modules/HapticsModule/HapticsModule.cs b/Scripts/Modules/HapticsModule/HapticsModule.cs index 4af17f24e..2e3f4eb6d 100644 --- a/Scripts/Modules/HapticsModule/HapticsModule.cs +++ b/Scripts/Modules/HapticsModule/HapticsModule.cs @@ -1,5 +1,4 @@ #if UNITY_EDITOR -using System; using UnityEditor.Experimental.EditorVR.Core; using UnityEngine; @@ -30,12 +29,6 @@ sealed class HapticsModule : MonoBehaviour /// bool m_SampleLengthWarningShown; - void Awake() - { - IControlHapticsMethods.pulse = Pulse; - IControlHapticsMethods.stopPulses = StopPulses; - } - void Start() { #if ENABLE_OVR_INPUT diff --git a/Scripts/Modules/HierarchyModule.cs b/Scripts/Modules/HierarchyModule.cs index d02a4ba8f..1ed13a6fa 100644 --- a/Scripts/Modules/HierarchyModule.cs +++ b/Scripts/Modules/HierarchyModule.cs @@ -6,7 +6,7 @@ namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class HierarchyModule : MonoBehaviour, ISelectionChanged, IInterfaceConnector + sealed class HierarchyModule : MonoBehaviour, ISelectionChanged { readonly List m_HierarchyLists = new List(); readonly List m_HierarchyData = new List(); @@ -47,32 +47,6 @@ void OnDisable() EditorApplication.hierarchyWindowChanged -= UpdateHierarchyData; } - public void ConnectInterface(object @object, object userData = null) - { - var usesHierarchyData = @object as IUsesHierarchyData; - if (usesHierarchyData != null) - { - AddConsumer(usesHierarchyData); - - var filterUI = @object as IFilterUI; - if (filterUI != null) - AddConsumer(filterUI); - } - } - - public void DisconnectInterface(object @object, object userData = null) - { - var usesHierarchy = @object as IUsesHierarchyData; - if (usesHierarchy != null) - { - RemoveConsumer(usesHierarchy); - - var filterUI = @object as IFilterUI; - if (filterUI != null) - RemoveConsumer(filterUI); - } - } - public void OnSelectionChanged() { UpdateHierarchyData(); diff --git a/Scripts/Modules/HighlightModule/HighlightModule.cs b/Scripts/Modules/HighlightModule/HighlightModule.cs index 49c7b2447..456f31387 100644 --- a/Scripts/Modules/HighlightModule/HighlightModule.cs +++ b/Scripts/Modules/HighlightModule/HighlightModule.cs @@ -1,14 +1,13 @@ #if UNITY_EDITOR using System; using System.Collections.Generic; -using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class HighlightModule : MonoBehaviour, IUsesGameObjectLocking, IInterfaceConnector + sealed class HighlightModule : MonoBehaviour, IUsesGameObjectLocking { class HighlightData { @@ -47,8 +46,6 @@ public Color highlightColor void Awake() { - ISetHighlightMethods.setHighlight = SetHighlight; - m_RayHighlightMaterial = Instantiate(m_RayHighlightMaterial); if (EditorPrefs.HasKey(k_SelectionOutlinePrefsKey)) { @@ -58,20 +55,6 @@ void Awake() } } - public void ConnectInterface(object @object, object userData = null) - { - var customHighlight = @object as ICustomHighlight; - if (customHighlight != null) - this.customHighlight += customHighlight.OnHighlight; - } - - public void DisconnectInterface(object @object, object userData = null) - { - var customHighlight = @object as ICustomHighlight; - if (customHighlight != null) - this.customHighlight -= customHighlight.OnHighlight; - } - void LateUpdate() { m_HighlightsToRemove.Clear(); diff --git a/Scripts/Modules/LockModule/LockModule.cs b/Scripts/Modules/LockModule/LockModule.cs index 5e506ddee..da405d2f3 100644 --- a/Scripts/Modules/LockModule/LockModule.cs +++ b/Scripts/Modules/LockModule/LockModule.cs @@ -39,9 +39,6 @@ public void ExecuteAction() void Awake() { - IUsesGameObjectLockingMethods.setLocked = SetLocked; - IUsesGameObjectLockingMethods.isLocked = IsLocked; - m_LockModuleAction.execute = ToggleLocked; UpdateAction(null); diff --git a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs index 6e620dca4..b27563841 100644 --- a/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs +++ b/Scripts/Modules/MultipleRayInputModule/MultipleRayInputModule.cs @@ -152,8 +152,6 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon protected override void Awake() { - IBlockUIInteractionMethods.setUIBlockedForRayOrigin = SetUIBlockedForRayOrigin; - IIsHoveringOverUIMethods.isHoveringOverUI = IsHoveringOverUI; base.Awake(); s_LayerMask = LayerMask.GetMask("UI"); @@ -454,7 +452,7 @@ public bool IsHoveringOverUI(Transform rayOrigin) return m_RaycastSources.TryGetValue(rayOrigin, out source) && source.hasObject; } - void SetUIBlockedForRayOrigin(Transform rayOrigin, bool blocked) + public void SetUIBlockedForRayOrigin(Transform rayOrigin, bool blocked) { RaycastSource source; if (m_RaycastSources.TryGetValue(rayOrigin, out source)) diff --git a/Scripts/Modules/ProjectFolderModule.cs b/Scripts/Modules/ProjectFolderModule.cs index 13e3e8dac..4eaaa41b0 100644 --- a/Scripts/Modules/ProjectFolderModule.cs +++ b/Scripts/Modules/ProjectFolderModule.cs @@ -3,13 +3,12 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Data; using UnityEngine; namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class ProjectFolderModule : MonoBehaviour, IInterfaceConnector + sealed class ProjectFolderModule : MonoBehaviour { // Maximum time (in ms) before yielding in CreateFolderData: should be target frame time const float k_MaxFrameTime = 0.01f; @@ -36,32 +35,6 @@ void OnDisable() EditorApplication.projectWindowChanged -= UpdateProjectFolders; } - public void ConnectInterface(object @object, object userData = null) - { - var usesProjectFolderData = @object as IUsesProjectFolderData; - if (usesProjectFolderData != null) - { - AddConsumer(usesProjectFolderData); - - var filterUI = @object as IFilterUI; - if (filterUI != null) - AddConsumer(filterUI); - } - } - - public void DisconnectInterface(object @object, object userData = null) - { - var usesProjectFolderData = @object as IUsesProjectFolderData; - if (usesProjectFolderData != null) - { - RemoveConsumer(usesProjectFolderData); - - var filterUI = @object as IFilterUI; - if (filterUI != null) - RemoveConsumer(filterUI); - } - } - public void AddConsumer(IUsesProjectFolderData consumer) { consumer.folderData = GetFolderData(); diff --git a/Scripts/Modules/SceneObjectModule.cs b/Scripts/Modules/SceneObjectModule.cs index e676b2481..b147efd91 100644 --- a/Scripts/Modules/SceneObjectModule.cs +++ b/Scripts/Modules/SceneObjectModule.cs @@ -13,13 +13,6 @@ sealed class SceneObjectModule : MonoBehaviour, IUsesSpatialHash public Func tryPlaceObject; - void Awake() - { - IDeleteSceneObjectMethods.deleteSceneObject = DeleteSceneObject; - IPlaceSceneObjectMethods.placeSceneObject = PlaceSceneObject; - IPlaceSceneObjectsMethods.placeSceneObjects = PlaceSceneObjects; - } - public void PlaceSceneObject(Transform obj, Vector3 targetScale) { if (tryPlaceObject == null || !tryPlaceObject(obj, targetScale)) diff --git a/Scripts/Modules/SelectionModule/SelectionModule.cs b/Scripts/Modules/SelectionModule/SelectionModule.cs index 68d5da0ab..76a67769b 100644 --- a/Scripts/Modules/SelectionModule/SelectionModule.cs +++ b/Scripts/Modules/SelectionModule/SelectionModule.cs @@ -20,12 +20,6 @@ sealed class SelectionModule : MonoBehaviour, IUsesGameObjectLocking, ISelection public event Action selected; - void Awake() - { - ISelectObjectMethods.getSelectionCandidate = GetSelectionCandidate; - ISelectObjectMethods.selectObject = SelectObject; - } - public GameObject GetSelectionCandidate(GameObject hoveredObject, bool useGrouping = false) { // If we can't even select the object we're starting with, then skip any further logic diff --git a/Scripts/Modules/SerializedPreferencesModule.cs b/Scripts/Modules/SerializedPreferencesModule.cs index ed0251332..723abf001 100644 --- a/Scripts/Modules/SerializedPreferencesModule.cs +++ b/Scripts/Modules/SerializedPreferencesModule.cs @@ -7,7 +7,7 @@ namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class SerializedPreferencesModule : MonoBehaviour, IInterfaceConnector + sealed class SerializedPreferencesModule : MonoBehaviour { List m_Serializers = new List(); SerializedPreferences m_Preferences; @@ -58,27 +58,19 @@ class SerializedPreferenceItem public string payload { get { return m_Payload; } set { m_Payload = value; } } } - public void ConnectInterface(object @object, object userData = null) + public void AddSerializer(ISerializePreferences serializer) { - var serializer = @object as ISerializePreferences; - if (serializer != null) - { - if (m_Preferences != null) - Deserialize(serializer); + if (m_Preferences != null) + Deserialize(serializer); - m_Serializers.Add(serializer); - } + m_Serializers.Add(serializer); } - public void DisconnectInterface(object @object, object userData = null) + public void RemoveSerializer(ISerializePreferences serializer) { - var serializer = @object as ISerializePreferences; - if (serializer != null) - { - // TODO: Support serializing one type at a time - SerializePreferences(); - m_Serializers.Remove(serializer); - } + // TODO: Support serializing one type at a time + SerializePreferences(); + m_Serializers.Remove(serializer); } internal void DeserializePreferences(string serializedPreferences) diff --git a/Scripts/Modules/SnappingModule/SnappingModule.cs b/Scripts/Modules/SnappingModule/SnappingModule.cs index 05949817a..a370cbfbd 100644 --- a/Scripts/Modules/SnappingModule/SnappingModule.cs +++ b/Scripts/Modules/SnappingModule/SnappingModule.cs @@ -370,10 +370,6 @@ public bool directSnappingEnabled void Awake() { - IUsesSnappingMethods.manipulatorSnap = ManipulatorSnap; - IUsesSnappingMethods.directSnap = DirectSnap; - IUsesSnappingMethods.clearSnappingState = ClearSnappingState; - m_GroundPlane = ObjectUtils.Instantiate(m_GroundPlane, transform); m_GroundPlane.SetActive(false); diff --git a/Scripts/Modules/SpatialHashModule.cs b/Scripts/Modules/SpatialHashModule.cs index 3afead776..06d57e379 100644 --- a/Scripts/Modules/SpatialHashModule.cs +++ b/Scripts/Modules/SpatialHashModule.cs @@ -16,8 +16,6 @@ sealed class SpatialHashModule : MonoBehaviour void Awake() { - IUsesSpatialHashMethods.addToSpatialHash = AddObject; - IUsesSpatialHashMethods.removeFromSpatialHash = RemoveObject; spatialHash = new SpatialHash(); } diff --git a/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs b/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs index b81889dd8..d4a7ef7bd 100644 --- a/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs +++ b/Scripts/Modules/SpatialHintModule/SpatialHintModule.cs @@ -77,15 +77,6 @@ Node controllingNode void Awake() { - IControlSpatialHintingMethods.setSpatialHintState = SetState; - IControlSpatialHintingMethods.setSpatialHintPosition = SetPosition; - IControlSpatialHintingMethods.setSpatialHintContainerRotation = SetContainerRotation; - IControlSpatialHintingMethods.setSpatialHintShowHideRotationTarget = SetShowHideRotationTarget; - IControlSpatialHintingMethods.setSpatialHintLookAtRotation = LookAt; - IControlSpatialHintingMethods.setSpatialHintDragThresholdTriggerPosition = SetDragThresholdTriggerPosition; - IControlSpatialHintingMethods.pulseSpatialHintScrollArrows = PulseScrollArrows; - IControlSpatialHintingMethods.setSpatialHintControlNode = SetSpatialHintControlNode; - m_SpatialHintUI = this.InstantiateUI(m_SpatialHintUI.gameObject).GetComponent(); this.ConnectInterfaces(m_SpatialHintUI); } diff --git a/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs b/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs index 83c4f9731..5b7f7dfc5 100644 --- a/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs +++ b/Scripts/Modules/SpatialScrollModule/SpatialScrollModule.cs @@ -104,12 +104,6 @@ public void UpdateExistingScrollData(Vector3 newPosition) } } - void Awake() - { - IControlSpatialScrollingMethods.performSpatialScroll = PerformScroll; - IControlSpatialScrollingMethods.endSpatialScroll = EndScroll; - } - internal SpatialScrollData PerformScroll(IControlSpatialScrolling caller, Node node, Vector3 startingPosition, Vector3 currentPosition, float repeatingScrollLengthRange, int scrollableItemCount, int maxItemCount = -1, bool centerScrollVisuals = true) { // Continue processing of spatial scrolling for a given caller, diff --git a/Scripts/Modules/TooltipModule/TooltipModule.cs b/Scripts/Modules/TooltipModule/TooltipModule.cs index 128d209c1..7e0bd7820 100644 --- a/Scripts/Modules/TooltipModule/TooltipModule.cs +++ b/Scripts/Modules/TooltipModule/TooltipModule.cs @@ -48,12 +48,6 @@ class TooltipData // Local method use only -- created here to reduce garbage collection readonly List m_TooltipsToHide = new List(); - void Awake() - { - ISetTooltipVisibilityMethods.showTooltip = ShowTooltip; - ISetTooltipVisibilityMethods.hideTooltip = HideTooltip; - } - void Start() { m_TooltipCanvas = Instantiate(m_TooltipCanvasPrefab).transform; diff --git a/Scripts/Modules/WorkspaceModule.cs b/Scripts/Modules/WorkspaceModule.cs index 9dc740ebc..31fb13a13 100644 --- a/Scripts/Modules/WorkspaceModule.cs +++ b/Scripts/Modules/WorkspaceModule.cs @@ -9,7 +9,7 @@ namespace UnityEditor.Experimental.EditorVR.Modules { - sealed class WorkspaceModule : MonoBehaviour, IConnectInterfaces, ISerializePreferences, IInterfaceConnector + sealed class WorkspaceModule : MonoBehaviour, IConnectInterfaces, ISerializePreferences { [Serializable] class Preferences @@ -68,8 +68,6 @@ static WorkspaceModule() void Awake() { - ICreateWorkspaceMethods.createWorkspace = CreateWorkspace; - IResetWorkspacesMethods.resetWorkspaceRotations = ResetWorkspaceRotations; preserveWorkspaces = true; } @@ -202,17 +200,6 @@ static void ResetRotation(IWorkspace workspace, Vector3 forward) { workspace.transform.rotation = Quaternion.LookRotation(forward) * DefaultWorkspaceTilt; } - - public void ConnectInterface(object @object, object userData = null) - { - var allWorkspaces = @object as IAllWorkspaces; - if (allWorkspaces != null) - allWorkspaces.allWorkspaces = workspaces; - } - - public void DisconnectInterface(object @object, object userData = null) - { - } } } #endif From 52c96b07d6b065957e46e8d2a27829f1033fe627 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 6 Oct 2017 16:39:01 -0700 Subject: [PATCH 098/457] Add missing ModuleConnectors; Serialization change on exit --- .../Materials/PrimitiveMenuFaceTitleIcon.mat | 2 +- .../FeedbackModuleConnector.cs | 24 +++++++++++++++++ .../FeedbackModuleConnector.cs.meta | 12 +++++++++ .../SerializedPreferencesModuleConnector.cs | 26 +++++++++++++++++++ ...rializedPreferencesModuleConnector.cs.meta | 12 +++++++++ 5 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs.meta create mode 100644 Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs create mode 100644 Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs.meta diff --git a/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat b/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat index 3b88ca4bf..218ae1483 100644 --- a/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat +++ b/Menus/MainMenu/Materials/PrimitiveMenuFaceTitleIcon.mat @@ -6,7 +6,7 @@ Material: m_ObjectHideFlags: 0 m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_Name: MenuFaceTitleIcon + m_Name: PrimitiveMenuFaceTitleIcon m_Shader: {fileID: 4800000, guid: 269bee83d6b662e489c098a4f0d9af32, type: 3} m_ShaderKeywords: _EMISSION _METALLICGLOSSMAP _NORMALMAP m_LightmapFlags: 1 diff --git a/Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs b/Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs new file mode 100644 index 000000000..1854081ac --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs @@ -0,0 +1,24 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class FeedbackModuleConnector : Nested, IInterfaceConnector + { + public void ConnectInterface(object @object, object userData = null) + { + var serializePreferences = @object as IFeedbackReceiver; + if (serializePreferences != null) + evr.GetModule().AddReceiver(serializePreferences); + } + + public void DisconnectInterface(object @object, object userData = null) + { + var serializePreferences = @object as IFeedbackReceiver; + if (serializePreferences != null) + evr.GetModule().RemoveReceiver(serializePreferences); + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs.meta new file mode 100644 index 000000000..df5b294f7 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/FeedbackModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e9b2a7430ba6570408260a19d805898a +timeCreated: 1507324179 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs b/Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs new file mode 100644 index 000000000..5371cf5c6 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs @@ -0,0 +1,26 @@ +#if UNITY_EDITOR && UNITY_EDITORVR +using UnityEditor.Experimental.EditorVR.Modules; + +namespace UnityEditor.Experimental.EditorVR.Core +{ + partial class EditorVR + { + class SerializedPreferencesModuleConnector : Nested, IInterfaceConnector + { + public void ConnectInterface(object @object, object userData = null) + { + var serializePreferences = @object as ISerializePreferences; + if (serializePreferences != null) + evr.GetModule().AddSerializer(serializePreferences); + } + + public void DisconnectInterface(object @object, object userData = null) + { + var serializePreferences = @object as ISerializePreferences; + if (serializePreferences != null) + evr.GetModule().RemoveSerializer(serializePreferences); + } + } + } +} +#endif diff --git a/Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs.meta b/Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs.meta new file mode 100644 index 000000000..7a723f8b8 --- /dev/null +++ b/Scripts/Core/InterfaceConnectors/SerializedPreferencesModuleConnector.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: df28d5adeb31db94bbe4a211ff061a2d +timeCreated: 1507324009 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 4cae9b52ca01ba6bcf9cc4d8d87352d69ad57c97 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Fri, 6 Oct 2017 16:40:33 -0700 Subject: [PATCH 099/457] Fix feedback priority sorting; Add feedback for direct selection; Fix cancel button for direct manipulation --- Scripts/Proxies/TwoHandedProxyBase.cs | 24 +++-- Tools/SelectionTool/SelectionTool.cs | 60 +++++++++-- Tools/TransformTool/TransformTool.cs | 143 +++++++++++++++++++++++--- 3 files changed, 194 insertions(+), 33 deletions(-) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 68eb946af..43cdb98bb 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -17,6 +17,7 @@ public class ProxyFeedbackRequest : FeedbackRequest public VRInputDevice.VRControl control; public Node node; public string tooltipText; + public bool hideExisting; } abstract class TwoHandedProxyBase : MonoBehaviour, IProxy, IFeedbackReceiver, ISetTooltipVisibility, ISetHighlight, IConnectInterfaces @@ -205,16 +206,21 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) foreach (var proxyNode in m_Buttons) { + if (proxyNode.Key != changedRequest.node) + continue; + foreach (var kvp in proxyNode.Value) { + if (kvp.Key != changedRequest.control) + continue; + ProxyFeedbackRequest request = null; foreach (var req in m_FeedbackRequests) { - var matchChanged = req.node == changedRequest.node && req.control == changedRequest.control; - var matchButton = req.node == proxyNode.Key && req.control == kvp.Key; - var sameCaller = req.caller == changedRequest.caller; - var priority = request == null || req.priority >= request.priority; - if (matchButton && priority && (matchChanged || sameCaller)) + if (req.node != proxyNode.Key || req.control != kvp.Key) + continue; + + if (request == null || req.priority >= request.priority) request = req; } @@ -224,12 +230,12 @@ void ExecuteFeedback(ProxyFeedbackRequest changedRequest) foreach (var button in kvp.Value) { if (button.renderer) - this.SetHighlight(button.renderer.gameObject, true, duration: k_FeedbackDuration); + this.SetHighlight(button.renderer.gameObject, !request.hideExisting, duration: k_FeedbackDuration); if (button.transform) { var tooltipText = request.tooltipText; - if (!string.IsNullOrEmpty(tooltipText)) + if (!string.IsNullOrEmpty(tooltipText) || request.hideExisting) { k_TooltipList.Clear(); button.transform.GetComponents(k_TooltipList); @@ -278,9 +284,9 @@ void RemoveFeedbackRequest(ProxyFeedbackRequest request) } } } - m_FeedbackRequests.Remove(request); - ExecuteFeedback(request); + if (m_FeedbackRequests.Remove(request)) + ExecuteFeedback(request); } public void ClearFeedbackRequests(IRequestFeedback caller) diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index e54f45275..71a25d2e2 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -34,9 +34,11 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR Color m_NormalRayColor; Color m_MultiselectRayColor; bool m_MultiSelect; + bool m_HasDirectHover; readonly Dictionary> m_Controls = new Dictionary>(); readonly List m_SelectFeedback = new List(); + readonly List m_DirectSelectFeedback = new List(); readonly Dictionary m_HoverGameObjects = new Dictionary(); @@ -71,8 +73,6 @@ void Start() tooltipTarget.localRotation = k_TooltipRotation; InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); - - ShowSelectFeedback(); } void OnDestroy() @@ -116,12 +116,11 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon { this.SetManipulatorsVisible(this, !m_MultiSelect); - var directSelection = this.GetDirectSelection(); - m_SelectionHoverGameObjects.Clear(); foreach (var linkedObject in linkedObjects) { var selectionTool = (SelectionTool)linkedObject; + selectionTool.m_HasDirectHover = false; // Clear old hover state var selectionRayOrigin = selectionTool.rayOrigin; if (!selectionTool.IsRayActive()) @@ -143,6 +142,8 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } } + var directSelection = this.GetDirectSelection(); + // Unset highlight old hovers var hovers = new Dictionary(m_HoverGameObjects); foreach (var kvp in hovers) @@ -198,6 +199,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon this.SetHighlight(lastHover, false, directRayOrigin); m_HoverGameObjects[directRayOrigin] = directHoveredObject; + selectionTool.m_HasDirectHover = true; } // Set highlight on new hovers @@ -207,13 +209,16 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } } - if (!this.IsRayVisible(rayOrigin)) - HideSelectFeedback(); - else if (m_SelectFeedback.Count == 0) - ShowSelectFeedback(); + if (!m_HasDirectHover) + HideDirectSelectFeedback(); + else if (m_DirectSelectFeedback.Count == 0) + ShowDirectSelectFeedback(); if (!IsRayActive()) + { + HideSelectFeedback(); return; + } // Need to call GetFirstGameObject a second time because we do not guarantee shared updater executes first var hoveredObject = this.GetFirstGameObject(rayOrigin); @@ -222,7 +227,15 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon hovered(hoveredObject, rayOrigin); if (!GetSelectionCandidate(ref hoveredObject)) + { + HideSelectFeedback(); return; + } + + if (!hoveredObject) + HideSelectFeedback(); + else if (m_SelectFeedback.Count == 0) + ShowSelectFeedback(); // Capture object on press if (m_SelectionInput.select.wasJustPressed) @@ -331,6 +344,28 @@ void ShowSelectFeedback() } } + void ShowDirectSelectFeedback() + { + foreach (var control in m_Controls) + { + if (control.Key != "Select") + continue; + + foreach (var id in control.Value) + { + var request = new ProxyFeedbackRequest + { + node = node, + control = id, + tooltipText = "Direct Select" + }; + + this.AddFeedbackRequest(request); + m_DirectSelectFeedback.Add(request); + } + } + } + void HideSelectFeedback() { foreach (var request in m_SelectFeedback) @@ -339,6 +374,15 @@ void HideSelectFeedback() } m_SelectFeedback.Clear(); } + + void HideDirectSelectFeedback() + { + foreach (var request in m_DirectSelectFeedback) + { + this.RemoveFeedbackRequest(request); + } + m_DirectSelectFeedback.Clear(); + } } } #endif diff --git a/Tools/TransformTool/TransformTool.cs b/Tools/TransformTool/TransformTool.cs index d9d2c7369..458e7bcb8 100644 --- a/Tools/TransformTool/TransformTool.cs +++ b/Tools/TransformTool/TransformTool.cs @@ -4,6 +4,7 @@ using System.Linq; using UnityEditor.Experimental.EditorVR.Core; using UnityEditor.Experimental.EditorVR.Manipulators; +using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; using UnityEngine.InputNew; @@ -13,7 +14,7 @@ namespace UnityEditor.Experimental.EditorVR.Tools sealed class TransformTool : MonoBehaviour, ITool, ITransformer, ISelectionChanged, IActions, IUsesDirectSelection, IGrabObjects, ISelectObject, IManipulatorController, IUsesSnapping, ISetHighlight, ILinkedObject, IRayToNode, IControlHaptics, IUsesRayOrigin, IUsesNode, ICustomActionMap, ITwoHandedScaler, IIsMainMenuVisible, - IGetRayVisibility, IRayVisibilitySettings + IGetRayVisibility, IRayVisibilitySettings, IRequestFeedback { const float k_LazyFollowTranslate = 8f; const float k_LazyFollowRotate = 12f; @@ -216,6 +217,10 @@ public List actions TransformInput m_Input; + readonly Dictionary> m_Controls = new Dictionary>(); + readonly List m_GrabFeedback = new List(); + readonly List m_ScaleFeedback = new List(); + readonly TransformAction m_PivotModeToggleAction = new TransformAction(); readonly TransformAction m_PivotRotationToggleAction = new TransformAction(); readonly TransformAction m_ManipulatorToggleAction = new TransformAction(); @@ -264,6 +269,8 @@ void Start() m_ScaleManipulator = CreateManipulator(m_ScaleManipulatorPrefab); m_CurrentManipulator = m_StandardManipulator; + + InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); } public void OnSelectionChanged() @@ -308,6 +315,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (manipulatorGameObject.activeSelf && (hoveringSelection || hasLeft || hasRight)) manipulatorGameObject.SetActive(false); + var scaleHover = false; foreach (var kvp in directSelection) { var directRayOrigin = kvp.Key; @@ -339,6 +347,28 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (transformTool == null) continue; + // Check if the other hand is already grabbing for two-handed scale + var otherNode = Node.None; + GrabData otherGrabData = null; + foreach (var grabData in m_GrabData) + { + var key = grabData.Key; + var value = grabData.Value; + if (key != grabbingNode && value.grabbedObjects.Contains(directHoveredObject.transform)) + { + otherNode = key; + otherGrabData = value; + break; + } + } + + if (otherGrabData != null) + { + scaleHover = true; + if (m_ScaleFeedback.Count == 0) + ShowScaleFeedback(grabbingNode); + } + var transformInput = transformTool.m_Input; if (transformInput.select.wasJustPressed) @@ -347,20 +377,12 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon consumeControl(transformInput.select); - // Check if the other hand is already grabbing for two-handed scale - foreach (var grabData in m_GrabData) + if (otherGrabData != null) { - var otherNode = grabData.Key; - var otherData = grabData.Value; - - if (otherNode != grabbingNode && otherData.grabbedObjects.Contains(directHoveredObject.transform)) - { - m_ScaleStartDistance = (directRayOrigin.position - otherData.rayOrigin.position).magnitude; - m_ScaleFirstNode = otherNode; - otherData.StartScaling(); - m_Scaling = true; - break; - } + m_ScaleStartDistance = (directRayOrigin.position - otherGrabData.rayOrigin.position).magnitude; + m_ScaleFirstNode = otherNode; + otherGrabData.StartScaling(); + m_Scaling = true; } var grabbedObjects = new HashSet { directHoveredObject.transform }; @@ -370,6 +392,7 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon objectsGrabbed(directRayOrigin, grabbedObjects); m_GrabData[grabbingNode] = new GrabData(directRayOrigin, transformInput, grabbedObjects.ToArray()); + ShowGrabFeedback(grabbingNode); // A direct selection has been made. Hide the manipulator until the selection changes m_DirectSelected = true; @@ -378,6 +401,9 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } } + if (!scaleHover) + HideScaleFeedback(); + GrabData leftData; hasLeft = m_GrabData.TryGetValue(Node.LeftHand, out leftData); @@ -391,11 +417,14 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (hasLeft) { + consumeControl(leftInput.cancel); if (leftInput.cancel.wasJustPressed) { DropHeldObjects(Node.LeftHand); + if (m_Scaling) + DropHeldObjects(Node.RightHand); + hasLeft = false; - consumeControl(leftInput.cancel); Undo.PerformUndo(); } @@ -409,11 +438,14 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon if (hasRight) { + consumeControl(rightInput.cancel); if (rightInput.cancel.wasJustPressed) { DropHeldObjects(Node.RightHand); + if (m_Scaling) + DropHeldObjects(Node.LeftHand); + hasRight = false; - consumeControl(rightInput.cancel); Undo.PerformUndo(); } @@ -583,6 +615,8 @@ public void DropHeldObjects(Node node) m_GrabData.Remove(node); + HideGrabFeedback(); + this.RemoveRayVisibilitySettings(grabData.rayOrigin, this); this.ClearSnappingState(rayOrigin); @@ -738,6 +772,83 @@ public bool IsTwoHandedScaling(Transform rayOrigin) { return m_Scaling && m_GrabData.Any(kvp => kvp.Value.rayOrigin == rayOrigin); } + + void ShowGrabFeedback(Node node) + { + List ids; + if (m_Controls.TryGetValue("Cancel", out ids)) + { + foreach (var id in ids) + { + var request = new ProxyFeedbackRequest + { + node = node, + control = id, + tooltipText = "Cancel", + priority = 1 + }; + + this.AddFeedbackRequest(request); + m_GrabFeedback.Add(request); + } + } + + if (m_Controls.TryGetValue("Select", out ids)) + { + foreach (var id in ids) + { + var request = new ProxyFeedbackRequest + { + node = node, + control = id, + priority = 1, + hideExisting = true + }; + + this.AddFeedbackRequest(request); + m_GrabFeedback.Add(request); + } + } + } + + void HideGrabFeedback() + { + foreach (var request in m_GrabFeedback) + { + this.RemoveFeedbackRequest(request); + } + m_GrabFeedback.Clear(); + } + + void ShowScaleFeedback(Node node) + { + List ids; + if (m_Controls.TryGetValue("Select", out ids)) + { + foreach (var id in ids) + { + var request = new ProxyFeedbackRequest + { + node = node, + control = id, + tooltipText = "Scale", + priority = 1 + }; + + this.AddFeedbackRequest(request); + m_ScaleFeedback.Add(request); + } + } + } + + void HideScaleFeedback() + { + foreach (var request in m_ScaleFeedback) + { + this.RemoveFeedbackRequest(request); + } + m_ScaleFeedback.Clear(); + } } } #endif From b8eb784726d0736af1f80a8e2ca6de0a11595e85 Mon Sep 17 00:00:00 2001 From: Matt Schoen Date: Mon, 9 Oct 2017 09:52:19 -0700 Subject: [PATCH 100/457] PR feedback --- Scripts/Proxies/ProxyAnimator.cs | 20 ++---------- Scripts/Proxies/TwoHandedProxyBase.cs | 46 +++++++++++---------------- Scripts/Proxies/ViveProxy.cs | 2 +- 3 files changed, 23 insertions(+), 45 deletions(-) diff --git a/Scripts/Proxies/ProxyAnimator.cs b/Scripts/Proxies/ProxyAnimator.cs index 75ab637d6..645189dbf 100644 --- a/Scripts/Proxies/ProxyAnimator.cs +++ b/Scripts/Proxies/ProxyAnimator.cs @@ -16,22 +16,6 @@ public class TransformInfo public Vector3 positionOffset; public Vector3 rotationOffset; - public void ResetOffsets() - { - positionOffset = Vector3.zero; - rotationOffset = Vector3.zero; - } - - public void ResetPositionOffset() - { - positionOffset = Vector3.zero; - } - - public void ResetRotationOffset() - { - rotationOffset = Vector3.zero; - } - public void Apply(Transform transform) { transform.localPosition = initialPosition + positionOffset; @@ -103,7 +87,9 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon foreach (var kvp in m_TransformInfos) { - kvp.Value.ResetOffsets(); + var transformInfo = kvp.Value; + transformInfo.positionOffset = Vector3.zero; + transformInfo.rotationOffset = Vector3.zero; } for (var i = 0; i < length; i++) diff --git a/Scripts/Proxies/TwoHandedProxyBase.cs b/Scripts/Proxies/TwoHandedProxyBase.cs index 68eb946af..c5d68cb43 100644 --- a/Scripts/Proxies/TwoHandedProxyBase.cs +++ b/Scripts/Proxies/TwoHandedProxyBase.cs @@ -98,33 +98,8 @@ public virtual void Awake() ObjectUtils.Destroy(tooltip); } - var leftButtons = new Dictionary>(); - foreach (var button in leftProxyHelper.buttons) - { - List buttons; - if (!leftButtons.TryGetValue(button.control, out buttons)) - { - buttons = new List(); - leftButtons[button.control] = buttons; - } - - buttons.Add(button); - } - m_Buttons[Node.LeftHand] = leftButtons; - - var rightButtons = new Dictionary>(); - foreach (var button in rightProxyHelper.buttons) - { - List buttons; - if (!rightButtons.TryGetValue(button.control, out buttons)) - { - buttons = new List(); - rightButtons[button.control] = buttons; - } - - buttons.Add(button); - } - m_Buttons[Node.RightHand] = rightButtons; + m_Buttons[Node.LeftHand] = GetButtonDictionary(leftProxyHelper); + m_Buttons[Node.RightHand] = GetButtonDictionary(rightProxyHelper); m_RayOrigins = new Dictionary { @@ -157,6 +132,23 @@ public virtual void Awake() }; } + static Dictionary> GetButtonDictionary(ProxyHelper helper) + { + var buttonDictionary = new Dictionary>(); + foreach (var button in helper.buttons) + { + List buttons; + if (!buttonDictionary.TryGetValue(button.control, out buttons)) + { + buttons = new List(); + buttonDictionary[button.control] = buttons; + } + + buttons.Add(button); + } + return buttonDictionary; + } + public virtual IEnumerator Start() { while (!active) diff --git a/Scripts/Proxies/ViveProxy.cs b/Scripts/Proxies/ViveProxy.cs index 1a466da00..c58cbcaa2 100644 --- a/Scripts/Proxies/ViveProxy.cs +++ b/Scripts/Proxies/ViveProxy.cs @@ -51,7 +51,7 @@ static void PostAnimate(ProxyHelper.ButtonObject[] buttons, Dictionary Date: Mon, 9 Oct 2017 15:12:31 -0700 Subject: [PATCH 101/457] PR feedback --- Scripts/Core/EditorVR.UI.cs | 18 ++++++++---------- Scripts/Core/EditorVR.Viewer.cs | 5 +---- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Scripts/Core/EditorVR.UI.cs b/Scripts/Core/EditorVR.UI.cs index 91f2cab88..317bd385e 100644 --- a/Scripts/Core/EditorVR.UI.cs +++ b/Scripts/Core/EditorVR.UI.cs @@ -129,16 +129,14 @@ void SetManipulatorsVisible(ISetManipulatorsVisible setter, bool visible) bool GetManipulatorDragState() { - var controllerCounter = 0; - while (controllerCounter < m_ManipulatorControllers.Count) - { - if (m_ManipulatorControllers[controllerCounter].manipulatorDragging) - { - return true; - } - controllerCounter++; - } - return false; + foreach (var currentController in m_ManipulatorControllers) + { + if (currentController.manipulatorDragging) + { + return true; + } + } + return false; } internal void UpdateManipulatorVisibilites() diff --git a/Scripts/Core/EditorVR.Viewer.cs b/Scripts/Core/EditorVR.Viewer.cs index 4464dfaed..5c3ef4211 100644 --- a/Scripts/Core/EditorVR.Viewer.cs +++ b/Scripts/Core/EditorVR.Viewer.cs @@ -204,14 +204,11 @@ static bool Overlaps(Transform rayOrigin, Collider trigger) var radius = DirectSelection.GetPointerLength(rayOrigin); var totalColliders = Physics.OverlapSphereNonAlloc(rayOrigin.position, radius, s_CachedColliders, -1, QueryTriggerInteraction.Collide); - var colliderIndex = 0; - while (colliderIndex < totalColliders) + for (var colliderIndex = 0; colliderIndex < totalColliders; colliderIndex++ ) { if (s_CachedColliders[colliderIndex] == trigger) return true; - - colliderIndex++; } return false; From 29dbacc835155dbcda23c2352ee567a3fa0c2daf Mon Sep 17 00:00:00 2001 From: Dylan Urquidi Date: Mon, 9 Oct 2017 15:24:51 -0700 Subject: [PATCH 102/457] Rollback SelectionTool to original Feedback branch state. --- Tools/SelectionTool/SelectionTool.cs | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/Tools/SelectionTool/SelectionTool.cs b/Tools/SelectionTool/SelectionTool.cs index e4dcda2c4..eb4a5f2bc 100644 --- a/Tools/SelectionTool/SelectionTool.cs +++ b/Tools/SelectionTool/SelectionTool.cs @@ -1,10 +1,8 @@ #if UNITY_EDITOR using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.EditorVR.Core; -using UnityEditor.Experimental.EditorVR.Extensions; using UnityEditor.Experimental.EditorVR.Proxies; using UnityEditor.Experimental.EditorVR.Utilities; using UnityEngine; @@ -36,8 +34,6 @@ sealed class SelectionTool : MonoBehaviour, ITool, IUsesRayOrigin, IUsesRaycastR Color m_NormalRayColor; Color m_MultiselectRayColor; bool m_MultiSelect; - bool m_RayWasHidden; - Coroutine m_ShowFeedbackRequestsCoroutine; readonly Dictionary> m_Controls = new Dictionary>(); readonly List m_SelectFeedback = new List(); @@ -75,7 +71,7 @@ void Start() InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls); - this.RestartCoroutine(ref m_ShowFeedbackRequestsCoroutine, ShowThenHideFeedbackRequests()); + ShowSelectFeedback(); } void OnDestroy() @@ -211,15 +207,9 @@ public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeCon } if (!this.IsRayVisible(rayOrigin)) - { HideSelectFeedback(); - m_RayWasHidden = true; - } - else if (m_RayWasHidden && m_SelectFeedback.Count == 0) - { - m_RayWasHidden = false; - this.RestartCoroutine(ref m_ShowFeedbackRequestsCoroutine, ShowThenHideFeedbackRequests()); - } + else if (m_SelectFeedback.Count == 0) + ShowSelectFeedback(); if (!IsRayActive()) return; @@ -307,15 +297,6 @@ bool IsRayActive() return true; } - IEnumerator ShowThenHideFeedbackRequests() - { - ShowSelectFeedback(); - - yield return new WaitForSeconds(4); - - HideSelectFeedback(); - } - void OnDisable() { foreach (var kvp in m_HoverGameObjects) @@ -323,8 +304,6 @@ void OnDisable() this.SetHighlight(kvp.Value, false, kvp.Key); } m_HoverGameObjects.Clear(); - - HideSelectFeedback(); } public void OnResetDirectSelectionState() { } From 12602be46aa0e86cd024b9013079826a2d58fdda Mon Sep 17 00:00:00 2001 From: andrewm Date: Mon, 9 Oct 2017 16:19:45 -0700 Subject: [PATCH 103/457] Resharper->Edit->Reformat Code (Actions) --- Actions/BaseAction.cs | 27 +++++++++--------- Actions/Clone.cs | 43 ++++++++++++++-------------- Actions/Copy.cs | 23 ++++++++------- Actions/Cut.cs | 41 ++++++++++++++------------- Actions/Delete.cs | 31 ++++++++++---------- Actions/OpenScene.cs | 17 +++++------ Actions/Paste.cs | 63 +++++++++++++++++++++-------------------- Actions/Play.cs | 23 ++++++++------- Actions/Redo.cs | 21 ++++++++------ Actions/SaveScene.cs | 17 +++++------ Actions/SelectParent.cs | 45 +++++++++++++++-------------- Actions/Undo.cs | 21 ++++++++------ AssemblyInfo.cs | 3 +- 13 files changed, 199 insertions(+), 176 deletions(-) diff --git a/Actions/BaseAction.cs b/Actions/BaseAction.cs index 35fe35564..76e14405b 100644 --- a/Actions/BaseAction.cs +++ b/Actions/BaseAction.cs @@ -3,20 +3,21 @@ namespace UnityEditor.Experimental.EditorVR.Actions { - /// - /// A convenience class for simple action implementations - /// - abstract class BaseAction : MonoBehaviour, IAction - { - public Sprite icon - { - get { return m_Icon; } - } + /// + /// A convenience class for simple action implementations + /// + abstract class BaseAction : MonoBehaviour, IAction + { + public Sprite icon + { + get { return m_Icon; } + } - [SerializeField] - Sprite m_Icon; + [SerializeField] + Sprite m_Icon; - public abstract void ExecuteAction(); - } + public abstract void ExecuteAction(); + } } + #endif diff --git a/Actions/Clone.cs b/Actions/Clone.cs index 035f18972..59a2b29db 100644 --- a/Actions/Clone.cs +++ b/Actions/Clone.cs @@ -4,26 +4,27 @@ namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Clone", ActionMenuItemAttribute.DefaultActionSectionName, 3)] - sealed class Clone : BaseAction, IUsesSpatialHash, IUsesViewerScale - { - public override void ExecuteAction() - { - Unsupported.DuplicateGameObjectsUsingPasteboard(); - var selection = Selection.transforms; - var bounds = ObjectUtils.GetBounds(selection); - foreach (var s in selection) - { - var clone = s.gameObject; - clone.hideFlags = HideFlags.None; - var cloneTransform = clone.transform; - var cameraTransform = CameraUtils.GetMainCamera().transform; - var viewDirection = cloneTransform.position - cameraTransform.position; - cloneTransform.position = cameraTransform.TransformPoint(Vector3.forward * viewDirection.magnitude / this.GetViewerScale()) - + cloneTransform.position - bounds.center; - this.AddToSpatialHash(clone); - } - } - } + [ActionMenuItem("Clone", ActionMenuItemAttribute.DefaultActionSectionName, 3)] + sealed class Clone : BaseAction, IUsesSpatialHash, IUsesViewerScale + { + public override void ExecuteAction() + { + Unsupported.DuplicateGameObjectsUsingPasteboard(); + var selection = Selection.transforms; + var bounds = ObjectUtils.GetBounds(selection); + foreach (var s in selection) + { + var clone = s.gameObject; + clone.hideFlags = HideFlags.None; + var cloneTransform = clone.transform; + var cameraTransform = CameraUtils.GetMainCamera().transform; + var viewDirection = cloneTransform.position - cameraTransform.position; + cloneTransform.position = cameraTransform.TransformPoint(Vector3.forward * viewDirection.magnitude / this.GetViewerScale()) + + cloneTransform.position - bounds.center; + this.AddToSpatialHash(clone); + } + } + } } + #endif diff --git a/Actions/Copy.cs b/Actions/Copy.cs index ff0fb4f8e..808ad32e2 100644 --- a/Actions/Copy.cs +++ b/Actions/Copy.cs @@ -1,14 +1,17 @@ -#if UNITY_EDITOR + +#if UNITY_EDITOR + namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Copy", ActionMenuItemAttribute.DefaultActionSectionName, 5)] - sealed class Copy : BaseAction - { - public override void ExecuteAction() - { - Unsupported.CopyGameObjectsToPasteboard(); - Paste.SetBufferDistance(Selection.transforms); - } - } + [ActionMenuItem("Copy", ActionMenuItemAttribute.DefaultActionSectionName, 5)] + sealed class Copy : BaseAction + { + public override void ExecuteAction() + { + Unsupported.CopyGameObjectsToPasteboard(); + Paste.SetBufferDistance(Selection.transforms); + } + } } + #endif diff --git a/Actions/Cut.cs b/Actions/Cut.cs index d53b2e798..8d06335c1 100644 --- a/Actions/Cut.cs +++ b/Actions/Cut.cs @@ -3,27 +3,28 @@ namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Cut", ActionMenuItemAttribute.DefaultActionSectionName, 4)] - sealed class Cut : BaseAction - { - public override void ExecuteAction() - { - var selection = Selection.transforms; - if (selection != null) - { - Unsupported.CopyGameObjectsToPasteboard(); - Paste.SetBufferDistance(Selection.transforms); + [ActionMenuItem("Cut", ActionMenuItemAttribute.DefaultActionSectionName, 4)] + sealed class Cut : BaseAction + { + public override void ExecuteAction() + { + var selection = Selection.transforms; + if (selection != null) + { + Unsupported.CopyGameObjectsToPasteboard(); + Paste.SetBufferDistance(Selection.transforms); - foreach (var transform in selection) - { - var go = transform.gameObject; - go.hideFlags = HideFlags.HideAndDontSave; - go.SetActive(false); - } + foreach (var transform in selection) + { + var go = transform.gameObject; + go.hideFlags = HideFlags.HideAndDontSave; + go.SetActive(false); + } - Selection.activeGameObject = null; - } - } - } + Selection.activeGameObject = null; + } + } + } } + #endif diff --git a/Actions/Delete.cs b/Actions/Delete.cs index b0c16e951..f2afca60a 100644 --- a/Actions/Delete.cs +++ b/Actions/Delete.cs @@ -5,22 +5,23 @@ namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Delete", ActionMenuItemAttribute.DefaultActionSectionName, 7)] - sealed class Delete : BaseAction, IDeleteSceneObject - { - public Action addToSpatialHash { private get; set; } - public Action removeFromSpatialHash { private get; set; } + [ActionMenuItem("Delete", ActionMenuItemAttribute.DefaultActionSectionName, 7)] + sealed class Delete : BaseAction, IDeleteSceneObject + { + public Action addToSpatialHash { private get; set; } + public Action removeFromSpatialHash { private get; set; } - public override void ExecuteAction() - { - var gameObjects = Selection.gameObjects; - foreach (var go in gameObjects) - { - this.DeleteSceneObject(go); - } + public override void ExecuteAction() + { + var gameObjects = Selection.gameObjects; + foreach (var go in gameObjects) + { + this.DeleteSceneObject(go); + } - Selection.activeGameObject = null; - } - } + Selection.activeGameObject = null; + } + } } + #endif diff --git a/Actions/OpenScene.cs b/Actions/OpenScene.cs index 3da587fcc..2544540ff 100644 --- a/Actions/OpenScene.cs +++ b/Actions/OpenScene.cs @@ -3,13 +3,14 @@ namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("OpenScene", "Scene")] - sealed class OpenScene : BaseAction - { - public override void ExecuteAction() - { - Debug.LogError("ExecuteAction Action should open a sub-panel showing available scenes to open, if any are found"); - } - } + [ActionMenuItem("OpenScene", "Scene")] + sealed class OpenScene : BaseAction + { + public override void ExecuteAction() + { + Debug.LogError("ExecuteAction Action should open a sub-panel showing available scenes to open, if any are found"); + } + } } + #endif diff --git a/Actions/Paste.cs b/Actions/Paste.cs index 4c09d6138..1770a7756 100644 --- a/Actions/Paste.cs +++ b/Actions/Paste.cs @@ -4,39 +4,40 @@ namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Paste", ActionMenuItemAttribute.DefaultActionSectionName, 6)] - sealed class Paste : BaseAction, IUsesSpatialHash, IUsesViewerScale - { - static float s_BufferDistance; + [ActionMenuItem("Paste", ActionMenuItemAttribute.DefaultActionSectionName, 6)] + sealed class Paste : BaseAction, IUsesSpatialHash, IUsesViewerScale + { + static float s_BufferDistance; - public static void SetBufferDistance(Transform[] transforms) - { - if (transforms != null) - { - var bounds = ObjectUtils.GetBounds(transforms); + public static void SetBufferDistance(Transform[] transforms) + { + if (transforms != null) + { + var bounds = ObjectUtils.GetBounds(transforms); - s_BufferDistance = bounds.size != Vector3.zero ? (bounds.center - CameraUtils.GetMainCamera().transform.position).magnitude : 1f; - s_BufferDistance /= IUsesViewerScaleMethods.getViewerScale(); // Normalize this value in case viewer scale changes before paste happens - } - } + s_BufferDistance = bounds.size != Vector3.zero ? (bounds.center - CameraUtils.GetMainCamera().transform.position).magnitude : 1f; + s_BufferDistance /= IUsesViewerScaleMethods.getViewerScale(); // Normalize this value in case viewer scale changes before paste happens + } + } - public override void ExecuteAction() - { - Unsupported.PasteGameObjectsFromPasteboard(); - var transforms = Selection.transforms; - var bounds = ObjectUtils.GetBounds(transforms); - foreach (var transform in transforms) - { - var pasted = transform.gameObject; - var pastedTransform = pasted.transform; - pasted.hideFlags = HideFlags.None; - var cameraTransform = CameraUtils.GetMainCamera().transform; - pastedTransform.position = cameraTransform.TransformPoint(Vector3.forward * s_BufferDistance) - + pastedTransform.position - bounds.center; - pasted.SetActive(true); - this.AddToSpatialHash(pasted); - } - } - } + public override void ExecuteAction() + { + Unsupported.PasteGameObjectsFromPasteboard(); + var transforms = Selection.transforms; + var bounds = ObjectUtils.GetBounds(transforms); + foreach (var transform in transforms) + { + var pasted = transform.gameObject; + var pastedTransform = pasted.transform; + pasted.hideFlags = HideFlags.None; + var cameraTransform = CameraUtils.GetMainCamera().transform; + pastedTransform.position = cameraTransform.TransformPoint(Vector3.forward * s_BufferDistance) + + pastedTransform.position - bounds.center; + pasted.SetActive(true); + this.AddToSpatialHash(pasted); + } + } + } } + #endif diff --git a/Actions/Play.cs b/Actions/Play.cs index d1b95b6ab..beca2382c 100644 --- a/Actions/Play.cs +++ b/Actions/Play.cs @@ -1,15 +1,18 @@ -#if UNITY_EDITOR + +#if UNITY_EDITOR + namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Play")] - sealed class Play : BaseAction - { - public override void ExecuteAction() - { + [ActionMenuItem("Play")] + sealed class Play : BaseAction + { + public override void ExecuteAction() + { #if UNITY_EDITOR - EditorApplication.isPlaying = true; + EditorApplication.isPlaying = true; #endif - } - } + } + } } -#endif \ No newline at end of file + +#endif diff --git a/Actions/Redo.cs b/Actions/Redo.cs index 59ebff6ab..ec86a0c7a 100644 --- a/Actions/Redo.cs +++ b/Actions/Redo.cs @@ -1,15 +1,18 @@ -#if UNITY_EDITOR + +#if UNITY_EDITOR + namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Redo", ActionMenuItemAttribute.DefaultActionSectionName, 1)] - sealed class Redo : BaseAction - { - public override void ExecuteAction() - { + [ActionMenuItem("Redo", ActionMenuItemAttribute.DefaultActionSectionName, 1)] + sealed class Redo : BaseAction + { + public override void ExecuteAction() + { #if UNITY_EDITOR - UnityEditor.Undo.PerformRedo(); + UnityEditor.Undo.PerformRedo(); #endif - } - } + } + } } + #endif diff --git a/Actions/SaveScene.cs b/Actions/SaveScene.cs index 1b84eb441..c6ec5d679 100644 --- a/Actions/SaveScene.cs +++ b/Actions/SaveScene.cs @@ -3,13 +3,14 @@ namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("SaveScene", "Scene")] - sealed class SaveScene : BaseAction - { - public override void ExecuteAction() - { - Debug.LogError("ExecuteAction Action should save a scene here"); - } - } + [ActionMenuItem("SaveScene", "Scene")] + sealed class SaveScene : BaseAction + { + public override void ExecuteAction() + { + Debug.LogError("ExecuteAction Action should save a scene here"); + } + } } + #endif diff --git a/Actions/SelectParent.cs b/Actions/SelectParent.cs index 6f401b127..f5cf9de05 100644 --- a/Actions/SelectParent.cs +++ b/Actions/SelectParent.cs @@ -1,25 +1,28 @@ -#if UNITY_EDITOR + +#if UNITY_EDITOR + namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("SelectParent", ActionMenuItemAttribute.DefaultActionSectionName, 8)] - sealed class SelectParent : BaseAction - { - public override void ExecuteAction() - { - var go = Selection.activeGameObject; - if (go != null) - { - var parent = go.transform.parent; - if (parent != null) - { - var parentGO = parent.gameObject; - if (parentGO) - { - Selection.activeGameObject = parentGO; - } - } - } - } - } + [ActionMenuItem("SelectParent", ActionMenuItemAttribute.DefaultActionSectionName, 8)] + sealed class SelectParent : BaseAction + { + public override void ExecuteAction() + { + var go = Selection.activeGameObject; + if (go != null) + { + var parent = go.transform.parent; + if (parent != null) + { + var parentGO = parent.gameObject; + if (parentGO) + { + Selection.activeGameObject = parentGO; + } + } + } + } + } } + #endif diff --git a/Actions/Undo.cs b/Actions/Undo.cs index f44cca637..40eef3dbd 100644 --- a/Actions/Undo.cs +++ b/Actions/Undo.cs @@ -1,15 +1,18 @@ -#if UNITY_EDITOR + +#if UNITY_EDITOR + namespace UnityEditor.Experimental.EditorVR.Actions { - [ActionMenuItem("Undo", ActionMenuItemAttribute.DefaultActionSectionName, 2)] - sealed class Undo : BaseAction - { - public override void ExecuteAction() - { + [ActionMenuItem("Undo", ActionMenuItemAttribute.DefaultActionSectionName, 2)] + sealed class Undo : BaseAction + { + public override void ExecuteAction() + { #if UNITY_EDITOR - UnityEditor.Undo.PerformUndo(); + UnityEditor.Undo.PerformUndo(); #endif - } - } + } + } } + #endif diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs index 9117af98a..9024bb9dd 100644 --- a/AssemblyInfo.cs +++ b/AssemblyInfo.cs @@ -3,5 +3,6 @@ // This is necessary to allow cross-communication between assemblies for classes in the UnityEditor.Experimental.EditorVR // namespace; The plan is that all code will eventually be within a single assembly. + [assembly: InternalsVisibleTo("Assembly-CSharp-Editor")] -#endif \ No newline at end of file +#endif From 5d3a3b54ab9743cf20c843d3dd52b6d01b7a7a82 Mon Sep 17 00:00:00 2001 From: andrewm Date: Mon, 9 Oct 2017 16:21:24 -0700 Subject: [PATCH 104/457] Resharper->Edit->Reformat Code (Manipulators) --- Manipulators/BaseManipulator.cs | 604 ++++++++++++++-------------- Manipulators/DirectManipulator.cs | 177 ++++---- Manipulators/ScaleManipulator.cs | 57 +-- Manipulators/StandardManipulator.cs | 169 ++++---- 4 files changed, 505 insertions(+), 502 deletions(-) diff --git a/Manipulators/BaseManipulator.cs b/Manipulators/BaseManipulator.cs index 8bc82a50a..d0e2a4537 100644 --- a/Manipulators/BaseManipulator.cs +++ b/Manipulators/BaseManipulator.cs @@ -7,307 +7,307 @@ namespace UnityEditor.Experimental.EditorVR.Manipulators { - class BaseManipulator : MonoBehaviour, IManipulator - { - protected const float k_BaseManipulatorSize = 0.3f; - const float k_MinHandleTipDirectionDelta = 0.01f; - const float k_LazyFollow = 40f; - - class HandleTip - { - public Renderer renderer; - public float direction = 1; - public Vector3 lastPosition; - public Vector3? positionOffset; - } - - [SerializeField] - Renderer m_HandleTip; - - [SerializeField] - protected List m_AllHandles; - - [SerializeField] - float m_LinearHandleScaleBump = 1.8f; - - [SerializeField] - float m_PlaneHandleScaleBump = 1.2f; - - [SerializeField] - float m_SphereHandleScaleBump = 1.1f; - - [SerializeField] - float m_HandleAlpha = 0.4f; - - [SerializeField] - float m_HandleHoverAlpha = 0.8f; - - readonly Dictionary m_ScaleBumps = new Dictionary(); - readonly Dictionary m_HandleTips = new Dictionary(); - - public bool adjustScaleForCamera { get; set; } - - public Action translate { protected get; set; } - public Action rotate { protected get; set; } - public Action scale { protected get; set; } - - public bool dragging { get; protected set; } - public event Action dragStarted; - public event Action dragEnded; - - void Awake() - { - m_ScaleBumps[typeof(LinearHandle)] = m_LinearHandleScaleBump; - m_ScaleBumps[typeof(PlaneHandle)] = m_PlaneHandleScaleBump; - m_ScaleBumps[typeof(SphereHandle)] = m_SphereHandleScaleBump; - - foreach (var handle in m_AllHandles) - { - MaterialUtils.CloneMaterials(handle.GetComponent()); - - handle.hoverStarted += OnHandleHoverStarted; - handle.hovering += OnHandleHovering; - handle.hoverEnded += OnHandleHoverEnded; - - - handle.dragStarted += OnHandleDragStarted; - handle.dragging += OnHandleDragging; - handle.dragEnded += OnHandleDragEnded; - } - } - - protected virtual void OnEnable() - { - if (adjustScaleForCamera) - Camera.onPreRender += OnCameraPreRender; - } - - protected virtual void OnDisable() - { - Camera.onPreRender -= OnCameraPreRender; - - foreach (var kvp in m_HandleTips) - { - kvp.Value.renderer.gameObject.SetActive(false); - } - } - - void OnDestroy() - { - foreach (var handle in m_AllHandles) - { - ObjectUtils.Destroy(handle.GetComponent().sharedMaterial); - } - } - - protected virtual void ShowHoverState(BaseHandle handle, bool hovering) - { - var type = handle.GetType(); - float scaleBump; - if (m_ScaleBumps.TryGetValue(type, out scaleBump)) - handle.transform.localScale = hovering ? handle.transform.localScale * scaleBump : handle.transform.localScale / scaleBump; - - var handleRenderer = handle.GetComponent(); - var material = handleRenderer.sharedMaterial; - var color = material.color; - color.a = hovering ? m_HandleHoverAlpha : m_HandleAlpha; - material.color = color; - } - - void OnCameraPreRender(Camera camera) - { - AdjustScale(camera.transform.position, camera.worldToCameraMatrix); - } - - public void AdjustScale(Vector3 cameraPosition, Matrix4x4 worldToCameraMatrix) - { - var originalCameraPosition = cameraPosition; - - // Adjust size of manipulator while accounting for any non-standard cameras (e.g. scaling applied to the camera) - var manipulatorPosition = worldToCameraMatrix.MultiplyPoint3x4(transform.position); - cameraPosition = worldToCameraMatrix.MultiplyPoint3x4(cameraPosition); - var delta = worldToCameraMatrix.inverse.MultiplyPoint3x4(cameraPosition - manipulatorPosition) - originalCameraPosition; - transform.localScale = Vector3.one * delta.magnitude * k_BaseManipulatorSize; - } - - protected virtual void UpdateHandleTip(BaseHandle handle, HandleEventData eventData, bool active) - { - var rayOrigin = eventData.rayOrigin; - HandleTip handleTip; - Renderer handleTipRenderer; - if (!m_HandleTips.TryGetValue(rayOrigin, out handleTip)) - { - handleTipRenderer = m_HandleTip; - if (m_HandleTips.Count > 0) - handleTipRenderer = ObjectUtils.Instantiate(handleTipRenderer.gameObject, transform).GetComponent(); - - handleTip = new HandleTip { renderer = handleTipRenderer }; - m_HandleTips[rayOrigin] = handleTip; - } - else - { - handleTipRenderer = handleTip.renderer; - } - - active = active && (handle is LinearHandle || handle is RadialHandle); - - var handleTipGameObject = handleTipRenderer.gameObject; - var wasActive = handleTipGameObject.activeSelf; - handleTipGameObject.SetActive(active); - var handleTipTransform = handleTipRenderer.transform; - - if (active) // Reposition handle tip based on current raycast position when hovering or dragging - { - handleTipRenderer.sharedMaterial = handle.GetComponent().sharedMaterial; - - var handleTransform = handle.transform; - var handleTipPosition = handleTipTransform.position; - var distanceFromRayOrigin = Vector3.Distance(handleTipPosition, rayOrigin.position); - - var linearEventData = eventData as LinearHandle.LinearHandleEventData; - var lerp = wasActive ? k_LazyFollow * Time.deltaTime : 1; - if (linearEventData != null) - { - handleTipTransform.position = Vector3.Lerp(handleTipPosition, - handleTransform.TransformPoint(new Vector3(0, 0, - handleTransform.InverseTransformPoint(linearEventData.raycastHitWorldPosition).z)), - lerp); - - var handleForward = handleTransform.forward; - var delta = handleTipPosition - handleTip.lastPosition; - if (delta.magnitude > k_MinHandleTipDirectionDelta * distanceFromRayOrigin) - { - handleTip.direction = Mathf.Sign(Vector3.Dot(delta, handleForward)); - handleTip.lastPosition = handleTipPosition; - } - - handleTipTransform.forward = handleForward * handleTip.direction; - } - - var radialEventData = eventData as RadialHandle.RadialHandleEventData; - if (radialEventData != null) - { - var positionOffset = handleTip.positionOffset; - if (positionOffset.HasValue) - { - handleTipTransform.position = handleTransform.TransformPoint(positionOffset.Value); - } - else - { - var newLocalPos = handleTransform.InverseTransformPoint(radialEventData.raycastHitWorldPosition); - newLocalPos.y = 0; - handleTipTransform.position = Vector3.Lerp(handleTipPosition, - handleTransform.TransformPoint(newLocalPos.normalized * 0.5f * handleTransform.localScale.x), - lerp); - } - - var forward = Vector3.Cross(handleTransform.up, (handleTipPosition - handleTransform.position).normalized); - var delta = handleTipPosition - handleTip.lastPosition; - if (delta.magnitude > k_MinHandleTipDirectionDelta * distanceFromRayOrigin) - { - handleTip.direction = Mathf.Sign(Vector3.Dot(delta, forward)); - handleTip.lastPosition = handleTipPosition; - } - - if (forward != Vector3.zero) - handleTipTransform.forward = forward * handleTip.direction; - } - - if (handle.hasDragSource && !handleTip.positionOffset.HasValue) - handleTip.positionOffset = handle.transform.InverseTransformPoint(handleTipTransform.position); - } - else if(!handle.hasDragSource) - { - handleTip.positionOffset = null; - } - } - - protected virtual void OnHandleHoverStarted(BaseHandle handle, HandleEventData eventData) - { - var rayOrigin = eventData.rayOrigin; - if (handle.IndexOfHoverSource(rayOrigin) > 0) - return; - - if (!handle.hasDragSource) - { - ShowHoverState(handle, true); - UpdateHandleTip(handle, eventData, true); - } - } - - protected virtual void OnHandleHovering(BaseHandle handle, HandleEventData eventData) - { - if (handle.IndexOfHoverSource(eventData.rayOrigin) > 0) - return; - - if (!handle.hasDragSource) - UpdateHandleTip(handle, eventData, true); - } - - protected virtual void OnHandleHoverEnded(BaseHandle handle, HandleEventData eventData) - { - var rayOrigin = eventData.rayOrigin; - if (handle.IndexOfHoverSource(rayOrigin) > 0) - return; - - if (!handle.hasDragSource) - { - UpdateHandleTip(handle, eventData, false); - - if (!handle.hasHoverSource) - ShowHoverState(handle, false); - } - } - - protected virtual void OnHandleDragStarted(BaseHandle handle, HandleEventData eventData) - { - var rayOrigin = eventData.rayOrigin; - if (handle.IndexOfDragSource(rayOrigin) > 0) - return; - - foreach (var h in m_AllHandles) - h.gameObject.SetActive(h == handle); - - foreach (var kvp in m_HandleTips) - kvp.Value.renderer.gameObject.SetActive(false); - - if (dragStarted != null) - dragStarted(); - - dragging = true; - - ShowHoverState(handle, false); - UpdateHandleTip(handle, eventData, true); - } - - protected virtual void OnHandleDragging(BaseHandle handle, HandleEventData eventData) - { - if (handle.IndexOfDragSource(eventData.rayOrigin) != 0) - return; - - UpdateHandleTip(handle, eventData, true); - } - - protected virtual void OnHandleDragEnded(BaseHandle handle, HandleEventData eventData) - { - var rayOrigin = eventData.rayOrigin; - - UpdateHandleTip(handle, eventData, false); - - if (handle.hasDragSource) - return; - - foreach (var h in m_AllHandles) - h.gameObject.SetActive(true); - - if (dragEnded != null) - dragEnded(rayOrigin); - - dragging = false; - - if (!handle.hasDragSource && handle.hasHoverSource) - ShowHoverState(handle, true); - } - } + class BaseManipulator : MonoBehaviour, IManipulator + { + protected const float k_BaseManipulatorSize = 0.3f; + const float k_MinHandleTipDirectionDelta = 0.01f; + const float k_LazyFollow = 40f; + + class HandleTip + { + public Renderer renderer; + public float direction = 1; + public Vector3 lastPosition; + public Vector3? positionOffset; + } + + [SerializeField] + Renderer m_HandleTip; + + [SerializeField] + protected List m_AllHandles; + + [SerializeField] + float m_LinearHandleScaleBump = 1.8f; + + [SerializeField] + float m_PlaneHandleScaleBump = 1.2f; + + [SerializeField] + float m_SphereHandleScaleBump = 1.1f; + + [SerializeField] + float m_HandleAlpha = 0.4f; + + [SerializeField] + float m_HandleHoverAlpha = 0.8f; + + readonly Dictionary m_ScaleBumps = new Dictionary(); + readonly Dictionary m_HandleTips = new Dictionary(); + + public bool adjustScaleForCamera { get; set; } + + public Action translate { protected get; set; } + public Action rotate { protected get; set; } + public Action scale { protected get; set; } + + public bool dragging { get; protected set; } + public event Action dragStarted; + public event Action dragEnded; + + void Awake() + { + m_ScaleBumps[typeof(LinearHandle)] = m_LinearHandleScaleBump; + m_ScaleBumps[typeof(PlaneHandle)] = m_PlaneHandleScaleBump; + m_ScaleBumps[typeof(SphereHandle)] = m_SphereHandleScaleBump; + + foreach (var handle in m_AllHandles) + { + MaterialUtils.CloneMaterials(handle.GetComponent()); + + handle.hoverStarted += OnHandleHoverStarted; + handle.hovering += OnHandleHovering; + handle.hoverEnded += OnHandleHoverEnded; + + handle.dragStarted += OnHandleDragStarted; + handle.dragging += OnHandleDragging; + handle.dragEnded += OnHandleDragEnded; + } + } + + protected virtual void OnEnable() + { + if (adjustScaleForCamera) + Camera.onPreRender += OnCameraPreRender; + } + + protected virtual void OnDisable() + { + Camera.onPreRender -= OnCameraPreRender; + + foreach (var kvp in m_HandleTips) + { + kvp.Value.renderer.gameObject.SetActive(false); + } + } + + void OnDestroy() + { + foreach (var handle in m_AllHandles) + { + ObjectUtils.Destroy(handle.GetComponent().sharedMaterial); + } + } + + protected virtual void ShowHoverState(BaseHandle handle, bool hovering) + { + var type = handle.GetType(); + float scaleBump; + if (m_ScaleBumps.TryGetValue(type, out scaleBump)) + handle.transform.localScale = hovering ? handle.transform.localScale * scaleBump : handle.transform.localScale / scaleBump; + + var handleRenderer = handle.GetComponent(); + var material = handleRenderer.sharedMaterial; + var color = material.color; + color.a = hovering ? m_HandleHoverAlpha : m_HandleAlpha; + material.color = color; + } + + void OnCameraPreRender(Camera camera) + { + AdjustScale(camera.transform.position, camera.worldToCameraMatrix); + } + + public void AdjustScale(Vector3 cameraPosition, Matrix4x4 worldToCameraMatrix) + { + var originalCameraPosition = cameraPosition; + + // Adjust size of manipulator while accounting for any non-standard cameras (e.g. scaling applied to the camera) + var manipulatorPosition = worldToCameraMatrix.MultiplyPoint3x4(transform.position); + cameraPosition = worldToCameraMatrix.MultiplyPoint3x4(cameraPosition); + var delta = worldToCameraMatrix.inverse.MultiplyPoint3x4(cameraPosition - manipulatorPosition) - originalCameraPosition; + transform.localScale = Vector3.one * delta.magnitude * k_BaseManipulatorSize; + } + + protected virtual void UpdateHandleTip(BaseHandle handle, HandleEventData eventData, bool active) + { + var rayOrigin = eventData.rayOrigin; + HandleTip handleTip; + Renderer handleTipRenderer; + if (!m_HandleTips.TryGetValue(rayOrigin, out handleTip)) + { + handleTipRenderer = m_HandleTip; + if (m_HandleTips.Count > 0) + handleTipRenderer = ObjectUtils.Instantiate(handleTipRenderer.gameObject, transform).GetComponent(); + + handleTip = new HandleTip { renderer = handleTipRenderer }; + m_HandleTips[rayOrigin] = handleTip; + } + else + { + handleTipRenderer = handleTip.renderer; + } + + active = active && (handle is LinearHandle || handle is RadialHandle); + + var handleTipGameObject = handleTipRenderer.gameObject; + var wasActive = handleTipGameObject.activeSelf; + handleTipGameObject.SetActive(active); + var handleTipTransform = handleTipRenderer.transform; + + if (active) // Reposition handle tip based on current raycast position when hovering or dragging + { + handleTipRenderer.sharedMaterial = handle.GetComponent().sharedMaterial; + + var handleTransform = handle.transform; + var handleTipPosition = handleTipTransform.position; + var distanceFromRayOrigin = Vector3.Distance(handleTipPosition, rayOrigin.position); + + var linearEventData = eventData as LinearHandle.LinearHandleEventData; + var lerp = wasActive ? k_LazyFollow * Time.deltaTime : 1; + if (linearEventData != null) + { + handleTipTransform.position = Vector3.Lerp(handleTipPosition, + handleTransform.TransformPoint(new Vector3(0, 0, + handleTransform.InverseTransformPoint(linearEventData.raycastHitWorldPosition).z)), + lerp); + + var handleForward = handleTransform.forward; + var delta = handleTipPosition - handleTip.lastPosition; + if (delta.magnitude > k_MinHandleTipDirectionDelta * distanceFromRayOrigin) + { + handleTip.direction = Mathf.Sign(Vector3.Dot(delta, handleForward)); + handleTip.lastPosition = handleTipPosition; + } + + handleTipTransform.forward = handleForward * handleTip.direction; + } + + var radialEventData = eventData as RadialHandle.RadialHandleEventData; + if (radialEventData != null) + { + var positionOffset = handleTip.positionOffset; + if (positionOffset.HasValue) + { + handleTipTransform.position = handleTransform.TransformPoint(positionOffset.Value); + } + else + { + var newLocalPos = handleTransform.InverseTransformPoint(radialEventData.raycastHitWorldPosition); + newLocalPos.y = 0; + handleTipTransform.position = Vector3.Lerp(handleTipPosition, + handleTransform.TransformPoint(newLocalPos.normalized * 0.5f * handleTransform.localScale.x), + lerp); + } + + var forward = Vector3.Cross(handleTransform.up, (handleTipPosition - handleTransform.position).normalized); + var delta = handleTipPosition - handleTip.lastPosition; + if (delta.magnitude > k_MinHandleTipDirectionDelta * distanceFromRayOrigin) + { + handleTip.direction = Mathf.Sign(Vector3.Dot(delta, forward)); + handleTip.lastPosition = handleTipPosition; + } + + if (forward != Vector3.zero) + handleTipTransform.forward = forward * handleTip.direction; + } + + if (handle.hasDragSource && !handleTip.positionOffset.HasValue) + handleTip.positionOffset = handle.transform.InverseTransformPoint(handleTipTransform.position); + } + else if (!handle.hasDragSource) + { + handleTip.positionOffset = null; + } + } + + protected virtual void OnHandleHoverStarted(BaseHandle handle, HandleEventData eventData) + { + var rayOrigin = eventData.rayOrigin; + if (handle.IndexOfHoverSource(rayOrigin) > 0) + return; + + if (!handle.hasDragSource) + { + ShowHoverState(handle, true); + UpdateHandleTip(handle, eventData, true); + } + } + + protected virtual void OnHandleHovering(BaseHandle handle, HandleEventData eventData) + { + if (handle.IndexOfHoverSource(eventData.rayOrigin) > 0) + return; + + if (!handle.hasDragSource) + UpdateHandleTip(handle, eventData, true); + } + + protected virtual void OnHandleHoverEnded(BaseHandle handle, HandleEventData eventData) + { + var rayOrigin = eventData.rayOrigin; + if (handle.IndexOfHoverSource(rayOrigin) > 0) + return; + + if (!handle.hasDragSource) + { + UpdateHandleTip(handle, eventData, false); + + if (!handle.hasHoverSource) + ShowHoverState(handle, false); + } + } + + protected virtual void OnHandleDragStarted(BaseHandle handle, HandleEventData eventData) + { + var rayOrigin = eventData.rayOrigin; + if (handle.IndexOfDragSource(rayOrigin) > 0) + return; + + foreach (var h in m_AllHandles) + h.gameObject.SetActive(h == handle); + + foreach (var kvp in m_HandleTips) + kvp.Value.renderer.gameObject.SetActive(false); + + if (dragStarted != null) + dragStarted(); + + dragging = true; + + ShowHoverState(handle, false); + UpdateHandleTip(handle, eventData, true); + } + + protected virtual void OnHandleDragging(BaseHandle handle, HandleEventData eventData) + { + if (handle.IndexOfDragSource(eventData.rayOrigin) != 0) + return; + + UpdateHandleTip(handle, eventData, true); + } + + protected virtual void OnHandleDragEnded(BaseHandle handle, HandleEventData eventData) + { + var rayOrigin = eventData.rayOrigin; + + UpdateHandleTip(handle, eventData, false); + + if (handle.hasDragSource) + return; + + foreach (var h in m_AllHandles) + h.gameObject.SetActive(true); + + if (dragEnded != null) + dragEnded(rayOrigin); + + dragging = false; + + if (!handle.hasDragSource && handle.hasHoverSource) + ShowHoverState(handle, true); + } + } } + #endif diff --git a/Manipulators/DirectManipulator.cs b/Manipulators/DirectManipulator.cs index fb0b9c1f0..6935e4bbc 100644 --- a/Manipulators/DirectManipulator.cs +++ b/Manipulators/DirectManipulator.cs @@ -6,93 +6,94 @@ namespace UnityEditor.Experimental.EditorVR.Manipulators { - sealed class DirectManipulator : MonoBehaviour, IManipulator - { - public Transform target - { - set { m_Target = value; } - } - - [SerializeField] - Transform m_Target; - - [SerializeField] - List m_AllHandles = new List(); - - Vector3 m_PositionOffset; - Quaternion m_RotationOffset; - - public Action translate { private get; set; } - public Action rotate { private get; set; } - public Action scale { private get; set; } - - public bool dragging { get; private set; } - public event Action dragStarted; - public event Action dragEnded; - - void OnEnable() - { - foreach (var h in m_AllHandles) - { - h.dragStarted += OnHandleDragStarted; - h.dragging += OnHandleDragging; - h.dragEnded += OnHandleDragEnded; - } - } - - void OnDisable() - { - foreach (var h in m_AllHandles) - { - h.dragStarted -= OnHandleDragStarted; - h.dragging -= OnHandleDragging; - h.dragEnded -= OnHandleDragEnded; - } - } - - void OnHandleDragStarted(BaseHandle handle, HandleEventData eventData) - { - foreach (var h in m_AllHandles) - { - h.gameObject.SetActive(h == handle); - } - dragging = true; - - var target = m_Target == null ? transform : m_Target; - - var rayOrigin = eventData.rayOrigin; - var inverseRotation = Quaternion.Inverse(rayOrigin.rotation); - m_PositionOffset = inverseRotation * (target.transform.position - rayOrigin.position); - m_RotationOffset = inverseRotation * target.transform.rotation; - - if (dragStarted != null) - dragStarted(); - } - - void OnHandleDragging(BaseHandle handle, HandleEventData eventData) - { - var target = m_Target == null ? transform : m_Target; - - var rayOrigin = eventData.rayOrigin; - translate(rayOrigin.position + rayOrigin.rotation * m_PositionOffset - target.position, rayOrigin, 0); - rotate(Quaternion.Inverse(target.rotation) * rayOrigin.rotation * m_RotationOffset, rayOrigin); - } - - void OnHandleDragEnded(BaseHandle handle, HandleEventData eventData) - { - if (gameObject.activeSelf) - { - foreach (var h in m_AllHandles) - { - h.gameObject.SetActive(true); - } - } - - dragging = false; - - if (dragEnded != null) - dragEnded(eventData.rayOrigin); - } - } + sealed class DirectManipulator : MonoBehaviour, IManipulator + { + public Transform target + { + set { m_Target = value; } + } + + [SerializeField] + Transform m_Target; + + [SerializeField] + List m_AllHandles = new List(); + + Vector3 m_PositionOffset; + Quaternion m_RotationOffset; + + public Action translate { private get; set; } + public Action rotate { private get; set; } + public Action scale { private get; set; } + + public bool dragging { get; private set; } + public event Action dragStarted; + public event Action dragEnded; + + void OnEnable() + { + foreach (var h in m_AllHandles) + { + h.dragStarted += OnHandleDragStarted; + h.dragging += OnHandleDragging; + h.dragEnded += OnHandleDragEnded; + } + } + + void OnDisable() + { + foreach (var h in m_AllHandles) + { + h.dragStarted -= OnHandleDragStarted; + h.dragging -= OnHandleDragging; + h.dragEnded -= OnHandleDragEnded; + } + } + + void OnHandleDragStarted(BaseHandle handle, HandleEventData eventData) + { + foreach (var h in m_AllHandles) + { + h.gameObject.SetActive(h == handle); + } + dragging = true; + + var target = m_Target == null ? transform : m_Target; + + var rayOrigin = eventData.rayOrigin; + var inverseRotation = Quaternion.Inverse(rayOrigin.rotation); + m_PositionOffset = inverseRotation * (target.transform.position - rayOrigin.position); + m_RotationOffset = inverseRotation * target.transform.rotation; + + if (dragStarted != null) + dragStarted(); + } + + void OnHandleDragging(BaseHandle handle, HandleEventData eventData) + { + var target = m_Target == null ? transform : m_Target; + + var rayOrigin = eventData.rayOrigin; + translate(rayOrigin.position + rayOrigin.rotation * m_PositionOffset - target.position, rayOrigin, 0); + rotate(Quaternion.Inverse(target.rotation) * rayOrigin.rotation * m_RotationOffset, rayOrigin); + } + + void OnHandleDragEnded(BaseHandle handle, HandleEventData eventData) + { + if (gameObject.activeSelf) + { + foreach (var h in m_AllHandles) + { + h.gameObject.SetActive(true); + } + } + + dragging = false; + + if (dragEnded != null) + dragEnded(eventData.rayOrigin); + } + } } + #endif diff --git a/Manipulators/ScaleManipulator.cs b/Manipulators/ScaleManipulator.cs index 5c59032cd..1143ad0c1 100644 --- a/Manipulators/ScaleManipulator.cs +++ b/Manipulators/ScaleManipulator.cs @@ -4,38 +4,39 @@ namespace UnityEditor.Experimental.EditorVR.Manipulators { - sealed class ScaleManipulator : BaseManipulator - { - [SerializeField] - BaseHandle m_UniformHandle; + sealed class ScaleManipulator : BaseManipulator + { + [SerializeField] + BaseHandle m_UniformHandle; - protected override void OnHandleDragging(BaseHandle handle, HandleEventData eventData) - { - base.OnHandleDragging(handle, eventData); + protected override void OnHandleDragging(BaseHandle handle, HandleEventData eventData) + { + base.OnHandleDragging(handle, eventData); - if (handle == m_UniformHandle) - { - scale(Vector3.one * eventData.deltaPosition.y / transform.localScale.x); - } - else - { - var handleTransform = handle.transform; - var inverseRotation = Quaternion.Inverse(handleTransform.rotation); + if (handle == m_UniformHandle) + { + scale(Vector3.one * eventData.deltaPosition.y / transform.localScale.x); + } + else + { + var handleTransform = handle.transform; + var inverseRotation = Quaternion.Inverse(handleTransform.rotation); - var localStartDragPosition = inverseRotation - * (handle.startDragPositions[eventData.rayOrigin] - handleTransform.position); - var delta = (inverseRotation * eventData.deltaPosition).z / localStartDragPosition.z; - scale(Quaternion.Inverse(transform.rotation) * handleTransform.forward * delta); - } - } + var localStartDragPosition = inverseRotation + * (handle.startDragPositions[eventData.rayOrigin] - handleTransform.position); + var delta = (inverseRotation * eventData.deltaPosition).z / localStartDragPosition.z; + scale(Quaternion.Inverse(transform.rotation) * handleTransform.forward * delta); + } + } - protected override void UpdateHandleTip(BaseHandle handle, HandleEventData eventData, bool active) - { - if (handle == m_UniformHandle) - return; + protected override void UpdateHandleTip(BaseHandle handle, HandleEventData eventData, bool active) + { + if (handle == m_UniformHandle) + return; - base.UpdateHandleTip(handle, eventData, active); - } - } + base.UpdateHandleTip(handle, eventData, active); + } + } } + #endif diff --git a/Manipulators/StandardManipulator.cs b/Manipulators/StandardManipulator.cs index 9bd7fd5eb..772f41fba 100644 --- a/Manipulators/StandardManipulator.cs +++ b/Manipulators/StandardManipulator.cs @@ -5,89 +5,90 @@ namespace UnityEditor.Experimental.EditorVR.Manipulators { - sealed class StandardManipulator : BaseManipulator - { - [SerializeField] - Transform m_PlaneHandlesParent; - - [SerializeField] - Mesh m_RadialHandleMesh; - - [SerializeField] - Mesh m_FatRadialHandleMesh; - - [SerializeField] - float m_SphereHandleHideScale = 0.1f; - - void Update() - { - if (!dragging) - { - // Place the plane handles in a good location that is accessible to the user - var viewerPosition = CameraUtils.GetMainCamera().transform.position; - foreach (Transform t in m_PlaneHandlesParent) - { - var localPos = t.localPosition; - localPos.x = Mathf.Abs(localPos.x) * (transform.position.x < viewerPosition.x ? 1 : -1); - localPos.y = Mathf.Abs(localPos.y) * (transform.position.y < viewerPosition.y ? 1 : -1); - localPos.z = Mathf.Abs(localPos.z) * (transform.position.z < viewerPosition.z ? 1 : -1); - t.localPosition = localPos; - } - } - } - - protected override void ShowHoverState(BaseHandle handle, bool hovering) - { - base.ShowHoverState(handle, hovering); - - if (handle is RadialHandle) - handle.GetComponent().sharedMesh = hovering ? m_FatRadialHandleMesh : m_RadialHandleMesh; - } - - protected override void OnHandleDragStarted(BaseHandle handle, HandleEventData eventData) - { - base.OnHandleDragStarted(handle, eventData); - - if (handle.IndexOfDragSource(eventData.rayOrigin) > 0) - return; - - if (handle is SphereHandle) - handle.transform.localScale *= m_SphereHandleHideScale; - } - - protected override void OnHandleDragging(BaseHandle handle, HandleEventData eventData) - { - base.OnHandleDragging(handle, eventData); - - var rayOrigin = eventData.rayOrigin; - if (handle.IndexOfDragSource(rayOrigin) > 0) - return; - - if (handle is RadialHandle) - { - rotate(eventData.deltaRotation, rayOrigin); - } - else - { - ConstrainedAxis constraints = 0; - var constrainedHandle = handle as IAxisConstraints; - if (constrainedHandle != null) - constraints = constrainedHandle.constraints; - - translate(eventData.deltaPosition, rayOrigin, constraints); - } - } - - protected override void OnHandleDragEnded(BaseHandle handle, HandleEventData eventData) - { - base.OnHandleDragEnded(handle, eventData); - - if (handle.IndexOfDragSource(eventData.rayOrigin) > 0) - return; - - if (handle is SphereHandle) - handle.transform.localScale /= m_SphereHandleHideScale; - } - } + sealed class StandardManipulator : BaseManipulator + { + [SerializeField] + Transform m_PlaneHandlesParent; + + [SerializeField] + Mesh m_RadialHandleMesh; + + [SerializeField] + Mesh m_FatRadialHandleMesh; + + [SerializeField] + float m_SphereHandleHideScale = 0.1f; + + void Update() + { + if (!dragging) + { + // Place the plane handles in a good location that is accessible to the user + var viewerPosition = CameraUtils.GetMainCamera().transform.position; + foreach (Transform t in m_PlaneHandlesParent) + { + var localPos = t.localPosition; + localPos.x = Mathf.Abs(localPos.x) * (transform.position.x < viewerPosition.x ? 1 : -1); + localPos.y = Mathf.Abs(localPos.y) * (transform.position.y < viewerPosition.y ? 1 : -1); + localPos.z = Mathf.Abs(localPos.z) * (transform.position.z < viewerPosition.z ? 1 : -1); + t.localPosition = localPos; + } + } + } + + protected override void ShowHoverState(BaseHandle handle, bool hovering) + { + base.ShowHoverState(handle, hovering); + + if (handle is RadialHandle) + handle.GetComponent().sharedMesh = hovering ? m_FatRadialHandleMesh : m_RadialHandleMesh; + } + + protected override void OnHandleDragStarted(BaseHandle handle, HandleEventData eventData) + { + base.OnHandleDragStarted(handle, eventData); + + if (handle.IndexOfDragSource(eventData.rayOrigin) > 0) + return; + + if (handle is SphereHandle) + handle.transform.localScale *= m_SphereHandleHideScale; + } + + protected override void OnHandleDragging(BaseHandle handle, HandleEventData eventData) + { + base.OnHandleDragging(handle, eventData); + + var rayOrigin = eventData.rayOrigin; + if (handle.IndexOfDragSource(rayOrigin) > 0) + return; + + if (handle is RadialHandle) + { + rotate(eventData.deltaRotation, rayOrigin); + } + else + { + ConstrainedAxis constraints = 0; + var constrainedHandle = handle as IAxisConstraints; + if (constrainedHandle != null) + constraints = constrainedHandle.constraints; + + translate(eventData.deltaPosition, rayOrigin, constraints); + } + } + + protected override void OnHandleDragEnded(BaseHandle handle, HandleEventData eventData) + { + base.OnHandleDragEnded(handle, eventData); + + if (handle.IndexOfDragSource(eventData.rayOrigin) > 0) + return; + + if (handle is SphereHandle) + handle.transform.localScale /= m_SphereHandleHideScale; + } + } } + #endif From a72c30d1f77c0caa87694b3d3acdbd460a3e331a Mon Sep 17 00:00:00 2001 From: andrewm Date: Mon, 9 Oct 2017 16:36:31 -0700 Subject: [PATCH 105/457] Resharper->Edit->Reformat Code (Menus) --- Menus/MainMenu/MainMenu.cs | 694 ++++---- .../MainMenu/Scripts/MainMenuActionButton.cs | 21 +- .../MainMenu/Scripts/MainMenuActionToggle.cs | 19 +- Menus/MainMenu/Scripts/MainMenuButton.cs | 141 +- Menus/MainMenu/Scripts/MainMenuFace.cs | 355 ++-- .../MainMenu/Scripts/MainMenuItemAttribute.cs | 69 +- Menus/MainMenu/Scripts/MainMenuUI.cs | 919 +++++----- Menus/RadialMenu/RadialMenu.cs | 274 +-- Menus/RadialMenu/Scripts/RadialMenuSlot.cs | 1005 +++++------ Menus/RadialMenu/Scripts/RadialMenuUI.cs | 693 ++++---- Menus/ToolsMenu/Scripts/HintIcon.cs | 268 +-- Menus/ToolsMenu/Scripts/HintLine.cs | 145 +- Menus/ToolsMenu/Scripts/ToolsMenuUI.cs | 1051 ++++++------ Menus/ToolsMenu/ToolsMenu.cs | 471 +++--- .../ToolsMenuButton/ToolsMenuButton.cs | 1472 +++++++++-------- 15 files changed, 3833 insertions(+), 3764 deletions(-) diff --git a/Menus/MainMenu/MainMenu.cs b/Menus/MainMenu/MainMenu.cs index aecebb20b..27450f4cb 100644 --- a/Menus/MainMenu/MainMenu.cs +++ b/Menus/MainMenu/MainMenu.cs @@ -11,352 +11,352 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class MainMenu : MonoBehaviour, IMainMenu, IConnectInterfaces, IInstantiateUI, ICreateWorkspace, - ICustomActionMap, IUsesMenuOrigins, IUsesProxyType, IControlHaptics, IUsesNode, IRayToNode, IUsesRayOrigin - { - const string k_SettingsMenuSectionName = "Settings"; - - [SerializeField] - ActionMap m_MainMenuActionMap; - - [SerializeField] - HapticPulse m_FaceRotationPulse; - - [SerializeField] - HapticPulse m_ShowPulse; - - [SerializeField] - HapticPulse m_HidePulse; - - [SerializeField] - MainMenuUI m_MainMenuPrefab; - - [SerializeField] - HapticPulse m_ButtonClickPulse; - - [SerializeField] - HapticPulse m_ButtonHoverPulse; - - Transform m_AlternateMenuOrigin; - Transform m_MenuOrigin; - MainMenuUI m_MainMenuUI; - float m_LastRotationInput; - MenuHideFlags m_MenuHideFlags = MenuHideFlags.Hidden; - readonly Dictionary m_ToolButtons = new Dictionary(); - readonly Dictionary m_SettingsMenus = new Dictionary(); - readonly Dictionary m_SettingsMenuItems = new Dictionary(); - - public List menuTools { private get; set; } - public List menuWorkspaces { private get; set; } - public Dictionary, ISettingsMenuProvider> settingsMenuProviders { get; set; } - public Dictionary, ISettingsMenuItemProvider> settingsMenuItemProviders { get; set; } - public List menuActions { get; set; } - public Transform targetRayOrigin { private get; set; } - public Type proxyType { private get; set; } - public Node? node { get; set; } - public GameObject menuContent { get { return m_MainMenuUI.gameObject; } } - public Transform rayOrigin { private get; set; } - - public Bounds localBounds { get { return m_MainMenuUI.localBounds; } } - - public bool focus { get { return m_MainMenuUI.hovering; } } - - public ActionMap actionMap { get { return m_MainMenuActionMap; } } - - public Transform menuOrigin - { - get { return m_MenuOrigin; } - set - { - m_MenuOrigin = value; - if (m_MainMenuUI) - m_MainMenuUI.menuOrigin = value; - } - } - - public Transform alternateMenuOrigin - { - get { return m_AlternateMenuOrigin; } - set - { - m_AlternateMenuOrigin = value; - if (m_MainMenuUI) - m_MainMenuUI.alternateMenuOrigin = value; - } - } - - public MenuHideFlags menuHideFlags - { - get { return m_MenuHideFlags; } - set - { - var wasVisible = m_MenuHideFlags == 0; - var wasPermanent = (m_MenuHideFlags & MenuHideFlags.Hidden) != 0; - if (m_MenuHideFlags != value) - { - m_MenuHideFlags = value; - if (m_MainMenuUI) - { - var isPermanent = (value & MenuHideFlags.Hidden) != 0; - m_MainMenuUI.visible = value == 0; - if (wasPermanent && value == 0 || wasVisible && isPermanent) - SendVisibilityPulse(); - } - } - } - } - - void Start() - { - m_MainMenuUI = this.InstantiateUI(m_MainMenuPrefab.gameObject).GetComponent(); - this.ConnectInterfaces(m_MainMenuUI); - m_MainMenuUI.alternateMenuOrigin = alternateMenuOrigin; - m_MainMenuUI.menuOrigin = menuOrigin; - m_MainMenuUI.Setup(); - - CreateFaceButtons(); - UpdateToolButtons(); - } - - public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) - { - var mainMenuInput = (MainMenuInput)input; - var rotationInput = -mainMenuInput.rotate.rawValue; - - consumeControl(mainMenuInput.rotate); - consumeControl(mainMenuInput.blockY); - - const float kFlickDeltaThreshold = 0.5f; - if ((proxyType != typeof(ViveProxy) && Mathf.Abs(rotationInput) >= kFlickDeltaThreshold && Mathf.Abs(m_LastRotationInput) < kFlickDeltaThreshold) - || mainMenuInput.flickFace.wasJustReleased) - { - m_MainMenuUI.targetFaceIndex += (int)Mathf.Sign(rotationInput); - this.Pulse(node, m_FaceRotationPulse); - } - - if (m_MenuHideFlags == 0) - consumeControl(mainMenuInput.flickFace); - - m_LastRotationInput = rotationInput; - } - - void OnDestroy() - { - if (m_MainMenuUI) - ObjectUtils.Destroy(m_MainMenuUI.gameObject); - } - - void CreateFaceButtons() - { - var types = new HashSet(); - types.UnionWith(menuTools); - types.UnionWith(menuWorkspaces); - types.UnionWith(settingsMenuProviders.Keys.Select(provider => provider.Key)); - types.UnionWith(settingsMenuItemProviders.Keys.Select(provider => provider.Key)); - - foreach (var type in types) - { - var customMenuAttribute = (MainMenuItemAttribute)type.GetCustomAttributes(typeof(MainMenuItemAttribute), false).FirstOrDefault(); - if (customMenuAttribute != null && !customMenuAttribute.shown) - continue; - - var isTool = typeof(ITool).IsAssignableFrom(type) && menuTools.Contains(type); - var isWorkspace = typeof(Workspace).IsAssignableFrom(type); - var isSettingsProvider = typeof(ISettingsMenuProvider).IsAssignableFrom(type); - var isSettingsItemProvider = typeof(ISettingsMenuItemProvider).IsAssignableFrom(type); - - ITooltip tooltip = null; - MainMenuUI.ButtonData buttonData = null; - - var selectedType = type; // Local variable for closure - if (customMenuAttribute != null && customMenuAttribute.shown) - { - tooltip = customMenuAttribute.tooltip; - - buttonData = new MainMenuUI.ButtonData(customMenuAttribute.name) - { - sectionName = customMenuAttribute.sectionName, - description = customMenuAttribute.description - }; - } - - if (isTool) - { - if (buttonData == null) - buttonData = new MainMenuUI.ButtonData(type.Name); - - var mainMenuButton = CreateFaceButton(buttonData, tooltip, () => - { - if (targetRayOrigin) - { - this.SelectTool(targetRayOrigin, selectedType, - hideMenu: typeof(IInstantiateMenuUI).IsAssignableFrom(selectedType)); - UpdateToolButtons(); - } - }); - - m_ToolButtons[type] = mainMenuButton; - - // Assign Tools Menu button preview properties - if (mainMenuButton != null) - mainMenuButton.toolType = selectedType; - } - - if (isWorkspace) - { - // For workspaces that haven't specified a custom attribute, do some menu categorization automatically - if (buttonData == null) - buttonData = new MainMenuUI.ButtonData(type.Name) { sectionName = "Workspaces" }; - - CreateFaceButton(buttonData, tooltip, () => - { - this.CreateWorkspace(selectedType); - }); - } - - if (isSettingsProvider) - { - foreach (var providerPair in settingsMenuProviders) - { - var kvp = providerPair.Key; - if (kvp.Key == type && (kvp.Value == null || kvp.Value == rayOrigin)) - AddSettingsMenu(providerPair.Value, buttonData, tooltip); - } - } - - if (isSettingsItemProvider) - { - foreach (var providerPair in settingsMenuItemProviders) - { - var kvp = providerPair.Key; - if (kvp.Key == type && (kvp.Value == null || kvp.Value == rayOrigin)) - AddSettingsMenuItem(providerPair.Value); - } - } - } - } - - MainMenuButton CreateFaceButton(MainMenuUI.ButtonData buttonData, ITooltip tooltip, Action buttonClickCallback) - { - var mainMenuButton = m_MainMenuUI.CreateFaceButton(buttonData); - if (mainMenuButton == null) - return null; - - var button = mainMenuButton.button; - button.onClick.RemoveAllListeners(); - button.onClick.AddListener(() => - { - if (m_MenuHideFlags == 0) - buttonClickCallback(); - }); - - mainMenuButton.hovered += OnButtonHovered; - mainMenuButton.clicked += OnButtonClicked; - mainMenuButton.tooltip = tooltip; - - return mainMenuButton; - } - - void UpdateToolButtons() - { - foreach (var kvp in m_ToolButtons) - { - kvp.Value.selected = this.IsToolActive(targetRayOrigin, kvp.Key); - } - } - - void OnButtonClicked(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); - } - - void OnButtonHovered(Transform rayOrigin, Type buttonType, string buttonDescription) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonHoverPulse); - - // Pass the pointer which is over us, so this information can supply context (e.g. selecting a tool for a different hand) - // Enable preview-mode on a Tools Menu button; Display on the opposite proxy device by evaluating the entering RayOrigin - // Disable any existing previews being displayed in ToolsMenus - this.ClearToolMenuButtonPreview(); - - if (buttonType != null && rayOrigin != null) - this.PreviewInToolMenuButton(rayOrigin, buttonType, buttonDescription); - } - - void SendVisibilityPulse() - { - this.Pulse(node, m_MenuHideFlags == 0 ? m_HidePulse : m_ShowPulse); - } - - public void AddSettingsMenu(ISettingsMenuProvider provider) - { - var type = provider.GetType(); - var customMenuAttribute = (MainMenuItemAttribute)type.GetCustomAttributes(typeof(MainMenuItemAttribute), false).FirstOrDefault(); - - ITooltip tooltip = null; - MainMenuUI.ButtonData buttonData; - if (customMenuAttribute != null && customMenuAttribute.shown) - { - tooltip = customMenuAttribute.tooltip; - - buttonData = new MainMenuUI.ButtonData(customMenuAttribute.name) - { - sectionName = customMenuAttribute.sectionName, - description = customMenuAttribute.description - }; - } - else - { - buttonData = new MainMenuUI.ButtonData(type.Name); - } - - AddSettingsMenu(provider, buttonData, tooltip); - } - - void AddSettingsMenu(ISettingsMenuProvider provider, MainMenuUI.ButtonData buttonData, ITooltip tooltip) - { - buttonData.sectionName = k_SettingsMenuSectionName; - - CreateFaceButton(buttonData, tooltip, () => - { - var instance = m_MainMenuUI.AddSubmenu(k_SettingsMenuSectionName, provider.settingsMenuPrefab); - m_SettingsMenus[provider] = instance; - provider.settingsMenuInstance = instance; - }); - } - - public void RemoveSettingsMenu(ISettingsMenuProvider provider) - { - GameObject instance; - if (m_SettingsMenus.TryGetValue(provider, out instance)) - { - if (instance) - ObjectUtils.Destroy(instance); - - m_SettingsMenus.Remove(provider); - } - provider.settingsMenuInstance = null; - } - - public void AddSettingsMenuItem(ISettingsMenuItemProvider provider) - { - var instance = m_MainMenuUI.CreateCustomButton(provider.settingsMenuItemPrefab, k_SettingsMenuSectionName); - m_SettingsMenuItems[provider] = instance; - provider.settingsMenuItemInstance = instance; - } - - public void RemoveSettingsMenuItem(ISettingsMenuItemProvider provider) - { - GameObject instance; - if (m_SettingsMenuItems.TryGetValue(provider, out instance)) - { - if (instance) - ObjectUtils.Destroy(instance); - - m_SettingsMenuItems.Remove(provider); - } - provider.settingsMenuItemInstance = null; - } - } + sealed class MainMenu : MonoBehaviour, IMainMenu, IConnectInterfaces, IInstantiateUI, ICreateWorkspace, + ICustomActionMap, IUsesMenuOrigins, IUsesProxyType, IControlHaptics, IUsesNode, IRayToNode, IUsesRayOrigin + { + const string k_SettingsMenuSectionName = "Settings"; + + [SerializeField] + ActionMap m_MainMenuActionMap; + + [SerializeField] + HapticPulse m_FaceRotationPulse; + + [SerializeField] + HapticPulse m_ShowPulse; + + [SerializeField] + HapticPulse m_HidePulse; + + [SerializeField] + MainMenuUI m_MainMenuPrefab; + + [SerializeField] + HapticPulse m_ButtonClickPulse; + + [SerializeField] + HapticPulse m_ButtonHoverPulse; + + Transform m_AlternateMenuOrigin; + Transform m_MenuOrigin; + MainMenuUI m_MainMenuUI; + float m_LastRotationInput; + MenuHideFlags m_MenuHideFlags = MenuHideFlags.Hidden; + readonly Dictionary m_ToolButtons = new Dictionary(); + readonly Dictionary m_SettingsMenus = new Dictionary(); + readonly Dictionary m_SettingsMenuItems = new Dictionary(); + + public List menuTools { private get; set; } + public List menuWorkspaces { private get; set; } + public Dictionary, ISettingsMenuProvider> settingsMenuProviders { get; set; } + public Dictionary, ISettingsMenuItemProvider> settingsMenuItemProviders { get; set; } + public List menuActions { get; set; } + public Transform targetRayOrigin { private get; set; } + public Type proxyType { private get; set; } + public Node? node { get; set; } + + public GameObject menuContent { get { return m_MainMenuUI.gameObject; } } + + public Transform rayOrigin { private get; set; } + + public Bounds localBounds { get { return m_MainMenuUI.localBounds; } } + + public bool focus { get { return m_MainMenuUI.hovering; } } + + public ActionMap actionMap { get { return m_MainMenuActionMap; } } + + public Transform menuOrigin + { + get { return m_MenuOrigin; } + set + { + m_MenuOrigin = value; + if (m_MainMenuUI) + m_MainMenuUI.menuOrigin = value; + } + } + + public Transform alternateMenuOrigin + { + get { return m_AlternateMenuOrigin; } + set + { + m_AlternateMenuOrigin = value; + if (m_MainMenuUI) + m_MainMenuUI.alternateMenuOrigin = value; + } + } + + public MenuHideFlags menuHideFlags + { + get { return m_MenuHideFlags; } + set + { + var wasVisible = m_MenuHideFlags == 0; + var wasPermanent = (m_MenuHideFlags & MenuHideFlags.Hidden) != 0; + if (m_MenuHideFlags != value) + { + m_MenuHideFlags = value; + if (m_MainMenuUI) + { + var isPermanent = (value & MenuHideFlags.Hidden) != 0; + m_MainMenuUI.visible = value == 0; + if (wasPermanent && value == 0 || wasVisible && isPermanent) + SendVisibilityPulse(); + } + } + } + } + + void Start() + { + m_MainMenuUI = this.InstantiateUI(m_MainMenuPrefab.gameObject).GetComponent(); + this.ConnectInterfaces(m_MainMenuUI); + m_MainMenuUI.alternateMenuOrigin = alternateMenuOrigin; + m_MainMenuUI.menuOrigin = menuOrigin; + m_MainMenuUI.Setup(); + + CreateFaceButtons(); + UpdateToolButtons(); + } + + public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) + { + var mainMenuInput = (MainMenuInput)input; + var rotationInput = -mainMenuInput.rotate.rawValue; + + consumeControl(mainMenuInput.rotate); + consumeControl(mainMenuInput.blockY); + + const float kFlickDeltaThreshold = 0.5f; + if ((proxyType != typeof(ViveProxy) && Mathf.Abs(rotationInput) >= kFlickDeltaThreshold && Mathf.Abs(m_LastRotationInput) < kFlickDeltaThreshold) + || mainMenuInput.flickFace.wasJustReleased) + { + m_MainMenuUI.targetFaceIndex += (int)Mathf.Sign(rotationInput); + this.Pulse(node, m_FaceRotationPulse); + } + + if (m_MenuHideFlags == 0) + consumeControl(mainMenuInput.flickFace); + + m_LastRotationInput = rotationInput; + } + + void OnDestroy() + { + if (m_MainMenuUI) + ObjectUtils.Destroy(m_MainMenuUI.gameObject); + } + + void CreateFaceButtons() + { + var types = new HashSet(); + types.UnionWith(menuTools); + types.UnionWith(menuWorkspaces); + types.UnionWith(settingsMenuProviders.Keys.Select(provider => provider.Key)); + types.UnionWith(settingsMenuItemProviders.Keys.Select(provider => provider.Key)); + + foreach (var type in types) + { + var customMenuAttribute = (MainMenuItemAttribute)type.GetCustomAttributes(typeof(MainMenuItemAttribute), false).FirstOrDefault(); + if (customMenuAttribute != null && !customMenuAttribute.shown) + continue; + + var isTool = typeof(ITool).IsAssignableFrom(type) && menuTools.Contains(type); + var isWorkspace = typeof(Workspace).IsAssignableFrom(type); + var isSettingsProvider = typeof(ISettingsMenuProvider).IsAssignableFrom(type); + var isSettingsItemProvider = typeof(ISettingsMenuItemProvider).IsAssignableFrom(type); + + ITooltip tooltip = null; + MainMenuUI.ButtonData buttonData = null; + + var selectedType = type; // Local variable for closure + if (customMenuAttribute != null && customMenuAttribute.shown) + { + tooltip = customMenuAttribute.tooltip; + + buttonData = new MainMenuUI.ButtonData(customMenuAttribute.name) + { + sectionName = customMenuAttribute.sectionName, + description = customMenuAttribute.description + }; + } + + if (isTool) + { + if (buttonData == null) + buttonData = new MainMenuUI.ButtonData(type.Name); + + var mainMenuButton = CreateFaceButton(buttonData, tooltip, () => + { + if (targetRayOrigin) + { + this.SelectTool(targetRayOrigin, selectedType, + hideMenu: typeof(IInstantiateMenuUI).IsAssignableFrom(selectedType)); + UpdateToolButtons(); + } + }); + + m_ToolButtons[type] = mainMenuButton; + + // Assign Tools Menu button preview properties + if (mainMenuButton != null) + mainMenuButton.toolType = selectedType; + } + + if (isWorkspace) + { + // For workspaces that haven't specified a custom attribute, do some menu categorization automatically + if (buttonData == null) + buttonData = new MainMenuUI.ButtonData(type.Name) { sectionName = "Workspaces" }; + + CreateFaceButton(buttonData, tooltip, () => { this.CreateWorkspace(selectedType); }); + } + + if (isSettingsProvider) + { + foreach (var providerPair in settingsMenuProviders) + { + var kvp = providerPair.Key; + if (kvp.Key == type && (kvp.Value == null || kvp.Value == rayOrigin)) + AddSettingsMenu(providerPair.Value, buttonData, tooltip); + } + } + + if (isSettingsItemProvider) + { + foreach (var providerPair in settingsMenuItemProviders) + { + var kvp = providerPair.Key; + if (kvp.Key == type && (kvp.Value == null || kvp.Value == rayOrigin)) + AddSettingsMenuItem(providerPair.Value); + } + } + } + } + + MainMenuButton CreateFaceButton(MainMenuUI.ButtonData buttonData, ITooltip tooltip, Action buttonClickCallback) + { + var mainMenuButton = m_MainMenuUI.CreateFaceButton(buttonData); + if (mainMenuButton == null) + return null; + + var button = mainMenuButton.button; + button.onClick.RemoveAllListeners(); + button.onClick.AddListener(() => + { + if (m_MenuHideFlags == 0) + buttonClickCallback(); + }); + + mainMenuButton.hovered += OnButtonHovered; + mainMenuButton.clicked += OnButtonClicked; + mainMenuButton.tooltip = tooltip; + + return mainMenuButton; + } + + void UpdateToolButtons() + { + foreach (var kvp in m_ToolButtons) + { + kvp.Value.selected = this.IsToolActive(targetRayOrigin, kvp.Key); + } + } + + void OnButtonClicked(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); + } + + void OnButtonHovered(Transform rayOrigin, Type buttonType, string buttonDescription) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonHoverPulse); + + // Pass the pointer which is over us, so this information can supply context (e.g. selecting a tool for a different hand) + // Enable preview-mode on a Tools Menu button; Display on the opposite proxy device by evaluating the entering RayOrigin + // Disable any existing previews being displayed in ToolsMenus + this.ClearToolMenuButtonPreview(); + + if (buttonType != null && rayOrigin != null) + this.PreviewInToolMenuButton(rayOrigin, buttonType, buttonDescription); + } + + void SendVisibilityPulse() + { + this.Pulse(node, m_MenuHideFlags == 0 ? m_HidePulse : m_ShowPulse); + } + + public void AddSettingsMenu(ISettingsMenuProvider provider) + { + var type = provider.GetType(); + var customMenuAttribute = (MainMenuItemAttribute)type.GetCustomAttributes(typeof(MainMenuItemAttribute), false).FirstOrDefault(); + + ITooltip tooltip = null; + MainMenuUI.ButtonData buttonData; + if (customMenuAttribute != null && customMenuAttribute.shown) + { + tooltip = customMenuAttribute.tooltip; + + buttonData = new MainMenuUI.ButtonData(customMenuAttribute.name) + { + sectionName = customMenuAttribute.sectionName, + description = customMenuAttribute.description + }; + } + else + { + buttonData = new MainMenuUI.ButtonData(type.Name); + } + + AddSettingsMenu(provider, buttonData, tooltip); + } + + void AddSettingsMenu(ISettingsMenuProvider provider, MainMenuUI.ButtonData buttonData, ITooltip tooltip) + { + buttonData.sectionName = k_SettingsMenuSectionName; + + CreateFaceButton(buttonData, tooltip, () => + { + var instance = m_MainMenuUI.AddSubmenu(k_SettingsMenuSectionName, provider.settingsMenuPrefab); + m_SettingsMenus[provider] = instance; + provider.settingsMenuInstance = instance; + }); + } + + public void RemoveSettingsMenu(ISettingsMenuProvider provider) + { + GameObject instance; + if (m_SettingsMenus.TryGetValue(provider, out instance)) + { + if (instance) + ObjectUtils.Destroy(instance); + + m_SettingsMenus.Remove(provider); + } + provider.settingsMenuInstance = null; + } + + public void AddSettingsMenuItem(ISettingsMenuItemProvider provider) + { + var instance = m_MainMenuUI.CreateCustomButton(provider.settingsMenuItemPrefab, k_SettingsMenuSectionName); + m_SettingsMenuItems[provider] = instance; + provider.settingsMenuItemInstance = instance; + } + + public void RemoveSettingsMenuItem(ISettingsMenuItemProvider provider) + { + GameObject instance; + if (m_SettingsMenuItems.TryGetValue(provider, out instance)) + { + if (instance) + ObjectUtils.Destroy(instance); + + m_SettingsMenuItems.Remove(provider); + } + provider.settingsMenuItemInstance = null; + } + } } + #endif diff --git a/Menus/MainMenu/Scripts/MainMenuActionButton.cs b/Menus/MainMenu/Scripts/MainMenuActionButton.cs index f2d16c752..bedd2bcc3 100644 --- a/Menus/MainMenu/Scripts/MainMenuActionButton.cs +++ b/Menus/MainMenu/Scripts/MainMenuActionButton.cs @@ -5,18 +5,19 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - class MainMenuActionButton : MonoBehaviour - { - [SerializeField] - Button m_Button; + class MainMenuActionButton : MonoBehaviour + { + [SerializeField] + Button m_Button; - [SerializeField] - Sprite m_Icon; + [SerializeField] + Sprite m_Icon; - [SerializeField] - Text m_NameText; + [SerializeField] + Text m_NameText; - public Func buttonPressed { get; set; } - } + public Func buttonPressed { get; set; } + } } + #endif diff --git a/Menus/MainMenu/Scripts/MainMenuActionToggle.cs b/Menus/MainMenu/Scripts/MainMenuActionToggle.cs index 14dda11de..6fc0bb865 100644 --- a/Menus/MainMenu/Scripts/MainMenuActionToggle.cs +++ b/Menus/MainMenu/Scripts/MainMenuActionToggle.cs @@ -4,16 +4,17 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class MainMenuActionToggle : MainMenuActionButton - { - [SerializeField] - private Button m_Button2; + sealed class MainMenuActionToggle : MainMenuActionButton + { + [SerializeField] + private Button m_Button2; - [SerializeField] - private Sprite m_Icon02; + [SerializeField] + private Sprite m_Icon02; - [SerializeField] - private Text m_NameText2; - } + [SerializeField] + private Text m_NameText2; + } } + #endif diff --git a/Menus/MainMenu/Scripts/MainMenuButton.cs b/Menus/MainMenu/Scripts/MainMenuButton.cs index 31790e49a..a62406b27 100644 --- a/Menus/MainMenu/Scripts/MainMenuButton.cs +++ b/Menus/MainMenu/Scripts/MainMenuButton.cs @@ -7,75 +7,76 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class MainMenuButton : MonoBehaviour, ITooltip, IRayEnterHandler, IRayExitHandler, IPointerClickHandler - { - [SerializeField] - Button m_Button; - - [SerializeField] - Text m_ButtonDescription; - - [SerializeField] - Text m_ButtonTitle; - - Color m_OriginalColor; - - public Button button { get { return m_Button; } } - - public string tooltipText { get { return tooltip != null ? tooltip.tooltipText : null; } } - - public ITooltip tooltip { private get; set; } - - public Type toolType { get; set; } - - public bool selected - { - set - { - if (value) - { - m_Button.transition = Selectable.Transition.None; - m_Button.targetGraphic.color = m_Button.colors.highlightedColor; - } - else - { - m_Button.transition = Selectable.Transition.ColorTint; - m_Button.targetGraphic.color = m_OriginalColor; - } - } - } - - public event Action hovered; - public event Action clicked; - - void Awake() - { - m_OriginalColor = m_Button.targetGraphic.color; - } - - public void SetData(string name, string description) - { - m_ButtonTitle.text = name; - m_ButtonDescription.text = description; - } - - public void OnRayEnter(RayEventData eventData) - { - if (hovered != null) - hovered(eventData.rayOrigin, toolType, m_ButtonDescription.text); - } - - public void OnRayExit(RayEventData eventData) - { - if (hovered != null) - hovered(eventData.rayOrigin, null, null); - } - - public void OnPointerClick(PointerEventData eventData) - { - if (clicked != null) - clicked(null); // Pass null to perform the selection haptic pulse on both nodes - } - } + sealed class MainMenuButton : MonoBehaviour, ITooltip, IRayEnterHandler, IRayExitHandler, IPointerClickHandler + { + [SerializeField] + Button m_Button; + + [SerializeField] + Text m_ButtonDescription; + + [SerializeField] + Text m_ButtonTitle; + + Color m_OriginalColor; + + public Button button { get { return m_Button; } } + + public string tooltipText { get { return tooltip != null ? tooltip.tooltipText : null; } } + + public ITooltip tooltip { private get; set; } + + public Type toolType { get; set; } + + public bool selected + { + set + { + if (value) + { + m_Button.transition = Selectable.Transition.None; + m_Button.targetGraphic.color = m_Button.colors.highlightedColor; + } + else + { + m_Button.transition = Selectable.Transition.ColorTint; + m_Button.targetGraphic.color = m_OriginalColor; + } + } + } + + public event Action hovered; + public event Action clicked; + + void Awake() + { + m_OriginalColor = m_Button.targetGraphic.color; + } + + public void SetData(string name, string description) + { + m_ButtonTitle.text = name; + m_ButtonDescription.text = description; + } + + public void OnRayEnter(RayEventData eventData) + { + if (hovered != null) + hovered(eventData.rayOrigin, toolType, m_ButtonDescription.text); + } + + public void OnRayExit(RayEventData eventData) + { + if (hovered != null) + hovered(eventData.rayOrigin, null, null); + } + + public void OnPointerClick(PointerEventData eventData) + { + if (clicked != null) + clicked(null); // Pass null to perform the selection haptic pulse on both nodes + } + } } + #endif diff --git a/Menus/MainMenu/Scripts/MainMenuFace.cs b/Menus/MainMenu/Scripts/MainMenuFace.cs index 459c99cf6..ff7555a9b 100644 --- a/Menus/MainMenu/Scripts/MainMenuFace.cs +++ b/Menus/MainMenu/Scripts/MainMenuFace.cs @@ -10,185 +10,180 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class MainMenuFace : MonoBehaviour - { - static readonly Vector3 k_LocalOffset = Vector3.down * 0.15f; - - [SerializeField] - MeshRenderer m_BorderOutline; - - [SerializeField] - CanvasGroup m_CanvasGroup; - - [SerializeField] - Text m_FaceTitle; - - [SerializeField] - Transform m_GridTransform; - - [SerializeField] - SkinnedMeshRenderer m_TitleIcon; - - [SerializeField] - ScrollRect m_ScrollRect; - - Material m_BorderOutlineMaterial; - Vector3 m_BorderOutlineOriginalLocalScale; - Transform m_BorderOutlineTransform; - Material m_TitleIconMaterial; - Coroutine m_VisibilityCoroutine; - Coroutine m_RevealCoroutine; - GradientPair m_GradientPair; - Vector3 m_OriginalLocalScale; - Vector3 m_HiddenLocalScale; - readonly Stack m_Submenus = new Stack(); - - const string k_BottomGradientProperty = "_ColorBottom"; - const string k_TopGradientProperty = "_ColorTop"; - readonly GradientPair k_EmptyGradient = new GradientPair(UnityBrandColorScheme.light, UnityBrandColorScheme.darker); - - public GradientPair gradientPair - { - get { return m_GradientPair; } - set - { - m_GradientPair = value; - m_BorderOutlineMaterial.SetColor(k_TopGradientProperty, gradientPair.a); - m_BorderOutlineMaterial.SetColor(k_BottomGradientProperty, gradientPair.b); - m_TitleIconMaterial.SetColor(k_TopGradientProperty, gradientPair.a); - m_TitleIconMaterial.SetColor(k_BottomGradientProperty, gradientPair.b); - } - } - - public string title { set { m_FaceTitle.text = value; } } - - public bool visible - { - set - { - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateVisibility(value)); - } - } - - void Awake() - { - m_CanvasGroup.alpha = 0f; - m_CanvasGroup.interactable = false; - m_BorderOutlineMaterial = MaterialUtils.GetMaterialClone(m_BorderOutline); - m_BorderOutlineTransform = m_BorderOutline.transform; - m_BorderOutlineOriginalLocalScale = m_BorderOutlineTransform.localScale; - m_TitleIconMaterial = MaterialUtils.GetMaterialClone(m_TitleIcon); - - m_OriginalLocalScale = transform.localScale; - m_HiddenLocalScale = new Vector3(0f, m_OriginalLocalScale.y * 0.5f, m_OriginalLocalScale.z); - - gradientPair = k_EmptyGradient; - } - - public void AddButton(Transform button) - { - button.SetParent(m_GridTransform); - button.localRotation = Quaternion.identity; - button.localScale = Vector3.one; - button.localPosition = Vector3.zero; - } - - public void Reveal(float delay = 0f) - { - this.RestartCoroutine(ref m_RevealCoroutine, AnimateReveal(delay)); - } - - IEnumerator AnimateVisibility(bool show) - { - if (show) - m_BorderOutlineTransform.localScale = m_BorderOutlineOriginalLocalScale; - - m_CanvasGroup.interactable = false; - - var smoothTime = show ? 0.35f : 0.125f; - var startingOpacity = m_CanvasGroup.alpha; - var targetOpacity = show ? 1f : 0f; - var smoothVelocity = 0f; - var currentDuration = 0f; - while (currentDuration < smoothTime) - { - startingOpacity = MathUtilsExt.SmoothDamp(startingOpacity, targetOpacity, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime); - currentDuration += Time.deltaTime; - m_CanvasGroup.alpha = startingOpacity * startingOpacity; - yield return null; - } - - m_CanvasGroup.alpha = targetOpacity; - - if (show) - m_CanvasGroup.interactable = true; - else - m_TitleIcon.SetBlendShapeWeight(0, 0); - } - - IEnumerator AnimateReveal(float delay = 0f) - { - var targetScale = m_OriginalLocalScale; - var targetPosition = Vector3.zero; - var currentScale = m_HiddenLocalScale; - var currentPosition = k_LocalOffset; - - transform.localScale = currentScale; - transform.localPosition = currentPosition; - - const float kSmoothTime = 0.1f; - var currentDelay = 0f; - var delayTarget = 0.25f + delay; // delay duration before starting the face reveal - while (currentDelay < delayTarget) // delay the reveal of each face slightly more than the previous - { - currentDelay += Time.deltaTime; - yield return null; - } - - var smoothVelocity = Vector3.zero; - while (!Mathf.Approximately(currentScale.x, targetScale.x)) - { - currentScale = Vector3.SmoothDamp(currentScale, targetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.deltaTime); - currentPosition = Vector3.Lerp(currentPosition, targetPosition, Mathf.Pow(currentScale.x / targetScale.x, 2)); // lerp the position with extra emphasis on the beginning transition - transform.localScale = currentScale; - transform.localPosition = currentPosition; - yield return null; - } - - transform.localScale = targetScale; - transform.localPosition = targetPosition; - } - - public void AddSubmenu(Transform submenu) - { - submenu.SetParent(transform.parent); - - submenu.localPosition = Vector3.zero; - submenu.localScale = Vector3.one; - submenu.localRotation = Quaternion.identity; - m_Submenus.Push(submenu.gameObject); - visible = false; - } - - public void RemoveSubmenu() - { - var target = m_Submenus.Pop(); - target.SetActive(false); - ObjectUtils.Destroy(target, .1f); - - if (m_Submenus.Count > 1) - m_Submenus.Last().SetActive(true); - else - visible = true; - } - - public void ClearSubmenus() - { - foreach (var submenu in m_Submenus) - { - ObjectUtils.Destroy(submenu); - } - } - } + sealed class MainMenuFace : MonoBehaviour + { + static readonly Vector3 k_LocalOffset = Vector3.down * 0.15f; + + [SerializeField] + MeshRenderer m_BorderOutline; + + [SerializeField] + CanvasGroup m_CanvasGroup; + + [SerializeField] + Text m_FaceTitle; + + [SerializeField] + Transform m_GridTransform; + + [SerializeField] + SkinnedMeshRenderer m_TitleIcon; + + [SerializeField] + ScrollRect m_ScrollRect; + + Material m_BorderOutlineMaterial; + Vector3 m_BorderOutlineOriginalLocalScale; + Transform m_BorderOutlineTransform; + Material m_TitleIconMaterial; + Coroutine m_VisibilityCoroutine; + Coroutine m_RevealCoroutine; + GradientPair m_GradientPair; + Vector3 m_OriginalLocalScale; + Vector3 m_HiddenLocalScale; + readonly Stack m_Submenus = new Stack(); + + const string k_BottomGradientProperty = "_ColorBottom"; + const string k_TopGradientProperty = "_ColorTop"; + readonly GradientPair k_EmptyGradient = new GradientPair(UnityBrandColorScheme.light, UnityBrandColorScheme.darker); + + public GradientPair gradientPair + { + get { return m_GradientPair; } + set + { + m_GradientPair = value; + m_BorderOutlineMaterial.SetColor(k_TopGradientProperty, gradientPair.a); + m_BorderOutlineMaterial.SetColor(k_BottomGradientProperty, gradientPair.b); + m_TitleIconMaterial.SetColor(k_TopGradientProperty, gradientPair.a); + m_TitleIconMaterial.SetColor(k_BottomGradientProperty, gradientPair.b); + } + } + + public string title { set { m_FaceTitle.text = value; } } + + public bool visible { set { this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateVisibility(value)); } } + + void Awake() + { + m_CanvasGroup.alpha = 0f; + m_CanvasGroup.interactable = false; + m_BorderOutlineMaterial = MaterialUtils.GetMaterialClone(m_BorderOutline); + m_BorderOutlineTransform = m_BorderOutline.transform; + m_BorderOutlineOriginalLocalScale = m_BorderOutlineTransform.localScale; + m_TitleIconMaterial = MaterialUtils.GetMaterialClone(m_TitleIcon); + + m_OriginalLocalScale = transform.localScale; + m_HiddenLocalScale = new Vector3(0f, m_OriginalLocalScale.y * 0.5f, m_OriginalLocalScale.z); + + gradientPair = k_EmptyGradient; + } + + public void AddButton(Transform button) + { + button.SetParent(m_GridTransform); + button.localRotation = Quaternion.identity; + button.localScale = Vector3.one; + button.localPosition = Vector3.zero; + } + + public void Reveal(float delay = 0f) + { + this.RestartCoroutine(ref m_RevealCoroutine, AnimateReveal(delay)); + } + + IEnumerator AnimateVisibility(bool show) + { + if (show) + m_BorderOutlineTransform.localScale = m_BorderOutlineOriginalLocalScale; + + m_CanvasGroup.interactable = false; + + var smoothTime = show ? 0.35f : 0.125f; + var startingOpacity = m_CanvasGroup.alpha; + var targetOpacity = show ? 1f : 0f; + var smoothVelocity = 0f; + var currentDuration = 0f; + while (currentDuration < smoothTime) + { + startingOpacity = MathUtilsExt.SmoothDamp(startingOpacity, targetOpacity, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime); + currentDuration += Time.deltaTime; + m_CanvasGroup.alpha = startingOpacity * startingOpacity; + yield return null; + } + + m_CanvasGroup.alpha = targetOpacity; + + if (show) + m_CanvasGroup.interactable = true; + else + m_TitleIcon.SetBlendShapeWeight(0, 0); + } + + IEnumerator AnimateReveal(float delay = 0f) + { + var targetScale = m_OriginalLocalScale; + var targetPosition = Vector3.zero; + var currentScale = m_HiddenLocalScale; + var currentPosition = k_LocalOffset; + + transform.localScale = currentScale; + transform.localPosition = currentPosition; + + const float kSmoothTime = 0.1f; + var currentDelay = 0f; + var delayTarget = 0.25f + delay; // delay duration before starting the face reveal + while (currentDelay < delayTarget) // delay the reveal of each face slightly more than the previous + { + currentDelay += Time.deltaTime; + yield return null; + } + + var smoothVelocity = Vector3.zero; + while (!Mathf.Approximately(currentScale.x, targetScale.x)) + { + currentScale = Vector3.SmoothDamp(currentScale, targetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.deltaTime); + currentPosition = Vector3.Lerp(currentPosition, targetPosition, Mathf.Pow(currentScale.x / targetScale.x, 2)); // lerp the position with extra emphasis on the beginning transition + transform.localScale = currentScale; + transform.localPosition = currentPosition; + yield return null; + } + + transform.localScale = targetScale; + transform.localPosition = targetPosition; + } + + public void AddSubmenu(Transform submenu) + { + submenu.SetParent(transform.parent); + + submenu.localPosition = Vector3.zero; + submenu.localScale = Vector3.one; + submenu.localRotation = Quaternion.identity; + m_Submenus.Push(submenu.gameObject); + visible = false; + } + + public void RemoveSubmenu() + { + var target = m_Submenus.Pop(); + target.SetActive(false); + ObjectUtils.Destroy(target, .1f); + + if (m_Submenus.Count > 1) + m_Submenus.Last().SetActive(true); + else + visible = true; + } + + public void ClearSubmenus() + { + foreach (var submenu in m_Submenus) + { + ObjectUtils.Destroy(submenu); + } + } + } } + #endif diff --git a/Menus/MainMenu/Scripts/MainMenuItemAttribute.cs b/Menus/MainMenu/Scripts/MainMenuItemAttribute.cs index 555d47e3e..0a436bbd0 100644 --- a/Menus/MainMenu/Scripts/MainMenuItemAttribute.cs +++ b/Menus/MainMenu/Scripts/MainMenuItemAttribute.cs @@ -3,41 +3,42 @@ namespace UnityEditor.Experimental.EditorVR { - /// - /// Attribute used to tag items (tools, actions, etc) that can be added to VR menus - /// - public class MainMenuItemAttribute : System.Attribute - { - internal string name; - internal string sectionName; - internal string description; - internal bool shown; - internal ITooltip tooltip; + /// + /// Attribute used to tag items (tools, actions, etc) that can be added to VR menus + /// + public class MainMenuItemAttribute : System.Attribute + { + internal string name; + internal string sectionName; + internal string description; + internal bool shown; + internal ITooltip tooltip; - /// - /// Custom constructor for hiding item from the main menu - /// - /// - public MainMenuItemAttribute(bool shown) - { - this.shown = shown; - } + /// + /// Custom constructor for hiding item from the main menu + /// + /// + public MainMenuItemAttribute(bool shown) + { + this.shown = shown; + } - /// - /// Constructor - /// - /// Display name of this tool, action, workspace, etc. - /// Section to place this tool, action, workspace, etc. - /// Description of this tool, action, workspace, etc. - /// (Optional) Tooltip type if a tooltip is needed - public MainMenuItemAttribute(string name, string sectionName, string description, Type tooltipType = null) - { - this.name = name; - this.sectionName = sectionName; - this.description = description; - this.shown = true; - this.tooltip = tooltipType != null && typeof(ITooltip).IsAssignableFrom(tooltipType) ? (ITooltip)Activator.CreateInstance(tooltipType) : null; - } - } + /// + /// Constructor + /// + /// Display name of this tool, action, workspace, etc. + /// Section to place this tool, action, workspace, etc. + /// Description of this tool, action, workspace, etc. + /// (Optional) Tooltip type if a tooltip is needed + public MainMenuItemAttribute(string name, string sectionName, string description, Type tooltipType = null) + { + this.name = name; + this.sectionName = sectionName; + this.description = description; + this.shown = true; + this.tooltip = tooltipType != null && typeof(ITooltip).IsAssignableFrom(tooltipType) ? (ITooltip)Activator.CreateInstance(tooltipType) : null; + } + } } + #endif diff --git a/Menus/MainMenu/Scripts/MainMenuUI.cs b/Menus/MainMenu/Scripts/MainMenuUI.cs index 32a2ef263..db55db5b6 100644 --- a/Menus/MainMenu/Scripts/MainMenuUI.cs +++ b/Menus/MainMenu/Scripts/MainMenuUI.cs @@ -9,464 +9,465 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class MainMenuUI : MonoBehaviour, IInstantiateUI, IConnectInterfaces, IRayEnterHandler, IRayExitHandler - { - public class ButtonData - { - public string name { get; private set; } - public string sectionName { get; set; } - public string description { get; set; } - - public ButtonData(string name) - { - this.name = name.Replace("Tool", string.Empty).Replace("Module", string.Empty) - .Replace("Workspace", string.Empty); - } - } - - enum RotationState - { - AtRest, - Snapping, - } - - enum VisibilityState - { - Hidden, - Visible, - TransitioningIn, - TransitioningOut - } - - const float k_FaceRotationSnapAngle = 90f; - const float k_DefaultSnapSpeed = 10f; - const float k_RotationEpsilon = 1f; - const int k_FaceCount = 4; - - readonly string k_UncategorizedFaceName = "Uncategorized"; - readonly Color k_MenuFacesHiddenColor = new Color(1f, 1f, 1f, 0.5f); - - [SerializeField] - MainMenuButton m_ButtonTemplatePrefab; - - [SerializeField] - Transform[] m_MenuFaceContainers; - - [SerializeField] - MainMenuFace m_MenuFacePrefab; - - [SerializeField] - Transform m_MenuFaceRotationOrigin; - - [SerializeField] - SkinnedMeshRenderer m_MenuFrameRenderer; - - [SerializeField] - Transform m_AlternateMenu; - - int m_TargetFaceIndex; - - readonly Dictionary m_Faces = new Dictionary(); - - VisibilityState m_VisibilityState = VisibilityState.Hidden; - RotationState m_RotationState; - Material m_MenuFacesMaterial; - Color m_MenuFacesColor; - Transform m_MenuOrigin; - Transform m_AlternateMenuOrigin; - Vector3 m_AlternateMenuOriginOriginalLocalScale; - Coroutine m_VisibilityCoroutine; - Coroutine m_FrameRevealCoroutine; - int m_Direction; - - public int targetFaceIndex - { - get { return m_TargetFaceIndex; } - set - { - m_Direction = (int)Mathf.Sign(value - m_TargetFaceIndex); - - // Loop around both ways - if (value < 0) - value += k_FaceCount; - - m_TargetFaceIndex = value % k_FaceCount; - } - } - - public Transform menuOrigin - { - get { return m_MenuOrigin; } - set - { - m_MenuOrigin = value; - transform.SetParent(menuOrigin); - transform.localPosition = Vector3.zero; - transform.localRotation = Quaternion.identity; - transform.localScale = Vector3.one; - } - } - - public Transform alternateMenuOrigin - { - get { return m_AlternateMenuOrigin; } - set - { - m_AlternateMenuOrigin = value; - m_AlternateMenu.SetParent(m_AlternateMenuOrigin); - m_AlternateMenu.localPosition = Vector3.zero; - m_AlternateMenu.localRotation = Quaternion.identity; - m_AlternateMenuOriginOriginalLocalScale = m_AlternateMenu.localScale; - } - } - - public float targetRotation { get; set; } - - public Node? node { get; set; } - - public bool visible - { - get { return m_VisibilityState == VisibilityState.Visible || m_VisibilityState == VisibilityState.TransitioningIn; } - set - { - switch (m_VisibilityState) - { - case VisibilityState.TransitioningOut: - case VisibilityState.Hidden: - if (value) - { - gameObject.SetActive(true); - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateShow()); - } - - return; - case VisibilityState.TransitioningIn: - case VisibilityState.Visible: - if (!value) - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHide()); - - return; - } - } - } - - int currentFaceIndex - { - get - { - // Floating point can leave us close to our actual rotation, but not quite (179.3438, - // which effectively we want to treat as 180) - return GetActualFaceIndexForRotation(Mathf.Ceil(currentRotation)); - } - } - - float currentRotation { get { return m_MenuFaceRotationOrigin.localRotation.eulerAngles.y; } } - public Bounds localBounds { get; private set; } - public bool hovering { get; private set; } - - - void Awake() - { - m_MenuFacesMaterial = MaterialUtils.GetMaterialClone(m_MenuFaceRotationOrigin.GetComponent()); - m_MenuFacesColor = m_MenuFacesMaterial.color; - localBounds = ObjectUtils.GetBounds(transform); - } - - public void Setup() - { - transform.localScale = Vector3.zero; - m_AlternateMenu.localScale = Vector3.zero; - gameObject.SetActive(false); - } - - void Update() - { - switch (m_VisibilityState) - { - case VisibilityState.TransitioningIn: - case VisibilityState.TransitioningOut: - case VisibilityState.Hidden: - return; - } - - // Allow any snaps to finish before resuming any other operations - if (m_RotationState == RotationState.Snapping) - return; - - var faceIndex = currentFaceIndex; - - if (faceIndex != targetFaceIndex) - StartCoroutine(SnapToFace(faceIndex + m_Direction, k_DefaultSnapSpeed)); - } - - void OnDestroy() - { - foreach (var kvp in m_Faces) - ObjectUtils.Destroy(kvp.Value.gameObject); - } - - public MainMenuButton CreateFaceButton(ButtonData buttonData) - { - var button = ObjectUtils.Instantiate(m_ButtonTemplatePrefab.gameObject); - button.name = buttonData.name; - var mainMenuButton = button.GetComponent(); - - if (string.IsNullOrEmpty(buttonData.sectionName)) - buttonData.sectionName = k_UncategorizedFaceName; - - mainMenuButton.SetData(buttonData.name, buttonData.description); - this.ConnectInterfaces(mainMenuButton); - - MainMenuFace face; - if (!m_Faces.TryGetValue(buttonData.sectionName, out face)) - face = CreateFace(buttonData.sectionName); - - if (face == null) - return null; - - face.AddButton(button.transform); - return mainMenuButton; - } - - public GameObject CreateCustomButton(GameObject prefab, string sectionName) - { - var button = ObjectUtils.Instantiate(prefab); - - if (string.IsNullOrEmpty(sectionName)) - sectionName = k_UncategorizedFaceName; - - MainMenuFace face; - if (!m_Faces.TryGetValue(sectionName, out face)) - face = CreateFace(sectionName); - - if (face == null) - return null; - - face.AddButton(button.transform); - - return button; - } - - MainMenuFace CreateFace(string sectionName) - { - if (m_Faces.Count == k_FaceCount) - { - Debug.LogWarning("Main Menu does not support more than 4 faces"); - return null; - } - - var faceTransform = this.InstantiateUI(m_MenuFacePrefab.gameObject).transform; - faceTransform.name = sectionName; - faceTransform.SetParent(m_MenuFaceContainers[m_Faces.Count]); - faceTransform.localRotation = Quaternion.identity; - faceTransform.localScale = Vector3.one; - faceTransform.localPosition = Vector3.zero; - var face = faceTransform.GetComponent(); - m_Faces[sectionName] = face; - face.gradientPair = UnityBrandColorScheme.GetRandomGradient(); - face.title = sectionName; - - return face; - } - - public GameObject AddSubmenu(string sectionName, GameObject submenuPrefab) - { - if (submenuPrefab.GetComponent() == null) - return null; - - MainMenuFace face; - if (!m_Faces.TryGetValue(sectionName, out face)) - face = CreateFace(sectionName); - - var submenu = this.InstantiateUI(submenuPrefab); - - face.AddSubmenu(submenu.transform); - - var submenuFace = submenu.GetComponent(); - if (submenuFace) - { - submenuFace.SetupBackButton(face.RemoveSubmenu); - submenuFace.gradientPair = face.gradientPair; - } - - return submenu; - } - - static int GetClosestFaceIndexForRotation(float rotation) - { - return Mathf.RoundToInt(rotation / k_FaceRotationSnapAngle) % k_FaceCount; - } - - static int GetActualFaceIndexForRotation(float rotation) - { - return Mathf.FloorToInt(rotation / k_FaceRotationSnapAngle) % k_FaceCount; - } - - static float GetRotationForFaceIndex(int faceIndex) - { - return faceIndex * k_FaceRotationSnapAngle; - } - - IEnumerator SnapToFace(int faceIndex, float snapSpeed) - { - if (m_RotationState == RotationState.Snapping) - yield break; - - m_RotationState = RotationState.Snapping; - - // When the user releases their input while rotating the menu, snap to the nearest face - StartCoroutine(AnimateFrameRotationShapeChange(m_RotationState)); - - var rotation = currentRotation; - var faceTargetRotation = GetRotationForFaceIndex(faceIndex); - - var smoothVelocity = 0f; - var smoothSnapSpeed = 0.5f; - while (Mathf.Abs(Mathf.DeltaAngle(rotation, faceTargetRotation)) > k_RotationEpsilon) - { - smoothSnapSpeed = MathUtilsExt.SmoothDamp(smoothSnapSpeed, snapSpeed, ref smoothVelocity, 0.0625f, Mathf.Infinity, Time.deltaTime); - rotation = Mathf.LerpAngle(rotation, faceTargetRotation, Time.deltaTime * smoothSnapSpeed); - m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, rotation, 0)); - yield return null; - } - m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, faceTargetRotation, 0)); - - // Target face index and rotation can be set separately, so both, must be kept in sync - targetRotation = faceTargetRotation; - - m_RotationState = RotationState.AtRest; - } - - IEnumerator AnimateShow() - { - m_VisibilityState = VisibilityState.TransitioningIn; - - foreach (var kvp in m_Faces) - { - kvp.Value.visible = true; - } - - this.RestartCoroutine(ref m_FrameRevealCoroutine, AnimateFrameReveal(m_VisibilityState)); - - const float faceDelay = 0.1f; - var count = 0; - foreach (var face in m_Faces) - { - face.Value.Reveal(count++ * faceDelay); - } - - const float kTargetScale = 1f; - const float kSmoothTime = 0.125f; - var scale = 0f; - var smoothVelocity = 0f; - var currentDuration = 0f; - while (currentDuration < kSmoothTime) - { - scale = MathUtilsExt.SmoothDamp(scale, kTargetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.deltaTime); - currentDuration += Time.deltaTime; - transform.localScale = Vector3.one * scale; - m_AlternateMenu.localScale = m_AlternateMenuOriginOriginalLocalScale * scale; - yield return null; - } - - m_VisibilityState = VisibilityState.Visible; - } - - IEnumerator AnimateHide() - { - m_VisibilityState = VisibilityState.TransitioningOut; - - foreach (var kvp in m_Faces) - { - var face = kvp.Value; - face.visible = false; - face.ClearSubmenus(); - } - - this.RestartCoroutine(ref m_FrameRevealCoroutine, AnimateFrameReveal(m_VisibilityState)); - - const float kTargetScale = 0f; - const float kSmoothTime = 0.06875f; - var scale = transform.localScale.x; - var smoothVelocity = 0f; - var currentDuration = 0f; - while (currentDuration < kSmoothTime) - { - scale = MathUtilsExt.SmoothDamp(scale, kTargetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.deltaTime); - currentDuration += Time.deltaTime; - transform.localScale = Vector3.one * scale; - m_AlternateMenu.localScale = m_AlternateMenuOriginOriginalLocalScale * scale; - yield return null; - } - - gameObject.SetActive(false); - - m_VisibilityState = VisibilityState.Hidden; - - var snapRotation = GetRotationForFaceIndex(GetClosestFaceIndexForRotation(currentRotation)); - m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, snapRotation, 0)); // set intended target rotation - m_RotationState = RotationState.AtRest; - } - - IEnumerator AnimateFrameRotationShapeChange(RotationState rotationState) - { - const float smoothTime = 0.0375f; - const float targetWeight = 0f; - var currentBlendShapeWeight = m_MenuFrameRenderer.GetBlendShapeWeight(0); - var smoothVelocity = 0f; - var currentDuration = 0f; - while (m_RotationState == rotationState && currentDuration < smoothTime) - { - currentBlendShapeWeight = MathUtilsExt.SmoothDamp(currentBlendShapeWeight, targetWeight, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime); - currentDuration += Time.deltaTime; - m_MenuFrameRenderer.SetBlendShapeWeight(0, currentBlendShapeWeight); - yield return null; - } - - if (m_RotationState == rotationState) - m_MenuFrameRenderer.SetBlendShapeWeight(0, targetWeight); - } - - IEnumerator AnimateFrameReveal(VisibilityState visibilityState) - { - m_MenuFrameRenderer.SetBlendShapeWeight(1, 100f); - const float zeroStartBlendShapePadding = 20f; // start the blendShape at a point slightly above the full hidden value for better visibility - const float kLerpEmphasisWeight = 0.25f; - var smoothTime = visibilityState == VisibilityState.TransitioningIn ? 0.1875f : 0.09375f; // slower if transitioning in - var currentBlendShapeWeight = m_MenuFrameRenderer.GetBlendShapeWeight(1); - var targetWeight = visibilityState == VisibilityState.TransitioningIn ? 0f : 100f; - var smoothVelocity = 0f; - currentBlendShapeWeight = currentBlendShapeWeight > 0 ? currentBlendShapeWeight : zeroStartBlendShapePadding; - - var currentDuration = 0f; - while (m_VisibilityState != VisibilityState.Hidden && currentDuration < smoothTime) - { - currentBlendShapeWeight = MathUtilsExt.SmoothDamp(currentBlendShapeWeight, targetWeight, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime); - currentDuration += Time.deltaTime; - m_MenuFrameRenderer.SetBlendShapeWeight(1, currentBlendShapeWeight * currentBlendShapeWeight); - m_MenuFacesMaterial.color = Color.Lerp(m_MenuFacesColor, k_MenuFacesHiddenColor, currentBlendShapeWeight * kLerpEmphasisWeight); - yield return null; - } - - if (m_VisibilityState == visibilityState) - { - m_MenuFrameRenderer.SetBlendShapeWeight(1, targetWeight); - m_MenuFacesMaterial.color = targetWeight > 0 ? m_MenuFacesColor : k_MenuFacesHiddenColor; - } - - if (m_VisibilityState == VisibilityState.Hidden) - m_MenuFrameRenderer.SetBlendShapeWeight(0, 0); - } - - public void OnRayEnter(RayEventData eventData) - { - hovering = true; - } - - public void OnRayExit(RayEventData eventData) - { - hovering = false; - } - } + sealed class MainMenuUI : MonoBehaviour, IInstantiateUI, IConnectInterfaces, IRayEnterHandler, IRayExitHandler + { + public class ButtonData + { + public string name { get; private set; } + public string sectionName { get; set; } + public string description { get; set; } + + public ButtonData(string name) + { + this.name = name.Replace("Tool", string.Empty).Replace("Module", string.Empty) + .Replace("Workspace", string.Empty); + } + } + + enum RotationState + { + AtRest, + Snapping, + } + + enum VisibilityState + { + Hidden, + Visible, + TransitioningIn, + TransitioningOut + } + + const float k_FaceRotationSnapAngle = 90f; + const float k_DefaultSnapSpeed = 10f; + const float k_RotationEpsilon = 1f; + const int k_FaceCount = 4; + + readonly string k_UncategorizedFaceName = "Uncategorized"; + readonly Color k_MenuFacesHiddenColor = new Color(1f, 1f, 1f, 0.5f); + + [SerializeField] + MainMenuButton m_ButtonTemplatePrefab; + + [SerializeField] + Transform[] m_MenuFaceContainers; + + [SerializeField] + MainMenuFace m_MenuFacePrefab; + + [SerializeField] + Transform m_MenuFaceRotationOrigin; + + [SerializeField] + SkinnedMeshRenderer m_MenuFrameRenderer; + + [SerializeField] + Transform m_AlternateMenu; + + int m_TargetFaceIndex; + + readonly Dictionary m_Faces = new Dictionary(); + + VisibilityState m_VisibilityState = VisibilityState.Hidden; + RotationState m_RotationState; + Material m_MenuFacesMaterial; + Color m_MenuFacesColor; + Transform m_MenuOrigin; + Transform m_AlternateMenuOrigin; + Vector3 m_AlternateMenuOriginOriginalLocalScale; + Coroutine m_VisibilityCoroutine; + Coroutine m_FrameRevealCoroutine; + int m_Direction; + + public int targetFaceIndex + { + get { return m_TargetFaceIndex; } + set + { + m_Direction = (int)Mathf.Sign(value - m_TargetFaceIndex); + + // Loop around both ways + if (value < 0) + value += k_FaceCount; + + m_TargetFaceIndex = value % k_FaceCount; + } + } + + public Transform menuOrigin + { + get { return m_MenuOrigin; } + set + { + m_MenuOrigin = value; + transform.SetParent(menuOrigin); + transform.localPosition = Vector3.zero; + transform.localRotation = Quaternion.identity; + transform.localScale = Vector3.one; + } + } + + public Transform alternateMenuOrigin + { + get { return m_AlternateMenuOrigin; } + set + { + m_AlternateMenuOrigin = value; + m_AlternateMenu.SetParent(m_AlternateMenuOrigin); + m_AlternateMenu.localPosition = Vector3.zero; + m_AlternateMenu.localRotation = Quaternion.identity; + m_AlternateMenuOriginOriginalLocalScale = m_AlternateMenu.localScale; + } + } + + public float targetRotation { get; set; } + + public Node? node { get; set; } + + public bool visible + { + get { return m_VisibilityState == VisibilityState.Visible || m_VisibilityState == VisibilityState.TransitioningIn; } + set + { + switch (m_VisibilityState) + { + case VisibilityState.TransitioningOut: + case VisibilityState.Hidden: + if (value) + { + gameObject.SetActive(true); + this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateShow()); + } + + return; + case VisibilityState.TransitioningIn: + case VisibilityState.Visible: + if (!value) + this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHide()); + + return; + } + } + } + + int currentFaceIndex + { + get + { + // Floating point can leave us close to our actual rotation, but not quite (179.3438, + // which effectively we want to treat as 180) + return GetActualFaceIndexForRotation(Mathf.Ceil(currentRotation)); + } + } + + float currentRotation { get { return m_MenuFaceRotationOrigin.localRotation.eulerAngles.y; } } + + public Bounds localBounds { get; private set; } + public bool hovering { get; private set; } + + void Awake() + { + m_MenuFacesMaterial = MaterialUtils.GetMaterialClone(m_MenuFaceRotationOrigin.GetComponent()); + m_MenuFacesColor = m_MenuFacesMaterial.color; + localBounds = ObjectUtils.GetBounds(transform); + } + + public void Setup() + { + transform.localScale = Vector3.zero; + m_AlternateMenu.localScale = Vector3.zero; + gameObject.SetActive(false); + } + + void Update() + { + switch (m_VisibilityState) + { + case VisibilityState.TransitioningIn: + case VisibilityState.TransitioningOut: + case VisibilityState.Hidden: + return; + } + + // Allow any snaps to finish before resuming any other operations + if (m_RotationState == RotationState.Snapping) + return; + + var faceIndex = currentFaceIndex; + + if (faceIndex != targetFaceIndex) + StartCoroutine(SnapToFace(faceIndex + m_Direction, k_DefaultSnapSpeed)); + } + + void OnDestroy() + { + foreach (var kvp in m_Faces) + ObjectUtils.Destroy(kvp.Value.gameObject); + } + + public MainMenuButton CreateFaceButton(ButtonData buttonData) + { + var button = ObjectUtils.Instantiate(m_ButtonTemplatePrefab.gameObject); + button.name = buttonData.name; + var mainMenuButton = button.GetComponent(); + + if (string.IsNullOrEmpty(buttonData.sectionName)) + buttonData.sectionName = k_UncategorizedFaceName; + + mainMenuButton.SetData(buttonData.name, buttonData.description); + this.ConnectInterfaces(mainMenuButton); + + MainMenuFace face; + if (!m_Faces.TryGetValue(buttonData.sectionName, out face)) + face = CreateFace(buttonData.sectionName); + + if (face == null) + return null; + + face.AddButton(button.transform); + return mainMenuButton; + } + + public GameObject CreateCustomButton(GameObject prefab, string sectionName) + { + var button = ObjectUtils.Instantiate(prefab); + + if (string.IsNullOrEmpty(sectionName)) + sectionName = k_UncategorizedFaceName; + + MainMenuFace face; + if (!m_Faces.TryGetValue(sectionName, out face)) + face = CreateFace(sectionName); + + if (face == null) + return null; + + face.AddButton(button.transform); + + return button; + } + + MainMenuFace CreateFace(string sectionName) + { + if (m_Faces.Count == k_FaceCount) + { + Debug.LogWarning("Main Menu does not support more than 4 faces"); + return null; + } + + var faceTransform = this.InstantiateUI(m_MenuFacePrefab.gameObject).transform; + faceTransform.name = sectionName; + faceTransform.SetParent(m_MenuFaceContainers[m_Faces.Count]); + faceTransform.localRotation = Quaternion.identity; + faceTransform.localScale = Vector3.one; + faceTransform.localPosition = Vector3.zero; + var face = faceTransform.GetComponent(); + m_Faces[sectionName] = face; + face.gradientPair = UnityBrandColorScheme.GetRandomGradient(); + face.title = sectionName; + + return face; + } + + public GameObject AddSubmenu(string sectionName, GameObject submenuPrefab) + { + if (submenuPrefab.GetComponent() == null) + return null; + + MainMenuFace face; + if (!m_Faces.TryGetValue(sectionName, out face)) + face = CreateFace(sectionName); + + var submenu = this.InstantiateUI(submenuPrefab); + + face.AddSubmenu(submenu.transform); + + var submenuFace = submenu.GetComponent(); + if (submenuFace) + { + submenuFace.SetupBackButton(face.RemoveSubmenu); + submenuFace.gradientPair = face.gradientPair; + } + + return submenu; + } + + static int GetClosestFaceIndexForRotation(float rotation) + { + return Mathf.RoundToInt(rotation / k_FaceRotationSnapAngle) % k_FaceCount; + } + + static int GetActualFaceIndexForRotation(float rotation) + { + return Mathf.FloorToInt(rotation / k_FaceRotationSnapAngle) % k_FaceCount; + } + + static float GetRotationForFaceIndex(int faceIndex) + { + return faceIndex * k_FaceRotationSnapAngle; + } + + IEnumerator SnapToFace(int faceIndex, float snapSpeed) + { + if (m_RotationState == RotationState.Snapping) + yield break; + + m_RotationState = RotationState.Snapping; + + // When the user releases their input while rotating the menu, snap to the nearest face + StartCoroutine(AnimateFrameRotationShapeChange(m_RotationState)); + + var rotation = currentRotation; + var faceTargetRotation = GetRotationForFaceIndex(faceIndex); + + var smoothVelocity = 0f; + var smoothSnapSpeed = 0.5f; + while (Mathf.Abs(Mathf.DeltaAngle(rotation, faceTargetRotation)) > k_RotationEpsilon) + { + smoothSnapSpeed = MathUtilsExt.SmoothDamp(smoothSnapSpeed, snapSpeed, ref smoothVelocity, 0.0625f, Mathf.Infinity, Time.deltaTime); + rotation = Mathf.LerpAngle(rotation, faceTargetRotation, Time.deltaTime * smoothSnapSpeed); + m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, rotation, 0)); + yield return null; + } + m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, faceTargetRotation, 0)); + + // Target face index and rotation can be set separately, so both, must be kept in sync + targetRotation = faceTargetRotation; + + m_RotationState = RotationState.AtRest; + } + + IEnumerator AnimateShow() + { + m_VisibilityState = VisibilityState.TransitioningIn; + + foreach (var kvp in m_Faces) + { + kvp.Value.visible = true; + } + + this.RestartCoroutine(ref m_FrameRevealCoroutine, AnimateFrameReveal(m_VisibilityState)); + + const float faceDelay = 0.1f; + var count = 0; + foreach (var face in m_Faces) + { + face.Value.Reveal(count++ * faceDelay); + } + + const float kTargetScale = 1f; + const float kSmoothTime = 0.125f; + var scale = 0f; + var smoothVelocity = 0f; + var currentDuration = 0f; + while (currentDuration < kSmoothTime) + { + scale = MathUtilsExt.SmoothDamp(scale, kTargetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.deltaTime); + currentDuration += Time.deltaTime; + transform.localScale = Vector3.one * scale; + m_AlternateMenu.localScale = m_AlternateMenuOriginOriginalLocalScale * scale; + yield return null; + } + + m_VisibilityState = VisibilityState.Visible; + } + + IEnumerator AnimateHide() + { + m_VisibilityState = VisibilityState.TransitioningOut; + + foreach (var kvp in m_Faces) + { + var face = kvp.Value; + face.visible = false; + face.ClearSubmenus(); + } + + this.RestartCoroutine(ref m_FrameRevealCoroutine, AnimateFrameReveal(m_VisibilityState)); + + const float kTargetScale = 0f; + const float kSmoothTime = 0.06875f; + var scale = transform.localScale.x; + var smoothVelocity = 0f; + var currentDuration = 0f; + while (currentDuration < kSmoothTime) + { + scale = MathUtilsExt.SmoothDamp(scale, kTargetScale, ref smoothVelocity, kSmoothTime, Mathf.Infinity, Time.deltaTime); + currentDuration += Time.deltaTime; + transform.localScale = Vector3.one * scale; + m_AlternateMenu.localScale = m_AlternateMenuOriginOriginalLocalScale * scale; + yield return null; + } + + gameObject.SetActive(false); + + m_VisibilityState = VisibilityState.Hidden; + + var snapRotation = GetRotationForFaceIndex(GetClosestFaceIndexForRotation(currentRotation)); + m_MenuFaceRotationOrigin.localRotation = Quaternion.Euler(new Vector3(0, snapRotation, 0)); // set intended target rotation + m_RotationState = RotationState.AtRest; + } + + IEnumerator AnimateFrameRotationShapeChange(RotationState rotationState) + { + const float smoothTime = 0.0375f; + const float targetWeight = 0f; + var currentBlendShapeWeight = m_MenuFrameRenderer.GetBlendShapeWeight(0); + var smoothVelocity = 0f; + var currentDuration = 0f; + while (m_RotationState == rotationState && currentDuration < smoothTime) + { + currentBlendShapeWeight = MathUtilsExt.SmoothDamp(currentBlendShapeWeight, targetWeight, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime); + currentDuration += Time.deltaTime; + m_MenuFrameRenderer.SetBlendShapeWeight(0, currentBlendShapeWeight); + yield return null; + } + + if (m_RotationState == rotationState) + m_MenuFrameRenderer.SetBlendShapeWeight(0, targetWeight); + } + + IEnumerator AnimateFrameReveal(VisibilityState visibilityState) + { + m_MenuFrameRenderer.SetBlendShapeWeight(1, 100f); + const float zeroStartBlendShapePadding = 20f; // start the blendShape at a point slightly above the full hidden value for better visibility + const float kLerpEmphasisWeight = 0.25f; + var smoothTime = visibilityState == VisibilityState.TransitioningIn ? 0.1875f : 0.09375f; // slower if transitioning in + var currentBlendShapeWeight = m_MenuFrameRenderer.GetBlendShapeWeight(1); + var targetWeight = visibilityState == VisibilityState.TransitioningIn ? 0f : 100f; + var smoothVelocity = 0f; + currentBlendShapeWeight = currentBlendShapeWeight > 0 ? currentBlendShapeWeight : zeroStartBlendShapePadding; + + var currentDuration = 0f; + while (m_VisibilityState != VisibilityState.Hidden && currentDuration < smoothTime) + { + currentBlendShapeWeight = MathUtilsExt.SmoothDamp(currentBlendShapeWeight, targetWeight, ref smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime); + currentDuration += Time.deltaTime; + m_MenuFrameRenderer.SetBlendShapeWeight(1, currentBlendShapeWeight * currentBlendShapeWeight); + m_MenuFacesMaterial.color = Color.Lerp(m_MenuFacesColor, k_MenuFacesHiddenColor, currentBlendShapeWeight * kLerpEmphasisWeight); + yield return null; + } + + if (m_VisibilityState == visibilityState) + { + m_MenuFrameRenderer.SetBlendShapeWeight(1, targetWeight); + m_MenuFacesMaterial.color = targetWeight > 0 ? m_MenuFacesColor : k_MenuFacesHiddenColor; + } + + if (m_VisibilityState == VisibilityState.Hidden) + m_MenuFrameRenderer.SetBlendShapeWeight(0, 0); + } + + public void OnRayEnter(RayEventData eventData) + { + hovering = true; + } + + public void OnRayExit(RayEventData eventData) + { + hovering = false; + } + } } + #endif diff --git a/Menus/RadialMenu/RadialMenu.cs b/Menus/RadialMenu/RadialMenu.cs index 4c182b5c2..a74e7417a 100644 --- a/Menus/RadialMenu/RadialMenu.cs +++ b/Menus/RadialMenu/RadialMenu.cs @@ -7,141 +7,143 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class RadialMenu : MonoBehaviour, IInstantiateUI, IAlternateMenu, IUsesMenuOrigins, ICustomActionMap, - IControlHaptics, IUsesNode, IConnectInterfaces - { - const float k_ActivationThreshold = 0.5f; // Do not consume thumbstick or activate menu if the control vector's magnitude is below this threshold - - public ActionMap actionMap { get {return m_RadialMenuActionMap; } } - [SerializeField] - ActionMap m_RadialMenuActionMap; - - [SerializeField] - RadialMenuUI m_RadialMenuPrefab; - - [SerializeField] - HapticPulse m_ReleasePulse; - - [SerializeField] - HapticPulse m_ButtonHoverPulse; - - [SerializeField] - HapticPulse m_ButtonClickedPulse; - - RadialMenuUI m_RadialMenuUI; - List m_MenuActions; - Transform m_AlternateMenuOrigin; - MenuHideFlags m_MenuHideFlags = MenuHideFlags.Hidden; - - public event Action itemWasSelected; - - public Transform rayOrigin { private get; set; } - - public Transform menuOrigin { get; set; } - - public GameObject menuContent { get { return m_RadialMenuUI.gameObject; } } - - public Node? node { get; set; } - - public Bounds localBounds { get { return default(Bounds); } } - - public List menuActions - { - get { return m_MenuActions; } - set - { - m_MenuActions = value; - - if (m_RadialMenuUI) - m_RadialMenuUI.actions = value; - } - } - - public Transform alternateMenuOrigin - { - get { return m_AlternateMenuOrigin; } - set - { - m_AlternateMenuOrigin = value; - - if (m_RadialMenuUI != null) - m_RadialMenuUI.alternateMenuOrigin = value; - } - } - - public MenuHideFlags menuHideFlags - { - get { return m_MenuHideFlags; } - set - { - if (m_MenuHideFlags != value) - { - m_MenuHideFlags = value; - if (m_RadialMenuUI) - m_RadialMenuUI.visible = value == 0; - } - } - } - - void Start() - { - m_RadialMenuUI = this.InstantiateUI(m_RadialMenuPrefab.gameObject).GetComponent(); - m_RadialMenuUI.alternateMenuOrigin = alternateMenuOrigin; - m_RadialMenuUI.actions = menuActions; - this.ConnectInterfaces(m_RadialMenuUI); // Connect interfaces before performing setup on the UI - m_RadialMenuUI.Setup(); - m_RadialMenuUI.buttonHovered += OnButtonHovered; - m_RadialMenuUI.buttonClicked += OnButtonClicked; - } - - public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) - { - var radialMenuInput = (RadialMenuInput)input; - if (radialMenuInput == null || m_MenuHideFlags != 0) - return; - - var inputDirection = radialMenuInput.navigate.vector2; - - if (inputDirection.magnitude > k_ActivationThreshold) - { - // Composite controls need to be consumed separately - consumeControl(radialMenuInput.navigateX); - consumeControl(radialMenuInput.navigateY); - m_RadialMenuUI.buttonInputDirection = inputDirection; - } - else - { - m_RadialMenuUI.buttonInputDirection = Vector3.zero; - return; - } - - var selectControl = radialMenuInput.selectItem; - m_RadialMenuUI.pressedDown = selectControl.wasJustPressed; - if (m_RadialMenuUI.pressedDown) - consumeControl(selectControl); - - if (selectControl.wasJustReleased) - { - this.Pulse(node, m_ReleasePulse); - - m_RadialMenuUI.SelectionOccurred(); - - if (itemWasSelected != null) - itemWasSelected(rayOrigin); - - consumeControl(selectControl); - } - } - - void OnButtonClicked() - { - this.Pulse(node, m_ButtonClickedPulse); - } - - void OnButtonHovered() - { - this.Pulse(node, m_ButtonHoverPulse); - } - } + sealed class RadialMenu : MonoBehaviour, IInstantiateUI, IAlternateMenu, IUsesMenuOrigins, ICustomActionMap, + IControlHaptics, IUsesNode, IConnectInterfaces + { + const float k_ActivationThreshold = 0.5f; // Do not consume thumbstick or activate menu if the control vector's magnitude is below this threshold + + public ActionMap actionMap { get { return m_RadialMenuActionMap; } } + + [SerializeField] + ActionMap m_RadialMenuActionMap; + + [SerializeField] + RadialMenuUI m_RadialMenuPrefab; + + [SerializeField] + HapticPulse m_ReleasePulse; + + [SerializeField] + HapticPulse m_ButtonHoverPulse; + + [SerializeField] + HapticPulse m_ButtonClickedPulse; + + RadialMenuUI m_RadialMenuUI; + List m_MenuActions; + Transform m_AlternateMenuOrigin; + MenuHideFlags m_MenuHideFlags = MenuHideFlags.Hidden; + + public event Action itemWasSelected; + + public Transform rayOrigin { private get; set; } + + public Transform menuOrigin { get; set; } + + public GameObject menuContent { get { return m_RadialMenuUI.gameObject; } } + + public Node? node { get; set; } + + public Bounds localBounds { get { return default(Bounds); } } + + public List menuActions + { + get { return m_MenuActions; } + set + { + m_MenuActions = value; + + if (m_RadialMenuUI) + m_RadialMenuUI.actions = value; + } + } + + public Transform alternateMenuOrigin + { + get { return m_AlternateMenuOrigin; } + set + { + m_AlternateMenuOrigin = value; + + if (m_RadialMenuUI != null) + m_RadialMenuUI.alternateMenuOrigin = value; + } + } + + public MenuHideFlags menuHideFlags + { + get { return m_MenuHideFlags; } + set + { + if (m_MenuHideFlags != value) + { + m_MenuHideFlags = value; + if (m_RadialMenuUI) + m_RadialMenuUI.visible = value == 0; + } + } + } + + void Start() + { + m_RadialMenuUI = this.InstantiateUI(m_RadialMenuPrefab.gameObject).GetComponent(); + m_RadialMenuUI.alternateMenuOrigin = alternateMenuOrigin; + m_RadialMenuUI.actions = menuActions; + this.ConnectInterfaces(m_RadialMenuUI); // Connect interfaces before performing setup on the UI + m_RadialMenuUI.Setup(); + m_RadialMenuUI.buttonHovered += OnButtonHovered; + m_RadialMenuUI.buttonClicked += OnButtonClicked; + } + + public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) + { + var radialMenuInput = (RadialMenuInput)input; + if (radialMenuInput == null || m_MenuHideFlags != 0) + return; + + var inputDirection = radialMenuInput.navigate.vector2; + + if (inputDirection.magnitude > k_ActivationThreshold) + { + // Composite controls need to be consumed separately + consumeControl(radialMenuInput.navigateX); + consumeControl(radialMenuInput.navigateY); + m_RadialMenuUI.buttonInputDirection = inputDirection; + } + else + { + m_RadialMenuUI.buttonInputDirection = Vector3.zero; + return; + } + + var selectControl = radialMenuInput.selectItem; + m_RadialMenuUI.pressedDown = selectControl.wasJustPressed; + if (m_RadialMenuUI.pressedDown) + consumeControl(selectControl); + + if (selectControl.wasJustReleased) + { + this.Pulse(node, m_ReleasePulse); + + m_RadialMenuUI.SelectionOccurred(); + + if (itemWasSelected != null) + itemWasSelected(rayOrigin); + + consumeControl(selectControl); + } + } + + void OnButtonClicked() + { + this.Pulse(node, m_ButtonClickedPulse); + } + + void OnButtonHovered() + { + this.Pulse(node, m_ButtonHoverPulse); + } + } } + #endif diff --git a/Menus/RadialMenu/Scripts/RadialMenuSlot.cs b/Menus/RadialMenu/Scripts/RadialMenuSlot.cs index 232b2e708..16033cae4 100644 --- a/Menus/RadialMenu/Scripts/RadialMenuSlot.cs +++ b/Menus/RadialMenu/Scripts/RadialMenuSlot.cs @@ -10,498 +10,517 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class RadialMenuSlot : MonoBehaviour, ISetTooltipVisibility, ITooltip, ITooltipPlacement, IRayEnterHandler, IRayExitHandler - { - static Color s_FrameOpaqueColor; - static readonly Vector3 k_HiddenLocalScale = new Vector3(1f, 0f, 1f); - const float k_IconHighlightedLocalYOffset = 0.006f; - const string k_MaterialAlphaProperty = "_Alpha"; - const string k_MaterialExpandProperty = "_Expand"; - const string k_MaterialColorTopProperty = "_ColorTop"; - const string k_MaterialColorBottomProperty = "_ColorBottom"; - const string k_MaterialColorProperty = "_Color"; - - [SerializeField] - MeshRenderer m_InsetMeshRenderer; - - [SerializeField] - Transform m_MenuInset; - - [SerializeField] - CanvasGroup m_CanvasGroup; - - [SerializeField] - Image m_Icon; - - [SerializeField] - Transform m_IconContainer; - - [SerializeField] - Button m_Button; - - [SerializeField] - MeshRenderer m_BorderRenderer; - - [SerializeField] - MeshRenderer m_FrameRenderer; - - public Transform tooltipTarget { get { return m_TooltipTarget; } } - [SerializeField] - Transform m_TooltipTarget; - - public Transform tooltipSource { get { return m_TooltipSource; } } - [SerializeField] - Transform m_TooltipSource; - - public TextAlignment tooltipAlignment { get; private set; } - - public bool pressed - { - set - { - // Proceed only if value is true after previously being false - if (m_Highlighted && value != m_Pressed && value && gameObject.activeSelf) - { - m_Pressed = value; - - this.StopCoroutine(ref m_IconHighlightCoroutine); - - // Don't begin a new icon highlight coroutine; Allow the currently running coroutine to finish itself according to the m_Highlighted value - SetIconPressed(); - } - } - } - bool m_Pressed; - - public bool highlighted - { - set - { - if (m_Highlighted == value || !gameObject.activeSelf) - return; - - this.StopCoroutine(ref m_IconHighlightCoroutine); - - m_Highlighted = value; - if (m_Highlighted) - { - // Only start the highlight coroutine if the highlight coroutine isnt already playing. Otherwise allow it to gracefully finish. - if (m_HighlightCoroutine == null) - m_HighlightCoroutine = StartCoroutine(Highlight()); - - if (hovered != null) - hovered(); - } - else - { - m_IconHighlightCoroutine = StartCoroutine(IconEndHighlight()); - } - - if (m_Highlighted) - this.ShowTooltip(this); - else - this.HideTooltip(this); - } - - get { return m_Highlighted; } - } - bool m_Highlighted; - - public bool semiTransparent - { - get { return m_SemiTransparent; } - set - { - if (value == m_SemiTransparent || !gameObject.activeSelf) - return; - - m_SemiTransparent = value; - - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateSemiTransparent(value)); - PostReveal(); - } - } - bool m_SemiTransparent; - - public bool visible - { - set - { - if (value && m_Visible == value) // Allow false to fall through and perform hiding regardless of visibility - return; - - m_Visible = value; - - if (value) - { - gameObject.SetActive(true); - m_MenuInset.localScale = m_HiddenInsetLocalScale; - m_Pressed = false; - m_Highlighted = false; - m_CanvasGroup.interactable = false; - - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateShow()); - } - else if (gameObject.activeSelf) - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHide()); - } - } - bool m_Visible; - - public GradientPair gradientPair - { - set - { - s_GradientPair = value; - m_BorderRendererMaterial.SetColor(k_MaterialColorTopProperty, value.a); - m_BorderRendererMaterial.SetColor(k_MaterialColorBottomProperty, value.b); - } - } - static GradientPair s_GradientPair; - - public Material borderRendererMaterial - { - get { return MaterialUtils.GetMaterialClone(m_BorderRenderer); } // return new unique color to the RadialMenuUI for settings in each RadialMenuSlot contained in a given RadialMenu - set - { - m_BorderRendererMaterial = value; - m_BorderRenderer.sharedMaterial = value; - } - } - Material m_BorderRendererMaterial; - - GradientPair m_OriginalInsetGradientPair; - Material m_InsetMaterial; - Vector3 m_VisibleInsetLocalScale; - Vector3 m_HiddenInsetLocalScale; - Vector3 m_HighlightedInsetLocalScale; - Vector3 m_OriginalIconLocalPosition; - Vector3 m_IconHighlightedLocalPosition; - Vector3 m_IconPressedLocalPosition; - float m_IconLookForwardOffset = 0.5f; - Vector3 m_IconLookDirection; - Material m_FrameMaterial; - Material m_IconMaterial; - Color m_SemiTransparentFrameColor; - - Coroutine m_VisibilityCoroutine; - Coroutine m_HighlightCoroutine; - Coroutine m_IconHighlightCoroutine; - Coroutine m_InsetRevealCoroutine; - Coroutine m_RayExitDelayCoroutine; - - public string tooltipText { get { return tooltip != null ? tooltip.tooltipText : m_TooltipText; } set { m_TooltipText = value; } } - string m_TooltipText; - - public Sprite icon { set { m_Icon.sprite = value; } get { return m_Icon.sprite; } } - public Button button { get { return m_Button; } } - - public int orderIndex { get; set; } - - public static Quaternion hiddenLocalRotation { get; set; } // All menu slots share the same hidden location - - public Quaternion visibleLocalRotation { get; set; } - - // For overriding text (i.e. TransformActions) - public ITooltip tooltip { private get; set; } - - public event Action hovered; - - void Awake() - { - m_InsetMaterial = MaterialUtils.GetMaterialClone(m_InsetMeshRenderer); - m_IconMaterial = MaterialUtils.GetMaterialClone(m_Icon); - m_OriginalInsetGradientPair = new GradientPair(m_InsetMaterial.GetColor(k_MaterialColorTopProperty), m_InsetMaterial.GetColor(k_MaterialColorBottomProperty)); - hiddenLocalRotation = transform.localRotation; - m_VisibleInsetLocalScale = m_MenuInset.localScale; - m_HighlightedInsetLocalScale = new Vector3(m_VisibleInsetLocalScale.x, m_VisibleInsetLocalScale.y * 1.2f, m_VisibleInsetLocalScale.z); - m_VisibleInsetLocalScale = new Vector3(m_VisibleInsetLocalScale.x, m_MenuInset.localScale.y * 0.35f, m_VisibleInsetLocalScale.z); - m_HiddenInsetLocalScale = new Vector3(m_VisibleInsetLocalScale.x * 0.5f, 0f, m_VisibleInsetLocalScale.z * 0.5f); - - m_OriginalIconLocalPosition = m_IconContainer.localPosition; - m_IconHighlightedLocalPosition = m_OriginalIconLocalPosition + Vector3.up * k_IconHighlightedLocalYOffset; - m_IconPressedLocalPosition = m_OriginalIconLocalPosition + Vector3.up * -k_IconHighlightedLocalYOffset; - - semiTransparent = false; - m_FrameMaterial = MaterialUtils.GetMaterialClone(m_FrameRenderer); - var frameMaterialColor = m_FrameMaterial.color; - s_FrameOpaqueColor = new Color(frameMaterialColor.r, frameMaterialColor.g, frameMaterialColor.b, 1f); - m_SemiTransparentFrameColor = new Color(s_FrameOpaqueColor.r, s_FrameOpaqueColor.g, s_FrameOpaqueColor.b, 0.5f); - } - - void OnDisable() - { - this.StopCoroutine(ref m_VisibilityCoroutine); - this.StopCoroutine(ref m_HighlightCoroutine); - this.StopCoroutine(ref m_IconHighlightCoroutine); - } - - void OnDestroy() - { - ObjectUtils.Destroy(m_InsetMaterial); - ObjectUtils.Destroy(m_IconMaterial); - ObjectUtils.Destroy(m_FrameMaterial); - } - - public void CorrectIconRotation() - { - m_IconLookDirection = m_Icon.transform.position + transform.parent.forward * m_IconLookForwardOffset; // set a position offset above the icon, regardless of the icon's rotation - m_IconContainer.LookAt(m_IconLookDirection); - m_IconContainer.localEulerAngles = new Vector3(0f, m_IconContainer.localEulerAngles.y, 0f); - var angle = m_IconContainer.localEulerAngles.y; - m_IconContainer.localEulerAngles = new Vector3(0f, angle, 0f); - m_TooltipTarget.localEulerAngles = new Vector3(90f, angle, 0f); - - var yaw = transform.localRotation.eulerAngles.y; - tooltipAlignment = yaw > 90 && yaw <= 270 ? TextAlignment.Right : TextAlignment.Left; - } - - IEnumerator AnimateShow() - { - m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, 0); - m_InsetMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalInsetGradientPair.a); - m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalInsetGradientPair.b); - m_FrameMaterial.SetColor(k_MaterialColorProperty, s_FrameOpaqueColor); - m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 0); - m_MenuInset.localScale = m_HiddenInsetLocalScale ; - transform.localScale = k_HiddenLocalScale; - m_IconContainer.localPosition = m_OriginalIconLocalPosition; - - this.RestartCoroutine(ref m_InsetRevealCoroutine, ShowInset()); - - var opacity = 0f; - var positionWait = orderIndex * 0.05f; - while (opacity < 1) - { - opacity += Time.deltaTime / positionWait * 2; - var opacityShaped = Mathf.Pow(opacity, opacity); - - transform.localScale = Vector3.Lerp(k_HiddenLocalScale, Vector3.one, opacity); - m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 1 - opacityShaped); - CorrectIconRotation(); - yield return null; - } - - transform.localScale = Vector3.one; - m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 0); - PostReveal(); - - m_VisibilityCoroutine = null; - } - - void PostReveal() - { - m_CanvasGroup.interactable = true; - CorrectIconRotation(); - } - - IEnumerator ShowInset() - { - m_CanvasGroup.alpha = 0.0001f; - - var duration = 0f; - var positionWait = (orderIndex + 1) * 0.075f; - while (duration < 2) - { - duration += Time.deltaTime / positionWait * 2; - var opacity = duration / 2; - opacity *= opacity; - m_CanvasGroup.alpha = Mathf.Clamp01(duration - 1); - m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, opacity); - m_MenuInset.localScale = Vector3.Lerp(m_HiddenInsetLocalScale, m_VisibleInsetLocalScale, opacity); - yield return null; - } - - m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, 1); - m_MenuInset.localScale = m_VisibleInsetLocalScale; - m_InsetRevealCoroutine = null; - } - - IEnumerator AnimateHide() - { - this.HideTooltip(this); - - m_CanvasGroup.interactable = false; - m_Pressed = false; - m_Highlighted = false; - - var opacity = m_InsetMaterial.GetFloat(k_MaterialAlphaProperty); - var opacityShaped = Mathf.Pow(opacity, opacity); - while (opacity > 0) - { - var newScale = Vector3.one * opacity * opacityShaped * (opacity * 0.5f); - transform.localScale = newScale; - - m_CanvasGroup.alpha = opacityShaped; - m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, opacityShaped); - m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, opacityShaped); - m_MenuInset.localScale = Vector3.Lerp(m_HiddenInsetLocalScale, m_VisibleInsetLocalScale, opacityShaped); - opacity -= Time.deltaTime * 1.5f; - opacityShaped = Mathf.Pow(opacity, opacity); - CorrectIconRotation(); - yield return null; - } - - FadeOutCleanup(); - m_VisibilityCoroutine = null; - gameObject.SetActive(false); - } - - void FadeOutCleanup() - { - m_CanvasGroup.alpha = 0; - m_InsetMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalInsetGradientPair.a); - m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalInsetGradientPair.b); - m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 1); - m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, 0); - m_MenuInset.localScale = m_HiddenInsetLocalScale; - CorrectIconRotation(); - transform.localScale = Vector3.zero; - this.HideTooltip(this); - } - - IEnumerator Highlight() - { - HighlightIcon(); - - var opacity = Time.deltaTime; - var topColor = m_OriginalInsetGradientPair.a; - var bottomColor = m_OriginalInsetGradientPair.b; - var initialFrameColor = m_FrameMaterial.color; - var currentFrameColor = initialFrameColor; - while (opacity > 0) - { - if (m_Highlighted) - { - opacity = Mathf.Clamp01(opacity + Time.deltaTime*4); // stay highlighted - currentFrameColor = Color.Lerp(initialFrameColor, s_FrameOpaqueColor, opacity); - m_FrameMaterial.SetColor(k_MaterialColorProperty, currentFrameColor); - } - else - opacity = Mathf.Clamp01(opacity - Time.deltaTime * 2); - - topColor = Color.Lerp(m_OriginalInsetGradientPair.a, s_GradientPair.a, opacity * 2f); - bottomColor = Color.Lerp(m_OriginalInsetGradientPair.b, s_GradientPair.b, opacity); - - m_InsetMaterial.SetColor(k_MaterialColorTopProperty, topColor); - m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, bottomColor); - - if (!semiTransparent) - m_MenuInset.localScale = Vector3.Lerp(m_VisibleInsetLocalScale, m_HighlightedInsetLocalScale, opacity * opacity); - - yield return null; - } - - m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 0); - m_InsetMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalInsetGradientPair.a); - m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalInsetGradientPair.b); - - m_HighlightCoroutine = null; - } - - void HighlightIcon() - { - this.StopCoroutine(ref m_IconHighlightCoroutine); - m_IconHighlightCoroutine = StartCoroutine(IconHighlightAnimatedShow()); - } - - void SetIconPressed() - { - this.StopCoroutine(ref m_IconHighlightCoroutine); - m_IconHighlightCoroutine = StartCoroutine(IconHighlightAnimatedShow(true)); - } - - IEnumerator IconHighlightAnimatedShow(bool pressed = false) - { - var currentPosition = m_IconContainer.localPosition; - var targetPosition = pressed == false ? m_IconHighlightedLocalPosition : m_IconPressedLocalPosition; // Raise up for highlight; lower for press - var transitionAmount = Time.deltaTime; - var transitionAddMultiplier = pressed == false ? 14 : 18; // Faster transition in for standard highlight; slower for pressed highlight - while (transitionAmount < 1) - { - m_IconContainer.localPosition = Vector3.Lerp(currentPosition, targetPosition, transitionAmount); - transitionAmount = transitionAmount + Time.deltaTime * transitionAddMultiplier * 2; - yield return null; - } - - m_IconContainer.localPosition = targetPosition; - m_IconHighlightCoroutine = null; - } - - IEnumerator IconEndHighlight() - { - var currentPosition = m_IconContainer.localPosition; - var transitionAmount = 1f; // this should account for the magnitude difference between the highlightedYPositionOffset, and the current magnitude difference between the local Y and the original Y - var transitionSubtractMultiplier = 5f; - while (transitionAmount > 0) - { - m_IconContainer.localPosition = Vector3.Lerp(m_OriginalIconLocalPosition, currentPosition, transitionAmount); - transitionAmount -= Time.deltaTime * transitionSubtractMultiplier; - yield return null; - } - - m_IconContainer.localPosition = m_OriginalIconLocalPosition; - m_IconHighlightCoroutine = null; - } - - IEnumerator AnimateSemiTransparent(bool makeSemiTransparent) - { - if (m_InsetRevealCoroutine != null) - { - // In case semiTransparency is triggered immediately upon showing the radial menu - this.StopCoroutine(ref m_InsetRevealCoroutine); - m_CanvasGroup.alpha = 1f; - PostReveal(); - } - - const float kFasterMotionMultiplier = 2f; - var transitionAmount = Time.deltaTime; - var positionWait = (orderIndex + 4) * 0.25f; // pad the order index for a faster start to the transition - var currentScale = transform.localScale; - var targetScale = Vector3.one; - var currentFrameColor = m_FrameMaterial.color; - var transparentFrameColor = new Color (s_FrameOpaqueColor.r, s_FrameOpaqueColor.g, s_FrameOpaqueColor.b, 0f); - var targetFrameColor = m_CanvasGroup.interactable ? (makeSemiTransparent ? m_SemiTransparentFrameColor : s_FrameOpaqueColor) : transparentFrameColor; - var currentInsetAlpha = m_InsetMaterial.GetFloat(k_MaterialAlphaProperty); - var targetInsetAlpha = makeSemiTransparent ? 0.25f : 1f; - var currentIconColor = m_IconMaterial.GetColor(k_MaterialColorProperty); - var targetIconColor = makeSemiTransparent ? m_SemiTransparentFrameColor : Color.white; - var currentInsetScale = m_MenuInset.localScale; - var targetInsetScale = makeSemiTransparent ? m_HighlightedInsetLocalScale * 4 : m_VisibleInsetLocalScale; - var currentIconScale = m_IconContainer.localScale; - var semiTransparentTargetIconScale = Vector3.one * 1.5f; - var targetIconScale = makeSemiTransparent ? semiTransparentTargetIconScale : Vector3.one; - while (transitionAmount < 1) - { - m_FrameMaterial.SetColor(k_MaterialColorProperty, Color.Lerp(currentFrameColor, targetFrameColor, transitionAmount * kFasterMotionMultiplier)); - m_MenuInset.localScale = Vector3.Lerp(currentInsetScale, targetInsetScale, transitionAmount * 2f); - m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, Mathf.Lerp(currentInsetAlpha, targetInsetAlpha, transitionAmount)); - m_IconMaterial.SetColor(k_MaterialColorProperty, Color.Lerp(currentIconColor, targetIconColor, transitionAmount)); - var shapedTransitionAmount = Mathf.Pow(transitionAmount, makeSemiTransparent ? 2 : 1) * kFasterMotionMultiplier; - transform.localScale = Vector3.Lerp(currentScale, targetScale, shapedTransitionAmount); - m_IconContainer.localScale = Vector3.Lerp(currentIconScale, targetIconScale, shapedTransitionAmount); - transitionAmount += Time.deltaTime * positionWait * 3f; - CorrectIconRotation(); - yield return null; - } - - transform.localScale = targetScale; - m_FrameMaterial.SetColor(k_MaterialColorProperty, targetFrameColor); - m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, targetInsetAlpha); - m_IconMaterial.SetColor(k_MaterialColorProperty, targetIconColor); - m_MenuInset.localScale = targetInsetScale; - m_IconContainer.localScale = targetIconScale; - } - - public void OnRayEnter(RayEventData eventData) - { - highlighted = true; - } - - public void OnRayExit(RayEventData eventData) - { - highlighted = false; - } - } + sealed class RadialMenuSlot : MonoBehaviour, ISetTooltipVisibility, ITooltip, ITooltipPlacement, IRayEnterHandler, IRayExitHandler + { + static Color s_FrameOpaqueColor; + static readonly Vector3 k_HiddenLocalScale = new Vector3(1f, 0f, 1f); + const float k_IconHighlightedLocalYOffset = 0.006f; + const string k_MaterialAlphaProperty = "_Alpha"; + const string k_MaterialExpandProperty = "_Expand"; + const string k_MaterialColorTopProperty = "_ColorTop"; + const string k_MaterialColorBottomProperty = "_ColorBottom"; + const string k_MaterialColorProperty = "_Color"; + + [SerializeField] + MeshRenderer m_InsetMeshRenderer; + + [SerializeField] + Transform m_MenuInset; + + [SerializeField] + CanvasGroup m_CanvasGroup; + + [SerializeField] + Image m_Icon; + + [SerializeField] + Transform m_IconContainer; + + [SerializeField] + Button m_Button; + + [SerializeField] + MeshRenderer m_BorderRenderer; + + [SerializeField] + MeshRenderer m_FrameRenderer; + + public Transform tooltipTarget { get { return m_TooltipTarget; } } + + [SerializeField] + Transform m_TooltipTarget; + + public Transform tooltipSource { get { return m_TooltipSource; } } + + [SerializeField] + Transform m_TooltipSource; + + public TextAlignment tooltipAlignment { get; private set; } + + public bool pressed + { + set + { + // Proceed only if value is true after previously being false + if (m_Highlighted && value != m_Pressed && value && gameObject.activeSelf) + { + m_Pressed = value; + + this.StopCoroutine(ref m_IconHighlightCoroutine); + + // Don't begin a new icon highlight coroutine; Allow the currently running coroutine to finish itself according to the m_Highlighted value + SetIconPressed(); + } + } + } + + bool m_Pressed; + + public bool highlighted + { + set + { + if (m_Highlighted == value || !gameObject.activeSelf) + return; + + this.StopCoroutine(ref m_IconHighlightCoroutine); + + m_Highlighted = value; + if (m_Highlighted) + { + // Only start the highlight coroutine if the highlight coroutine isnt already playing. Otherwise allow it to gracefully finish. + if (m_HighlightCoroutine == null) + m_HighlightCoroutine = StartCoroutine(Highlight()); + + if (hovered != null) + hovered(); + } + else + { + m_IconHighlightCoroutine = StartCoroutine(IconEndHighlight()); + } + + if (m_Highlighted) + this.ShowTooltip(this); + else + this.HideTooltip(this); + } + + get { return m_Highlighted; } + } + + bool m_Highlighted; + + public bool semiTransparent + { + get { return m_SemiTransparent; } + set + { + if (value == m_SemiTransparent || !gameObject.activeSelf) + return; + + m_SemiTransparent = value; + + this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateSemiTransparent(value)); + PostReveal(); + } + } + + bool m_SemiTransparent; + + public bool visible + { + set + { + if (value && m_Visible == value) // Allow false to fall through and perform hiding regardless of visibility + return; + + m_Visible = value; + + if (value) + { + gameObject.SetActive(true); + m_MenuInset.localScale = m_HiddenInsetLocalScale; + m_Pressed = false; + m_Highlighted = false; + m_CanvasGroup.interactable = false; + + this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateShow()); + } + else if (gameObject.activeSelf) + this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHide()); + } + } + + bool m_Visible; + + public GradientPair gradientPair + { + set + { + s_GradientPair = value; + m_BorderRendererMaterial.SetColor(k_MaterialColorTopProperty, value.a); + m_BorderRendererMaterial.SetColor(k_MaterialColorBottomProperty, value.b); + } + } + + static GradientPair s_GradientPair; + + public Material borderRendererMaterial + { + get { return MaterialUtils.GetMaterialClone(m_BorderRenderer); } // return new unique color to the RadialMenuUI for settings in each RadialMenuSlot contained in a given RadialMenu + set + { + m_BorderRendererMaterial = value; + m_BorderRenderer.sharedMaterial = value; + } + } + + Material m_BorderRendererMaterial; + + GradientPair m_OriginalInsetGradientPair; + Material m_InsetMaterial; + Vector3 m_VisibleInsetLocalScale; + Vector3 m_HiddenInsetLocalScale; + Vector3 m_HighlightedInsetLocalScale; + Vector3 m_OriginalIconLocalPosition; + Vector3 m_IconHighlightedLocalPosition; + Vector3 m_IconPressedLocalPosition; + float m_IconLookForwardOffset = 0.5f; + Vector3 m_IconLookDirection; + Material m_FrameMaterial; + Material m_IconMaterial; + Color m_SemiTransparentFrameColor; + + Coroutine m_VisibilityCoroutine; + Coroutine m_HighlightCoroutine; + Coroutine m_IconHighlightCoroutine; + Coroutine m_InsetRevealCoroutine; + Coroutine m_RayExitDelayCoroutine; + + public string tooltipText + { + get { return tooltip != null ? tooltip.tooltipText : m_TooltipText; } + set { m_TooltipText = value; } + } + + string m_TooltipText; + + public Sprite icon + { + set { m_Icon.sprite = value; } + get { return m_Icon.sprite; } + } + + public Button button { get { return m_Button; } } + + public int orderIndex { get; set; } + + public static Quaternion hiddenLocalRotation { get; set; } // All menu slots share the same hidden location + + public Quaternion visibleLocalRotation { get; set; } + + // For overriding text (i.e. TransformActions) + public ITooltip tooltip { private get; set; } + + public event Action hovered; + + void Awake() + { + m_InsetMaterial = MaterialUtils.GetMaterialClone(m_InsetMeshRenderer); + m_IconMaterial = MaterialUtils.GetMaterialClone(m_Icon); + m_OriginalInsetGradientPair = new GradientPair(m_InsetMaterial.GetColor(k_MaterialColorTopProperty), m_InsetMaterial.GetColor(k_MaterialColorBottomProperty)); + hiddenLocalRotation = transform.localRotation; + m_VisibleInsetLocalScale = m_MenuInset.localScale; + m_HighlightedInsetLocalScale = new Vector3(m_VisibleInsetLocalScale.x, m_VisibleInsetLocalScale.y * 1.2f, m_VisibleInsetLocalScale.z); + m_VisibleInsetLocalScale = new Vector3(m_VisibleInsetLocalScale.x, m_MenuInset.localScale.y * 0.35f, m_VisibleInsetLocalScale.z); + m_HiddenInsetLocalScale = new Vector3(m_VisibleInsetLocalScale.x * 0.5f, 0f, m_VisibleInsetLocalScale.z * 0.5f); + + m_OriginalIconLocalPosition = m_IconContainer.localPosition; + m_IconHighlightedLocalPosition = m_OriginalIconLocalPosition + Vector3.up * k_IconHighlightedLocalYOffset; + m_IconPressedLocalPosition = m_OriginalIconLocalPosition + Vector3.up * -k_IconHighlightedLocalYOffset; + + semiTransparent = false; + m_FrameMaterial = MaterialUtils.GetMaterialClone(m_FrameRenderer); + var frameMaterialColor = m_FrameMaterial.color; + s_FrameOpaqueColor = new Color(frameMaterialColor.r, frameMaterialColor.g, frameMaterialColor.b, 1f); + m_SemiTransparentFrameColor = new Color(s_FrameOpaqueColor.r, s_FrameOpaqueColor.g, s_FrameOpaqueColor.b, 0.5f); + } + + void OnDisable() + { + this.StopCoroutine(ref m_VisibilityCoroutine); + this.StopCoroutine(ref m_HighlightCoroutine); + this.StopCoroutine(ref m_IconHighlightCoroutine); + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_InsetMaterial); + ObjectUtils.Destroy(m_IconMaterial); + ObjectUtils.Destroy(m_FrameMaterial); + } + + public void CorrectIconRotation() + { + m_IconLookDirection = m_Icon.transform.position + transform.parent.forward * m_IconLookForwardOffset; // set a position offset above the icon, regardless of the icon's rotation + m_IconContainer.LookAt(m_IconLookDirection); + m_IconContainer.localEulerAngles = new Vector3(0f, m_IconContainer.localEulerAngles.y, 0f); + var angle = m_IconContainer.localEulerAngles.y; + m_IconContainer.localEulerAngles = new Vector3(0f, angle, 0f); + m_TooltipTarget.localEulerAngles = new Vector3(90f, angle, 0f); + + var yaw = transform.localRotation.eulerAngles.y; + tooltipAlignment = yaw > 90 && yaw <= 270 ? TextAlignment.Right : TextAlignment.Left; + } + + IEnumerator AnimateShow() + { + m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, 0); + m_InsetMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalInsetGradientPair.a); + m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalInsetGradientPair.b); + m_FrameMaterial.SetColor(k_MaterialColorProperty, s_FrameOpaqueColor); + m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 0); + m_MenuInset.localScale = m_HiddenInsetLocalScale; + transform.localScale = k_HiddenLocalScale; + m_IconContainer.localPosition = m_OriginalIconLocalPosition; + + this.RestartCoroutine(ref m_InsetRevealCoroutine, ShowInset()); + + var opacity = 0f; + var positionWait = orderIndex * 0.05f; + while (opacity < 1) + { + opacity += Time.deltaTime / positionWait * 2; + var opacityShaped = Mathf.Pow(opacity, opacity); + + transform.localScale = Vector3.Lerp(k_HiddenLocalScale, Vector3.one, opacity); + m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 1 - opacityShaped); + CorrectIconRotation(); + yield return null; + } + + transform.localScale = Vector3.one; + m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 0); + PostReveal(); + + m_VisibilityCoroutine = null; + } + + void PostReveal() + { + m_CanvasGroup.interactable = true; + CorrectIconRotation(); + } + + IEnumerator ShowInset() + { + m_CanvasGroup.alpha = 0.0001f; + + var duration = 0f; + var positionWait = (orderIndex + 1) * 0.075f; + while (duration < 2) + { + duration += Time.deltaTime / positionWait * 2; + var opacity = duration / 2; + opacity *= opacity; + m_CanvasGroup.alpha = Mathf.Clamp01(duration - 1); + m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, opacity); + m_MenuInset.localScale = Vector3.Lerp(m_HiddenInsetLocalScale, m_VisibleInsetLocalScale, opacity); + yield return null; + } + + m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, 1); + m_MenuInset.localScale = m_VisibleInsetLocalScale; + m_InsetRevealCoroutine = null; + } + + IEnumerator AnimateHide() + { + this.HideTooltip(this); + + m_CanvasGroup.interactable = false; + m_Pressed = false; + m_Highlighted = false; + + var opacity = m_InsetMaterial.GetFloat(k_MaterialAlphaProperty); + var opacityShaped = Mathf.Pow(opacity, opacity); + while (opacity > 0) + { + var newScale = Vector3.one * opacity * opacityShaped * (opacity * 0.5f); + transform.localScale = newScale; + + m_CanvasGroup.alpha = opacityShaped; + m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, opacityShaped); + m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, opacityShaped); + m_MenuInset.localScale = Vector3.Lerp(m_HiddenInsetLocalScale, m_VisibleInsetLocalScale, opacityShaped); + opacity -= Time.deltaTime * 1.5f; + opacityShaped = Mathf.Pow(opacity, opacity); + CorrectIconRotation(); + yield return null; + } + + FadeOutCleanup(); + m_VisibilityCoroutine = null; + gameObject.SetActive(false); + } + + void FadeOutCleanup() + { + m_CanvasGroup.alpha = 0; + m_InsetMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalInsetGradientPair.a); + m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalInsetGradientPair.b); + m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 1); + m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, 0); + m_MenuInset.localScale = m_HiddenInsetLocalScale; + CorrectIconRotation(); + transform.localScale = Vector3.zero; + this.HideTooltip(this); + } + + IEnumerator Highlight() + { + HighlightIcon(); + + var opacity = Time.deltaTime; + var topColor = m_OriginalInsetGradientPair.a; + var bottomColor = m_OriginalInsetGradientPair.b; + var initialFrameColor = m_FrameMaterial.color; + var currentFrameColor = initialFrameColor; + while (opacity > 0) + { + if (m_Highlighted) + { + opacity = Mathf.Clamp01(opacity + Time.deltaTime * 4); // stay highlighted + currentFrameColor = Color.Lerp(initialFrameColor, s_FrameOpaqueColor, opacity); + m_FrameMaterial.SetColor(k_MaterialColorProperty, currentFrameColor); + } + else + opacity = Mathf.Clamp01(opacity - Time.deltaTime * 2); + + topColor = Color.Lerp(m_OriginalInsetGradientPair.a, s_GradientPair.a, opacity * 2f); + bottomColor = Color.Lerp(m_OriginalInsetGradientPair.b, s_GradientPair.b, opacity); + + m_InsetMaterial.SetColor(k_MaterialColorTopProperty, topColor); + m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, bottomColor); + + if (!semiTransparent) + m_MenuInset.localScale = Vector3.Lerp(m_VisibleInsetLocalScale, m_HighlightedInsetLocalScale, opacity * opacity); + + yield return null; + } + + m_BorderRendererMaterial.SetFloat(k_MaterialExpandProperty, 0); + m_InsetMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalInsetGradientPair.a); + m_InsetMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalInsetGradientPair.b); + + m_HighlightCoroutine = null; + } + + void HighlightIcon() + { + this.StopCoroutine(ref m_IconHighlightCoroutine); + m_IconHighlightCoroutine = StartCoroutine(IconHighlightAnimatedShow()); + } + + void SetIconPressed() + { + this.StopCoroutine(ref m_IconHighlightCoroutine); + m_IconHighlightCoroutine = StartCoroutine(IconHighlightAnimatedShow(true)); + } + + IEnumerator IconHighlightAnimatedShow(bool pressed = false) + { + var currentPosition = m_IconContainer.localPosition; + var targetPosition = pressed == false ? m_IconHighlightedLocalPosition : m_IconPressedLocalPosition; // Raise up for highlight; lower for press + var transitionAmount = Time.deltaTime; + var transitionAddMultiplier = pressed == false ? 14 : 18; // Faster transition in for standard highlight; slower for pressed highlight + while (transitionAmount < 1) + { + m_IconContainer.localPosition = Vector3.Lerp(currentPosition, targetPosition, transitionAmount); + transitionAmount = transitionAmount + Time.deltaTime * transitionAddMultiplier * 2; + yield return null; + } + + m_IconContainer.localPosition = targetPosition; + m_IconHighlightCoroutine = null; + } + + IEnumerator IconEndHighlight() + { + var currentPosition = m_IconContainer.localPosition; + var transitionAmount = 1f; // this should account for the magnitude difference between the highlightedYPositionOffset, and the current magnitude difference between the local Y and the original Y + var transitionSubtractMultiplier = 5f; + while (transitionAmount > 0) + { + m_IconContainer.localPosition = Vector3.Lerp(m_OriginalIconLocalPosition, currentPosition, transitionAmount); + transitionAmount -= Time.deltaTime * transitionSubtractMultiplier; + yield return null; + } + + m_IconContainer.localPosition = m_OriginalIconLocalPosition; + m_IconHighlightCoroutine = null; + } + + IEnumerator AnimateSemiTransparent(bool makeSemiTransparent) + { + if (m_InsetRevealCoroutine != null) + { + // In case semiTransparency is triggered immediately upon showing the radial menu + this.StopCoroutine(ref m_InsetRevealCoroutine); + m_CanvasGroup.alpha = 1f; + PostReveal(); + } + + const float kFasterMotionMultiplier = 2f; + var transitionAmount = Time.deltaTime; + var positionWait = (orderIndex + 4) * 0.25f; // pad the order index for a faster start to the transition + var currentScale = transform.localScale; + var targetScale = Vector3.one; + var currentFrameColor = m_FrameMaterial.color; + var transparentFrameColor = new Color(s_FrameOpaqueColor.r, s_FrameOpaqueColor.g, s_FrameOpaqueColor.b, 0f); + var targetFrameColor = m_CanvasGroup.interactable ? (makeSemiTransparent ? m_SemiTransparentFrameColor : s_FrameOpaqueColor) : transparentFrameColor; + var currentInsetAlpha = m_InsetMaterial.GetFloat(k_MaterialAlphaProperty); + var targetInsetAlpha = makeSemiTransparent ? 0.25f : 1f; + var currentIconColor = m_IconMaterial.GetColor(k_MaterialColorProperty); + var targetIconColor = makeSemiTransparent ? m_SemiTransparentFrameColor : Color.white; + var currentInsetScale = m_MenuInset.localScale; + var targetInsetScale = makeSemiTransparent ? m_HighlightedInsetLocalScale * 4 : m_VisibleInsetLocalScale; + var currentIconScale = m_IconContainer.localScale; + var semiTransparentTargetIconScale = Vector3.one * 1.5f; + var targetIconScale = makeSemiTransparent ? semiTransparentTargetIconScale : Vector3.one; + while (transitionAmount < 1) + { + m_FrameMaterial.SetColor(k_MaterialColorProperty, Color.Lerp(currentFrameColor, targetFrameColor, transitionAmount * kFasterMotionMultiplier)); + m_MenuInset.localScale = Vector3.Lerp(currentInsetScale, targetInsetScale, transitionAmount * 2f); + m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, Mathf.Lerp(currentInsetAlpha, targetInsetAlpha, transitionAmount)); + m_IconMaterial.SetColor(k_MaterialColorProperty, Color.Lerp(currentIconColor, targetIconColor, transitionAmount)); + var shapedTransitionAmount = Mathf.Pow(transitionAmount, makeSemiTransparent ? 2 : 1) * kFasterMotionMultiplier; + transform.localScale = Vector3.Lerp(currentScale, targetScale, shapedTransitionAmount); + m_IconContainer.localScale = Vector3.Lerp(currentIconScale, targetIconScale, shapedTransitionAmount); + transitionAmount += Time.deltaTime * positionWait * 3f; + CorrectIconRotation(); + yield return null; + } + + transform.localScale = targetScale; + m_FrameMaterial.SetColor(k_MaterialColorProperty, targetFrameColor); + m_InsetMaterial.SetFloat(k_MaterialAlphaProperty, targetInsetAlpha); + m_IconMaterial.SetColor(k_MaterialColorProperty, targetIconColor); + m_MenuInset.localScale = targetInsetScale; + m_IconContainer.localScale = targetIconScale; + } + + public void OnRayEnter(RayEventData eventData) + { + highlighted = true; + } + + public void OnRayExit(RayEventData eventData) + { + highlighted = false; + } + } } + #endif diff --git a/Menus/RadialMenu/Scripts/RadialMenuUI.cs b/Menus/RadialMenu/Scripts/RadialMenuUI.cs index 3c4f2797f..3d393f7bb 100644 --- a/Menus/RadialMenu/Scripts/RadialMenuUI.cs +++ b/Menus/RadialMenu/Scripts/RadialMenuUI.cs @@ -9,347 +9,356 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class RadialMenuUI : MonoBehaviour, IConnectInterfaces - { - const int k_SlotCount = 16; - - [SerializeField] - Sprite m_MissingActionIcon; - - [SerializeField] - RadialMenuSlot m_RadialMenuSlotTemplate; - - [SerializeField] - Transform m_SlotContainer; - - List m_RadialMenuSlots; - Coroutine m_VisibilityCoroutine; - RadialMenuSlot m_HighlightedButton; - float m_PhaseOffset; // Correcting the coordinates, based on actions count, so that the menu is centered at the bottom - - public Transform alternateMenuOrigin - { - get { return m_AlternateMenuOrigin; } - set - { - if (m_AlternateMenuOrigin == value) - return; - - m_AlternateMenuOrigin = value; - transform.SetParent(m_AlternateMenuOrigin); - transform.localPosition = Vector3.zero; - transform.localRotation = Quaternion.identity; - } - } - Transform m_AlternateMenuOrigin; - - public bool visible - { - get { return m_Visible; } - set - { - if (m_Visible == value) - return; - - m_Visible = value; - - this.StopCoroutine(ref m_VisibilityCoroutine); - - gameObject.SetActive(true); - if (value && actions.Count > 0) - m_VisibilityCoroutine = StartCoroutine(AnimateShow()); - else if (!value && m_RadialMenuSlots != null) // only perform hiding if slots have been initialized - m_VisibilityCoroutine = StartCoroutine(AnimateHide()); - else if (!value) - gameObject.SetActive(false); - } - } - bool m_Visible; - - public List actions - { - get { return m_Actions; } - set - { - if (value != null) - { - m_Actions = value - .Where(a => a.sectionName != null && a.sectionName == ActionMenuItemAttribute.DefaultActionSectionName) - .OrderBy(a => a.priority) - .ToList(); - - if (visible && actions.Count > 0) - { - this.StopCoroutine(ref m_VisibilityCoroutine); - m_VisibilityCoroutine = StartCoroutine(AnimateShow()); - } - } - else if (visible && m_RadialMenuSlots != null) // only perform hiding if slots have been initialized - visible = false; - } - } - List m_Actions; - - public bool pressedDown - { - get { return m_PressedDown; } - set - { - if (m_PressedDown != value) - { - m_PressedDown = value; - - foreach (var slot in m_RadialMenuSlots) - { - if (slot == m_HighlightedButton) - slot.pressed = true; // If the button is pressed AND this slot is the one being highlighted, set the pressed event to true - else - slot.pressed = false; - } - - if (m_HighlightedButton == null) - { - // No button was selected on the Radial Menu. Close the radial menu, and deselect. - Selection.activeGameObject = null; - visible = false; - } - } - } - } - bool m_PressedDown; - - public Vector2 buttonInputDirection - { - set - { - if (Mathf.Approximately(value.magnitude, 0) && !Mathf.Approximately(m_ButtonInputDirection.magnitude, 0)) - { - foreach (var slot in m_RadialMenuSlots) - slot.highlighted = false; - } - else if (value.magnitude > 0) - { - var angle = Mathf.Atan2(value.y, value.x) * Mathf.Rad2Deg; - angle -= m_PhaseOffset; - - // Handle lower quadrant to put it into full 360 degree range - if (angle < 0f) - angle += 360f; - - const float kSlotAngleRange = 360f / k_SlotCount; - var kPadding = m_HighlightedButton ? 0.4f : 0.01; // allow for immediate visibility of the menu if no button has been highlighted yet - var index = angle / kSlotAngleRange; - var t = index % 1f; - // Use padding to prevent unintended button switches - if (t >= kPadding && t <= 1f - kPadding) - { - m_HighlightedButton = m_RadialMenuSlots[(int)index]; - foreach (var slot in m_RadialMenuSlots) - slot.highlighted = slot == m_HighlightedButton; - } - } - m_ButtonInputDirection = value; - } - } - Vector2 m_ButtonInputDirection; - - bool semiTransparent - { - set - { - m_SemiTransparent = value; - - if (!value) - m_HighlightedButton = null; - - for (int i = 0; i < m_RadialMenuSlots.Count; ++i) - { - // Only set the semiTransparent value on menu slots representing actions - m_RadialMenuSlots[i].semiTransparent = m_Actions.Count > i && m_SemiTransparent; - } - } - } - bool m_SemiTransparent; - - public event Action buttonHovered; - public event Action buttonClicked; - - void Update() - { - if (m_Actions != null) - { - // Action icons can update after being displayed - for (int i = 0; i < m_Actions.Count; ++i) - { - var action = m_Actions[i].action; - var radialMenuSlot = m_RadialMenuSlots[i]; - if (radialMenuSlot.icon != action.icon) - radialMenuSlot.icon = action.icon; - } - } - - if (m_Visible) // don't override transparency if the menu is in the process of hiding itself - semiTransparent = !m_RadialMenuSlots.Any(x => x.highlighted); - } - - public void Setup() - { - m_RadialMenuSlots = new List(); - Material slotBorderMaterial = null; - - for (int i = 0; i < k_SlotCount; ++i) - { - var menuSlot = ObjectUtils.Instantiate(m_RadialMenuSlotTemplate.gameObject, m_SlotContainer, false).GetComponent(); - this.ConnectInterfaces(menuSlot); - menuSlot.orderIndex = i; - m_RadialMenuSlots.Add(menuSlot); - menuSlot.hovered += OnButtonHovered; - - if (slotBorderMaterial == null) - slotBorderMaterial = menuSlot.borderRendererMaterial; - - // Set a new shared material for the slots in a RadialMenu. - // This isolates shader changes in a RadialMenu's border material to only the slots in a given RadialMenu - menuSlot.borderRendererMaterial = slotBorderMaterial; - } - SetupRadialSlotPositions(); - } - - void SetupRadialSlotPositions() - { - const float kRotationSpacing = 360f / k_SlotCount; - for (int i = 0; i < k_SlotCount; ++i) - { - var slot = m_RadialMenuSlots[i]; - // We move in counter-clockwise direction - // Account for the input & position phase offset, based on the number of actions, rotating the menu content to be bottom-centered - m_PhaseOffset = 270 - (m_Actions.Count * 0.5f) * kRotationSpacing; - slot.visibleLocalRotation = Quaternion.AngleAxis(m_PhaseOffset + kRotationSpacing * i, Vector3.down); - slot.visible = false; - } - - this.StopCoroutine(ref m_VisibilityCoroutine); - m_VisibilityCoroutine = StartCoroutine(AnimateHide()); - } - - void UpdateRadialSlots() - { - var gradientPair = UnityBrandColorScheme.saturatedSessionGradient; - - for (int i = 0; i < m_Actions.Count; ++i) - { - // prevent more actions being added beyond the max slot count - if (i >= k_SlotCount) - break; - - var actionMenuData = m_Actions[i]; - var action = actionMenuData.action; - var slot = m_RadialMenuSlots[i]; - slot.gradientPair = gradientPair; - slot.icon = action.icon ?? m_MissingActionIcon; - - var index = i; // Closure - slot.button.onClick.RemoveAllListeners(); - slot.button.onClick.AddListener(() => - { - var selectedSlot = m_RadialMenuSlots[index]; - var buttonAction = m_Actions[index].action; - buttonAction.ExecuteAction(); - selectedSlot.icon = buttonAction.icon ?? m_MissingActionIcon; - }); - - slot.tooltip = null; - slot.tooltipText = actionMenuData.tooltipText; - - var tooltip = action as ITooltip; - if (tooltip != null) - slot.tooltip = tooltip; - } - } - - IEnumerator AnimateShow() - { - UpdateRadialSlots(); - - for (int i = 0; i < m_RadialMenuSlots.Count; ++i) - { - if (i < m_Actions.Count) - m_RadialMenuSlots[i].visible = true; - else - m_RadialMenuSlots[i].visible = false; - } - - semiTransparent = false; - semiTransparent = true; - - const float kSpeedScalar = 8f; - var revealAmount = 0f; - var hiddenSlotRotation = RadialMenuSlot.hiddenLocalRotation; - while (revealAmount < 1) - { - revealAmount += Time.unscaledDeltaTime * kSpeedScalar; - var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(revealAmount); - - for (int i = 0; i < m_RadialMenuSlots.Count; ++i) - { - if (i < m_Actions.Count) - { - m_RadialMenuSlots[i].transform.localRotation = Quaternion.Lerp(hiddenSlotRotation, m_RadialMenuSlots[i].visibleLocalRotation, shapedAmount); - m_RadialMenuSlots[i].CorrectIconRotation(); - } - } - - yield return null; - } - - revealAmount = 0; - while (revealAmount < 1) - { - revealAmount += Time.deltaTime; - yield return null; - } - - m_VisibilityCoroutine = null; - } - - IEnumerator AnimateHide() - { - var revealAmount = 0f; - var hiddenSlotRotation = RadialMenuSlot.hiddenLocalRotation; - - for (int i = 0; i < m_RadialMenuSlots.Count; ++i) - m_RadialMenuSlots[i].visible = false; - - revealAmount = 1; - while (revealAmount > 0) - { - revealAmount -= Time.deltaTime * 8; - - for (int i = 0; i < m_RadialMenuSlots.Count; ++i) - m_RadialMenuSlots[i].transform.localRotation = Quaternion.Lerp(hiddenSlotRotation, m_RadialMenuSlots[i].visibleLocalRotation, revealAmount); - - yield return null; - } - - semiTransparent = false; - gameObject.SetActive(false); - m_VisibilityCoroutine = null; - } - - public void SelectionOccurred() - { - if (m_HighlightedButton != null) - m_HighlightedButton.button.onClick.Invoke(); - - if (buttonClicked != null) - buttonClicked(); - } - - void OnButtonHovered() - { - if (buttonHovered != null) - buttonHovered(); - } - } + sealed class RadialMenuUI : MonoBehaviour, IConnectInterfaces + { + const int k_SlotCount = 16; + + [SerializeField] + Sprite m_MissingActionIcon; + + [SerializeField] + RadialMenuSlot m_RadialMenuSlotTemplate; + + [SerializeField] + Transform m_SlotContainer; + + List m_RadialMenuSlots; + Coroutine m_VisibilityCoroutine; + RadialMenuSlot m_HighlightedButton; + float m_PhaseOffset; // Correcting the coordinates, based on actions count, so that the menu is centered at the bottom + + public Transform alternateMenuOrigin + { + get { return m_AlternateMenuOrigin; } + set + { + if (m_AlternateMenuOrigin == value) + return; + + m_AlternateMenuOrigin = value; + transform.SetParent(m_AlternateMenuOrigin); + transform.localPosition = Vector3.zero; + transform.localRotation = Quaternion.identity; + } + } + + Transform m_AlternateMenuOrigin; + + public bool visible + { + get { return m_Visible; } + set + { + if (m_Visible == value) + return; + + m_Visible = value; + + this.StopCoroutine(ref m_VisibilityCoroutine); + + gameObject.SetActive(true); + if (value && actions.Count > 0) + m_VisibilityCoroutine = StartCoroutine(AnimateShow()); + else if (!value && m_RadialMenuSlots != null) // only perform hiding if slots have been initialized + m_VisibilityCoroutine = StartCoroutine(AnimateHide()); + else if (!value) + gameObject.SetActive(false); + } + } + + bool m_Visible; + + public List actions + { + get { return m_Actions; } + set + { + if (value != null) + { + m_Actions = value + .Where(a => a.sectionName != null && a.sectionName == ActionMenuItemAttribute.DefaultActionSectionName) + .OrderBy(a => a.priority) + .ToList(); + + if (visible && actions.Count > 0) + { + this.StopCoroutine(ref m_VisibilityCoroutine); + m_VisibilityCoroutine = StartCoroutine(AnimateShow()); + } + } + else if (visible && m_RadialMenuSlots != null) // only perform hiding if slots have been initialized + visible = false; + } + } + + List m_Actions; + + public bool pressedDown + { + get { return m_PressedDown; } + set + { + if (m_PressedDown != value) + { + m_PressedDown = value; + + foreach (var slot in m_RadialMenuSlots) + { + if (slot == m_HighlightedButton) + slot.pressed = true; // If the button is pressed AND this slot is the one being highlighted, set the pressed event to true + else + slot.pressed = false; + } + + if (m_HighlightedButton == null) + { + // No button was selected on the Radial Menu. Close the radial menu, and deselect. + Selection.activeGameObject = null; + visible = false; + } + } + } + } + + bool m_PressedDown; + + public Vector2 buttonInputDirection + { + set + { + if (Mathf.Approximately(value.magnitude, 0) && !Mathf.Approximately(m_ButtonInputDirection.magnitude, 0)) + { + foreach (var slot in m_RadialMenuSlots) + slot.highlighted = false; + } + else if (value.magnitude > 0) + { + var angle = Mathf.Atan2(value.y, value.x) * Mathf.Rad2Deg; + angle -= m_PhaseOffset; + + // Handle lower quadrant to put it into full 360 degree range + if (angle < 0f) + angle += 360f; + + const float kSlotAngleRange = 360f / k_SlotCount; + var kPadding = m_HighlightedButton ? 0.4f : 0.01; // allow for immediate visibility of the menu if no button has been highlighted yet + var index = angle / kSlotAngleRange; + var t = index % 1f; + + // Use padding to prevent unintended button switches + if (t >= kPadding && t <= 1f - kPadding) + { + m_HighlightedButton = m_RadialMenuSlots[(int)index]; + foreach (var slot in m_RadialMenuSlots) + slot.highlighted = slot == m_HighlightedButton; + } + } + m_ButtonInputDirection = value; + } + } + + Vector2 m_ButtonInputDirection; + + bool semiTransparent + { + set + { + m_SemiTransparent = value; + + if (!value) + m_HighlightedButton = null; + + for (int i = 0; i < m_RadialMenuSlots.Count; ++i) + { + // Only set the semiTransparent value on menu slots representing actions + m_RadialMenuSlots[i].semiTransparent = m_Actions.Count > i && m_SemiTransparent; + } + } + } + + bool m_SemiTransparent; + + public event Action buttonHovered; + public event Action buttonClicked; + + void Update() + { + if (m_Actions != null) + { + // Action icons can update after being displayed + for (int i = 0; i < m_Actions.Count; ++i) + { + var action = m_Actions[i].action; + var radialMenuSlot = m_RadialMenuSlots[i]; + if (radialMenuSlot.icon != action.icon) + radialMenuSlot.icon = action.icon; + } + } + + if (m_Visible) // don't override transparency if the menu is in the process of hiding itself + semiTransparent = !m_RadialMenuSlots.Any(x => x.highlighted); + } + + public void Setup() + { + m_RadialMenuSlots = new List(); + Material slotBorderMaterial = null; + + for (int i = 0; i < k_SlotCount; ++i) + { + var menuSlot = ObjectUtils.Instantiate(m_RadialMenuSlotTemplate.gameObject, m_SlotContainer, false).GetComponent(); + this.ConnectInterfaces(menuSlot); + menuSlot.orderIndex = i; + m_RadialMenuSlots.Add(menuSlot); + menuSlot.hovered += OnButtonHovered; + + if (slotBorderMaterial == null) + slotBorderMaterial = menuSlot.borderRendererMaterial; + + // Set a new shared material for the slots in a RadialMenu. + // This isolates shader changes in a RadialMenu's border material to only the slots in a given RadialMenu + menuSlot.borderRendererMaterial = slotBorderMaterial; + } + SetupRadialSlotPositions(); + } + + void SetupRadialSlotPositions() + { + const float kRotationSpacing = 360f / k_SlotCount; + for (int i = 0; i < k_SlotCount; ++i) + { + var slot = m_RadialMenuSlots[i]; + + // We move in counter-clockwise direction + // Account for the input & position phase offset, based on the number of actions, rotating the menu content to be bottom-centered + m_PhaseOffset = 270 - (m_Actions.Count * 0.5f) * kRotationSpacing; + slot.visibleLocalRotation = Quaternion.AngleAxis(m_PhaseOffset + kRotationSpacing * i, Vector3.down); + slot.visible = false; + } + + this.StopCoroutine(ref m_VisibilityCoroutine); + m_VisibilityCoroutine = StartCoroutine(AnimateHide()); + } + + void UpdateRadialSlots() + { + var gradientPair = UnityBrandColorScheme.saturatedSessionGradient; + + for (int i = 0; i < m_Actions.Count; ++i) + { + // prevent more actions being added beyond the max slot count + if (i >= k_SlotCount) + break; + + var actionMenuData = m_Actions[i]; + var action = actionMenuData.action; + var slot = m_RadialMenuSlots[i]; + slot.gradientPair = gradientPair; + slot.icon = action.icon ?? m_MissingActionIcon; + + var index = i; // Closure + slot.button.onClick.RemoveAllListeners(); + slot.button.onClick.AddListener(() => + { + var selectedSlot = m_RadialMenuSlots[index]; + var buttonAction = m_Actions[index].action; + buttonAction.ExecuteAction(); + selectedSlot.icon = buttonAction.icon ?? m_MissingActionIcon; + }); + + slot.tooltip = null; + slot.tooltipText = actionMenuData.tooltipText; + + var tooltip = action as ITooltip; + if (tooltip != null) + slot.tooltip = tooltip; + } + } + + IEnumerator AnimateShow() + { + UpdateRadialSlots(); + + for (int i = 0; i < m_RadialMenuSlots.Count; ++i) + { + if (i < m_Actions.Count) + m_RadialMenuSlots[i].visible = true; + else + m_RadialMenuSlots[i].visible = false; + } + + semiTransparent = false; + semiTransparent = true; + + const float kSpeedScalar = 8f; + var revealAmount = 0f; + var hiddenSlotRotation = RadialMenuSlot.hiddenLocalRotation; + while (revealAmount < 1) + { + revealAmount += Time.unscaledDeltaTime * kSpeedScalar; + var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(revealAmount); + + for (int i = 0; i < m_RadialMenuSlots.Count; ++i) + { + if (i < m_Actions.Count) + { + m_RadialMenuSlots[i].transform.localRotation = Quaternion.Lerp(hiddenSlotRotation, m_RadialMenuSlots[i].visibleLocalRotation, shapedAmount); + m_RadialMenuSlots[i].CorrectIconRotation(); + } + } + + yield return null; + } + + revealAmount = 0; + while (revealAmount < 1) + { + revealAmount += Time.deltaTime; + yield return null; + } + + m_VisibilityCoroutine = null; + } + + IEnumerator AnimateHide() + { + var revealAmount = 0f; + var hiddenSlotRotation = RadialMenuSlot.hiddenLocalRotation; + + for (int i = 0; i < m_RadialMenuSlots.Count; ++i) + m_RadialMenuSlots[i].visible = false; + + revealAmount = 1; + while (revealAmount > 0) + { + revealAmount -= Time.deltaTime * 8; + + for (int i = 0; i < m_RadialMenuSlots.Count; ++i) + m_RadialMenuSlots[i].transform.localRotation = Quaternion.Lerp(hiddenSlotRotation, m_RadialMenuSlots[i].visibleLocalRotation, revealAmount); + + yield return null; + } + + semiTransparent = false; + gameObject.SetActive(false); + m_VisibilityCoroutine = null; + } + + public void SelectionOccurred() + { + if (m_HighlightedButton != null) + m_HighlightedButton.button.onClick.Invoke(); + + if (buttonClicked != null) + buttonClicked(); + } + + void OnButtonHovered() + { + if (buttonHovered != null) + buttonHovered(); + } + } } + #endif diff --git a/Menus/ToolsMenu/Scripts/HintIcon.cs b/Menus/ToolsMenu/Scripts/HintIcon.cs index d23323494..695cba991 100644 --- a/Menus/ToolsMenu/Scripts/HintIcon.cs +++ b/Menus/ToolsMenu/Scripts/HintIcon.cs @@ -8,138 +8,140 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - public class HintIcon : MonoBehaviour - { - [SerializeField] - bool m_HideOnInitialize = true; - - [SerializeField] - Image m_Icon; - - [SerializeField] - Color m_VisibleColor = Color.white; - - [SerializeField] - Color m_HiddenColor = Color.clear; - - [SerializeField] - Color m_PulseColor = Color.white; - - [SerializeField] - float m_ShowDuration = 0.125f; - - [SerializeField] - float m_HideDuration = 0.25f; - - [SerializeField] - bool m_SlightlyRandomizeHideDuration = true; - - readonly Vector3 k_HiddenScale = Vector3.zero; - - Transform m_IconTransform; - Vector3 m_VisibleLocalScale; - Coroutine m_VisibilityCoroutine; - Coroutine m_ScrollArrowPulseCoroutine; - float m_PulseDuration; - - /// - /// Bool denoting the visibility state of this icon - /// - public bool visible { set { this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateVisibility(value)); } } - - /// - /// The color to be displayed by this icon when it is visible - /// - public Color visibleColor - { - set - { - m_VisibleColor = value; - visible = true; - } - } - - void Awake() - { - m_IconTransform = m_Icon.transform; - m_VisibleLocalScale = m_IconTransform.localScale * 1.25F; - m_Icon.color = m_VisibleColor; - - if (m_HideOnInitialize) - visible = false; - } - - IEnumerator AnimateVisibility(bool show = true) - { - var currentDuration = 0f; - float targetDuration; - var currentLocalScale = m_IconTransform.localScale; - var targetLocalScale = show ? m_VisibleLocalScale : k_HiddenScale; - // Only perform this wait if showing/revealing, not hiding - if (show && currentLocalScale == k_HiddenScale) - { - // Only perform delay if fully hidden; otherwise resume showing - targetDuration = Random.Range(0.125f, 0.175f); // Set an initial random wait duration - while (currentDuration < targetDuration) - { - currentDuration += Time.unscaledDeltaTime; - yield return null; - } - } - - currentDuration = 0f; - targetDuration = show ? m_ShowDuration : m_HideDuration + (m_SlightlyRandomizeHideDuration ? 0f : Random.Range(0.125f, 0.2f)); // Set an initial random wait duration - const int kAdditionalDurationShaping = 4; - const int kAdditionalHideSpeedScalar = 3; - var currentColor = m_Icon.color; - var targetColor = show ? m_VisibleColor : m_HiddenColor; - while (currentDuration < targetDuration) - { - var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(currentDuration / targetDuration); - shapedDuration = Mathf.Pow(shapedDuration, kAdditionalDurationShaping); - var colorLerpAmount = show ? shapedDuration : currentDuration * kAdditionalHideSpeedScalar; - m_IconTransform.localScale = Vector3.Lerp(currentLocalScale, targetLocalScale, shapedDuration); - m_Icon.color = Color.Lerp(currentColor, targetColor, colorLerpAmount); - currentDuration += Time.unscaledDeltaTime; - yield return null; - } - - m_IconTransform.localScale = targetLocalScale; - } - - /// - /// Perform a colored visual pulse - /// - public void PulseColor() - { - if (Mathf.Approximately(m_PulseDuration, 0f) || m_PulseDuration > 0.85f) - this.RestartCoroutine(ref m_ScrollArrowPulseCoroutine, AnimatePulseColor()); - } - - IEnumerator AnimatePulseColor() - { - const float kTargetDuration = 1f; - m_PulseDuration = 0f; - var currentColor = m_Icon.color; - while (m_PulseDuration < kTargetDuration) - { - var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); - m_Icon.color = Color.Lerp(currentColor, m_PulseColor, shapedDuration); - m_PulseDuration += Time.unscaledDeltaTime * 5; - yield return null; - } - - while (m_PulseDuration > 0f) - { - var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); - m_Icon.color = Color.Lerp(m_VisibleColor, m_PulseColor, shapedDuration); - m_PulseDuration -= Time.unscaledDeltaTime * 2; - yield return null; - } - - m_Icon.color = m_VisibleColor; - m_PulseDuration = 0f; - } - } + public class HintIcon : MonoBehaviour + { + [SerializeField] + bool m_HideOnInitialize = true; + + [SerializeField] + Image m_Icon; + + [SerializeField] + Color m_VisibleColor = Color.white; + + [SerializeField] + Color m_HiddenColor = Color.clear; + + [SerializeField] + Color m_PulseColor = Color.white; + + [SerializeField] + float m_ShowDuration = 0.125f; + + [SerializeField] + float m_HideDuration = 0.25f; + + [SerializeField] + bool m_SlightlyRandomizeHideDuration = true; + + readonly Vector3 k_HiddenScale = Vector3.zero; + + Transform m_IconTransform; + Vector3 m_VisibleLocalScale; + Coroutine m_VisibilityCoroutine; + Coroutine m_ScrollArrowPulseCoroutine; + float m_PulseDuration; + + /// + /// Bool denoting the visibility state of this icon + /// + public bool visible { set { this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateVisibility(value)); } } + + /// + /// The color to be displayed by this icon when it is visible + /// + public Color visibleColor + { + set + { + m_VisibleColor = value; + visible = true; + } + } + + void Awake() + { + m_IconTransform = m_Icon.transform; + m_VisibleLocalScale = m_IconTransform.localScale * 1.25F; + m_Icon.color = m_VisibleColor; + + if (m_HideOnInitialize) + visible = false; + } + + IEnumerator AnimateVisibility(bool show = true) + { + var currentDuration = 0f; + float targetDuration; + var currentLocalScale = m_IconTransform.localScale; + var targetLocalScale = show ? m_VisibleLocalScale : k_HiddenScale; + + // Only perform this wait if showing/revealing, not hiding + if (show && currentLocalScale == k_HiddenScale) + { + // Only perform delay if fully hidden; otherwise resume showing + targetDuration = Random.Range(0.125f, 0.175f); // Set an initial random wait duration + while (currentDuration < targetDuration) + { + currentDuration += Time.unscaledDeltaTime; + yield return null; + } + } + + currentDuration = 0f; + targetDuration = show ? m_ShowDuration : m_HideDuration + (m_SlightlyRandomizeHideDuration ? 0f : Random.Range(0.125f, 0.2f)); // Set an initial random wait duration + const int kAdditionalDurationShaping = 4; + const int kAdditionalHideSpeedScalar = 3; + var currentColor = m_Icon.color; + var targetColor = show ? m_VisibleColor : m_HiddenColor; + while (currentDuration < targetDuration) + { + var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(currentDuration / targetDuration); + shapedDuration = Mathf.Pow(shapedDuration, kAdditionalDurationShaping); + var colorLerpAmount = show ? shapedDuration : currentDuration * kAdditionalHideSpeedScalar; + m_IconTransform.localScale = Vector3.Lerp(currentLocalScale, targetLocalScale, shapedDuration); + m_Icon.color = Color.Lerp(currentColor, targetColor, colorLerpAmount); + currentDuration += Time.unscaledDeltaTime; + yield return null; + } + + m_IconTransform.localScale = targetLocalScale; + } + + /// + /// Perform a colored visual pulse + /// + public void PulseColor() + { + if (Mathf.Approximately(m_PulseDuration, 0f) || m_PulseDuration > 0.85f) + this.RestartCoroutine(ref m_ScrollArrowPulseCoroutine, AnimatePulseColor()); + } + + IEnumerator AnimatePulseColor() + { + const float kTargetDuration = 1f; + m_PulseDuration = 0f; + var currentColor = m_Icon.color; + while (m_PulseDuration < kTargetDuration) + { + var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); + m_Icon.color = Color.Lerp(currentColor, m_PulseColor, shapedDuration); + m_PulseDuration += Time.unscaledDeltaTime * 5; + yield return null; + } + + while (m_PulseDuration > 0f) + { + var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); + m_Icon.color = Color.Lerp(m_VisibleColor, m_PulseColor, shapedDuration); + m_PulseDuration -= Time.unscaledDeltaTime * 2; + yield return null; + } + + m_Icon.color = m_VisibleColor; + m_PulseDuration = 0f; + } + } } + #endif diff --git a/Menus/ToolsMenu/Scripts/HintLine.cs b/Menus/ToolsMenu/Scripts/HintLine.cs index de8ba288a..ab9abf0e3 100644 --- a/Menus/ToolsMenu/Scripts/HintLine.cs +++ b/Menus/ToolsMenu/Scripts/HintLine.cs @@ -6,89 +6,90 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - public class HintLine : MonoBehaviour - { - const string k_ShaderLineRadiusPropertyName = "_lineRadius"; + public class HintLine : MonoBehaviour + { + const string k_ShaderLineRadiusPropertyName = "_lineRadius"; - [SerializeField] - VRLineRenderer m_ScrollLineRenderer; + [SerializeField] + VRLineRenderer m_ScrollLineRenderer; - [SerializeField] - Color m_VisibleColor = Color.white; + [SerializeField] + Color m_VisibleColor = Color.white; - [SerializeField] - Color m_PulseColor = Color.white; + [SerializeField] + Color m_PulseColor = Color.white; - [SerializeField] - MeshRenderer m_MeshRenderer; + [SerializeField] + MeshRenderer m_MeshRenderer; - Coroutine m_ScrollArrowPulseCoroutine; - float m_PulseDuration; - Material m_HintLineMaterial; + Coroutine m_ScrollArrowPulseCoroutine; + float m_PulseDuration; + Material m_HintLineMaterial; - /// - /// Set the width of the line visuals - /// - public float LineWidth { set { m_ScrollLineRenderer.SetWidth(value, value); } } + /// + /// Set the width of the line visuals + /// + public float LineWidth { set { m_ScrollLineRenderer.SetWidth(value, value); } } - /// - /// Set the start & end positions for the line visuals - /// - public Vector3[] Positions { set { m_ScrollLineRenderer.SetPositions(value) ; } } + /// + /// Set the start & end positions for the line visuals + /// + public Vector3[] Positions { set { m_ScrollLineRenderer.SetPositions(value); } } - void Awake() - { - m_ScrollLineRenderer.SetVertexCount(4); - m_ScrollLineRenderer.useWorldSpace = true; - m_ScrollLineRenderer.SetWidth(0f, 0f); - m_HintLineMaterial = MaterialUtils.GetMaterialClone(m_MeshRenderer); - } + void Awake() + { + m_ScrollLineRenderer.SetVertexCount(4); + m_ScrollLineRenderer.useWorldSpace = true; + m_ScrollLineRenderer.SetWidth(0f, 0f); + m_HintLineMaterial = MaterialUtils.GetMaterialClone(m_MeshRenderer); + } - void OnDestroy() - { - ObjectUtils.Destroy(m_HintLineMaterial); - } + void OnDestroy() + { + ObjectUtils.Destroy(m_HintLineMaterial); + } - /// - /// Perform an animated visual pulsing of color - /// - public void PulseColor() - { - if (Mathf.Approximately(m_PulseDuration, 0f) || m_PulseDuration > 0.85f) - this.RestartCoroutine(ref m_ScrollArrowPulseCoroutine, AnimatePulseColor()); - } + /// + /// Perform an animated visual pulsing of color + /// + public void PulseColor() + { + if (Mathf.Approximately(m_PulseDuration, 0f) || m_PulseDuration > 0.85f) + this.RestartCoroutine(ref m_ScrollArrowPulseCoroutine, AnimatePulseColor()); + } - IEnumerator AnimatePulseColor() - { - const float kTargetDuration = 1f; - m_PulseDuration = 0f; - var maxShaderLineRadius = new Vector3 (0.03f, 0f, 100f); - var minShaderLineRadius = new Vector3 (0.005f, 0f, 100f); - var currentVector3ShaderLineRadius = m_HintLineMaterial.GetVector(k_ShaderLineRadiusPropertyName); - var currentColor = m_ScrollLineRenderer.colorStart; // The line stand & end colors are the same; fetch only one of them - while (m_PulseDuration < kTargetDuration) - { - var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); - var newColor = Color.Lerp(currentColor, m_PulseColor, shapedDuration); - m_ScrollLineRenderer.SetColors(newColor, newColor); - m_PulseDuration += Time.unscaledDeltaTime * 5; - m_HintLineMaterial.SetVector(k_ShaderLineRadiusPropertyName, Vector3.Lerp(currentVector3ShaderLineRadius, maxShaderLineRadius, shapedDuration)); - yield return null; - } + IEnumerator AnimatePulseColor() + { + const float kTargetDuration = 1f; + m_PulseDuration = 0f; + var maxShaderLineRadius = new Vector3(0.03f, 0f, 100f); + var minShaderLineRadius = new Vector3(0.005f, 0f, 100f); + var currentVector3ShaderLineRadius = m_HintLineMaterial.GetVector(k_ShaderLineRadiusPropertyName); + var currentColor = m_ScrollLineRenderer.colorStart; // The line stand & end colors are the same; fetch only one of them + while (m_PulseDuration < kTargetDuration) + { + var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); + var newColor = Color.Lerp(currentColor, m_PulseColor, shapedDuration); + m_ScrollLineRenderer.SetColors(newColor, newColor); + m_PulseDuration += Time.unscaledDeltaTime * 5; + m_HintLineMaterial.SetVector(k_ShaderLineRadiusPropertyName, Vector3.Lerp(currentVector3ShaderLineRadius, maxShaderLineRadius, shapedDuration)); + yield return null; + } - while (m_PulseDuration > 0f) - { - var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); - var newColor = Color.Lerp(m_VisibleColor, m_PulseColor, shapedDuration); - m_ScrollLineRenderer.SetColors(newColor, newColor); - m_PulseDuration -= Time.unscaledDeltaTime * 1.5f; - m_HintLineMaterial.SetVector(k_ShaderLineRadiusPropertyName, Vector3.Lerp(minShaderLineRadius, maxShaderLineRadius, shapedDuration)); - yield return null; - } + while (m_PulseDuration > 0f) + { + var shapedDuration = MathUtilsExt.SmoothInOutLerpFloat(m_PulseDuration / kTargetDuration); + var newColor = Color.Lerp(m_VisibleColor, m_PulseColor, shapedDuration); + m_ScrollLineRenderer.SetColors(newColor, newColor); + m_PulseDuration -= Time.unscaledDeltaTime * 1.5f; + m_HintLineMaterial.SetVector(k_ShaderLineRadiusPropertyName, Vector3.Lerp(minShaderLineRadius, maxShaderLineRadius, shapedDuration)); + yield return null; + } - m_ScrollLineRenderer.SetColors(m_VisibleColor, m_VisibleColor); - m_PulseDuration = 0f; - } - } + m_ScrollLineRenderer.SetColors(m_VisibleColor, m_VisibleColor); + m_PulseDuration = 0f; + } + } } -#endif \ No newline at end of file + +#endif diff --git a/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs b/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs index c4062cc55..3b0e5b9f3 100644 --- a/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs +++ b/Menus/ToolsMenu/Scripts/ToolsMenuUI.cs @@ -11,524 +11,537 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class ToolsMenuUI : MonoBehaviour, IUsesViewerScale, IInstantiateUI, - IConnectInterfaces, IControlSpatialHinting, IUsesRayOrigin - { - const int k_MenuButtonOrderPosition = 0; // Menu button position used in this particular ToolButton implementation - const int k_ActiveToolOrderPosition = 1; // Active-tool button position used in this particular ToolButton implementation - const int k_InactiveButtonInitialOrderPosition = -1; - const float k_RaySelectIconHighlightedZOffset = -0.0075f; - const float k_SpatialSelectIconHighlightedZOffset = -0.02f; - - [SerializeField] - Transform m_ButtonContainer; - - [Header("Used when displaying Alternate Menu")] - [SerializeField] - Vector3 m_AlternatePosition; - - [SerializeField] - Vector3 m_AlternateLocalScale; - - [SerializeField] - Transform m_ButtonTooltipTarget; - - bool m_AllButtonsVisible; - List m_OrderedButtons; - Coroutine m_ShowHideAllButtonsCoroutine; - Coroutine m_MoveCoroutine; - Coroutine m_ButtonHoverExitDelayCoroutine; - int m_VisibleButtonCount; - bool m_MoveToAlternatePosition; - Vector3 m_OriginalLocalScale; - bool m_RayHovered; - float m_SpatialDragDistance; - Quaternion m_HintContentContainerInitialRotation; - Vector3 m_HintContentWorldPosition; - Vector3 m_DragTarget; - - public int maxButtonCount { get; set; } - public Transform buttonContainer { get { return m_ButtonContainer; } } - public Transform rayOrigin { private get; set; } - public Action mainMenuActivatorSelected { get; set; } - public List buttons { get { return m_OrderedButtons; } } - - public bool allButtonsVisible - { - get { return m_AllButtonsVisible; } - set - { - m_AllButtonsVisible = value; - - if (m_AllButtonsVisible) - { - this.StopCoroutine(ref m_ShowHideAllButtonsCoroutine); - ShowAllExceptMenuButton(); - } - else - { - ShowOnlyMenuAndActiveToolButtons(); - spatiallyScrolling = false; - this.SetSpatialHintShowHideRotationTarget(Vector3.zero); - } - } - } - - public bool moveToAlternatePosition - { - set - { - if (m_MoveToAlternatePosition == value) - return; - - m_MoveToAlternatePosition = value; - var newPosition = m_MoveToAlternatePosition ? m_AlternatePosition : Vector3.zero; - var newScale = m_MoveToAlternatePosition ? m_AlternateLocalScale : m_OriginalLocalScale; - this.RestartCoroutine(ref m_MoveCoroutine, MoveToLocation(newPosition, newScale)); - } - } - - bool aboveMinimumButtonCount - { - get - { - const int kSelectionToolButtonHideCount = 2; - var count = m_OrderedButtons.Count; - var aboveMinCount = count > kSelectionToolButtonHideCount; // Has at least one tool been added beyond the default MainMenu & SelectionTool - - // Prevent the display of the SelectionTool button, if only the MainMenu and SelectionTool buttons reside in the buttons collection - if (count == kSelectionToolButtonHideCount) - aboveMinCount = buttons.All( x => x.toolType != typeof(SelectionTool) ); - - return aboveMinCount; - } - } - - public bool spatiallyScrolling - { - set - { - for (int i = 0; i < m_OrderedButtons.Count; ++i) - { - var button = m_OrderedButtons[i]; - button.iconHighlightedLocalZOffset = value ? k_SpatialSelectIconHighlightedZOffset : k_RaySelectIconHighlightedZOffset; - } - - if (value) - { - var currentRotation = transform.rotation.eulerAngles; - m_SpatialDragDistance = 0f; - m_HintContentContainerInitialRotation = Quaternion.Euler(0f, currentRotation.y, 0f); - m_HintContentWorldPosition = transform.position; - this.SetSpatialHintPosition(m_HintContentWorldPosition); - } - } - } - - public float spatialDragDistance { set { m_SpatialDragDistance = value; } } - - public Vector3? startingDragOrigin { set { if (value != null) this.SetSpatialHintLookAtRotation(value.Value); } } - - public event Action buttonHovered; - public event Action buttonClicked; - public event Action buttonSelected; - public event Action closeMenu; - - void Awake() - { - m_OriginalLocalScale = transform.localScale; - m_OrderedButtons = new List(); - } - - void Update() - { - var newHintContainerRotation = m_HintContentContainerInitialRotation; - - // Perform activation of visuals after the user has dragged beyond the initial drag trigger threshold - // The drag distance is a 0-1 lerped value, based off of the origin to trigger magnitude - if (m_SpatialDragDistance >= 1f && m_SpatialDragDistance < 2) - { - if (Mathf.Approximately(m_SpatialDragDistance, 1f)) - { - m_DragTarget = transform.position; // Cache the initial drag target position, before performing any extra shaping to the target Vec3 - this.SetSpatialHintState(SpatialHintModule.SpatialHintStateFlags.Scrolling); - } - - // Follow the user's input for a short additional period of time - // Update the dragTarget with the current device position, to allow for visuals to better match the expected rotation/position - m_DragTarget = transform.position; - this.SetSpatialHintDragThresholdTriggerPosition(transform.position); - this.SetSpatialHintContainerRotation(newHintContainerRotation); - - // Perform a smooth lerp of the hint contents after dragging beyond the distance trigger threshold - m_SpatialDragDistance += Time.unscaledDeltaTime * 8; // Continue to increase the amount - } - else if (m_AllButtonsVisible && m_SpatialDragDistance > 2) - { - this.SetSpatialHintDragThresholdTriggerPosition(transform.position); - this.SetSpatialHintContainerRotation(newHintContainerRotation); - this.SetSpatialHintShowHideRotationTarget(m_DragTarget); - } - } - - public void AddButton(IToolsMenuButton button, Transform buttonTransform) - { - button.showAllButtons = ShowAllButtons; - button.hoverExit = ButtonHoverExitPerformed; - button.maxButtonCount = maxButtonCount; - button.selectTool = SelectExistingToolTypeFromButton; - button.closeButton = DeleteHighlightedButton; - button.visibleButtonCount = VisibleButtonCount; // allow buttons to fetch local buttonCount - button.iconHighlightedLocalZOffset = k_RaySelectIconHighlightedZOffset; - button.tooltipTarget = m_ButtonTooltipTarget; - button.hovered += OnButtonHover; - - bool allowSecondaryButton = false; // Secondary button is the close button - var insertPosition = k_MenuButtonOrderPosition; - if (!IsMainMenuButton(button)) - { - insertPosition = k_ActiveToolOrderPosition; - allowSecondaryButton = !IsSelectionToolButton(button); - } - - var initializingButtons = m_OrderedButtons.Count == 1; - m_OrderedButtons.Insert(insertPosition, button); - // If only the MainMenu & SelectionTool buttons exist, set visible button count to 1 - m_VisibleButtonCount = aboveMinimumButtonCount || initializingButtons ? m_OrderedButtons.Count : 1; - button.implementsSecondaryButton = allowSecondaryButton; - button.isActiveTool = true; - button.order = insertPosition; - - buttonTransform.rotation = Quaternion.identity; - buttonTransform.localPosition = Vector3.zero; - buttonTransform.localScale = Vector3.zero; - - if (aboveMinimumButtonCount) // aboveMinimumCount will change throughout function, don't cache for re-use - this.RestartCoroutine(ref m_ShowHideAllButtonsCoroutine, ShowThenHideAllButtons(1.25f, false)); - else - SetupButtonOrder(); // Setup the MainMenu and active tool buttons only - } - - IEnumerator ShowThenHideAllButtons(float delayBeforeHiding = 1.25f, bool showMenuButton = true) - { - if (showMenuButton) - SetupButtonOrder(); - else - ShowAllExceptMenuButton(); - - if (delayBeforeHiding > 0) - { - var duration = Time.unscaledDeltaTime; - while (duration < delayBeforeHiding) - { - duration += Time.unscaledDeltaTime; - yield return null; - } - } - - // Hide all but menu and active tool buttons after visually adding new button - allButtonsVisible = false; - m_ShowHideAllButtonsCoroutine = null; - } - - void Reinsert(IToolsMenuButton button, int newOrderPosition, bool updateButtonOrder = false) - { - var removed = m_OrderedButtons.Remove(button); - if (!removed) - return; - - m_OrderedButtons.Insert(newOrderPosition, button); - - if (updateButtonOrder) - button.order = newOrderPosition; - } - - void SetupButtonOrder() - { - for (int i = 0; i < m_OrderedButtons.Count; ++i) - { - var button = m_OrderedButtons[i]; - button.isActiveTool = i == k_ActiveToolOrderPosition; - // Allow settings of regular button order if there are more buttons that just the MainMenu & SelectionTool - button.order = aboveMinimumButtonCount || IsMainMenuButton(button) ? i : k_InactiveButtonInitialOrderPosition; - } - } - - void ShowAllExceptMenuButton() - { - // The MainMenu button will be hidden, subtract 1 from the m_VisibleButtonCount - m_VisibleButtonCount = Mathf.Max(0, m_OrderedButtons.Count - 1); - for (int i = 0; i < m_OrderedButtons.Count; ++i) - { - var button = m_OrderedButtons[i]; - button.isActiveTool = i == k_ActiveToolOrderPosition; - button.order = i == k_MenuButtonOrderPosition ? k_InactiveButtonInitialOrderPosition : i - 1; // Hide the menu buttons when revealing all tools buttons - } - } - - void ShowOnlyMenuAndActiveToolButtons() - { - if (!aboveMinimumButtonCount) // If only the Selection and MainMenu buttons exist, don't proceed - return; - - m_VisibleButtonCount = 2; // Show only the menu and active tool button - for (int i = 0; i < m_OrderedButtons.Count; ++i) - { - var button = m_OrderedButtons[i]; - button.tooltipVisible = false; - if (IsMainMenuButton(button)) - Reinsert(button, k_MenuButtonOrderPosition, true); // Return the main menu button to its original position after being hidden when showing tool buttons - else - m_OrderedButtons[i].order = i > k_ActiveToolOrderPosition ? k_InactiveButtonInitialOrderPosition : i; // Hide buttons beyond the active tool button threshold - } - } - - void SetupButtonOrderThenSelectTool(IToolsMenuButton toolsMenuButton, bool selectAfterSettingButtonOrder = true) - { - var mainMenu = IsMainMenuButton(toolsMenuButton); - if (mainMenu) - { - mainMenuActivatorSelected(rayOrigin); - return; - } - - var showMenuButton = !aboveMinimumButtonCount; - - Reinsert(toolsMenuButton, k_ActiveToolOrderPosition); - - this.RestartCoroutine(ref m_ShowHideAllButtonsCoroutine, ShowThenHideAllButtons(1f, showMenuButton)); - - if (selectAfterSettingButtonOrder && buttonSelected != null) - { - bool existingButton = m_OrderedButtons.Any((x) => x.toolType == toolsMenuButton.toolType); - if (existingButton) - buttonSelected(rayOrigin, toolsMenuButton.toolType); // Select the tool in the Tools Menu - } - } - - /// - /// Utilized by Tools Menu to select an existing button by type, without creating a new button - /// - /// Button ToolType to compare against existing button types - public void SelectExistingToolType(Type type) - { - foreach (var button in m_OrderedButtons) - { - if (button.toolType == type) - { - SetupButtonOrderThenSelectTool(button, false); - return; - } - } - } - - /// - /// Utilized by ToolsMenuButtons to select an existing button by type, without creating a new button - /// - /// Button ToolType to compare against existing button types - void SelectExistingToolTypeFromButton(Type type) - { - foreach (var button in m_OrderedButtons) - { - if (button.toolType == type) - { - SetupButtonOrderThenSelectTool(button); - return; - } - } - } - - public void SelectNextExistingToolButton() - { - var button = m_OrderedButtons[aboveMinimumButtonCount ? k_ActiveToolOrderPosition + 1 : k_ActiveToolOrderPosition]; - SetupButtonOrderThenSelectTool(button); - } - - public void HighlightSingleButtonWithoutMenu(int buttonOrderPosition) - { - for (int i = 1; i < m_OrderedButtons.Count; ++i) - { - var button = m_OrderedButtons[i]; - if (i == buttonOrderPosition) - { - if (!button.highlighted && buttonHovered != null) - { - // Process haptic pulse if button was not already highlighted - this.PulseSpatialHintScrollArrows(); - - if (buttonHovered != null) - buttonHovered(); - } - - button.highlighted = true; - } - else - { - button.highlighted = false; - } - } - } - - /// - /// Used when spatially selecting a highlighted button - /// - public void SelectHighlightedButton() - { - for (int i = 0; i < m_OrderedButtons.Count; ++i) - { - var button = m_OrderedButtons[i]; - var isHighlighted = button.highlighted; - if (isHighlighted) - { - // Force the selection of the button regardless of it previously existing via a call to EVR that triggers a call to SelectExistingType() - if (buttonSelected != null) - buttonSelected(rayOrigin, button.toolType); - - if (buttonClicked != null) - buttonClicked(); - - allButtonsVisible = false; - - return; - } - } - } - - /// - /// Delete a highlighted button, then select the next active tool button - /// - /// Bool denoting that a highlighted button other than the selection tool button was deleted - public bool DeleteHighlightedButton() - { - IToolsMenuButton button = null; - for (int i = 0; i < m_OrderedButtons.Count; ++i) - { - button = m_OrderedButtons[i]; - if ((button.highlighted || button.secondaryButtonHighlighted) && !IsSelectionToolButton(button)) - break; - - button = null; - } - - if (button != null) - { - m_OrderedButtons.Remove(button); - button.destroy(); - button = m_OrderedButtons[k_ActiveToolOrderPosition]; // Assign next ordered button - - if (buttonSelected != null) - buttonSelected(rayOrigin, button.toolType); // Select the new active tool button - } - - if (!aboveMinimumButtonCount && closeMenu != null) - closeMenu(); // Close the menu if below the minimum button count (only MainMenu & SelectionTool are active) - - return button != null; - } - - /// - /// Delete a button of a given type, then select the next active tool button - /// - /// Bool denoting that a button of the given type was deleted - public bool DeleteButtonOfType(Type type) - { - bool buttonDeleted = false; - for (int i = 0; i < m_OrderedButtons.Count; ++i) - { - var button = m_OrderedButtons[i]; - if (button.toolType == type && !IsMainMenuButton(button) && !IsSelectionToolButton(button)) - { - buttonDeleted = true; - m_OrderedButtons.Remove(button); - button.destroy(); - break; - } - } - - return buttonDeleted; - } - - static bool IsMainMenuButton(IToolsMenuButton button) - { - return button.toolType == typeof(IMainMenu); - } - - static bool IsSelectionToolButton(IToolsMenuButton button) - { - return button.toolType == typeof(SelectionTool); - } - - int VisibleButtonCount(Type buttonType) - { - // If button type is main menu, and only the selection tool and main menu buttons are available - // return a value of ZERO so the main menu button is centered - return m_VisibleButtonCount - (aboveMinimumButtonCount ? 0 : 1); - } - - IEnumerator MoveToLocation(Vector3 targetPosition, Vector3 targetScale) - { - const float kPrimaryButtonUIAlternatePositionScalar = 0.65f; - const int kDurationMultiplier = 6; - const int kShapeMultiplier = 4; - var currentPosition = transform.localPosition; - var currentScale = transform.localScale; - var currentPrimaryButtonUIContainerLocalScale = m_OrderedButtons[0].primaryUIContentContainerLocalScale; - var targetPrimaryButtonUIContainerLocalScale = Vector3.one * (m_MoveToAlternatePosition ? kPrimaryButtonUIAlternatePositionScalar : 1f); - var duration = 0f; - while (duration < 1) - { - duration += Time.unscaledDeltaTime * kDurationMultiplier; - var durationShaped = Mathf.Pow(MathUtilsExt.SmoothInOutLerpFloat(duration), kShapeMultiplier); - transform.localScale = Vector3.Lerp(currentScale, targetScale, durationShaped); - transform.localPosition = Vector3.Lerp(currentPosition, targetPosition, durationShaped); - - var newPrimaryButtonScale = Vector3.Lerp(currentPrimaryButtonUIContainerLocalScale, targetPrimaryButtonUIContainerLocalScale, durationShaped); - for (int i = 0; i < m_OrderedButtons.Count; ++i) - m_OrderedButtons[i].primaryUIContentContainerLocalScale = newPrimaryButtonScale; - - yield return null; - } - - transform.localScale = targetScale; - transform.localPosition = targetPosition; - m_MoveCoroutine = null; - } - - void ShowAllButtons(IToolsMenuButton button) - { - m_RayHovered = true; - if (!allButtonsVisible && aboveMinimumButtonCount && !IsMainMenuButton(button) && m_ButtonHoverExitDelayCoroutine == null) - allButtonsVisible = true; - } - - void ButtonHoverExitPerformed() - { - this.RestartCoroutine(ref m_ButtonHoverExitDelayCoroutine, DelayedHoverExitCheck()); - } - - IEnumerator DelayedHoverExitCheck() - { - var duration = Time.unscaledDeltaTime; - m_RayHovered = false; - while (duration < 0.25f) - { - duration += Time.unscaledDeltaTime; - yield return null; - - if (m_RayHovered) - yield break; - } - - // Only proceed if no other button is being hovered - allButtonsVisible = false; - m_ButtonHoverExitDelayCoroutine = null; - } - - void OnButtonHover() - { - if (buttonHovered != null) - buttonHovered(); - } - } + sealed class ToolsMenuUI : MonoBehaviour, IUsesViewerScale, IInstantiateUI, + IConnectInterfaces, IControlSpatialHinting, IUsesRayOrigin + { + const int k_MenuButtonOrderPosition = 0; // Menu button position used in this particular ToolButton implementation + const int k_ActiveToolOrderPosition = 1; // Active-tool button position used in this particular ToolButton implementation + const int k_InactiveButtonInitialOrderPosition = -1; + const float k_RaySelectIconHighlightedZOffset = -0.0075f; + const float k_SpatialSelectIconHighlightedZOffset = -0.02f; + + [SerializeField] + Transform m_ButtonContainer; + + [Header("Used when displaying Alternate Menu")] + [SerializeField] + Vector3 m_AlternatePosition; + + [SerializeField] + Vector3 m_AlternateLocalScale; + + [SerializeField] + Transform m_ButtonTooltipTarget; + + bool m_AllButtonsVisible; + List m_OrderedButtons; + Coroutine m_ShowHideAllButtonsCoroutine; + Coroutine m_MoveCoroutine; + Coroutine m_ButtonHoverExitDelayCoroutine; + int m_VisibleButtonCount; + bool m_MoveToAlternatePosition; + Vector3 m_OriginalLocalScale; + bool m_RayHovered; + float m_SpatialDragDistance; + Quaternion m_HintContentContainerInitialRotation; + Vector3 m_HintContentWorldPosition; + Vector3 m_DragTarget; + + public int maxButtonCount { get; set; } + + public Transform buttonContainer { get { return m_ButtonContainer; } } + + public Transform rayOrigin { private get; set; } + public Action mainMenuActivatorSelected { get; set; } + + public List buttons { get { return m_OrderedButtons; } } + + public bool allButtonsVisible + { + get { return m_AllButtonsVisible; } + set + { + m_AllButtonsVisible = value; + + if (m_AllButtonsVisible) + { + this.StopCoroutine(ref m_ShowHideAllButtonsCoroutine); + ShowAllExceptMenuButton(); + } + else + { + ShowOnlyMenuAndActiveToolButtons(); + spatiallyScrolling = false; + this.SetSpatialHintShowHideRotationTarget(Vector3.zero); + } + } + } + + public bool moveToAlternatePosition + { + set + { + if (m_MoveToAlternatePosition == value) + return; + + m_MoveToAlternatePosition = value; + var newPosition = m_MoveToAlternatePosition ? m_AlternatePosition : Vector3.zero; + var newScale = m_MoveToAlternatePosition ? m_AlternateLocalScale : m_OriginalLocalScale; + this.RestartCoroutine(ref m_MoveCoroutine, MoveToLocation(newPosition, newScale)); + } + } + + bool aboveMinimumButtonCount + { + get + { + const int kSelectionToolButtonHideCount = 2; + var count = m_OrderedButtons.Count; + var aboveMinCount = count > kSelectionToolButtonHideCount; // Has at least one tool been added beyond the default MainMenu & SelectionTool + + // Prevent the display of the SelectionTool button, if only the MainMenu and SelectionTool buttons reside in the buttons collection + if (count == kSelectionToolButtonHideCount) + aboveMinCount = buttons.All(x => x.toolType != typeof(SelectionTool)); + + return aboveMinCount; + } + } + + public bool spatiallyScrolling + { + set + { + for (int i = 0; i < m_OrderedButtons.Count; ++i) + { + var button = m_OrderedButtons[i]; + button.iconHighlightedLocalZOffset = value ? k_SpatialSelectIconHighlightedZOffset : k_RaySelectIconHighlightedZOffset; + } + + if (value) + { + var currentRotation = transform.rotation.eulerAngles; + m_SpatialDragDistance = 0f; + m_HintContentContainerInitialRotation = Quaternion.Euler(0f, currentRotation.y, 0f); + m_HintContentWorldPosition = transform.position; + this.SetSpatialHintPosition(m_HintContentWorldPosition); + } + } + } + + public float spatialDragDistance { set { m_SpatialDragDistance = value; } } + + public Vector3? startingDragOrigin + { + set + { + if (value != null) + this.SetSpatialHintLookAtRotation(value.Value); + } + } + + public event Action buttonHovered; + public event Action buttonClicked; + public event Action buttonSelected; + public event Action closeMenu; + + void Awake() + { + m_OriginalLocalScale = transform.localScale; + m_OrderedButtons = new List(); + } + + void Update() + { + var newHintContainerRotation = m_HintContentContainerInitialRotation; + + // Perform activation of visuals after the user has dragged beyond the initial drag trigger threshold + // The drag distance is a 0-1 lerped value, based off of the origin to trigger magnitude + if (m_SpatialDragDistance >= 1f && m_SpatialDragDistance < 2) + { + if (Mathf.Approximately(m_SpatialDragDistance, 1f)) + { + m_DragTarget = transform.position; // Cache the initial drag target position, before performing any extra shaping to the target Vec3 + this.SetSpatialHintState(SpatialHintModule.SpatialHintStateFlags.Scrolling); + } + + // Follow the user's input for a short additional period of time + // Update the dragTarget with the current device position, to allow for visuals to better match the expected rotation/position + m_DragTarget = transform.position; + this.SetSpatialHintDragThresholdTriggerPosition(transform.position); + this.SetSpatialHintContainerRotation(newHintContainerRotation); + + // Perform a smooth lerp of the hint contents after dragging beyond the distance trigger threshold + m_SpatialDragDistance += Time.unscaledDeltaTime * 8; // Continue to increase the amount + } + else if (m_AllButtonsVisible && m_SpatialDragDistance > 2) + { + this.SetSpatialHintDragThresholdTriggerPosition(transform.position); + this.SetSpatialHintContainerRotation(newHintContainerRotation); + this.SetSpatialHintShowHideRotationTarget(m_DragTarget); + } + } + + public void AddButton(IToolsMenuButton button, Transform buttonTransform) + { + button.showAllButtons = ShowAllButtons; + button.hoverExit = ButtonHoverExitPerformed; + button.maxButtonCount = maxButtonCount; + button.selectTool = SelectExistingToolTypeFromButton; + button.closeButton = DeleteHighlightedButton; + button.visibleButtonCount = VisibleButtonCount; // allow buttons to fetch local buttonCount + button.iconHighlightedLocalZOffset = k_RaySelectIconHighlightedZOffset; + button.tooltipTarget = m_ButtonTooltipTarget; + button.hovered += OnButtonHover; + + bool allowSecondaryButton = false; // Secondary button is the close button + var insertPosition = k_MenuButtonOrderPosition; + if (!IsMainMenuButton(button)) + { + insertPosition = k_ActiveToolOrderPosition; + allowSecondaryButton = !IsSelectionToolButton(button); + } + + var initializingButtons = m_OrderedButtons.Count == 1; + m_OrderedButtons.Insert(insertPosition, button); + + // If only the MainMenu & SelectionTool buttons exist, set visible button count to 1 + m_VisibleButtonCount = aboveMinimumButtonCount || initializingButtons ? m_OrderedButtons.Count : 1; + button.implementsSecondaryButton = allowSecondaryButton; + button.isActiveTool = true; + button.order = insertPosition; + + buttonTransform.rotation = Quaternion.identity; + buttonTransform.localPosition = Vector3.zero; + buttonTransform.localScale = Vector3.zero; + + if (aboveMinimumButtonCount) // aboveMinimumCount will change throughout function, don't cache for re-use + this.RestartCoroutine(ref m_ShowHideAllButtonsCoroutine, ShowThenHideAllButtons(1.25f, false)); + else + SetupButtonOrder(); // Setup the MainMenu and active tool buttons only + } + + IEnumerator ShowThenHideAllButtons(float delayBeforeHiding = 1.25f, bool showMenuButton = true) + { + if (showMenuButton) + SetupButtonOrder(); + else + ShowAllExceptMenuButton(); + + if (delayBeforeHiding > 0) + { + var duration = Time.unscaledDeltaTime; + while (duration < delayBeforeHiding) + { + duration += Time.unscaledDeltaTime; + yield return null; + } + } + + // Hide all but menu and active tool buttons after visually adding new button + allButtonsVisible = false; + m_ShowHideAllButtonsCoroutine = null; + } + + void Reinsert(IToolsMenuButton button, int newOrderPosition, bool updateButtonOrder = false) + { + var removed = m_OrderedButtons.Remove(button); + if (!removed) + return; + + m_OrderedButtons.Insert(newOrderPosition, button); + + if (updateButtonOrder) + button.order = newOrderPosition; + } + + void SetupButtonOrder() + { + for (int i = 0; i < m_OrderedButtons.Count; ++i) + { + var button = m_OrderedButtons[i]; + button.isActiveTool = i == k_ActiveToolOrderPosition; + + // Allow settings of regular button order if there are more buttons that just the MainMenu & SelectionTool + button.order = aboveMinimumButtonCount || IsMainMenuButton(button) ? i : k_InactiveButtonInitialOrderPosition; + } + } + + void ShowAllExceptMenuButton() + { + // The MainMenu button will be hidden, subtract 1 from the m_VisibleButtonCount + m_VisibleButtonCount = Mathf.Max(0, m_OrderedButtons.Count - 1); + for (int i = 0; i < m_OrderedButtons.Count; ++i) + { + var button = m_OrderedButtons[i]; + button.isActiveTool = i == k_ActiveToolOrderPosition; + button.order = i == k_MenuButtonOrderPosition ? k_InactiveButtonInitialOrderPosition : i - 1; // Hide the menu buttons when revealing all tools buttons + } + } + + void ShowOnlyMenuAndActiveToolButtons() + { + if (!aboveMinimumButtonCount) // If only the Selection and MainMenu buttons exist, don't proceed + return; + + m_VisibleButtonCount = 2; // Show only the menu and active tool button + for (int i = 0; i < m_OrderedButtons.Count; ++i) + { + var button = m_OrderedButtons[i]; + button.tooltipVisible = false; + if (IsMainMenuButton(button)) + Reinsert(button, k_MenuButtonOrderPosition, true); // Return the main menu button to its original position after being hidden when showing tool buttons + else + m_OrderedButtons[i].order = i > k_ActiveToolOrderPosition ? k_InactiveButtonInitialOrderPosition : i; // Hide buttons beyond the active tool button threshold + } + } + + void SetupButtonOrderThenSelectTool(IToolsMenuButton toolsMenuButton, bool selectAfterSettingButtonOrder = true) + { + var mainMenu = IsMainMenuButton(toolsMenuButton); + if (mainMenu) + { + mainMenuActivatorSelected(rayOrigin); + return; + } + + var showMenuButton = !aboveMinimumButtonCount; + + Reinsert(toolsMenuButton, k_ActiveToolOrderPosition); + + this.RestartCoroutine(ref m_ShowHideAllButtonsCoroutine, ShowThenHideAllButtons(1f, showMenuButton)); + + if (selectAfterSettingButtonOrder && buttonSelected != null) + { + bool existingButton = m_OrderedButtons.Any((x) => x.toolType == toolsMenuButton.toolType); + if (existingButton) + buttonSelected(rayOrigin, toolsMenuButton.toolType); // Select the tool in the Tools Menu + } + } + + /// + /// Utilized by Tools Menu to select an existing button by type, without creating a new button + /// + /// Button ToolType to compare against existing button types + public void SelectExistingToolType(Type type) + { + foreach (var button in m_OrderedButtons) + { + if (button.toolType == type) + { + SetupButtonOrderThenSelectTool(button, false); + return; + } + } + } + + /// + /// Utilized by ToolsMenuButtons to select an existing button by type, without creating a new button + /// + /// Button ToolType to compare against existing button types + void SelectExistingToolTypeFromButton(Type type) + { + foreach (var button in m_OrderedButtons) + { + if (button.toolType == type) + { + SetupButtonOrderThenSelectTool(button); + return; + } + } + } + + public void SelectNextExistingToolButton() + { + var button = m_OrderedButtons[aboveMinimumButtonCount ? k_ActiveToolOrderPosition + 1 : k_ActiveToolOrderPosition]; + SetupButtonOrderThenSelectTool(button); + } + + public void HighlightSingleButtonWithoutMenu(int buttonOrderPosition) + { + for (int i = 1; i < m_OrderedButtons.Count; ++i) + { + var button = m_OrderedButtons[i]; + if (i == buttonOrderPosition) + { + if (!button.highlighted && buttonHovered != null) + { + // Process haptic pulse if button was not already highlighted + this.PulseSpatialHintScrollArrows(); + + if (buttonHovered != null) + buttonHovered(); + } + + button.highlighted = true; + } + else + { + button.highlighted = false; + } + } + } + + /// + /// Used when spatially selecting a highlighted button + /// + public void SelectHighlightedButton() + { + for (int i = 0; i < m_OrderedButtons.Count; ++i) + { + var button = m_OrderedButtons[i]; + var isHighlighted = button.highlighted; + if (isHighlighted) + { + // Force the selection of the button regardless of it previously existing via a call to EVR that triggers a call to SelectExistingType() + if (buttonSelected != null) + buttonSelected(rayOrigin, button.toolType); + + if (buttonClicked != null) + buttonClicked(); + + allButtonsVisible = false; + + return; + } + } + } + + /// + /// Delete a highlighted button, then select the next active tool button + /// + /// Bool denoting that a highlighted button other than the selection tool button was deleted + public bool DeleteHighlightedButton() + { + IToolsMenuButton button = null; + for (int i = 0; i < m_OrderedButtons.Count; ++i) + { + button = m_OrderedButtons[i]; + if ((button.highlighted || button.secondaryButtonHighlighted) && !IsSelectionToolButton(button)) + break; + + button = null; + } + + if (button != null) + { + m_OrderedButtons.Remove(button); + button.destroy(); + button = m_OrderedButtons[k_ActiveToolOrderPosition]; // Assign next ordered button + + if (buttonSelected != null) + buttonSelected(rayOrigin, button.toolType); // Select the new active tool button + } + + if (!aboveMinimumButtonCount && closeMenu != null) + closeMenu(); // Close the menu if below the minimum button count (only MainMenu & SelectionTool are active) + + return button != null; + } + + /// + /// Delete a button of a given type, then select the next active tool button + /// + /// Bool denoting that a button of the given type was deleted + public bool DeleteButtonOfType(Type type) + { + bool buttonDeleted = false; + for (int i = 0; i < m_OrderedButtons.Count; ++i) + { + var button = m_OrderedButtons[i]; + if (button.toolType == type && !IsMainMenuButton(button) && !IsSelectionToolButton(button)) + { + buttonDeleted = true; + m_OrderedButtons.Remove(button); + button.destroy(); + break; + } + } + + return buttonDeleted; + } + + static bool IsMainMenuButton(IToolsMenuButton button) + { + return button.toolType == typeof(IMainMenu); + } + + static bool IsSelectionToolButton(IToolsMenuButton button) + { + return button.toolType == typeof(SelectionTool); + } + + int VisibleButtonCount(Type buttonType) + { + // If button type is main menu, and only the selection tool and main menu buttons are available + // return a value of ZERO so the main menu button is centered + return m_VisibleButtonCount - (aboveMinimumButtonCount ? 0 : 1); + } + + IEnumerator MoveToLocation(Vector3 targetPosition, Vector3 targetScale) + { + const float kPrimaryButtonUIAlternatePositionScalar = 0.65f; + const int kDurationMultiplier = 6; + const int kShapeMultiplier = 4; + var currentPosition = transform.localPosition; + var currentScale = transform.localScale; + var currentPrimaryButtonUIContainerLocalScale = m_OrderedButtons[0].primaryUIContentContainerLocalScale; + var targetPrimaryButtonUIContainerLocalScale = Vector3.one * (m_MoveToAlternatePosition ? kPrimaryButtonUIAlternatePositionScalar : 1f); + var duration = 0f; + while (duration < 1) + { + duration += Time.unscaledDeltaTime * kDurationMultiplier; + var durationShaped = Mathf.Pow(MathUtilsExt.SmoothInOutLerpFloat(duration), kShapeMultiplier); + transform.localScale = Vector3.Lerp(currentScale, targetScale, durationShaped); + transform.localPosition = Vector3.Lerp(currentPosition, targetPosition, durationShaped); + + var newPrimaryButtonScale = Vector3.Lerp(currentPrimaryButtonUIContainerLocalScale, targetPrimaryButtonUIContainerLocalScale, durationShaped); + for (int i = 0; i < m_OrderedButtons.Count; ++i) + m_OrderedButtons[i].primaryUIContentContainerLocalScale = newPrimaryButtonScale; + + yield return null; + } + + transform.localScale = targetScale; + transform.localPosition = targetPosition; + m_MoveCoroutine = null; + } + + void ShowAllButtons(IToolsMenuButton button) + { + m_RayHovered = true; + if (!allButtonsVisible && aboveMinimumButtonCount && !IsMainMenuButton(button) && m_ButtonHoverExitDelayCoroutine == null) + allButtonsVisible = true; + } + + void ButtonHoverExitPerformed() + { + this.RestartCoroutine(ref m_ButtonHoverExitDelayCoroutine, DelayedHoverExitCheck()); + } + + IEnumerator DelayedHoverExitCheck() + { + var duration = Time.unscaledDeltaTime; + m_RayHovered = false; + while (duration < 0.25f) + { + duration += Time.unscaledDeltaTime; + yield return null; + + if (m_RayHovered) + yield break; + } + + // Only proceed if no other button is being hovered + allButtonsVisible = false; + m_ButtonHoverExitDelayCoroutine = null; + } + + void OnButtonHover() + { + if (buttonHovered != null) + buttonHovered(); + } + } } + #endif diff --git a/Menus/ToolsMenu/ToolsMenu.cs b/Menus/ToolsMenu/ToolsMenu.cs index 86633948d..d2c960214 100644 --- a/Menus/ToolsMenu/ToolsMenu.cs +++ b/Menus/ToolsMenu/ToolsMenu.cs @@ -10,237 +10,244 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class ToolsMenu : MonoBehaviour, IToolsMenu, IConnectInterfaces, IInstantiateUI, - IControlHaptics, IUsesViewerScale, IControlSpatialScrolling, IControlSpatialHinting, IRayVisibilitySettings, IUsesRayOrigin - { - const int k_ActiveToolOrderPosition = 1; // A active-tool button position used in this particular ToolButton implementation - const int k_MaxButtonCount = 16; - - [SerializeField] - Sprite m_MainMenuIcon; - - [SerializeField] - ActionMap m_MainMenuActionMap; - - [SerializeField] - ToolsMenuUI m_ToolsMenuPrefab; - - [SerializeField] - ToolsMenuButton _mToolsMenuButtonTemplate; - - [SerializeField] - HapticPulse m_ButtonClickPulse; - - [SerializeField] - HapticPulse m_ButtonHoverPulse; - - [SerializeField] - HapticPulse m_HidingPulse; // The pulse performed when ending a spatial selection - - float m_AllowToolToggleBeforeThisTime; - Vector3 m_SpatialScrollStartPosition; - ToolsMenuUI m_ToolsMenuUI; - - public Transform menuOrigin { get; set; } - List buttons { get { return m_ToolsMenuUI.buttons; } } - public bool alternateMenuVisible { set { m_ToolsMenuUI.moveToAlternatePosition = value; } } - - public Action highlightSingleButton { get; set; } - public Action selectHighlightedButton { get; set; } - public Action setButtonForType { get; set; } - public Action deleteToolsMenuButton { get; set; } - public Node? node { get; set; } - public IToolsMenuButton PreviewToolsMenuButton { get; private set; } - public Transform alternateMenuOrigin { get; set; } - public SpatialScrollModule.SpatialScrollData spatialScrollData { get; set; } - public ActionMap actionMap { get { return m_MainMenuActionMap; } } - public Transform rayOrigin { get; set; } - - public bool mainMenuActivatorInteractable - { - set { PreviewToolsMenuButton.interactable = value; } - } - - void Awake() - { - setButtonForType = CreateToolsMenuButton; - deleteToolsMenuButton = DeleteToolsMenuButton; - } - - void OnDestroy() - { - this.RemoveRayVisibilitySettings(rayOrigin, this); - } - - void CreateToolsMenuUI() - { - m_ToolsMenuUI = this.InstantiateUI(m_ToolsMenuPrefab.gameObject, rayOrigin, true, rayOrigin).GetComponent(); - m_ToolsMenuUI.maxButtonCount = k_MaxButtonCount; - m_ToolsMenuUI.mainMenuActivatorSelected = this.MainMenuActivatorSelected; - m_ToolsMenuUI.buttonHovered += OnButtonHover; - m_ToolsMenuUI.buttonClicked += OnButtonClick; - m_ToolsMenuUI.buttonSelected += OnButtonSelected; - m_ToolsMenuUI.closeMenu += CloseMenu; - - // Alternate menu origin isn't set when awake or start run - var toolsMenuUITransform = m_ToolsMenuUI.transform; - toolsMenuUITransform.SetParent(alternateMenuOrigin); - toolsMenuUITransform.localPosition = Vector3.zero; - toolsMenuUITransform.localRotation = Quaternion.identity; - } - - void CreateToolsMenuButton(Type toolType, Sprite buttonIcon) - { - // Verify first that the ToolsMenuUI exists - // This is called in EditorVR.Tools before the UI can be created herein in Awake - // The SelectionTool & MainMenu buttons are created immediately after instantiating the ToolsMenu - if (m_ToolsMenuUI == null) - CreateToolsMenuUI(); - - // Select an existing ToolButton if the type is already present in a button - if (buttons.Any( x => x.toolType == toolType)) - { - m_ToolsMenuUI.SelectExistingToolType(toolType); - return; - } - - if (buttons.Count >= k_MaxButtonCount) // Return if tool type already occupies a tool button - return; - - var buttonTransform = ObjectUtils.Instantiate(_mToolsMenuButtonTemplate.gameObject, m_ToolsMenuUI.buttonContainer, false).transform; - var button = buttonTransform.GetComponent(); - this.ConnectInterfaces(button); - - button.rayOrigin = rayOrigin; - button.toolType = toolType; // Assign Tool Type before assigning order - button.icon = toolType != typeof(IMainMenu) ? buttonIcon : m_MainMenuIcon; - button.highlightSingleButton = highlightSingleButton; - button.selectHighlightedButton = selectHighlightedButton; - button.rayOrigin = rayOrigin; - - if (toolType == typeof(IMainMenu)) - PreviewToolsMenuButton = button; - - m_ToolsMenuUI.AddButton(button, buttonTransform); - } - - void DeleteToolsMenuButton(Type toolTypeToDelete, Type toolTypeToSelectAfterDelete) - { - if (m_ToolsMenuUI.DeleteButtonOfType(toolTypeToDelete)) - m_ToolsMenuUI.SelectNextExistingToolButton(); - } - - public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) - { - var buttonCount = buttons.Count; - if (buttonCount <= k_ActiveToolOrderPosition + 1) - return; - - const float kAllowToggleDuration = 0.25f; - - var toolslMenuInput = (ToolsMenuInput) input; - - if (spatialScrollData != null && toolslMenuInput.cancel.wasJustPressed) - { - consumeControl(toolslMenuInput.cancel); - consumeControl(toolslMenuInput.show); - consumeControl(toolslMenuInput.select); - OnButtonClick(); - CloseMenu(); // Also ends spatial scroll - m_ToolsMenuUI.allButtonsVisible = false; - } - - if (spatialScrollData == null && (toolslMenuInput.show.wasJustPressed || toolslMenuInput.show.isHeld) && toolslMenuInput.select.wasJustPressed) - { - m_SpatialScrollStartPosition = alternateMenuOrigin.position; - m_AllowToolToggleBeforeThisTime = Time.realtimeSinceStartup + kAllowToggleDuration; - this.SetSpatialHintControlNode(node); - m_ToolsMenuUI.spatiallyScrolling = true; // Triggers the display of the directional hint arrows - consumeControl(toolslMenuInput.show); - consumeControl(toolslMenuInput.select); - // Assign initial SpatialScrollData; begin scroll - spatialScrollData = this.PerformSpatialScroll(node, m_SpatialScrollStartPosition, alternateMenuOrigin.position, 0.325f, m_ToolsMenuUI.buttons.Count, m_ToolsMenuUI.maxButtonCount); - } - else if (spatialScrollData != null && toolslMenuInput.show.isHeld) - { - consumeControl(toolslMenuInput.show); - consumeControl(toolslMenuInput.select); - // Attempt to close a button, if a scroll has passed the trigger threshold - if (spatialScrollData != null && toolslMenuInput.select.wasJustPressed) - { - if (m_ToolsMenuUI.DeleteHighlightedButton()) - buttonCount = buttons.Count; // The MainMenu button will be hidden, subtract 1 from the activeButtonCount - - if (buttonCount <= k_ActiveToolOrderPosition + 1) - { - if (spatialScrollData != null) - this.EndSpatialScroll(); - - return; - } - } - - // normalized input should loop after reaching the 0.15f length - buttonCount -= 1; // Decrement to disallow cycling through the main menu button - spatialScrollData = this.PerformSpatialScroll(node, m_SpatialScrollStartPosition, alternateMenuOrigin.position, 0.325f, m_ToolsMenuUI.buttons.Count, m_ToolsMenuUI.maxButtonCount); - var normalizedRepeatingPosition = spatialScrollData.normalizedLoopingPosition; - if (!Mathf.Approximately(normalizedRepeatingPosition, 0f)) - { - if (!m_ToolsMenuUI.allButtonsVisible) - { - m_ToolsMenuUI.spatialDragDistance = spatialScrollData.dragDistance; - this.SetSpatialHintState(SpatialHintModule.SpatialHintStateFlags.CenteredScrolling); - m_ToolsMenuUI.allButtonsVisible = true; - } - else if (spatialScrollData.spatialDirection != null) - { - m_ToolsMenuUI.startingDragOrigin = spatialScrollData.spatialDirection; - } - - m_ToolsMenuUI.HighlightSingleButtonWithoutMenu((int)(buttonCount * normalizedRepeatingPosition) + 1); - } - } - else if (spatialScrollData != null && !toolslMenuInput.show.isHeld && !toolslMenuInput.select.isHeld) - { - consumeControl(toolslMenuInput.show); - consumeControl(toolslMenuInput.select); - - if (spatialScrollData != null && spatialScrollData.passedMinDragActivationThreshold) - { - m_ToolsMenuUI.SelectHighlightedButton(); - } - else if (Time.realtimeSinceStartup < m_AllowToolToggleBeforeThisTime) - { - // Allow for single press+release to cycle through tools - m_ToolsMenuUI.SelectNextExistingToolButton(); - OnButtonClick(); - } - - CloseMenu(); - } - } - - void OnButtonClick() - { - this.Pulse(node, m_ButtonClickPulse); - this.SetSpatialHintState(SpatialHintModule.SpatialHintStateFlags.Hidden); - } - - void OnButtonHover() - { - this.Pulse(node, m_ButtonHoverPulse); - } - - void OnButtonSelected(Transform rayOrigin, Type buttonType) - { - this.SelectTool(rayOrigin, buttonType, false); - } - - void CloseMenu() - { - this.Pulse(node, m_HidingPulse); - this.EndSpatialScroll(); // Free the spatial scroll data owned by this object - } - } + sealed class ToolsMenu : MonoBehaviour, IToolsMenu, IConnectInterfaces, IInstantiateUI, + IControlHaptics, IUsesViewerScale, IControlSpatialScrolling, IControlSpatialHinting, IRayVisibilitySettings, IUsesRayOrigin + { + const int k_ActiveToolOrderPosition = 1; // A active-tool button position used in this particular ToolButton implementation + const int k_MaxButtonCount = 16; + + [SerializeField] + Sprite m_MainMenuIcon; + + [SerializeField] + ActionMap m_MainMenuActionMap; + + [SerializeField] + ToolsMenuUI m_ToolsMenuPrefab; + + [SerializeField] + ToolsMenuButton _mToolsMenuButtonTemplate; + + [SerializeField] + HapticPulse m_ButtonClickPulse; + + [SerializeField] + HapticPulse m_ButtonHoverPulse; + + [SerializeField] + HapticPulse m_HidingPulse; // The pulse performed when ending a spatial selection + + float m_AllowToolToggleBeforeThisTime; + Vector3 m_SpatialScrollStartPosition; + ToolsMenuUI m_ToolsMenuUI; + + public Transform menuOrigin { get; set; } + + List buttons { get { return m_ToolsMenuUI.buttons; } } + + public bool alternateMenuVisible { set { m_ToolsMenuUI.moveToAlternatePosition = value; } } + + public Action highlightSingleButton { get; set; } + public Action selectHighlightedButton { get; set; } + public Action setButtonForType { get; set; } + public Action deleteToolsMenuButton { get; set; } + public Node? node { get; set; } + public IToolsMenuButton PreviewToolsMenuButton { get; private set; } + public Transform alternateMenuOrigin { get; set; } + public SpatialScrollModule.SpatialScrollData spatialScrollData { get; set; } + + public ActionMap actionMap { get { return m_MainMenuActionMap; } } + + public Transform rayOrigin { get; set; } + + public bool mainMenuActivatorInteractable + { + set { PreviewToolsMenuButton.interactable = value; } + } + + void Awake() + { + setButtonForType = CreateToolsMenuButton; + deleteToolsMenuButton = DeleteToolsMenuButton; + } + + void OnDestroy() + { + this.RemoveRayVisibilitySettings(rayOrigin, this); + } + + void CreateToolsMenuUI() + { + m_ToolsMenuUI = this.InstantiateUI(m_ToolsMenuPrefab.gameObject, rayOrigin, true, rayOrigin).GetComponent(); + m_ToolsMenuUI.maxButtonCount = k_MaxButtonCount; + m_ToolsMenuUI.mainMenuActivatorSelected = this.MainMenuActivatorSelected; + m_ToolsMenuUI.buttonHovered += OnButtonHover; + m_ToolsMenuUI.buttonClicked += OnButtonClick; + m_ToolsMenuUI.buttonSelected += OnButtonSelected; + m_ToolsMenuUI.closeMenu += CloseMenu; + + // Alternate menu origin isn't set when awake or start run + var toolsMenuUITransform = m_ToolsMenuUI.transform; + toolsMenuUITransform.SetParent(alternateMenuOrigin); + toolsMenuUITransform.localPosition = Vector3.zero; + toolsMenuUITransform.localRotation = Quaternion.identity; + } + + void CreateToolsMenuButton(Type toolType, Sprite buttonIcon) + { + // Verify first that the ToolsMenuUI exists + // This is called in EditorVR.Tools before the UI can be created herein in Awake + // The SelectionTool & MainMenu buttons are created immediately after instantiating the ToolsMenu + if (m_ToolsMenuUI == null) + CreateToolsMenuUI(); + + // Select an existing ToolButton if the type is already present in a button + if (buttons.Any(x => x.toolType == toolType)) + { + m_ToolsMenuUI.SelectExistingToolType(toolType); + return; + } + + if (buttons.Count >= k_MaxButtonCount) // Return if tool type already occupies a tool button + return; + + var buttonTransform = ObjectUtils.Instantiate(_mToolsMenuButtonTemplate.gameObject, m_ToolsMenuUI.buttonContainer, false).transform; + var button = buttonTransform.GetComponent(); + this.ConnectInterfaces(button); + + button.rayOrigin = rayOrigin; + button.toolType = toolType; // Assign Tool Type before assigning order + button.icon = toolType != typeof(IMainMenu) ? buttonIcon : m_MainMenuIcon; + button.highlightSingleButton = highlightSingleButton; + button.selectHighlightedButton = selectHighlightedButton; + button.rayOrigin = rayOrigin; + + if (toolType == typeof(IMainMenu)) + PreviewToolsMenuButton = button; + + m_ToolsMenuUI.AddButton(button, buttonTransform); + } + + void DeleteToolsMenuButton(Type toolTypeToDelete, Type toolTypeToSelectAfterDelete) + { + if (m_ToolsMenuUI.DeleteButtonOfType(toolTypeToDelete)) + m_ToolsMenuUI.SelectNextExistingToolButton(); + } + + public void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) + { + var buttonCount = buttons.Count; + if (buttonCount <= k_ActiveToolOrderPosition + 1) + return; + + const float kAllowToggleDuration = 0.25f; + + var toolslMenuInput = (ToolsMenuInput)input; + + if (spatialScrollData != null && toolslMenuInput.cancel.wasJustPressed) + { + consumeControl(toolslMenuInput.cancel); + consumeControl(toolslMenuInput.show); + consumeControl(toolslMenuInput.select); + OnButtonClick(); + CloseMenu(); // Also ends spatial scroll + m_ToolsMenuUI.allButtonsVisible = false; + } + + if (spatialScrollData == null && (toolslMenuInput.show.wasJustPressed || toolslMenuInput.show.isHeld) && toolslMenuInput.select.wasJustPressed) + { + m_SpatialScrollStartPosition = alternateMenuOrigin.position; + m_AllowToolToggleBeforeThisTime = Time.realtimeSinceStartup + kAllowToggleDuration; + this.SetSpatialHintControlNode(node); + m_ToolsMenuUI.spatiallyScrolling = true; // Triggers the display of the directional hint arrows + consumeControl(toolslMenuInput.show); + consumeControl(toolslMenuInput.select); + + // Assign initial SpatialScrollData; begin scroll + spatialScrollData = this.PerformSpatialScroll(node, m_SpatialScrollStartPosition, alternateMenuOrigin.position, 0.325f, m_ToolsMenuUI.buttons.Count, m_ToolsMenuUI.maxButtonCount); + } + else if (spatialScrollData != null && toolslMenuInput.show.isHeld) + { + consumeControl(toolslMenuInput.show); + consumeControl(toolslMenuInput.select); + + // Attempt to close a button, if a scroll has passed the trigger threshold + if (spatialScrollData != null && toolslMenuInput.select.wasJustPressed) + { + if (m_ToolsMenuUI.DeleteHighlightedButton()) + buttonCount = buttons.Count; // The MainMenu button will be hidden, subtract 1 from the activeButtonCount + + if (buttonCount <= k_ActiveToolOrderPosition + 1) + { + if (spatialScrollData != null) + this.EndSpatialScroll(); + + return; + } + } + + // normalized input should loop after reaching the 0.15f length + buttonCount -= 1; // Decrement to disallow cycling through the main menu button + spatialScrollData = this.PerformSpatialScroll(node, m_SpatialScrollStartPosition, alternateMenuOrigin.position, 0.325f, m_ToolsMenuUI.buttons.Count, m_ToolsMenuUI.maxButtonCount); + var normalizedRepeatingPosition = spatialScrollData.normalizedLoopingPosition; + if (!Mathf.Approximately(normalizedRepeatingPosition, 0f)) + { + if (!m_ToolsMenuUI.allButtonsVisible) + { + m_ToolsMenuUI.spatialDragDistance = spatialScrollData.dragDistance; + this.SetSpatialHintState(SpatialHintModule.SpatialHintStateFlags.CenteredScrolling); + m_ToolsMenuUI.allButtonsVisible = true; + } + else if (spatialScrollData.spatialDirection != null) + { + m_ToolsMenuUI.startingDragOrigin = spatialScrollData.spatialDirection; + } + + m_ToolsMenuUI.HighlightSingleButtonWithoutMenu((int)(buttonCount * normalizedRepeatingPosition) + 1); + } + } + else if (spatialScrollData != null && !toolslMenuInput.show.isHeld && !toolslMenuInput.select.isHeld) + { + consumeControl(toolslMenuInput.show); + consumeControl(toolslMenuInput.select); + + if (spatialScrollData != null && spatialScrollData.passedMinDragActivationThreshold) + { + m_ToolsMenuUI.SelectHighlightedButton(); + } + else if (Time.realtimeSinceStartup < m_AllowToolToggleBeforeThisTime) + { + // Allow for single press+release to cycle through tools + m_ToolsMenuUI.SelectNextExistingToolButton(); + OnButtonClick(); + } + + CloseMenu(); + } + } + + void OnButtonClick() + { + this.Pulse(node, m_ButtonClickPulse); + this.SetSpatialHintState(SpatialHintModule.SpatialHintStateFlags.Hidden); + } + + void OnButtonHover() + { + this.Pulse(node, m_ButtonHoverPulse); + } + + void OnButtonSelected(Transform rayOrigin, Type buttonType) + { + this.SelectTool(rayOrigin, buttonType, false); + } + + void CloseMenu() + { + this.Pulse(node, m_HidingPulse); + this.EndSpatialScroll(); // Free the spatial scroll data owned by this object + } + } } + #endif diff --git a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs index 473642db0..29916b653 100644 --- a/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs +++ b/Menus/ToolsMenu/ToolsMenuButton/ToolsMenuButton.cs @@ -12,733 +12,749 @@ namespace UnityEditor.Experimental.EditorVR.Menus { - sealed class ToolsMenuButton : MonoBehaviour, IToolsMenuButton, ITooltip, ITooltipPlacement, ISetTooltipVisibility, ISetCustomTooltipColor - { - static Color s_FrameOpaqueColor; - - const float k_AlternateLocalScaleMultiplier = 0.85f; // Meets outer bounds of the radial menu - const string k_MaterialColorProperty = "_Color"; - const string k_SelectionTooltipText = "Selection Tool (cannot be closed)"; - const string k_MainMenuTipText = "Main Menu"; - readonly Vector3 k_ToolButtonActivePosition = new Vector3(0f, 0f, -0.035f); - - [SerializeField] - GradientButton m_GradientButton; - - [SerializeField] - Transform m_IconContainer; - - [SerializeField] - Transform m_PrimaryUIContentContainer; - - [SerializeField] - CanvasGroup m_IconContainerCanvasGroup; - - [SerializeField] - SkinnedMeshRenderer m_FrameRenderer; - - [SerializeField] - SkinnedMeshRenderer m_InsetMeshRenderer; - - [SerializeField] - Collider[] m_PrimaryButtonColliders; - - [SerializeField] - [FormerlySerializedAs("m_CloseButton")] - GradientButton m_CloseButton; - - [SerializeField] - [FormerlySerializedAs("m_CloseButtonContainerCanvasGroup")] - CanvasGroup m_CloseButtonContainerCanvasGroup; - - [SerializeField] - [FormerlySerializedAs("m_CloseInsetMeshRenderer")] - SkinnedMeshRenderer m_CloseInsetMeshRenderer; - - [SerializeField] - [FormerlySerializedAs("m_CloseInsetMaskMeshRenderer")] - SkinnedMeshRenderer m_CloseInsetMaskMeshRenderer; - - [SerializeField] - [FormerlySerializedAs("m_CloseButtonColliders")] - Collider[] m_CloseButtonColliders; // disable for the main menu button & solitary primary tool button - - [SerializeField] - Transform m_TooltipTarget; - - [SerializeField] - Transform m_TooltipSource; - - [SerializeField] - Vector3 m_AlternateLocalPosition; - - [SerializeField] - Image m_ButtonIcon; - - Coroutine m_PositionCoroutine; - Coroutine m_VisibilityCoroutine; - Coroutine m_HighlightCoroutine; - Coroutine m_ActivatorMoveCoroutine; - Coroutine m_HoverCheckCoroutine; - Coroutine m_SecondaryButtonVisibilityCoroutine; - - string m_TooltipText; - string m_PreviewToolDescription; - bool m_MoveToAlternatePosition; - int m_Order = -1; - Type m_PreviewToolType; - Type m_ToolType; - GradientPair m_GradientPair; - Material m_FrameMaterial; - Material m_InsetMaterial; - Vector3 m_OriginalLocalPosition; - Vector3 m_OriginalLocalScale; - Material m_IconMaterial; - Vector3 m_OriginalIconContainerLocalScale; - Sprite m_Icon; - Sprite m_PreviewIcon; - bool m_Highlighted; - bool m_ActiveTool; - - public Transform tooltipTarget { get { return m_TooltipTarget; } set { m_TooltipTarget = value; } } - public Transform tooltipSource { get { return m_TooltipSource; } } - public TextAlignment tooltipAlignment { get; private set; } - public Transform rayOrigin { get; set; } - public Node node { get; set; } - public ITooltip tooltip { private get; set; } // Overrides text - public GradientPair customTooltipHighlightColor { get; set; } - public bool isSelectionTool { get { return m_ToolType != null && m_ToolType == typeof(Tools.SelectionTool); } } - public bool isMainMenu { get { return m_ToolType != null && m_ToolType == typeof(IMainMenu); } } - public int activeButtonCount { get; set; } - public int maxButtonCount { get; set; } - public Transform menuOrigin { get; set; } - public bool implementsSecondaryButton { get; set; } - - public Action openMenu { get; set; } - public Action selectTool { get; set; } - public Func closeButton { get; set; } - public Action highlightSingleButton { get; set; } - public Action selectHighlightedButton { get; set; } - public Vector3 toolButtonActivePosition { get { return k_ToolButtonActivePosition; } } // Shared active button offset from the alternate menu - public Func visibleButtonCount { get; set; } - public Action destroy { get { return DestroyButton; } } - public Action showAllButtons { private get; set; } - public Action hoverExit { get; set; } - - public Type toolType - { - get - { - return m_ToolType; - } - - set - { - m_ToolType = value; - - m_GradientButton.gameObject.SetActive(true); - - if (m_ToolType != null) - { - gradientPair = UnityBrandColorScheme.saturatedSessionGradient; - - if (isSelectionTool || isMainMenu) - { - tooltipText = isSelectionTool ? k_SelectionTooltipText : k_MainMenuTipText; - secondaryButtonCollidersEnabled = false; - } - else - { - tooltipText = toolType.Name; - } - - isActiveTool = isActiveTool; - m_GradientButton.visible = true; - } - else - { - m_GradientButton.visible = false; - gradientPair = UnityBrandColorScheme.grayscaleSessionGradient; - } - } - } - - public int order - { - get { return m_Order; } - set - { - m_Order = value; // Position of this button in relation to other tool buttons - - highlighted = false; - - this.RestartCoroutine(ref m_PositionCoroutine, AnimatePosition(m_Order)); - - if (m_Order == -1) - this.HideTooltip(this); - } - } - - /// - /// GradientPair should be set with new random gradientPair each time a new Tool is associated with this Button - /// This gradientPair is also used to highlight the input device when appropriate - /// - public GradientPair gradientPair - { - get { return m_GradientPair; } - set - { - m_GradientPair = value; - customTooltipHighlightColor = value; - } - } - - /// - /// Type, that if not null, denotes that preview-mode is enabled - /// This is enabled when highlighting a tool on the main menu - /// - public Type previewToolType - { - private get { return m_PreviewToolType; } - set - { - m_PreviewToolType = value; - - if (m_PreviewToolType != null) // Show the highlight if the preview type is valid; hide otherwise - { - var tempToolGo = ObjectUtils.AddComponent(m_PreviewToolType, gameObject); - var tempTool = tempToolGo as ITool; - if (tempTool != null) - { - var iMenuIcon = tempTool as IMenuIcon; - if (iMenuIcon != null) - previewIcon = iMenuIcon.icon; - - ObjectUtils.Destroy(tempToolGo); - } - - // Show the grayscale highlight when previewing a tool on this button - m_GradientButton.highlightGradientPair = UnityBrandColorScheme.saturatedSessionGradient; // UnityBrandColorScheme.grayscaleSessionGradient; - - if (!previewIcon) - m_GradientButton.SetContent(GetTypeAbbreviation(m_PreviewToolType)); - } - else - { - previewToolDescription = null; // Clear the preview tooltip - isActiveTool = isActiveTool; // Set active tool back to pre-preview state - icon = icon; // Gradient button will set its icon back to that representing the current tool, if one existed before previewing new tool type in this button - m_GradientButton.highlightGradientPair = gradientPair; - } - - m_GradientButton.highlighted = m_PreviewToolType != null; - } - } - - public string previewToolDescription - { - get { return m_PreviewToolDescription; } - set - { - if (value != null) - { - m_PreviewToolDescription = value; - this.ShowTooltip(this); - } - else - { - m_PreviewToolDescription = null; - tooltipVisible = false; - } - } - } - - public string tooltipText - { - get - { - if (!interactable && toolType == typeof(IMainMenu)) - return "Main Menu hidden"; - - return tooltip != null ? tooltip.tooltipText : (previewToolType == null ? m_TooltipText : previewToolDescription); - } - - private set { m_TooltipText = value; } - } - - public bool isActiveTool - { - private get { return m_ActiveTool; } - set - { - m_ActiveTool = value; - - m_GradientButton.normalGradientPair = m_ActiveTool ? gradientPair : UnityBrandColorScheme.darkGrayscaleSessionGradient; - m_GradientButton.highlightGradientPair = m_ActiveTool ? UnityBrandColorScheme.darkGrayscaleSessionGradient : gradientPair; - - m_GradientButton.highlighted = true; - m_GradientButton.highlighted = false; - } - } - - public bool highlighted - { - get { return m_Highlighted; } - set - { - if (m_Highlighted == value) - return; - - m_Highlighted = value; - m_GradientButton.highlighted = m_Highlighted; - - if (!m_Highlighted) - this.HideTooltip(this); - else - this.ShowTooltip(this); - - if (implementsSecondaryButton && (!isMainMenu || !isSelectionTool)) - { - // This show/hide functionality utilized by spatial scrolling - if (m_Highlighted) - this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, ShowSecondaryButton()); - else - this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, HideSecondaryButton()); - } - } - } - - public bool interactable - { - get { return m_GradientButton.interactable; } - set { m_GradientButton.interactable = value; } - } - - public bool secondaryButtonHighlighted { get { return m_CloseButton.highlighted; } } - - public bool tooltipVisible - { - set - { - if (!value) - this.HideTooltip(this); - } - } - - bool primaryButtonCollidersEnabled - { - set - { - foreach (var collider in m_PrimaryButtonColliders) - { - collider.enabled = value; - } - } - } - - bool secondaryButtonCollidersEnabled - { - set - { - foreach (var collider in m_CloseButtonColliders) - { - collider.enabled = value; - } - } - } - - public Sprite icon - { - private get { return m_Icon; } - set - { - m_PreviewIcon = null; // clear any cached preview icons - m_Icon = value; - - if (m_Icon) - m_GradientButton.SetContent(m_Icon); - else - m_GradientButton.SetContent(GetTypeAbbreviation(m_ToolType)); // Set backup tool abbreviation if no icon is set - } - } - - public Sprite previewIcon - { - get { return m_PreviewIcon; } - set - { - m_PreviewIcon = value; - m_GradientButton.SetContent(m_PreviewIcon); - } - } - - public bool moveToAlternatePosition - { - get { return m_MoveToAlternatePosition; } - set - { - if (m_MoveToAlternatePosition == value) - return; - - m_MoveToAlternatePosition = value; - - this.StopCoroutine(ref m_ActivatorMoveCoroutine); - - m_ActivatorMoveCoroutine = StartCoroutine(AnimateMoveActivatorButton(m_MoveToAlternatePosition)); - } - } - - bool visible { set { this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateVisibility(value)); } } - - public Vector3 primaryUIContentContainerLocalScale { get { return m_PrimaryUIContentContainer.localScale; } set { m_PrimaryUIContentContainer.localScale = value; } } - public float iconHighlightedLocalZOffset { set { m_GradientButton.iconHighlightedLocalZOffset = value; } } - - public event Action hovered; - - void Awake() - { - m_OriginalLocalPosition = transform.localPosition; - m_OriginalLocalScale = transform.localScale; - m_FrameMaterial = MaterialUtils.GetMaterialClone(m_FrameRenderer); - var frameMaterialColor = m_FrameMaterial.color; - s_FrameOpaqueColor = new Color(frameMaterialColor.r, frameMaterialColor.g, frameMaterialColor.b, 1f); - m_FrameMaterial.SetColor(k_MaterialColorProperty, s_FrameOpaqueColor); - - m_IconMaterial = MaterialUtils.GetMaterialClone(m_ButtonIcon); - m_InsetMaterial = MaterialUtils.GetMaterialClone(m_InsetMeshRenderer); - m_OriginalIconContainerLocalScale = m_IconContainer.localScale; - } - - void Start() - { - if (m_ToolType == null) - m_GradientButton.gameObject.SetActive(false); - - tooltipAlignment = TextAlignment.Center; - - m_GradientButton.hoverEnter += OnBackgroundHoverEnter; // Display the foreground button actions - m_GradientButton.hoverExit += OnActionButtonHoverExit; - m_GradientButton.click += OnBackgroundButtonClick; - - m_FrameRenderer.SetBlendShapeWeight(1, 0f); - m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, 100f); - m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, 100f); - - m_CloseButton.hoverEnter += OnBackgroundHoverEnter; // Display the foreground button actions - m_CloseButton.hoverExit += OnActionButtonHoverExit; - m_CloseButton.click += OnSecondaryButtonClicked; - m_CloseButtonContainerCanvasGroup.alpha = 0f; - } - - void OnDestroy() - { - ObjectUtils.Destroy(m_InsetMaterial); - ObjectUtils.Destroy(m_IconMaterial); - ObjectUtils.Destroy(m_FrameMaterial); - - this.StopCoroutine(ref m_PositionCoroutine); - this.StopCoroutine(ref m_VisibilityCoroutine); - this.StopCoroutine(ref m_HighlightCoroutine); - this.StopCoroutine(ref m_ActivatorMoveCoroutine); - this.StopCoroutine(ref m_HoverCheckCoroutine); - this.StopCoroutine(ref m_SecondaryButtonVisibilityCoroutine); - } - - void DestroyButton() - { - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHideAndDestroy()); - } - - static string GetTypeAbbreviation(Type type) - { - // Create periodic table-style names for types - var abbreviation = new StringBuilder(); - foreach (var ch in type.Name.ToCharArray()) - { - if (char.IsUpper(ch)) - abbreviation.Append(abbreviation.Length > 0 ? char.ToLower(ch) : ch); - - if (abbreviation.Length >= 2) - break; - } - - return abbreviation.ToString(); - } - - void OnBackgroundHoverEnter () - { - if (hovered != null) // Raised in order to trigger the haptic in the Tools Menu - hovered(); - - if (isMainMenu) - { - m_GradientButton.highlighted = true; - return; - } - - if (implementsSecondaryButton) - this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, ShowSecondaryButton()); - - showAllButtons(this); - } - - void OnActionButtonHoverExit() - { - ActionButtonHoverExit(); - } - - void ActionButtonHoverExit() - { - if (m_PositionCoroutine != null) - return; - - if (isMainMenu) - { - m_GradientButton.highlighted = false; - return; - } - - if (!m_CloseButton.highlighted) - this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, HideSecondaryButton()); - - hoverExit(); - } - - void OnBackgroundButtonClick() - { - if (!interactable) - return; - - selectTool(toolType); - - if (!isMainMenu) - ActionButtonHoverExit(); - - m_GradientButton.UpdateMaterialColors(); - } - - void OnSecondaryButtonClicked() - { - if (!implementsSecondaryButton) - return; - this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHideAndDestroy()); - closeButton(); - ActionButtonHoverExit(); - } - - IEnumerator AnimateHideAndDestroy() - { - this.StopCoroutine(ref m_PositionCoroutine); - this.StopCoroutine(ref m_HighlightCoroutine); - this.StopCoroutine(ref m_ActivatorMoveCoroutine); - this.StopCoroutine(ref m_HoverCheckCoroutine); - this.StopCoroutine(ref m_SecondaryButtonVisibilityCoroutine); - - this.HideTooltip(this); - const int kDurationScalar = 3; - var duration = 0f; - var currentScale = transform.localScale; - var targetScale = Vector3.zero; - while (duration < 1) - { - var durationShaped = Mathf.Pow(MathUtilsExt.SmoothInOutLerpFloat(duration += Time.unscaledDeltaTime * kDurationScalar), 4); - transform.localScale = Vector3.Lerp(currentScale, targetScale, durationShaped); - yield return null; - } - - transform.localScale = targetScale; - m_VisibilityCoroutine = null; - ObjectUtils.Destroy(gameObject, 0.1f); - } - - IEnumerator AnimateVisibility(bool show = true) - { - const float kSpeedScalar = 8f; - var targetPosition = show ? (moveToAlternatePosition ? m_AlternateLocalPosition : m_OriginalLocalPosition) : Vector3.zero; - var targetScale = show ? (moveToAlternatePosition ? m_OriginalLocalScale : m_OriginalLocalScale * k_AlternateLocalScaleMultiplier) : Vector3.zero; - var currentPosition = transform.localPosition; - var currentIconScale = m_IconContainer.localScale; - var targetIconContainerScale = show ? m_OriginalIconContainerLocalScale : Vector3.zero; - var transitionAmount = 0f; - var currentScale = transform.localScale; - while (transitionAmount < 1) - { - var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(transitionAmount += Time.unscaledDeltaTime * kSpeedScalar); - m_IconContainer.localScale = Vector3.Lerp(currentIconScale, targetIconContainerScale, shapedAmount); - transform.localPosition = Vector3.Lerp(currentPosition, targetPosition, shapedAmount); - transform.localScale = Vector3.Lerp(currentScale, targetScale, shapedAmount); - yield return null; - } - - m_IconContainer.localScale = targetIconContainerScale; - transform.localScale = targetScale; - transform.localPosition = targetPosition; - m_VisibilityCoroutine = null; - } - - IEnumerator AnimatePosition(int orderPosition) - { - primaryButtonCollidersEnabled = false; - secondaryButtonCollidersEnabled = false; - - this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, HideSecondaryButton()); - - visible = orderPosition != -1; - - const float kTimeScalar = 6f; - const float kCenterLocationAmount = 0.5f; - const float kCircularRange = 360f; - const int kDurationShapeAmount = 3; - var rotationSpacing = kCircularRange / maxButtonCount; // dividend should be the count of tool buttons showing at this time - // Center the MainMenu & Active tool buttons at the bottom of the RadialMenu - var phaseOffset = orderPosition > -1 ? rotationSpacing * kCenterLocationAmount - (visibleButtonCount(m_ToolType) * kCenterLocationAmount) * rotationSpacing : 0; - var targetRotation = orderPosition > -1 ? Quaternion.AngleAxis(phaseOffset + rotationSpacing * Mathf.Max(0f, orderPosition), Vector3.down) : Quaternion.identity; - - var duration = 0f; - var currentCanvasAlpha = m_IconContainerCanvasGroup.alpha; - var targetCanvasAlpha = orderPosition > -1 ? 1f : 0f; - var currentRotation = transform.localRotation; - var positionWait = 1f; - while (duration < 1) - { - duration += Time.unscaledDeltaTime * kTimeScalar * positionWait; - var durationShaped = Mathf.Pow(MathUtilsExt.SmoothInOutLerpFloat(duration), kDurationShapeAmount); - transform.localRotation = Quaternion.Lerp(currentRotation, targetRotation, durationShaped); - m_IconContainerCanvasGroup.alpha = Mathf.Lerp(currentCanvasAlpha, targetCanvasAlpha, durationShaped); - CorrectIconRotation(); - yield return null; - } - - transform.localRotation = targetRotation; - CorrectIconRotation(); - primaryButtonCollidersEnabled = orderPosition > -1; - secondaryButtonCollidersEnabled = orderPosition > -1; - m_PositionCoroutine = null; - - if (implementsSecondaryButton && orderPosition > -1 && m_GradientButton.highlighted) - this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, ShowSecondaryButton()); - } - - IEnumerator AnimateMoveActivatorButton(bool moveToAlternatePosition = true) - { - const float kSpeedDecreaseScalar = 0.275f; - var amount = 0f; - var currentPosition = transform.localPosition; - var targetPosition = moveToAlternatePosition ? m_AlternateLocalPosition : m_OriginalLocalPosition; - var currentLocalScale = transform.localScale; - var targetLocalScale = moveToAlternatePosition ? m_OriginalLocalScale : m_OriginalLocalScale * k_AlternateLocalScaleMultiplier; - var speed = moveToAlternatePosition ? 5f : 4.5f; // Perform faster is returning to original position - speed += (order + 1) * kSpeedDecreaseScalar; - while (amount < 1f) - { - var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(amount += Time.unscaledDeltaTime * speed); - transform.localPosition = Vector3.Lerp(currentPosition, targetPosition, shapedAmount); - transform.localScale = Vector3.Lerp(currentLocalScale, targetLocalScale, shapedAmount); - yield return null; - } - - transform.localPosition = targetPosition; - transform.localScale = targetLocalScale; - m_ActivatorMoveCoroutine = null; - } - - void CorrectIconRotation() - { - const float kIconLookForwardOffset = 0.5f; - var iconLookDirection = m_IconContainer.transform.position + transform.forward * kIconLookForwardOffset; // set a position offset above the icon, regardless of the icon's rotation - m_IconContainer.LookAt(iconLookDirection); - m_IconContainer.localEulerAngles = new Vector3(0f, 0f, m_IconContainer.localEulerAngles.z); - } - - IEnumerator ShowSecondaryButton() - { - // Don't perform additional animated visuals if already in a fully revealed state - if (Mathf.Approximately(m_CloseButtonContainerCanvasGroup.alpha, 1f)) - { - m_SecondaryButtonVisibilityCoroutine = null; - yield break; - } - - const float kSecondaryButtonFrameVisibleBlendShapeWeight = 16f; // The extra amount of the frame to show on hover-before the full reveal of the secondary button - const float kTargetDuration = 1f; - const int kIntroDurationMultiplier = 10; - var currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); - var currentDuration = 0f; - while (currentDuration < kTargetDuration) - { - var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentDuration += Time.unscaledDeltaTime * kIntroDurationMultiplier); - m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, kSecondaryButtonFrameVisibleBlendShapeWeight, shapedAmount)); - yield return null; - } - - const float kDelayBeforeSecondaryButtonReveal = 0.25f; - currentDuration = 0f; // Reset current duration - while (currentDuration < kDelayBeforeSecondaryButtonReveal) - { - currentDuration += Time.unscaledDeltaTime; - yield return null; - } - - const float kFrameSecondaryButtonVisibleBlendShapeWeight = 61f; - const float kSecondaryButtonVisibleBlendShapeWeight = 46f; - const int kDurationMultiplier = 25; - - this.StopCoroutine(ref m_HighlightCoroutine); - - var currentSecondaryButtonVisibilityAmount = m_CloseInsetMeshRenderer.GetBlendShapeWeight(0); - var currentSecondaryCanvasGroupAlpha = m_CloseButtonContainerCanvasGroup.alpha; - currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); - currentDuration = 0f; - while (currentDuration < 1f) - { - var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentDuration += Time.unscaledDeltaTime * kDurationMultiplier); - m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, kFrameSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); - m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); - m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); - m_CloseButtonContainerCanvasGroup.alpha = Mathf.Lerp(currentSecondaryCanvasGroupAlpha, 1f, shapedAmount); - yield return null; - } - - m_SecondaryButtonVisibilityCoroutine = null; - } - - IEnumerator HideSecondaryButton() - { - const float kMaxDelayDuration = 0.125f; - var delayDuration = 0f; - while (delayDuration < kMaxDelayDuration) - { - delayDuration += Time.unscaledDeltaTime; - yield return null; - } - - const float kSecondaryButtonHiddenBlendShapeWeight = 100f; - const int kDurationMultiplier = 12; - var currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); - var currentSecondaryButtonVisibilityAmount = m_CloseInsetMeshRenderer.GetBlendShapeWeight(0); - var currentSecondaryCanvasGroupAlpha = m_CloseButtonContainerCanvasGroup.alpha; - var amount = 0f; - while (amount < 1f) - { - yield return null; - - if (m_CloseButton.highlighted) - { - m_SecondaryButtonVisibilityCoroutine = null; - yield break; - } - - this.StopCoroutine(ref m_HighlightCoroutine); - - var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(amount += Time.unscaledDeltaTime * kDurationMultiplier); - m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, 0f, shapedAmount)); - m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonHiddenBlendShapeWeight, shapedAmount)); - m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonHiddenBlendShapeWeight, shapedAmount)); - m_CloseButtonContainerCanvasGroup.alpha = Mathf.Lerp(currentSecondaryCanvasGroupAlpha, 0f, shapedAmount); - } - - m_SecondaryButtonVisibilityCoroutine = null; - } - } + sealed class ToolsMenuButton : MonoBehaviour, IToolsMenuButton, ITooltip, ITooltipPlacement, ISetTooltipVisibility, ISetCustomTooltipColor + { + static Color s_FrameOpaqueColor; + + const float k_AlternateLocalScaleMultiplier = 0.85f; // Meets outer bounds of the radial menu + const string k_MaterialColorProperty = "_Color"; + const string k_SelectionTooltipText = "Selection Tool (cannot be closed)"; + const string k_MainMenuTipText = "Main Menu"; + readonly Vector3 k_ToolButtonActivePosition = new Vector3(0f, 0f, -0.035f); + + [SerializeField] + GradientButton m_GradientButton; + + [SerializeField] + Transform m_IconContainer; + + [SerializeField] + Transform m_PrimaryUIContentContainer; + + [SerializeField] + CanvasGroup m_IconContainerCanvasGroup; + + [SerializeField] + SkinnedMeshRenderer m_FrameRenderer; + + [SerializeField] + SkinnedMeshRenderer m_InsetMeshRenderer; + + [SerializeField] + Collider[] m_PrimaryButtonColliders; + + [SerializeField] + [FormerlySerializedAs("m_CloseButton")] + GradientButton m_CloseButton; + + [SerializeField] + [FormerlySerializedAs("m_CloseButtonContainerCanvasGroup")] + CanvasGroup m_CloseButtonContainerCanvasGroup; + + [SerializeField] + [FormerlySerializedAs("m_CloseInsetMeshRenderer")] + SkinnedMeshRenderer m_CloseInsetMeshRenderer; + + [SerializeField] + [FormerlySerializedAs("m_CloseInsetMaskMeshRenderer")] + SkinnedMeshRenderer m_CloseInsetMaskMeshRenderer; + + [SerializeField] + [FormerlySerializedAs("m_CloseButtonColliders")] + Collider[] m_CloseButtonColliders; // disable for the main menu button & solitary primary tool button + + [SerializeField] + Transform m_TooltipTarget; + + [SerializeField] + Transform m_TooltipSource; + + [SerializeField] + Vector3 m_AlternateLocalPosition; + + [SerializeField] + Image m_ButtonIcon; + + Coroutine m_PositionCoroutine; + Coroutine m_VisibilityCoroutine; + Coroutine m_HighlightCoroutine; + Coroutine m_ActivatorMoveCoroutine; + Coroutine m_HoverCheckCoroutine; + Coroutine m_SecondaryButtonVisibilityCoroutine; + + string m_TooltipText; + string m_PreviewToolDescription; + bool m_MoveToAlternatePosition; + int m_Order = -1; + Type m_PreviewToolType; + Type m_ToolType; + GradientPair m_GradientPair; + Material m_FrameMaterial; + Material m_InsetMaterial; + Vector3 m_OriginalLocalPosition; + Vector3 m_OriginalLocalScale; + Material m_IconMaterial; + Vector3 m_OriginalIconContainerLocalScale; + Sprite m_Icon; + Sprite m_PreviewIcon; + bool m_Highlighted; + bool m_ActiveTool; + + public Transform tooltipTarget + { + get { return m_TooltipTarget; } + set { m_TooltipTarget = value; } + } + + public Transform tooltipSource { get { return m_TooltipSource; } } + + public TextAlignment tooltipAlignment { get; private set; } + public Transform rayOrigin { get; set; } + public Node node { get; set; } + public ITooltip tooltip { private get; set; } // Overrides text + public GradientPair customTooltipHighlightColor { get; set; } + + public bool isSelectionTool { get { return m_ToolType != null && m_ToolType == typeof(Tools.SelectionTool); } } + + public bool isMainMenu { get { return m_ToolType != null && m_ToolType == typeof(IMainMenu); } } + + public int activeButtonCount { get; set; } + public int maxButtonCount { get; set; } + public Transform menuOrigin { get; set; } + public bool implementsSecondaryButton { get; set; } + + public Action openMenu { get; set; } + public Action selectTool { get; set; } + public Func closeButton { get; set; } + public Action highlightSingleButton { get; set; } + public Action selectHighlightedButton { get; set; } + + public Vector3 toolButtonActivePosition { get { return k_ToolButtonActivePosition; } } // Shared active button offset from the alternate menu + public Func visibleButtonCount { get; set; } + + public Action destroy { get { return DestroyButton; } } + + public Action showAllButtons { private get; set; } + public Action hoverExit { get; set; } + + public Type toolType + { + get { return m_ToolType; } + + set + { + m_ToolType = value; + + m_GradientButton.gameObject.SetActive(true); + + if (m_ToolType != null) + { + gradientPair = UnityBrandColorScheme.saturatedSessionGradient; + + if (isSelectionTool || isMainMenu) + { + tooltipText = isSelectionTool ? k_SelectionTooltipText : k_MainMenuTipText; + secondaryButtonCollidersEnabled = false; + } + else + { + tooltipText = toolType.Name; + } + + isActiveTool = isActiveTool; + m_GradientButton.visible = true; + } + else + { + m_GradientButton.visible = false; + gradientPair = UnityBrandColorScheme.grayscaleSessionGradient; + } + } + } + + public int order + { + get { return m_Order; } + set + { + m_Order = value; // Position of this button in relation to other tool buttons + + highlighted = false; + + this.RestartCoroutine(ref m_PositionCoroutine, AnimatePosition(m_Order)); + + if (m_Order == -1) + this.HideTooltip(this); + } + } + + /// + /// GradientPair should be set with new random gradientPair each time a new Tool is associated with this Button + /// This gradientPair is also used to highlight the input device when appropriate + /// + public GradientPair gradientPair + { + get { return m_GradientPair; } + set + { + m_GradientPair = value; + customTooltipHighlightColor = value; + } + } + + /// + /// Type, that if not null, denotes that preview-mode is enabled + /// This is enabled when highlighting a tool on the main menu + /// + public Type previewToolType + { + private get { return m_PreviewToolType; } + set + { + m_PreviewToolType = value; + + if (m_PreviewToolType != null) // Show the highlight if the preview type is valid; hide otherwise + { + var tempToolGo = ObjectUtils.AddComponent(m_PreviewToolType, gameObject); + var tempTool = tempToolGo as ITool; + if (tempTool != null) + { + var iMenuIcon = tempTool as IMenuIcon; + if (iMenuIcon != null) + previewIcon = iMenuIcon.icon; + + ObjectUtils.Destroy(tempToolGo); + } + + // Show the grayscale highlight when previewing a tool on this button + m_GradientButton.highlightGradientPair = UnityBrandColorScheme.saturatedSessionGradient; // UnityBrandColorScheme.grayscaleSessionGradient; + + if (!previewIcon) + m_GradientButton.SetContent(GetTypeAbbreviation(m_PreviewToolType)); + } + else + { + previewToolDescription = null; // Clear the preview tooltip + isActiveTool = isActiveTool; // Set active tool back to pre-preview state + icon = icon; // Gradient button will set its icon back to that representing the current tool, if one existed before previewing new tool type in this button + m_GradientButton.highlightGradientPair = gradientPair; + } + + m_GradientButton.highlighted = m_PreviewToolType != null; + } + } + + public string previewToolDescription + { + get { return m_PreviewToolDescription; } + set + { + if (value != null) + { + m_PreviewToolDescription = value; + this.ShowTooltip(this); + } + else + { + m_PreviewToolDescription = null; + tooltipVisible = false; + } + } + } + + public string tooltipText + { + get + { + if (!interactable && toolType == typeof(IMainMenu)) + return "Main Menu hidden"; + + return tooltip != null ? tooltip.tooltipText : (previewToolType == null ? m_TooltipText : previewToolDescription); + } + + private set { m_TooltipText = value; } + } + + public bool isActiveTool + { + private get { return m_ActiveTool; } + set + { + m_ActiveTool = value; + + m_GradientButton.normalGradientPair = m_ActiveTool ? gradientPair : UnityBrandColorScheme.darkGrayscaleSessionGradient; + m_GradientButton.highlightGradientPair = m_ActiveTool ? UnityBrandColorScheme.darkGrayscaleSessionGradient : gradientPair; + + m_GradientButton.highlighted = true; + m_GradientButton.highlighted = false; + } + } + + public bool highlighted + { + get { return m_Highlighted; } + set + { + if (m_Highlighted == value) + return; + + m_Highlighted = value; + m_GradientButton.highlighted = m_Highlighted; + + if (!m_Highlighted) + this.HideTooltip(this); + else + this.ShowTooltip(this); + + if (implementsSecondaryButton && (!isMainMenu || !isSelectionTool)) + { + // This show/hide functionality utilized by spatial scrolling + if (m_Highlighted) + this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, ShowSecondaryButton()); + else + this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, HideSecondaryButton()); + } + } + } + + public bool interactable + { + get { return m_GradientButton.interactable; } + set { m_GradientButton.interactable = value; } + } + + public bool secondaryButtonHighlighted { get { return m_CloseButton.highlighted; } } + + public bool tooltipVisible + { + set + { + if (!value) + this.HideTooltip(this); + } + } + + bool primaryButtonCollidersEnabled + { + set + { + foreach (var collider in m_PrimaryButtonColliders) + { + collider.enabled = value; + } + } + } + + bool secondaryButtonCollidersEnabled + { + set + { + foreach (var collider in m_CloseButtonColliders) + { + collider.enabled = value; + } + } + } + + public Sprite icon + { + private get { return m_Icon; } + set + { + m_PreviewIcon = null; // clear any cached preview icons + m_Icon = value; + + if (m_Icon) + m_GradientButton.SetContent(m_Icon); + else + m_GradientButton.SetContent(GetTypeAbbreviation(m_ToolType)); // Set backup tool abbreviation if no icon is set + } + } + + public Sprite previewIcon + { + get { return m_PreviewIcon; } + set + { + m_PreviewIcon = value; + m_GradientButton.SetContent(m_PreviewIcon); + } + } + + public bool moveToAlternatePosition + { + get { return m_MoveToAlternatePosition; } + set + { + if (m_MoveToAlternatePosition == value) + return; + + m_MoveToAlternatePosition = value; + + this.StopCoroutine(ref m_ActivatorMoveCoroutine); + + m_ActivatorMoveCoroutine = StartCoroutine(AnimateMoveActivatorButton(m_MoveToAlternatePosition)); + } + } + + bool visible { set { this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateVisibility(value)); } } + + public Vector3 primaryUIContentContainerLocalScale + { + get { return m_PrimaryUIContentContainer.localScale; } + set { m_PrimaryUIContentContainer.localScale = value; } + } + + public float iconHighlightedLocalZOffset { set { m_GradientButton.iconHighlightedLocalZOffset = value; } } + + public event Action hovered; + + void Awake() + { + m_OriginalLocalPosition = transform.localPosition; + m_OriginalLocalScale = transform.localScale; + m_FrameMaterial = MaterialUtils.GetMaterialClone(m_FrameRenderer); + var frameMaterialColor = m_FrameMaterial.color; + s_FrameOpaqueColor = new Color(frameMaterialColor.r, frameMaterialColor.g, frameMaterialColor.b, 1f); + m_FrameMaterial.SetColor(k_MaterialColorProperty, s_FrameOpaqueColor); + + m_IconMaterial = MaterialUtils.GetMaterialClone(m_ButtonIcon); + m_InsetMaterial = MaterialUtils.GetMaterialClone(m_InsetMeshRenderer); + m_OriginalIconContainerLocalScale = m_IconContainer.localScale; + } + + void Start() + { + if (m_ToolType == null) + m_GradientButton.gameObject.SetActive(false); + + tooltipAlignment = TextAlignment.Center; + + m_GradientButton.hoverEnter += OnBackgroundHoverEnter; // Display the foreground button actions + m_GradientButton.hoverExit += OnActionButtonHoverExit; + m_GradientButton.click += OnBackgroundButtonClick; + + m_FrameRenderer.SetBlendShapeWeight(1, 0f); + m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, 100f); + m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, 100f); + + m_CloseButton.hoverEnter += OnBackgroundHoverEnter; // Display the foreground button actions + m_CloseButton.hoverExit += OnActionButtonHoverExit; + m_CloseButton.click += OnSecondaryButtonClicked; + m_CloseButtonContainerCanvasGroup.alpha = 0f; + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_InsetMaterial); + ObjectUtils.Destroy(m_IconMaterial); + ObjectUtils.Destroy(m_FrameMaterial); + + this.StopCoroutine(ref m_PositionCoroutine); + this.StopCoroutine(ref m_VisibilityCoroutine); + this.StopCoroutine(ref m_HighlightCoroutine); + this.StopCoroutine(ref m_ActivatorMoveCoroutine); + this.StopCoroutine(ref m_HoverCheckCoroutine); + this.StopCoroutine(ref m_SecondaryButtonVisibilityCoroutine); + } + + void DestroyButton() + { + this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHideAndDestroy()); + } + + static string GetTypeAbbreviation(Type type) + { + // Create periodic table-style names for types + var abbreviation = new StringBuilder(); + foreach (var ch in type.Name.ToCharArray()) + { + if (char.IsUpper(ch)) + abbreviation.Append(abbreviation.Length > 0 ? char.ToLower(ch) : ch); + + if (abbreviation.Length >= 2) + break; + } + + return abbreviation.ToString(); + } + + void OnBackgroundHoverEnter() + { + if (hovered != null) // Raised in order to trigger the haptic in the Tools Menu + hovered(); + + if (isMainMenu) + { + m_GradientButton.highlighted = true; + return; + } + + if (implementsSecondaryButton) + this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, ShowSecondaryButton()); + + showAllButtons(this); + } + + void OnActionButtonHoverExit() + { + ActionButtonHoverExit(); + } + + void ActionButtonHoverExit() + { + if (m_PositionCoroutine != null) + return; + + if (isMainMenu) + { + m_GradientButton.highlighted = false; + return; + } + + if (!m_CloseButton.highlighted) + this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, HideSecondaryButton()); + + hoverExit(); + } + + void OnBackgroundButtonClick() + { + if (!interactable) + return; + + selectTool(toolType); + + if (!isMainMenu) + ActionButtonHoverExit(); + + m_GradientButton.UpdateMaterialColors(); + } + + void OnSecondaryButtonClicked() + { + if (!implementsSecondaryButton) + return; + this.RestartCoroutine(ref m_VisibilityCoroutine, AnimateHideAndDestroy()); + closeButton(); + ActionButtonHoverExit(); + } + + IEnumerator AnimateHideAndDestroy() + { + this.StopCoroutine(ref m_PositionCoroutine); + this.StopCoroutine(ref m_HighlightCoroutine); + this.StopCoroutine(ref m_ActivatorMoveCoroutine); + this.StopCoroutine(ref m_HoverCheckCoroutine); + this.StopCoroutine(ref m_SecondaryButtonVisibilityCoroutine); + + this.HideTooltip(this); + const int kDurationScalar = 3; + var duration = 0f; + var currentScale = transform.localScale; + var targetScale = Vector3.zero; + while (duration < 1) + { + var durationShaped = Mathf.Pow(MathUtilsExt.SmoothInOutLerpFloat(duration += Time.unscaledDeltaTime * kDurationScalar), 4); + transform.localScale = Vector3.Lerp(currentScale, targetScale, durationShaped); + yield return null; + } + + transform.localScale = targetScale; + m_VisibilityCoroutine = null; + ObjectUtils.Destroy(gameObject, 0.1f); + } + + IEnumerator AnimateVisibility(bool show = true) + { + const float kSpeedScalar = 8f; + var targetPosition = show ? (moveToAlternatePosition ? m_AlternateLocalPosition : m_OriginalLocalPosition) : Vector3.zero; + var targetScale = show ? (moveToAlternatePosition ? m_OriginalLocalScale : m_OriginalLocalScale * k_AlternateLocalScaleMultiplier) : Vector3.zero; + var currentPosition = transform.localPosition; + var currentIconScale = m_IconContainer.localScale; + var targetIconContainerScale = show ? m_OriginalIconContainerLocalScale : Vector3.zero; + var transitionAmount = 0f; + var currentScale = transform.localScale; + while (transitionAmount < 1) + { + var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(transitionAmount += Time.unscaledDeltaTime * kSpeedScalar); + m_IconContainer.localScale = Vector3.Lerp(currentIconScale, targetIconContainerScale, shapedAmount); + transform.localPosition = Vector3.Lerp(currentPosition, targetPosition, shapedAmount); + transform.localScale = Vector3.Lerp(currentScale, targetScale, shapedAmount); + yield return null; + } + + m_IconContainer.localScale = targetIconContainerScale; + transform.localScale = targetScale; + transform.localPosition = targetPosition; + m_VisibilityCoroutine = null; + } + + IEnumerator AnimatePosition(int orderPosition) + { + primaryButtonCollidersEnabled = false; + secondaryButtonCollidersEnabled = false; + + this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, HideSecondaryButton()); + + visible = orderPosition != -1; + + const float kTimeScalar = 6f; + const float kCenterLocationAmount = 0.5f; + const float kCircularRange = 360f; + const int kDurationShapeAmount = 3; + var rotationSpacing = kCircularRange / maxButtonCount; // dividend should be the count of tool buttons showing at this time + + // Center the MainMenu & Active tool buttons at the bottom of the RadialMenu + var phaseOffset = orderPosition > -1 ? rotationSpacing * kCenterLocationAmount - (visibleButtonCount(m_ToolType) * kCenterLocationAmount) * rotationSpacing : 0; + var targetRotation = orderPosition > -1 ? Quaternion.AngleAxis(phaseOffset + rotationSpacing * Mathf.Max(0f, orderPosition), Vector3.down) : Quaternion.identity; + + var duration = 0f; + var currentCanvasAlpha = m_IconContainerCanvasGroup.alpha; + var targetCanvasAlpha = orderPosition > -1 ? 1f : 0f; + var currentRotation = transform.localRotation; + var positionWait = 1f; + while (duration < 1) + { + duration += Time.unscaledDeltaTime * kTimeScalar * positionWait; + var durationShaped = Mathf.Pow(MathUtilsExt.SmoothInOutLerpFloat(duration), kDurationShapeAmount); + transform.localRotation = Quaternion.Lerp(currentRotation, targetRotation, durationShaped); + m_IconContainerCanvasGroup.alpha = Mathf.Lerp(currentCanvasAlpha, targetCanvasAlpha, durationShaped); + CorrectIconRotation(); + yield return null; + } + + transform.localRotation = targetRotation; + CorrectIconRotation(); + primaryButtonCollidersEnabled = orderPosition > -1; + secondaryButtonCollidersEnabled = orderPosition > -1; + m_PositionCoroutine = null; + + if (implementsSecondaryButton && orderPosition > -1 && m_GradientButton.highlighted) + this.RestartCoroutine(ref m_SecondaryButtonVisibilityCoroutine, ShowSecondaryButton()); + } + + IEnumerator AnimateMoveActivatorButton(bool moveToAlternatePosition = true) + { + const float kSpeedDecreaseScalar = 0.275f; + var amount = 0f; + var currentPosition = transform.localPosition; + var targetPosition = moveToAlternatePosition ? m_AlternateLocalPosition : m_OriginalLocalPosition; + var currentLocalScale = transform.localScale; + var targetLocalScale = moveToAlternatePosition ? m_OriginalLocalScale : m_OriginalLocalScale * k_AlternateLocalScaleMultiplier; + var speed = moveToAlternatePosition ? 5f : 4.5f; // Perform faster is returning to original position + speed += (order + 1) * kSpeedDecreaseScalar; + while (amount < 1f) + { + var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(amount += Time.unscaledDeltaTime * speed); + transform.localPosition = Vector3.Lerp(currentPosition, targetPosition, shapedAmount); + transform.localScale = Vector3.Lerp(currentLocalScale, targetLocalScale, shapedAmount); + yield return null; + } + + transform.localPosition = targetPosition; + transform.localScale = targetLocalScale; + m_ActivatorMoveCoroutine = null; + } + + void CorrectIconRotation() + { + const float kIconLookForwardOffset = 0.5f; + var iconLookDirection = m_IconContainer.transform.position + transform.forward * kIconLookForwardOffset; // set a position offset above the icon, regardless of the icon's rotation + m_IconContainer.LookAt(iconLookDirection); + m_IconContainer.localEulerAngles = new Vector3(0f, 0f, m_IconContainer.localEulerAngles.z); + } + + IEnumerator ShowSecondaryButton() + { + // Don't perform additional animated visuals if already in a fully revealed state + if (Mathf.Approximately(m_CloseButtonContainerCanvasGroup.alpha, 1f)) + { + m_SecondaryButtonVisibilityCoroutine = null; + yield break; + } + + const float kSecondaryButtonFrameVisibleBlendShapeWeight = 16f; // The extra amount of the frame to show on hover-before the full reveal of the secondary button + const float kTargetDuration = 1f; + const int kIntroDurationMultiplier = 10; + var currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); + var currentDuration = 0f; + while (currentDuration < kTargetDuration) + { + var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentDuration += Time.unscaledDeltaTime * kIntroDurationMultiplier); + m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, kSecondaryButtonFrameVisibleBlendShapeWeight, shapedAmount)); + yield return null; + } + + const float kDelayBeforeSecondaryButtonReveal = 0.25f; + currentDuration = 0f; // Reset current duration + while (currentDuration < kDelayBeforeSecondaryButtonReveal) + { + currentDuration += Time.unscaledDeltaTime; + yield return null; + } + + const float kFrameSecondaryButtonVisibleBlendShapeWeight = 61f; + const float kSecondaryButtonVisibleBlendShapeWeight = 46f; + const int kDurationMultiplier = 25; + + this.StopCoroutine(ref m_HighlightCoroutine); + + var currentSecondaryButtonVisibilityAmount = m_CloseInsetMeshRenderer.GetBlendShapeWeight(0); + var currentSecondaryCanvasGroupAlpha = m_CloseButtonContainerCanvasGroup.alpha; + currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); + currentDuration = 0f; + while (currentDuration < 1f) + { + var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(currentDuration += Time.unscaledDeltaTime * kDurationMultiplier); + m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, kFrameSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); + m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); + m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonVisibleBlendShapeWeight, shapedAmount)); + m_CloseButtonContainerCanvasGroup.alpha = Mathf.Lerp(currentSecondaryCanvasGroupAlpha, 1f, shapedAmount); + yield return null; + } + + m_SecondaryButtonVisibilityCoroutine = null; + } + + IEnumerator HideSecondaryButton() + { + const float kMaxDelayDuration = 0.125f; + var delayDuration = 0f; + while (delayDuration < kMaxDelayDuration) + { + delayDuration += Time.unscaledDeltaTime; + yield return null; + } + + const float kSecondaryButtonHiddenBlendShapeWeight = 100f; + const int kDurationMultiplier = 12; + var currentVisibilityAmount = m_FrameRenderer.GetBlendShapeWeight(1); + var currentSecondaryButtonVisibilityAmount = m_CloseInsetMeshRenderer.GetBlendShapeWeight(0); + var currentSecondaryCanvasGroupAlpha = m_CloseButtonContainerCanvasGroup.alpha; + var amount = 0f; + while (amount < 1f) + { + yield return null; + + if (m_CloseButton.highlighted) + { + m_SecondaryButtonVisibilityCoroutine = null; + yield break; + } + + this.StopCoroutine(ref m_HighlightCoroutine); + + var shapedAmount = MathUtilsExt.SmoothInOutLerpFloat(amount += Time.unscaledDeltaTime * kDurationMultiplier); + m_FrameRenderer.SetBlendShapeWeight(1, Mathf.Lerp(currentVisibilityAmount, 0f, shapedAmount)); + m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonHiddenBlendShapeWeight, shapedAmount)); + m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(currentSecondaryButtonVisibilityAmount, kSecondaryButtonHiddenBlendShapeWeight, shapedAmount)); + m_CloseButtonContainerCanvasGroup.alpha = Mathf.Lerp(currentSecondaryCanvasGroupAlpha, 0f, shapedAmount); + } + + m_SecondaryButtonVisibilityCoroutine = null; + } + } } + #endif From a061ea43a4601eb45742478e71bbe69cf01cbfb2 Mon Sep 17 00:00:00 2001 From: andrewm Date: Mon, 9 Oct 2017 16:52:38 -0700 Subject: [PATCH 106/457] Resharper->Edit->Reformat Code (Workspaces) --- Workspaces/Base/Workspace.cs | 606 +++--- Workspaces/Base/WorkspaceUI.cs | 1764 +++++++++-------- .../Common/Scripts/DraggableListItem.cs | 195 +- .../Common/Scripts/EditorWindowWorkspace.cs | 95 +- Workspaces/Common/Scripts/FilterButtonUI.cs | 169 +- Workspaces/Common/Scripts/FilterUI.cs | 538 +++-- .../Scripts/NestedListViewController.cs | 316 +-- Workspaces/Common/Scripts/WorkspaceButton.cs | 951 ++++----- .../Common/Scripts/WorkspaceHighlight.cs | 144 +- Workspaces/Common/Scripts/ZoomSliderUI.cs | 26 +- .../ConsoleWorkspace/ConsoleWorkspace.cs | 11 +- .../HierarchyWorkspace/HierarchyWorkspace.cs | 476 ++--- .../Scripts/HierarchyListItem.cs | 1016 +++++----- .../Scripts/HierarchyListViewController.cs | 844 ++++---- .../HierarchyWorkspace/Scripts/HierarchyUI.cs | 20 +- .../InspectorWorkspace/InspectorWorkspace.cs | 721 +++---- .../Scripts/InspectorListViewController.cs | 553 +++--- .../InspectorWorkspace/Scripts/InspectorUI.cs | 43 +- .../ListItems/InspectorArrayHeaderItem.cs | 33 +- .../Scripts/ListItems/InspectorBoolItem.cs | 71 +- .../Scripts/ListItems/InspectorBoundsItem.cs | 277 +-- .../Scripts/ListItems/InspectorColorItem.cs | 314 +-- .../ListItems/InspectorComponentItem.cs | 132 +- .../ListItems/InspectorDropDownItem.cs | 358 ++-- .../Scripts/ListItems/InspectorHeaderItem.cs | 339 ++-- .../Scripts/ListItems/InspectorListItem.cs | 712 ++++--- .../Scripts/ListItems/InspectorNumberItem.cs | 369 ++-- .../ListItems/InspectorObjectFieldItem.cs | 189 +- .../ListItems/InspectorPropertyItem.cs | 91 +- .../Scripts/ListItems/InspectorRectItem.cs | 342 ++-- .../Scripts/ListItems/InspectorStringItem.cs | 181 +- .../ListItems/InspectorUnimplementedItem.cs | 21 +- .../Scripts/ListItems/InspectorVectorItem.cs | 591 +++--- .../InspectorWorkspace/Scripts/LockUI.cs | 97 +- .../LockedObjectsWorkspace.cs | 123 +- .../MiniWorldWorkspace/MiniWorldWorkspace.cs | 826 ++++---- .../MiniWorldWorkspace/Scripts/MiniWorld.cs | 193 +- .../Scripts/MiniWorldRenderer.cs | 245 +-- .../MiniWorldWorkspace/Scripts/MiniWorldUI.cs | 31 +- .../MiniWorldWorkspace/Scripts/ResetUI.cs | 19 +- .../ProfilerWorkspace/ProfilerWorkspace.cs | 97 +- .../ProjectWorkspace/ProjectWorkspace.cs | 603 +++--- .../ProjectWorkspace/Scripts/AssetGridItem.cs | 1082 +++++----- .../Scripts/AssetGridViewController.cs | 501 ++--- .../Scripts/FolderListItem.cs | 263 +-- .../Scripts/FolderListViewController.cs | 353 ++-- .../ProjectWorkspace/Scripts/ProjectUI.cs | 43 +- 47 files changed, 8536 insertions(+), 8448 deletions(-) diff --git a/Workspaces/Base/Workspace.cs b/Workspaces/Base/Workspace.cs index 01712f4fb..65f4661c9 100644 --- a/Workspaces/Base/Workspace.cs +++ b/Workspaces/Base/Workspace.cs @@ -9,306 +9,310 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - abstract class Workspace : MonoBehaviour, IWorkspace, IInstantiateUI, IUsesStencilRef, IConnectInterfaces, - IUsesViewerScale, IControlHaptics, IRayToNode - { - const float k_MaxFrameSize = 100f; // Because BlendShapes cap at 100, our workspace maxes out at 100m wide - - public static readonly Vector3 DefaultBounds = new Vector3(0.7f, 0f, 0.4f); - public static readonly Vector3 MinBounds = new Vector3(0.677f, 0f, 0.1f); - - public const float FaceMargin = 0.025f; - public const float HighlightMargin = 0.002f; - - [SerializeField] - Vector3 m_MinBounds = MinBounds; - - [SerializeField] - GameObject m_BasePrefab; - - [SerializeField] - ActionMap m_ActionMap; - - [SerializeField] - HapticPulse m_ButtonClickPulse; - - [SerializeField] - HapticPulse m_ButtonHoverPulse; - - [SerializeField] - HapticPulse m_ResizePulse; - - [SerializeField] - HapticPulse m_MovePulse; - - Bounds m_ContentBounds; - BoxCollider m_OuterCollider; - - Coroutine m_VisibilityCoroutine; - Coroutine m_ResetSizeCoroutine; - - protected WorkspaceUI m_WorkspaceUI; - - protected Vector3? m_CustomStartingBounds; - - public Vector3 minBounds { get { return m_MinBounds; } set { m_MinBounds = value; } } - - public Bounds contentBounds - { - get { return m_ContentBounds; } - set - { - if (!value.Equals(contentBounds)) - { - m_ContentBounds = value; - var size = value.size; - size.x = Mathf.Clamp(Mathf.Max(size.x, minBounds.x), 0, k_MaxFrameSize); - size.y = Mathf.Max(size.y, minBounds.y); - size.z = Mathf.Clamp(Mathf.Max(size.z, minBounds.z), 0, k_MaxFrameSize); - m_ContentBounds.size = size; - - // Offset by half height - var center = m_ContentBounds.center; - center.y = size.y * 0.5f; - m_ContentBounds.center = center; - - UpdateBounds(); - OnBoundsChanged(); - } - } - } - - public Bounds outerBounds - { - get - { - const float outerBoundsCenterOffset = 0.09275f; //Amount to extend the bounds to include frame - return new Bounds(contentBounds.center + Vector3.down * outerBoundsCenterOffset * 0.5f, - new Vector3( - contentBounds.size.x, - contentBounds.size.y + outerBoundsCenterOffset, - contentBounds.size.z - )); - } - } - - public Bounds vacuumBounds { get { return outerBounds; } } - - public byte stencilRef { get; set; } - - /// - /// If true, allow the front face of the workspace to dynamically adjust its angle when rotated - /// - public bool dynamicFaceAdjustment { set { m_WorkspaceUI.dynamicFaceAdjustment = value; } } - - /// - /// If true, prevent the resizing of a workspace - /// - public bool preventResize { set { m_WorkspaceUI.preventResize = value; } } - - /// - /// (-1 to 1) ranged value that controls the separator mask's X-offset placement - /// A value of zero will leave the mask in the center of the workspace - /// - public float topPanelDividerOffset - { - set - { - m_WorkspaceUI.topPanelDividerOffset = value; - m_WorkspaceUI.bounds = contentBounds; - } - } - - public event Action destroyed; - - public Transform topPanel { get { return m_WorkspaceUI.topFaceContainer; } } - - public Transform frontPanel { get { return m_WorkspaceUI.frontPanel; } } - - public ActionMap actionMap { get { return m_ActionMap; } } - - public Transform leftRayOrigin { protected get; set; } - public Transform rightRayOrigin { protected get; set; } - - public virtual void Setup() - { - var baseObject = this.InstantiateUI(m_BasePrefab, transform, false); - - m_WorkspaceUI = baseObject.GetComponent(); - this.ConnectInterfaces(m_WorkspaceUI); - m_WorkspaceUI.closeClicked += OnCloseClicked; - m_WorkspaceUI.resetSizeClicked += OnResetClicked; - m_WorkspaceUI.buttonHovered += OnButtonHovered; - m_WorkspaceUI.hoveringFrame += OnHoveringFrame; - m_WorkspaceUI.moving += OnMoving; - m_WorkspaceUI.resizing += OnResizing; - - m_WorkspaceUI.leftRayOrigin = leftRayOrigin; - m_WorkspaceUI.rightRayOrigin = rightRayOrigin; - - m_WorkspaceUI.resize += bounds => - { - var size = contentBounds.size; - var boundsSize = bounds.size; - size.x = boundsSize.x; - size.z = boundsSize.z; - var content = contentBounds; - content.size = size; - contentBounds = content; - }; - - m_WorkspaceUI.sceneContainer.transform.localPosition = Vector3.zero; - - m_OuterCollider = gameObject.AddComponent(); - m_OuterCollider.isTrigger = true; - - var startingBounds = m_CustomStartingBounds ?? DefaultBounds; - //Do not set bounds directly, in case OnBoundsChanged requires Setup override to complete - m_ContentBounds = new Bounds(Vector3.up * startingBounds.y * 0.5f, startingBounds); // If custom bounds have been set, use them as the initial bounds - UpdateBounds(); - - this.StopCoroutine(ref m_VisibilityCoroutine); - - m_VisibilityCoroutine = StartCoroutine(AnimateShow()); - } - - public void Close() - { - this.StopCoroutine(ref m_VisibilityCoroutine); - m_VisibilityCoroutine = StartCoroutine(AnimateHide()); - } - - protected virtual void OnCloseClicked(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); - Close(); - } - - protected virtual void OnResetClicked(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); - - this.StopCoroutine(ref m_ResetSizeCoroutine); - m_ResetSizeCoroutine = StartCoroutine(AnimateResetSize()); - } - - protected void OnButtonHovered(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonHoverPulse); - } - - public void SetUIHighlightsVisible(bool value) - { - m_WorkspaceUI.highlightsVisible = value; - } - - void UpdateBounds() - { - m_WorkspaceUI.bounds = contentBounds; - - var outerBounds = this.outerBounds; - m_OuterCollider.size = outerBounds.size; - m_OuterCollider.center = outerBounds.center; - } - - protected virtual void OnDestroy() - { - destroyed(this); - } - - protected virtual void OnBoundsChanged() - { - } - - IEnumerator AnimateShow() - { - m_WorkspaceUI.highlightsVisible = true; - - var targetScale = Vector3.one; - var scale = Vector3.zero; - var smoothVelocity = Vector3.zero; - var currentDuration = 0f; - const float kTargetDuration = 0.75f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - transform.localScale = scale; - scale = MathUtilsExt.SmoothDamp(scale, targetScale, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - yield return null; - } - - transform.localScale = targetScale; - - m_WorkspaceUI.highlightsVisible = false; - m_VisibilityCoroutine = null; - } - - IEnumerator AnimateHide() - { - var targetScale = Vector3.zero; - var scale = transform.localScale; - var smoothVelocity = Vector3.zero; - var currentDuration = 0f; - const float kTargetDuration = 0.185f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - transform.localScale = scale; - scale = MathUtilsExt.SmoothDamp(scale, targetScale, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - yield return null; - } - transform.localScale = targetScale; - - m_WorkspaceUI.highlightsVisible = false; - m_VisibilityCoroutine = null; - ObjectUtils.Destroy(gameObject); - } - - IEnumerator AnimateResetSize() - { - var currentBoundsSize = contentBounds.size; - var currentBoundsCenter = contentBounds.center; - var targetBoundsSize = m_CustomStartingBounds ?? minBounds; - var targetBoundsCenter = Vector3.zero; - var smoothVelocitySize = Vector3.zero; - var smoothVelocityCenter = Vector3.zero; - var currentDuration = 0f; - const float kTargetDuration = 0.75f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - currentBoundsCenter = MathUtilsExt.SmoothDamp(currentBoundsCenter, targetBoundsCenter, ref smoothVelocityCenter, kTargetDuration, Mathf.Infinity, Time.deltaTime); - currentBoundsSize = MathUtilsExt.SmoothDamp(currentBoundsSize, targetBoundsSize, ref smoothVelocitySize, kTargetDuration, Mathf.Infinity, Time.deltaTime); - contentBounds = new Bounds(currentBoundsCenter, currentBoundsSize); - OnBoundsChanged(); - yield return null; - } - } - - public virtual void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) - { - m_WorkspaceUI.ProcessInput((WorkspaceInput)input, consumeControl); - } - - protected void OnButtonClicked(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); - } - - void OnMoving(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_MovePulse); - } - - void OnResizing(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ResizePulse); - } - - void OnHoveringFrame(Transform rayOrigin) - { - this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ResizePulse); - } - } + abstract class Workspace : MonoBehaviour, IWorkspace, IInstantiateUI, IUsesStencilRef, IConnectInterfaces, + IUsesViewerScale, IControlHaptics, IRayToNode + { + const float k_MaxFrameSize = 100f; // Because BlendShapes cap at 100, our workspace maxes out at 100m wide + + public static readonly Vector3 DefaultBounds = new Vector3(0.7f, 0f, 0.4f); + public static readonly Vector3 MinBounds = new Vector3(0.677f, 0f, 0.1f); + + public const float FaceMargin = 0.025f; + public const float HighlightMargin = 0.002f; + + [SerializeField] + Vector3 m_MinBounds = MinBounds; + + [SerializeField] + GameObject m_BasePrefab; + + [SerializeField] + ActionMap m_ActionMap; + + [SerializeField] + HapticPulse m_ButtonClickPulse; + + [SerializeField] + HapticPulse m_ButtonHoverPulse; + + [SerializeField] + HapticPulse m_ResizePulse; + + [SerializeField] + HapticPulse m_MovePulse; + + Bounds m_ContentBounds; + BoxCollider m_OuterCollider; + + Coroutine m_VisibilityCoroutine; + Coroutine m_ResetSizeCoroutine; + + protected WorkspaceUI m_WorkspaceUI; + + protected Vector3? m_CustomStartingBounds; + + public Vector3 minBounds + { + get { return m_MinBounds; } + set { m_MinBounds = value; } + } + + public Bounds contentBounds + { + get { return m_ContentBounds; } + set + { + if (!value.Equals(contentBounds)) + { + m_ContentBounds = value; + var size = value.size; + size.x = Mathf.Clamp(Mathf.Max(size.x, minBounds.x), 0, k_MaxFrameSize); + size.y = Mathf.Max(size.y, minBounds.y); + size.z = Mathf.Clamp(Mathf.Max(size.z, minBounds.z), 0, k_MaxFrameSize); + m_ContentBounds.size = size; + + // Offset by half height + var center = m_ContentBounds.center; + center.y = size.y * 0.5f; + m_ContentBounds.center = center; + + UpdateBounds(); + OnBoundsChanged(); + } + } + } + + public Bounds outerBounds + { + get + { + const float outerBoundsCenterOffset = 0.09275f; //Amount to extend the bounds to include frame + return new Bounds(contentBounds.center + Vector3.down * outerBoundsCenterOffset * 0.5f, + new Vector3( + contentBounds.size.x, + contentBounds.size.y + outerBoundsCenterOffset, + contentBounds.size.z + )); + } + } + + public Bounds vacuumBounds { get { return outerBounds; } } + + public byte stencilRef { get; set; } + + /// + /// If true, allow the front face of the workspace to dynamically adjust its angle when rotated + /// + public bool dynamicFaceAdjustment { set { m_WorkspaceUI.dynamicFaceAdjustment = value; } } + + /// + /// If true, prevent the resizing of a workspace + /// + public bool preventResize { set { m_WorkspaceUI.preventResize = value; } } + + /// + /// (-1 to 1) ranged value that controls the separator mask's X-offset placement + /// A value of zero will leave the mask in the center of the workspace + /// + public float topPanelDividerOffset + { + set + { + m_WorkspaceUI.topPanelDividerOffset = value; + m_WorkspaceUI.bounds = contentBounds; + } + } + + public event Action destroyed; + + public Transform topPanel { get { return m_WorkspaceUI.topFaceContainer; } } + + public Transform frontPanel { get { return m_WorkspaceUI.frontPanel; } } + + public ActionMap actionMap { get { return m_ActionMap; } } + + public Transform leftRayOrigin { protected get; set; } + public Transform rightRayOrigin { protected get; set; } + + public virtual void Setup() + { + var baseObject = this.InstantiateUI(m_BasePrefab, transform, false); + + m_WorkspaceUI = baseObject.GetComponent(); + this.ConnectInterfaces(m_WorkspaceUI); + m_WorkspaceUI.closeClicked += OnCloseClicked; + m_WorkspaceUI.resetSizeClicked += OnResetClicked; + m_WorkspaceUI.buttonHovered += OnButtonHovered; + m_WorkspaceUI.hoveringFrame += OnHoveringFrame; + m_WorkspaceUI.moving += OnMoving; + m_WorkspaceUI.resizing += OnResizing; + + m_WorkspaceUI.leftRayOrigin = leftRayOrigin; + m_WorkspaceUI.rightRayOrigin = rightRayOrigin; + + m_WorkspaceUI.resize += bounds => + { + var size = contentBounds.size; + var boundsSize = bounds.size; + size.x = boundsSize.x; + size.z = boundsSize.z; + var content = contentBounds; + content.size = size; + contentBounds = content; + }; + + m_WorkspaceUI.sceneContainer.transform.localPosition = Vector3.zero; + + m_OuterCollider = gameObject.AddComponent(); + m_OuterCollider.isTrigger = true; + + var startingBounds = m_CustomStartingBounds ?? DefaultBounds; + + //Do not set bounds directly, in case OnBoundsChanged requires Setup override to complete + m_ContentBounds = new Bounds(Vector3.up * startingBounds.y * 0.5f, startingBounds); // If custom bounds have been set, use them as the initial bounds + UpdateBounds(); + + this.StopCoroutine(ref m_VisibilityCoroutine); + + m_VisibilityCoroutine = StartCoroutine(AnimateShow()); + } + + public void Close() + { + this.StopCoroutine(ref m_VisibilityCoroutine); + m_VisibilityCoroutine = StartCoroutine(AnimateHide()); + } + + protected virtual void OnCloseClicked(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); + Close(); + } + + protected virtual void OnResetClicked(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); + + this.StopCoroutine(ref m_ResetSizeCoroutine); + m_ResetSizeCoroutine = StartCoroutine(AnimateResetSize()); + } + + protected void OnButtonHovered(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonHoverPulse); + } + + public void SetUIHighlightsVisible(bool value) + { + m_WorkspaceUI.highlightsVisible = value; + } + + void UpdateBounds() + { + m_WorkspaceUI.bounds = contentBounds; + + var outerBounds = this.outerBounds; + m_OuterCollider.size = outerBounds.size; + m_OuterCollider.center = outerBounds.center; + } + + protected virtual void OnDestroy() + { + destroyed(this); + } + + protected virtual void OnBoundsChanged() {} + + IEnumerator AnimateShow() + { + m_WorkspaceUI.highlightsVisible = true; + + var targetScale = Vector3.one; + var scale = Vector3.zero; + var smoothVelocity = Vector3.zero; + var currentDuration = 0f; + const float kTargetDuration = 0.75f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + transform.localScale = scale; + scale = MathUtilsExt.SmoothDamp(scale, targetScale, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + yield return null; + } + + transform.localScale = targetScale; + + m_WorkspaceUI.highlightsVisible = false; + m_VisibilityCoroutine = null; + } + + IEnumerator AnimateHide() + { + var targetScale = Vector3.zero; + var scale = transform.localScale; + var smoothVelocity = Vector3.zero; + var currentDuration = 0f; + const float kTargetDuration = 0.185f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + transform.localScale = scale; + scale = MathUtilsExt.SmoothDamp(scale, targetScale, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + yield return null; + } + transform.localScale = targetScale; + + m_WorkspaceUI.highlightsVisible = false; + m_VisibilityCoroutine = null; + ObjectUtils.Destroy(gameObject); + } + + IEnumerator AnimateResetSize() + { + var currentBoundsSize = contentBounds.size; + var currentBoundsCenter = contentBounds.center; + var targetBoundsSize = m_CustomStartingBounds ?? minBounds; + var targetBoundsCenter = Vector3.zero; + var smoothVelocitySize = Vector3.zero; + var smoothVelocityCenter = Vector3.zero; + var currentDuration = 0f; + const float kTargetDuration = 0.75f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + currentBoundsCenter = MathUtilsExt.SmoothDamp(currentBoundsCenter, targetBoundsCenter, ref smoothVelocityCenter, kTargetDuration, Mathf.Infinity, Time.deltaTime); + currentBoundsSize = MathUtilsExt.SmoothDamp(currentBoundsSize, targetBoundsSize, ref smoothVelocitySize, kTargetDuration, Mathf.Infinity, Time.deltaTime); + contentBounds = new Bounds(currentBoundsCenter, currentBoundsSize); + OnBoundsChanged(); + yield return null; + } + } + + public virtual void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl) + { + m_WorkspaceUI.ProcessInput((WorkspaceInput)input, consumeControl); + } + + protected void OnButtonClicked(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ButtonClickPulse); + } + + void OnMoving(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_MovePulse); + } + + void OnResizing(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ResizePulse); + } + + void OnHoveringFrame(Transform rayOrigin) + { + this.Pulse(this.RequestNodeFromRayOrigin(rayOrigin), m_ResizePulse); + } + } } + #endif diff --git a/Workspaces/Base/WorkspaceUI.cs b/Workspaces/Base/WorkspaceUI.cs index 4969b086f..27a8dce31 100644 --- a/Workspaces/Base/WorkspaceUI.cs +++ b/Workspaces/Base/WorkspaceUI.cs @@ -12,914 +12,928 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class WorkspaceUI : MonoBehaviour, IUsesStencilRef, IUsesViewerScale, IGetPointerLength, IUsesNode - { - const int k_AngledFaceBlendShapeIndex = 2; - const int k_ThinFrameBlendShapeIndex = 3; - const string k_MaterialStencilRef = "_StencilRef"; + sealed class WorkspaceUI : MonoBehaviour, IUsesStencilRef, IUsesViewerScale, IGetPointerLength, IUsesNode + { + const int k_AngledFaceBlendShapeIndex = 2; + const int k_ThinFrameBlendShapeIndex = 3; + const string k_MaterialStencilRef = "_StencilRef"; - const float k_ResizeIconCrossfadeDuration = 0.1f; - const float k_ResizeIconSmoothFollow = 10f; + const float k_ResizeIconCrossfadeDuration = 0.1f; + const float k_ResizeIconSmoothFollow = 10f; - const float k_FrontFrameZOffset = 0.088f; + const float k_FrontFrameZOffset = 0.088f; - static readonly Vector3 k_BaseFrontPanelRotation = Vector3.zero; - static readonly Vector3 k_MaxFrontPanelRotation = new Vector3(90f, 0f, 0f); + static readonly Vector3 k_BaseFrontPanelRotation = Vector3.zero; + static readonly Vector3 k_MaxFrontPanelRotation = new Vector3(90f, 0f, 0f); - [SerializeField] - Transform m_SceneContainer; + [SerializeField] + Transform m_SceneContainer; - [SerializeField] - RectTransform m_FrontPanel; + [SerializeField] + RectTransform m_FrontPanel; - [SerializeField] - BaseHandle[] m_Handles; + [SerializeField] + BaseHandle[] m_Handles; - [SerializeField] - Image[] m_ResizeIcons; + [SerializeField] + Image[] m_ResizeIcons; - [SerializeField] - Transform m_FrontLeftHandle; + [SerializeField] + Transform m_FrontLeftHandle; - [SerializeField] - Transform m_FrontLeftCornerHandle; + [SerializeField] + Transform m_FrontLeftCornerHandle; - [SerializeField] - Transform m_FrontRightHandle; + [SerializeField] + Transform m_FrontRightHandle; - [SerializeField] - Transform m_FrontRightCornerHandle; + [SerializeField] + Transform m_FrontRightCornerHandle; - [SerializeField] - Transform m_BottomFrontHandle; + [SerializeField] + Transform m_BottomFrontHandle; - [SerializeField] - Transform m_TopFaceContainer; + [SerializeField] + Transform m_TopFaceContainer; - [SerializeField] - WorkspaceHighlight m_TopHighlight; + [SerializeField] + WorkspaceHighlight m_TopHighlight; - [SerializeField] - SkinnedMeshRenderer m_Frame; + [SerializeField] + SkinnedMeshRenderer m_Frame; - [SerializeField] - Transform m_FrameFrontFaceTransform; + [SerializeField] + Transform m_FrameFrontFaceTransform; - [SerializeField] - Transform m_FrameFrontFaceHighlightTransform; + [SerializeField] + Transform m_FrameFrontFaceHighlightTransform; - [SerializeField] - Transform m_TopPanelDividerTransform; + [SerializeField] + Transform m_TopPanelDividerTransform; - [SerializeField] - RectTransform m_UIContentContainer; + [SerializeField] + RectTransform m_UIContentContainer; - [SerializeField] - Image m_FrontResizeIcon; + [SerializeField] + Image m_FrontResizeIcon; - [SerializeField] - Image m_RightResizeIcon; + [SerializeField] + Image m_RightResizeIcon; - [SerializeField] - Image m_LeftResizeIcon; + [SerializeField] + Image m_LeftResizeIcon; - [SerializeField] - Image m_BackResizeIcon; + [SerializeField] + Image m_BackResizeIcon; - [SerializeField] - Image m_FrontLeftResizeIcon; + [SerializeField] + Image m_FrontLeftResizeIcon; - [SerializeField] - Image m_FrontRightResizeIcon; + [SerializeField] + Image m_FrontRightResizeIcon; - [SerializeField] - Image m_BackLeftResizeIcon; + [SerializeField] + Image m_BackLeftResizeIcon; - [SerializeField] - Image m_BackRightResizeIcon; + [SerializeField] + Image m_BackRightResizeIcon; - [SerializeField] - Transform m_TopHighlightContainer; + [SerializeField] + Transform m_TopHighlightContainer; - [SerializeField] - RectTransform m_HandleRectTransform; + [SerializeField] + RectTransform m_HandleRectTransform; - [SerializeField] - RectTransform m_ResizeIconRectTransform; + [SerializeField] + RectTransform m_ResizeIconRectTransform; - [SerializeField] - WorkspaceHighlight m_FrontHighlight; + [SerializeField] + WorkspaceHighlight m_FrontHighlight; - [SerializeField] - float m_FrameHandleSize = 0.03f; + [SerializeField] + float m_FrameHandleSize = 0.03f; - [SerializeField] - float m_FrontFrameHandleSize = 0.01f; + [SerializeField] + float m_FrontFrameHandleSize = 0.01f; - [SerializeField] - float m_FrameHeight = 0.09275f; - - [SerializeField] - float m_ResizeHandleMargin = 0.01f; - - [SerializeField] - float m_ResizeCornerSize = 0.05f; - - [SerializeField] - bool m_DynamicFaceAdjustment = true; - - [SerializeField] - WorkspaceButton m_CloseButton; - - [SerializeField] - WorkspaceButton m_ResizeButton; - - BoxCollider m_FrameCollider; - Bounds m_Bounds; - float? m_TopPanelDividerOffset; - - // Cached for optimization - float m_PreviousXRotation; - Coroutine m_FrameThicknessCoroutine; - Coroutine m_TopFaceVisibleCoroutine; - Material m_TopFaceMaterial; - Material m_FrontFaceMaterial; - - float m_LerpAmount; - float m_FrontZOffset; - - DragState m_DragState; - - [Flags] - enum ResizeDirection - { - Front = 1, - Back = 2, - Left = 4, - Right = 8 - } - - class DragState - { - public Transform rayOrigin { get; private set; } - bool m_Resizing; - Vector3 m_PositionOffset; - Quaternion m_RotationOffset; - WorkspaceUI m_WorkspaceUI; - Vector3 m_DragStart; - Vector3 m_PositionStart; - Vector3 m_BoundsSizeStart; - ResizeDirection m_Direction; - - public DragState(WorkspaceUI workspaceUI, Transform rayOrigin, bool resizing) - { - m_WorkspaceUI = workspaceUI; - m_Resizing = resizing; - this.rayOrigin = rayOrigin; - - if (resizing) - { - var pointerPosition = m_WorkspaceUI.GetPointerPositionForRayOrigin(rayOrigin); - m_DragStart = pointerPosition; - m_PositionStart = workspaceUI.transform.parent.position; - m_BoundsSizeStart = workspaceUI.bounds.size; - var localPosition = m_WorkspaceUI.transform.InverseTransformPoint(pointerPosition); - m_Direction = m_WorkspaceUI.GetResizeDirectionForLocalPosition(localPosition); - } - else - { - MathUtilsExt.GetTransformOffset(rayOrigin, m_WorkspaceUI.transform.parent, out m_PositionOffset, out m_RotationOffset); - } - } - - public void OnDragging() - { - if (m_Resizing) - { - var viewerScale = m_WorkspaceUI.GetViewerScale(); - var pointerPosition = m_WorkspaceUI.GetPointerPositionForRayOrigin(rayOrigin); - var dragVector = (pointerPosition - m_DragStart) / viewerScale; - var bounds = m_WorkspaceUI.bounds; - var transform = m_WorkspaceUI.transform; - - var positionOffsetForward = Vector3.Dot(dragVector, transform.forward) * 0.5f; - var positionOffsetRight = Vector3.Dot(dragVector, transform.right) * 0.5f; - - switch (m_Direction) - { - default: - bounds.size = m_BoundsSizeStart + Vector3.back * Vector3.Dot(dragVector, transform.forward); - positionOffsetRight = 0; - break; - case ResizeDirection.Back: - bounds.size = m_BoundsSizeStart + Vector3.forward * Vector3.Dot(dragVector, transform.forward); - positionOffsetRight = 0; - break; - case ResizeDirection.Left: - bounds.size = m_BoundsSizeStart + Vector3.left * Vector3.Dot(dragVector, transform.right); - positionOffsetForward = 0; - break; - case ResizeDirection.Right: - bounds.size = m_BoundsSizeStart + Vector3.right * Vector3.Dot(dragVector, transform.right); - positionOffsetForward = 0; - break; - case ResizeDirection.Front | ResizeDirection.Left: - bounds.size = m_BoundsSizeStart + Vector3.left * Vector3.Dot(dragVector, transform.right) - + Vector3.back * Vector3.Dot(dragVector, transform.forward); - break; - case ResizeDirection.Front | ResizeDirection.Right: - bounds.size = m_BoundsSizeStart + Vector3.right * Vector3.Dot(dragVector, transform.right) - + Vector3.back * Vector3.Dot(dragVector, transform.forward); - break; - case ResizeDirection.Back | ResizeDirection.Left: - bounds.size = m_BoundsSizeStart + Vector3.left * Vector3.Dot(dragVector, transform.right) - + Vector3.forward * Vector3.Dot(dragVector, transform.forward); - break; - case ResizeDirection.Back | ResizeDirection.Right: - bounds.size = m_BoundsSizeStart + Vector3.right * Vector3.Dot(dragVector, transform.right) - + Vector3.forward * Vector3.Dot(dragVector, transform.forward); - break; - } - - if (m_WorkspaceUI.resize != null) - m_WorkspaceUI.resize(bounds); - - var currentExtents = m_WorkspaceUI.bounds.extents; - var extents = bounds.extents; - var absRight = Mathf.Abs(positionOffsetRight); - var absForward = Mathf.Abs(positionOffsetForward); - var positionOffset = transform.right * (absRight - (currentExtents.x - extents.x)) * Mathf.Sign(positionOffsetRight) - + transform.forward * (absForward - (currentExtents.z - extents.z)) * Mathf.Sign(positionOffsetForward); - - m_WorkspaceUI.transform.parent.position = m_PositionStart + positionOffset * viewerScale; - m_WorkspaceUI.OnResizing(rayOrigin); - } - else - { - MathUtilsExt.SetTransformOffset(rayOrigin, m_WorkspaceUI.transform.parent, m_PositionOffset, m_RotationOffset); - m_WorkspaceUI.OnMoving(rayOrigin); - } - } - } - - readonly List m_HovereringRayOrigins = new List(); - readonly Dictionary m_LastResizeIcons = new Dictionary(); - - public event Action buttonHovered; - public event Action closeClicked; - public event Action resetSizeClicked; - public event Action resizing; - public event Action moving; - public event Action hoveringFrame; - - public bool highlightsVisible - { - set - { - if (m_TopHighlight.visible == value && m_FrontHighlight.visible == value) - return; - - m_TopHighlight.visible = value; - m_FrontHighlight.visible = value; - - if (value) - IncreaseFrameThickness(); - else - ResetFrameThickness(); - } - } - - public bool frontHighlightVisible - { - set - { - if (m_FrontHighlight.visible == value) - return; - - m_FrontHighlight.visible = value; - - if (value) - IncreaseFrameThickness(); - else - ResetFrameThickness(); - } - } - - public bool amplifyTopHighlight - { - set - { - this.StopCoroutine(ref m_TopFaceVisibleCoroutine); - m_TopFaceVisibleCoroutine = value ? StartCoroutine(HideTopFace()) : StartCoroutine(ShowTopFace()); - } - } - - /// - /// (-1 to 1) ranged value that controls the separator mask's X-offset placement - /// A value of zero will leave the mask in the center of the workspace - /// - public float topPanelDividerOffset - { - set - { - m_TopPanelDividerOffset = value; - m_TopPanelDividerTransform.gameObject.SetActive(true); - } - } - - public Transform topFaceContainer { get { return m_TopFaceContainer; } set { m_TopFaceContainer = value; } } - public Transform sceneContainer { get { return m_SceneContainer; } } - public RectTransform frontPanel { get { return m_FrontPanel; } } - public WorkspaceHighlight topHighlight { get { return m_TopHighlight; } } - public bool dynamicFaceAdjustment { get { return m_DynamicFaceAdjustment; } set { m_DynamicFaceAdjustment = value; } } - - public bool preventResize - { - set - { - foreach (var handle in m_Handles) - { - handle.gameObject.SetActive(!value); - } - } - } - - public byte stencilRef { get; set; } - - public Transform leftRayOrigin { private get; set; } - public Transform rightRayOrigin { private get; set; } - public Node? node { get; set; } - - public event Action resize; - - public Bounds bounds - { - get { return m_Bounds; } - set - { - m_Bounds = value; - - m_Bounds.center = Vector3.down * m_FrameHeight * 0.5f; - - var extents = m_Bounds.extents; - var size = m_Bounds.size; - size.y = m_FrameHeight + m_FrameHandleSize; - m_Bounds.size = size; - - const float kWidthMultiplier = 0.96154f; - const float kDepthMultiplier = 0.99383f; - const float kWidthOffset = -0.156f; - const float kDepthOffset = -0.0318f; - const float kDepthCompensation = -0.008f; - - var width = size.x; - var depth = size.z; - var faceWidth = width - Workspace.FaceMargin; - var faceDepth = depth - Workspace.FaceMargin; - - m_Frame.SetBlendShapeWeight(0, width * kWidthMultiplier + kWidthOffset); - m_Frame.SetBlendShapeWeight(1, depth * kDepthMultiplier + kDepthOffset + kDepthCompensation * m_LerpAmount); - - // Resize content container - m_UIContentContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, faceWidth); - var localPosition = m_UIContentContainer.localPosition; - localPosition.z = -extents.z; - m_UIContentContainer.localPosition = localPosition; - - // Resize front panel - m_FrameFrontFaceTransform.localScale = new Vector3(faceWidth, 1f, 1f); - const float kFrontFaceHighlightMargin = 0.0008f; - m_FrameFrontFaceHighlightTransform.localScale = new Vector3(faceWidth + kFrontFaceHighlightMargin, 1f, 1f); - - // Position the separator mask if enabled - if (m_TopPanelDividerOffset != null) - { - m_TopPanelDividerTransform.localPosition = new Vector3(faceWidth * (m_TopPanelDividerOffset.Value - 0.5f), 0f, 0f); - m_TopPanelDividerTransform.localScale = new Vector3(1f, 1f, faceDepth + Workspace.HighlightMargin); - } - - // Scale the Top Face and the Top Face Highlight - const float kHighlightMargin = 0.0005f; - m_TopHighlightContainer.localScale = new Vector3(faceWidth + kHighlightMargin, 1f, faceDepth + kHighlightMargin); - m_TopFaceContainer.localScale = new Vector3(faceWidth, 1f, faceDepth); - - var frameBounds = adjustedBounds; - m_FrameCollider.size = frameBounds.size; - m_FrameCollider.center = frameBounds.center; - - AdjustHandlesAndIcons(); - } - } - - public Bounds adjustedBounds - { - get - { - var adjustedBounds = bounds; - adjustedBounds.size += Vector3.forward * m_FrontZOffset; - adjustedBounds.center += Vector3.back * m_FrontZOffset * 0.5f; - return adjustedBounds; - } - } - - void Awake() - { - foreach (var icon in m_ResizeIcons) - { - icon.CrossFadeAlpha(0f, 0f, true); - } - - m_Frame.SetBlendShapeWeight(k_ThinFrameBlendShapeIndex, 50f); // Set default frame thickness to be in middle for a thinner initial frame - - if (m_TopPanelDividerOffset == null) - m_TopPanelDividerTransform.gameObject.SetActive(false); - - foreach (var handle in m_Handles) - { - handle.hoverStarted += OnHandleHoverStarted; - handle.hoverEnded += OnHandleHoverEnded; - } - - m_CloseButton.clicked += OnCloseClicked; - m_CloseButton.hovered += OnButtonHovered; - m_ResizeButton.clicked += OnResetSizeClicked; - m_ResizeButton.hovered += OnButtonHovered; - - m_FrameCollider = transform.parent.gameObject.AddComponent(); - } - - IEnumerator Start() - { - const string kShaderBlur = "_Blur"; - const string kShaderAlpha = "_Alpha"; - const string kShaderVerticalOffset = "_VerticalOffset"; - const float kTargetDuration = 1.25f; - - m_TopFaceMaterial = MaterialUtils.GetMaterialClone(m_TopFaceContainer.GetComponentInChildren()); - m_TopFaceMaterial.SetFloat("_Alpha", 1f); - m_TopFaceMaterial.SetInt(k_MaterialStencilRef, stencilRef); - - m_FrontFaceMaterial = MaterialUtils.GetMaterialClone(m_FrameFrontFaceTransform.GetComponentInChildren()); - m_FrontFaceMaterial.SetInt(k_MaterialStencilRef, stencilRef); - - var originalBlurAmount = m_TopFaceMaterial.GetFloat("_Blur"); - var currentBlurAmount = 10f; // also the maximum blur amount - var currentDuration = 0f; - var currentVelocity = 0f; - - m_TopFaceMaterial.SetFloat(kShaderBlur, currentBlurAmount); - m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 1f); // increase the blur sample offset to amplify the effect - m_TopFaceMaterial.SetFloat(kShaderAlpha, 0.5f); // set partially transparent - - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - currentBlurAmount = MathUtilsExt.SmoothDamp(currentBlurAmount, originalBlurAmount, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_TopFaceMaterial.SetFloat(kShaderBlur, currentBlurAmount); - - var percentageComplete = currentDuration / kTargetDuration; - m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 1 - percentageComplete); // lerp back towards an offset of zero - m_TopFaceMaterial.SetFloat(kShaderAlpha, percentageComplete * 0.5f + 0.5f); // lerp towards fully opaque from 50% transparent - - yield return null; - } - - m_TopFaceMaterial.SetFloat(kShaderBlur, originalBlurAmount); - m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 0f); - m_TopFaceMaterial.SetFloat(kShaderAlpha, 1f); - - yield return null; - } - - void AdjustHandlesAndIcons() - { - var size = m_Bounds.size; - m_HandleRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); - m_HandleRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.z); - - var halfFrontZOffset = m_FrontZOffset * 0.5f; - var localPosition = m_ResizeIconRectTransform.localPosition; - localPosition.z = -halfFrontZOffset; - m_ResizeIconRectTransform.localPosition = localPosition; - m_ResizeIconRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); - m_ResizeIconRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.z + m_FrontZOffset); - - var extents = m_Bounds.extents; - var halfWidth = extents.x; - var halfDepth = extents.z; - var yOffset = m_FrameHeight * (0.5f - m_LerpAmount); - localPosition = m_BottomFrontHandle.localPosition; - localPosition.z = yOffset; - localPosition.y = -halfDepth - m_FrontZOffset; - m_BottomFrontHandle.localPosition = localPosition; - - yOffset = (1 - m_LerpAmount) * m_FrameHeight; - var angle = Mathf.Atan(m_FrontZOffset / yOffset) * Mathf.Rad2Deg; - - m_FrontLeftHandle.localPosition = new Vector3(-halfWidth, -yOffset * 0.5f, -halfDepth - halfFrontZOffset); - m_FrontLeftHandle.localRotation = Quaternion.AngleAxis(angle, Vector3.right); - m_FrontLeftHandle.localScale = new Vector3(m_FrontFrameHandleSize, m_FrameHeight, m_FrontFrameHandleSize); - localPosition = m_FrontLeftHandle.localPosition; - localPosition.x = halfWidth; - - m_FrontRightHandle.localPosition = localPosition; - m_FrontRightHandle.localRotation = m_FrontLeftHandle.localRotation; - m_FrontRightHandle.localScale = m_FrontLeftHandle.localScale; - - var zOffset = m_FrontZOffset - (k_FrontFrameZOffset + m_FrontFrameHandleSize) * 0.5f; - var zScale = m_FrameHeight * m_LerpAmount; - var yPosition = -m_FrontFrameHandleSize * 0.5f - m_FrameHeight + zScale * 0.5f; - m_FrontLeftCornerHandle.localPosition = new Vector3(-halfWidth, yPosition, -halfDepth - zOffset - m_FrontFrameHandleSize); - m_FrontLeftCornerHandle.localScale = new Vector3(m_FrontFrameHandleSize, k_FrontFrameZOffset, zScale); - - m_FrontRightCornerHandle = m_FrontRightCornerHandle.transform; - localPosition = m_FrontLeftCornerHandle.localPosition; - localPosition.x = halfWidth; - m_FrontRightCornerHandle.localPosition = localPosition; - m_FrontRightCornerHandle.localRotation = m_FrontLeftCornerHandle.localRotation; - m_FrontRightCornerHandle.localScale = m_FrontLeftCornerHandle.localScale; - } - - void OnHandleHoverStarted(BaseHandle handle, HandleEventData eventData) - { - var rayOrigin = eventData.rayOrigin; - if (m_HovereringRayOrigins.Count == 0 && m_DragState == null) - IncreaseFrameThickness(rayOrigin); - - m_HovereringRayOrigins.Add(rayOrigin); - } - - ResizeDirection GetResizeDirectionForLocalPosition(Vector3 localPosition) - { - var direction = localPosition.z > 0 ? ResizeDirection.Back : ResizeDirection.Front; - var xDirection = localPosition.x > 0 ? ResizeDirection.Right : ResizeDirection.Left; - - var zDistance = bounds.extents.z - Mathf.Abs(localPosition.z); - if (localPosition.z < 0) - zDistance += m_FrontZOffset; - - var cornerZ = zDistance < m_ResizeCornerSize; - var cornerX = bounds.extents.x - Mathf.Abs(localPosition.x) < m_ResizeCornerSize; - - if (cornerZ && cornerX) - direction |= xDirection; - else if (cornerX) - direction = xDirection; - - return direction; - } - - Image GetResizeIconForDirection(ResizeDirection direction) - { - switch (direction) - { - default: - return m_FrontResizeIcon; - case ResizeDirection.Back: - return m_BackResizeIcon; - case ResizeDirection.Left: - return m_LeftResizeIcon; - case ResizeDirection.Right: - return m_RightResizeIcon; - case ResizeDirection.Front | ResizeDirection.Left: - return m_FrontLeftResizeIcon; - case ResizeDirection.Front | ResizeDirection.Right: - return m_FrontRightResizeIcon; - case ResizeDirection.Back | ResizeDirection.Left: - return m_BackLeftResizeIcon; - case ResizeDirection.Back | ResizeDirection.Right: - return m_BackRightResizeIcon; - } - } - - void OnHandleHoverEnded(BaseHandle handle, HandleEventData eventData) - { - var rayOrigin = eventData.rayOrigin; - if (m_HovereringRayOrigins.Remove(rayOrigin)) - { - Image lastResizeIcon; - if (m_LastResizeIcons.TryGetValue(rayOrigin, out lastResizeIcon)) - { - lastResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true); - m_LastResizeIcons.Remove(rayOrigin); - } - } - - if (m_HovereringRayOrigins.Count == 0) - ResetFrameThickness(); - } - - void Update() - { - if (!m_DynamicFaceAdjustment) - return; - - var currentXRotation = transform.rotation.eulerAngles.x; - if (Mathf.Approximately(currentXRotation, m_PreviousXRotation)) - return; // Exit if no x rotation change occurred for this frame - - m_PreviousXRotation = currentXRotation; - - // a second additional value added to the y offset of the front panel when it is in mid-reveal, - // lerped in at the middle of the rotation/reveal, and lerped out at the beginning & end of the rotation/reveal - const int kRevealCompensationBlendShapeIndex = 5; - const float kLerpPadding = 1.2f; // pad lerp values increasingly as it increases, displaying the "front face reveal" sooner - const float kCorrectiveRevealShapeMultiplier = 1.85f; - var angledAmount = Mathf.Clamp(Mathf.DeltaAngle(currentXRotation, 0f), 0f, 90f); - var midRevealCorrectiveShapeAmount = Mathf.PingPong(angledAmount * kCorrectiveRevealShapeMultiplier, 90); - // add lerp padding to reach and maintain the target value sooner - m_LerpAmount = angledAmount / 90f; - var paddedLerp = m_LerpAmount * kLerpPadding; - - // offset front panel according to workspace rotation angle - const float kAdditionalFrontPanelLerpPadding = 1.1f; - const float kFrontPanelYOffset = 0.03f; - const float kFrontPanelZStartOffset = 0.0084f; - const float kFrontPanelZEndOffset = -0.05f; - m_FrontPanel.localRotation = Quaternion.Euler(Vector3.Lerp(k_BaseFrontPanelRotation, k_MaxFrontPanelRotation, paddedLerp * kAdditionalFrontPanelLerpPadding)); - m_FrontPanel.localPosition = Vector3.Lerp(Vector3.forward * kFrontPanelZStartOffset, new Vector3(0, kFrontPanelYOffset, kFrontPanelZEndOffset), paddedLerp); - - m_FrontZOffset = (k_FrontFrameZOffset + m_FrontFrameHandleSize) * Mathf.Clamp01(paddedLerp * kAdditionalFrontPanelLerpPadding); - var frameBounds = adjustedBounds; - m_FrameCollider.size = frameBounds.size; - m_FrameCollider.center = frameBounds.center; - - AdjustHandlesAndIcons(); - - // change blendshapes according to workspace rotation angle - m_Frame.SetBlendShapeWeight(k_AngledFaceBlendShapeIndex, angledAmount * kLerpPadding); - m_Frame.SetBlendShapeWeight(kRevealCompensationBlendShapeIndex, midRevealCorrectiveShapeAmount); - } - - public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeControl) - { - var moveResizeLeft = input.moveResizeLeft; - var moveResizeRight = input.moveResizeRight; - - if (m_DragState != null) - { - var rayOrigin = m_DragState.rayOrigin; - - if ((rayOrigin == leftRayOrigin && moveResizeLeft.wasJustReleased) - || (rayOrigin == rightRayOrigin && moveResizeRight.wasJustReleased)) - { - m_DragState = null; - m_LastResizeIcons.Clear(); - - foreach (var smoothMotion in GetComponentsInChildren()) - { - smoothMotion.enabled = true; - } - - if (m_HovereringRayOrigins.Contains(rayOrigin)) - { - var localPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rayOrigin)); - var direction = GetResizeDirectionForLocalPosition(localPosition); - GetResizeIconForDirection(direction); - } - - highlightsVisible = false; - } - else - { - m_DragState.OnDragging(); - } - - return; - } - - Transform dragRayOrigin = null; - Image dragResizeIcon = null; - var resizing = false; - - for (int i = 0; i < m_HovereringRayOrigins.Count; i++) - { - var rayOrigin = m_HovereringRayOrigins[i]; - Image lastResizeIcon; - m_LastResizeIcons.TryGetValue(rayOrigin, out lastResizeIcon); - if (rayOrigin == leftRayOrigin && moveResizeLeft.wasJustPressed) - { - consumeControl(moveResizeLeft); - dragRayOrigin = rayOrigin; - dragResizeIcon = lastResizeIcon; - resizing = true; - } - - if (rayOrigin == rightRayOrigin && moveResizeRight.wasJustPressed) - { - consumeControl(moveResizeRight); - dragRayOrigin = rayOrigin; - dragResizeIcon = lastResizeIcon; - resizing = true; - } - - const float kVisibleOpacity = 0.75f; - var localPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rayOrigin)); - var direction = GetResizeDirectionForLocalPosition(localPosition); - var resizeIcon = GetResizeIconForDirection(direction); - - if (lastResizeIcon != null) - { - if (resizeIcon != lastResizeIcon) - { - resizeIcon.CrossFadeAlpha(kVisibleOpacity, k_ResizeIconCrossfadeDuration, true); - lastResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true); - } - } - else - { - resizeIcon.CrossFadeAlpha(kVisibleOpacity, k_ResizeIconCrossfadeDuration, true); - } - - m_LastResizeIcons[rayOrigin] = resizeIcon; - - var iconTransform = resizeIcon.transform; - var iconPosition = iconTransform.localPosition; - var smoothFollow = lastResizeIcon == null ? 1 : k_ResizeIconSmoothFollow * Time.deltaTime; - var localDirection = localPosition - transform.InverseTransformPoint(rayOrigin.position); - switch (direction) - { - case ResizeDirection.Front: - case ResizeDirection.Back: - var iconPositionX = iconPosition.x; - var positionOffsetX = Mathf.Sign(localDirection.x) * m_ResizeHandleMargin; - var tergetPositionX = localPosition.x + positionOffsetX; - if (Mathf.Abs(tergetPositionX) > bounds.extents.x - m_ResizeCornerSize) - tergetPositionX = localPosition.x - positionOffsetX; - - iconPosition.x = Mathf.Lerp(iconPositionX, tergetPositionX, smoothFollow); - break; - case ResizeDirection.Left: - case ResizeDirection.Right: - var iconPositionY = iconPosition.y; - var positionOffsetY = Mathf.Sign(localDirection.z) * m_ResizeHandleMargin; - var tergetPositionY = localPosition.z + positionOffsetY; - if (Mathf.Abs(tergetPositionY) > bounds.extents.z - m_ResizeCornerSize) - tergetPositionY = localPosition.z - positionOffsetY; - - iconPosition.y = Mathf.Lerp(iconPositionY, tergetPositionY, smoothFollow); - break; - } - iconTransform.localPosition = iconPosition; - } - - var adjustedBounds = this.adjustedBounds; - if (!dragRayOrigin) - { - var leftPosition = transform.InverseTransformPoint(leftRayOrigin.position); - var leftPointerPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(leftRayOrigin)); - if (moveResizeLeft.wasJustPressed && (adjustedBounds.Contains(leftPosition) || adjustedBounds.Contains(leftPointerPosition))) - { - dragRayOrigin = leftRayOrigin; - m_LastResizeIcons.TryGetValue(dragRayOrigin, out dragResizeIcon); - consumeControl(moveResizeLeft); - } - - var rightPosition = transform.InverseTransformPoint(rightRayOrigin.position); - var rightPointerPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rightRayOrigin)); - if (moveResizeRight.wasJustPressed && (adjustedBounds.Contains(rightPosition) || adjustedBounds.Contains(rightPointerPosition))) - { - dragRayOrigin = rightRayOrigin; - m_LastResizeIcons.TryGetValue(dragRayOrigin, out dragResizeIcon); - consumeControl(moveResizeRight); - } - } - - if (dragRayOrigin) - { - m_DragState = new DragState(this, dragRayOrigin, resizing); - if (dragResizeIcon != null) - dragResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true); - - ResetFrameThickness(); - - foreach (var smoothMotion in GetComponentsInChildren()) - { - smoothMotion.enabled = false; - } - - highlightsVisible = true; - } - } - - Vector3 GetPointerPositionForRayOrigin(Transform rayOrigin) - { - return rayOrigin.position + rayOrigin.forward * this.GetPointerLength(rayOrigin); - } - - void OnDestroy() - { - ObjectUtils.Destroy(m_TopFaceMaterial); - ObjectUtils.Destroy(m_FrontFaceMaterial); - - m_CloseButton.clicked -= OnCloseClicked; - m_CloseButton.hovered -= OnButtonHovered; - m_ResizeButton.clicked -= OnResetSizeClicked; - m_ResizeButton.hovered -= OnButtonHovered; - } - - void OnCloseClicked(Transform rayOrigin) - { - if (closeClicked != null) - closeClicked(rayOrigin); - } - - void OnResetSizeClicked(Transform rayOrigin) - { - if (resetSizeClicked != null) - resetSizeClicked(rayOrigin); - } - - void OnButtonHovered(Transform rayOrigin) - { - if (buttonHovered != null) - buttonHovered(rayOrigin); - } - - void IncreaseFrameThickness(Transform rayOrigin = null) - { - this.StopCoroutine(ref m_FrameThicknessCoroutine); - const float kTargetBlendAmount = 0f; - m_FrameThicknessCoroutine = StartCoroutine(ChangeFrameThickness(kTargetBlendAmount, rayOrigin)); - } - - void ResetFrameThickness() - { - this.StopCoroutine(ref m_FrameThicknessCoroutine); - const float kTargetBlendAmount = 50f; - m_FrameThicknessCoroutine = StartCoroutine(ChangeFrameThickness(kTargetBlendAmount, null)); - } - - IEnumerator ChangeFrameThickness(float targetBlendAmount, Transform rayOrigin) - { - const float kTargetDuration = 0.25f; - var currentDuration = 0f; - var currentBlendAmount = m_Frame.GetBlendShapeWeight(k_ThinFrameBlendShapeIndex); - var currentVelocity = 0f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - currentBlendAmount = MathUtilsExt.SmoothDamp(currentBlendAmount, targetBlendAmount, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_Frame.SetBlendShapeWeight(k_ThinFrameBlendShapeIndex, currentBlendAmount); - yield return null; - } - - // If hovering the frame, and not moving, perform haptic feedback - if (hoveringFrame != null && m_HovereringRayOrigins.Count > 0 && m_DragState == null && Mathf.Approximately(targetBlendAmount, 0f)) - hoveringFrame(rayOrigin); - - m_FrameThicknessCoroutine = null; - } - - IEnumerator ShowTopFace() - { - const string kMaterialHighlightAlphaProperty = "_Alpha"; - const float kTargetAlpha = 1f; - const float kTargetDuration = 0.35f; - var currentDuration = 0f; - var currentAlpha = m_TopFaceMaterial.GetFloat(kMaterialHighlightAlphaProperty); - var currentVelocity = 0f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_TopFaceMaterial.SetFloat(kMaterialHighlightAlphaProperty, currentAlpha); - yield return null; - } - - m_TopFaceVisibleCoroutine = null; - } - - IEnumerator HideTopFace() - { - const string kMaterialHighlightAlphaProperty = "_Alpha"; - const float kTargetAlpha = 0f; - const float kTargetDuration = 0.2f; - var currentDuration = 0f; - var currentAlpha = m_TopFaceMaterial.GetFloat(kMaterialHighlightAlphaProperty); - var currentVelocity = 0f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_TopFaceMaterial.SetFloat(kMaterialHighlightAlphaProperty, currentAlpha); - yield return null; - } - - m_TopFaceVisibleCoroutine = null; - } - - void OnMoving(Transform rayOrigin) - { - if (moving != null) - moving(rayOrigin); - } - - void OnResizing(Transform rayOrigin) - { - if (resizing != null) - resizing(rayOrigin); - } - } + [SerializeField] + float m_FrameHeight = 0.09275f; + + [SerializeField] + float m_ResizeHandleMargin = 0.01f; + + [SerializeField] + float m_ResizeCornerSize = 0.05f; + + [SerializeField] + bool m_DynamicFaceAdjustment = true; + + [SerializeField] + WorkspaceButton m_CloseButton; + + [SerializeField] + WorkspaceButton m_ResizeButton; + + BoxCollider m_FrameCollider; + Bounds m_Bounds; + float? m_TopPanelDividerOffset; + + // Cached for optimization + float m_PreviousXRotation; + Coroutine m_FrameThicknessCoroutine; + Coroutine m_TopFaceVisibleCoroutine; + Material m_TopFaceMaterial; + Material m_FrontFaceMaterial; + + float m_LerpAmount; + float m_FrontZOffset; + + DragState m_DragState; + + [Flags] + enum ResizeDirection + { + Front = 1, + Back = 2, + Left = 4, + Right = 8 + } + + class DragState + { + public Transform rayOrigin { get; private set; } + bool m_Resizing; + Vector3 m_PositionOffset; + Quaternion m_RotationOffset; + WorkspaceUI m_WorkspaceUI; + Vector3 m_DragStart; + Vector3 m_PositionStart; + Vector3 m_BoundsSizeStart; + ResizeDirection m_Direction; + + public DragState(WorkspaceUI workspaceUI, Transform rayOrigin, bool resizing) + { + m_WorkspaceUI = workspaceUI; + m_Resizing = resizing; + this.rayOrigin = rayOrigin; + + if (resizing) + { + var pointerPosition = m_WorkspaceUI.GetPointerPositionForRayOrigin(rayOrigin); + m_DragStart = pointerPosition; + m_PositionStart = workspaceUI.transform.parent.position; + m_BoundsSizeStart = workspaceUI.bounds.size; + var localPosition = m_WorkspaceUI.transform.InverseTransformPoint(pointerPosition); + m_Direction = m_WorkspaceUI.GetResizeDirectionForLocalPosition(localPosition); + } + else + { + MathUtilsExt.GetTransformOffset(rayOrigin, m_WorkspaceUI.transform.parent, out m_PositionOffset, out m_RotationOffset); + } + } + + public void OnDragging() + { + if (m_Resizing) + { + var viewerScale = m_WorkspaceUI.GetViewerScale(); + var pointerPosition = m_WorkspaceUI.GetPointerPositionForRayOrigin(rayOrigin); + var dragVector = (pointerPosition - m_DragStart) / viewerScale; + var bounds = m_WorkspaceUI.bounds; + var transform = m_WorkspaceUI.transform; + + var positionOffsetForward = Vector3.Dot(dragVector, transform.forward) * 0.5f; + var positionOffsetRight = Vector3.Dot(dragVector, transform.right) * 0.5f; + + switch (m_Direction) + { + default: + bounds.size = m_BoundsSizeStart + Vector3.back * Vector3.Dot(dragVector, transform.forward); + positionOffsetRight = 0; + break; + case ResizeDirection.Back: + bounds.size = m_BoundsSizeStart + Vector3.forward * Vector3.Dot(dragVector, transform.forward); + positionOffsetRight = 0; + break; + case ResizeDirection.Left: + bounds.size = m_BoundsSizeStart + Vector3.left * Vector3.Dot(dragVector, transform.right); + positionOffsetForward = 0; + break; + case ResizeDirection.Right: + bounds.size = m_BoundsSizeStart + Vector3.right * Vector3.Dot(dragVector, transform.right); + positionOffsetForward = 0; + break; + case ResizeDirection.Front | ResizeDirection.Left: + bounds.size = m_BoundsSizeStart + Vector3.left * Vector3.Dot(dragVector, transform.right) + + Vector3.back * Vector3.Dot(dragVector, transform.forward); + break; + case ResizeDirection.Front | ResizeDirection.Right: + bounds.size = m_BoundsSizeStart + Vector3.right * Vector3.Dot(dragVector, transform.right) + + Vector3.back * Vector3.Dot(dragVector, transform.forward); + break; + case ResizeDirection.Back | ResizeDirection.Left: + bounds.size = m_BoundsSizeStart + Vector3.left * Vector3.Dot(dragVector, transform.right) + + Vector3.forward * Vector3.Dot(dragVector, transform.forward); + break; + case ResizeDirection.Back | ResizeDirection.Right: + bounds.size = m_BoundsSizeStart + Vector3.right * Vector3.Dot(dragVector, transform.right) + + Vector3.forward * Vector3.Dot(dragVector, transform.forward); + break; + } + + if (m_WorkspaceUI.resize != null) + m_WorkspaceUI.resize(bounds); + + var currentExtents = m_WorkspaceUI.bounds.extents; + var extents = bounds.extents; + var absRight = Mathf.Abs(positionOffsetRight); + var absForward = Mathf.Abs(positionOffsetForward); + var positionOffset = transform.right * (absRight - (currentExtents.x - extents.x)) * Mathf.Sign(positionOffsetRight) + + transform.forward * (absForward - (currentExtents.z - extents.z)) * Mathf.Sign(positionOffsetForward); + + m_WorkspaceUI.transform.parent.position = m_PositionStart + positionOffset * viewerScale; + m_WorkspaceUI.OnResizing(rayOrigin); + } + else + { + MathUtilsExt.SetTransformOffset(rayOrigin, m_WorkspaceUI.transform.parent, m_PositionOffset, m_RotationOffset); + m_WorkspaceUI.OnMoving(rayOrigin); + } + } + } + + readonly List m_HovereringRayOrigins = new List(); + readonly Dictionary m_LastResizeIcons = new Dictionary(); + + public event Action buttonHovered; + public event Action closeClicked; + public event Action resetSizeClicked; + public event Action resizing; + public event Action moving; + public event Action hoveringFrame; + + public bool highlightsVisible + { + set + { + if (m_TopHighlight.visible == value && m_FrontHighlight.visible == value) + return; + + m_TopHighlight.visible = value; + m_FrontHighlight.visible = value; + + if (value) + IncreaseFrameThickness(); + else + ResetFrameThickness(); + } + } + + public bool frontHighlightVisible + { + set + { + if (m_FrontHighlight.visible == value) + return; + + m_FrontHighlight.visible = value; + + if (value) + IncreaseFrameThickness(); + else + ResetFrameThickness(); + } + } + + public bool amplifyTopHighlight + { + set + { + this.StopCoroutine(ref m_TopFaceVisibleCoroutine); + m_TopFaceVisibleCoroutine = value ? StartCoroutine(HideTopFace()) : StartCoroutine(ShowTopFace()); + } + } + + /// + /// (-1 to 1) ranged value that controls the separator mask's X-offset placement + /// A value of zero will leave the mask in the center of the workspace + /// + public float topPanelDividerOffset + { + set + { + m_TopPanelDividerOffset = value; + m_TopPanelDividerTransform.gameObject.SetActive(true); + } + } + + public Transform topFaceContainer + { + get { return m_TopFaceContainer; } + set { m_TopFaceContainer = value; } + } + + public Transform sceneContainer { get { return m_SceneContainer; } } + + public RectTransform frontPanel { get { return m_FrontPanel; } } + + public WorkspaceHighlight topHighlight { get { return m_TopHighlight; } } + + public bool dynamicFaceAdjustment + { + get { return m_DynamicFaceAdjustment; } + set { m_DynamicFaceAdjustment = value; } + } + + public bool preventResize + { + set + { + foreach (var handle in m_Handles) + { + handle.gameObject.SetActive(!value); + } + } + } + + public byte stencilRef { get; set; } + + public Transform leftRayOrigin { private get; set; } + public Transform rightRayOrigin { private get; set; } + public Node? node { get; set; } + + public event Action resize; + + public Bounds bounds + { + get { return m_Bounds; } + set + { + m_Bounds = value; + + m_Bounds.center = Vector3.down * m_FrameHeight * 0.5f; + + var extents = m_Bounds.extents; + var size = m_Bounds.size; + size.y = m_FrameHeight + m_FrameHandleSize; + m_Bounds.size = size; + + const float kWidthMultiplier = 0.96154f; + const float kDepthMultiplier = 0.99383f; + const float kWidthOffset = -0.156f; + const float kDepthOffset = -0.0318f; + const float kDepthCompensation = -0.008f; + + var width = size.x; + var depth = size.z; + var faceWidth = width - Workspace.FaceMargin; + var faceDepth = depth - Workspace.FaceMargin; + + m_Frame.SetBlendShapeWeight(0, width * kWidthMultiplier + kWidthOffset); + m_Frame.SetBlendShapeWeight(1, depth * kDepthMultiplier + kDepthOffset + kDepthCompensation * m_LerpAmount); + + // Resize content container + m_UIContentContainer.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, faceWidth); + var localPosition = m_UIContentContainer.localPosition; + localPosition.z = -extents.z; + m_UIContentContainer.localPosition = localPosition; + + // Resize front panel + m_FrameFrontFaceTransform.localScale = new Vector3(faceWidth, 1f, 1f); + const float kFrontFaceHighlightMargin = 0.0008f; + m_FrameFrontFaceHighlightTransform.localScale = new Vector3(faceWidth + kFrontFaceHighlightMargin, 1f, 1f); + + // Position the separator mask if enabled + if (m_TopPanelDividerOffset != null) + { + m_TopPanelDividerTransform.localPosition = new Vector3(faceWidth * (m_TopPanelDividerOffset.Value - 0.5f), 0f, 0f); + m_TopPanelDividerTransform.localScale = new Vector3(1f, 1f, faceDepth + Workspace.HighlightMargin); + } + + // Scale the Top Face and the Top Face Highlight + const float kHighlightMargin = 0.0005f; + m_TopHighlightContainer.localScale = new Vector3(faceWidth + kHighlightMargin, 1f, faceDepth + kHighlightMargin); + m_TopFaceContainer.localScale = new Vector3(faceWidth, 1f, faceDepth); + + var frameBounds = adjustedBounds; + m_FrameCollider.size = frameBounds.size; + m_FrameCollider.center = frameBounds.center; + + AdjustHandlesAndIcons(); + } + } + + public Bounds adjustedBounds + { + get + { + var adjustedBounds = bounds; + adjustedBounds.size += Vector3.forward * m_FrontZOffset; + adjustedBounds.center += Vector3.back * m_FrontZOffset * 0.5f; + return adjustedBounds; + } + } + + void Awake() + { + foreach (var icon in m_ResizeIcons) + { + icon.CrossFadeAlpha(0f, 0f, true); + } + + m_Frame.SetBlendShapeWeight(k_ThinFrameBlendShapeIndex, 50f); // Set default frame thickness to be in middle for a thinner initial frame + + if (m_TopPanelDividerOffset == null) + m_TopPanelDividerTransform.gameObject.SetActive(false); + + foreach (var handle in m_Handles) + { + handle.hoverStarted += OnHandleHoverStarted; + handle.hoverEnded += OnHandleHoverEnded; + } + + m_CloseButton.clicked += OnCloseClicked; + m_CloseButton.hovered += OnButtonHovered; + m_ResizeButton.clicked += OnResetSizeClicked; + m_ResizeButton.hovered += OnButtonHovered; + + m_FrameCollider = transform.parent.gameObject.AddComponent(); + } + + IEnumerator Start() + { + const string kShaderBlur = "_Blur"; + const string kShaderAlpha = "_Alpha"; + const string kShaderVerticalOffset = "_VerticalOffset"; + const float kTargetDuration = 1.25f; + + m_TopFaceMaterial = MaterialUtils.GetMaterialClone(m_TopFaceContainer.GetComponentInChildren()); + m_TopFaceMaterial.SetFloat("_Alpha", 1f); + m_TopFaceMaterial.SetInt(k_MaterialStencilRef, stencilRef); + + m_FrontFaceMaterial = MaterialUtils.GetMaterialClone(m_FrameFrontFaceTransform.GetComponentInChildren()); + m_FrontFaceMaterial.SetInt(k_MaterialStencilRef, stencilRef); + + var originalBlurAmount = m_TopFaceMaterial.GetFloat("_Blur"); + var currentBlurAmount = 10f; // also the maximum blur amount + var currentDuration = 0f; + var currentVelocity = 0f; + + m_TopFaceMaterial.SetFloat(kShaderBlur, currentBlurAmount); + m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 1f); // increase the blur sample offset to amplify the effect + m_TopFaceMaterial.SetFloat(kShaderAlpha, 0.5f); // set partially transparent + + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + currentBlurAmount = MathUtilsExt.SmoothDamp(currentBlurAmount, originalBlurAmount, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_TopFaceMaterial.SetFloat(kShaderBlur, currentBlurAmount); + + var percentageComplete = currentDuration / kTargetDuration; + m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 1 - percentageComplete); // lerp back towards an offset of zero + m_TopFaceMaterial.SetFloat(kShaderAlpha, percentageComplete * 0.5f + 0.5f); // lerp towards fully opaque from 50% transparent + + yield return null; + } + + m_TopFaceMaterial.SetFloat(kShaderBlur, originalBlurAmount); + m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 0f); + m_TopFaceMaterial.SetFloat(kShaderAlpha, 1f); + + yield return null; + } + + void AdjustHandlesAndIcons() + { + var size = m_Bounds.size; + m_HandleRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); + m_HandleRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.z); + + var halfFrontZOffset = m_FrontZOffset * 0.5f; + var localPosition = m_ResizeIconRectTransform.localPosition; + localPosition.z = -halfFrontZOffset; + m_ResizeIconRectTransform.localPosition = localPosition; + m_ResizeIconRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); + m_ResizeIconRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.z + m_FrontZOffset); + + var extents = m_Bounds.extents; + var halfWidth = extents.x; + var halfDepth = extents.z; + var yOffset = m_FrameHeight * (0.5f - m_LerpAmount); + localPosition = m_BottomFrontHandle.localPosition; + localPosition.z = yOffset; + localPosition.y = -halfDepth - m_FrontZOffset; + m_BottomFrontHandle.localPosition = localPosition; + + yOffset = (1 - m_LerpAmount) * m_FrameHeight; + var angle = Mathf.Atan(m_FrontZOffset / yOffset) * Mathf.Rad2Deg; + + m_FrontLeftHandle.localPosition = new Vector3(-halfWidth, -yOffset * 0.5f, -halfDepth - halfFrontZOffset); + m_FrontLeftHandle.localRotation = Quaternion.AngleAxis(angle, Vector3.right); + m_FrontLeftHandle.localScale = new Vector3(m_FrontFrameHandleSize, m_FrameHeight, m_FrontFrameHandleSize); + localPosition = m_FrontLeftHandle.localPosition; + localPosition.x = halfWidth; + + m_FrontRightHandle.localPosition = localPosition; + m_FrontRightHandle.localRotation = m_FrontLeftHandle.localRotation; + m_FrontRightHandle.localScale = m_FrontLeftHandle.localScale; + + var zOffset = m_FrontZOffset - (k_FrontFrameZOffset + m_FrontFrameHandleSize) * 0.5f; + var zScale = m_FrameHeight * m_LerpAmount; + var yPosition = -m_FrontFrameHandleSize * 0.5f - m_FrameHeight + zScale * 0.5f; + m_FrontLeftCornerHandle.localPosition = new Vector3(-halfWidth, yPosition, -halfDepth - zOffset - m_FrontFrameHandleSize); + m_FrontLeftCornerHandle.localScale = new Vector3(m_FrontFrameHandleSize, k_FrontFrameZOffset, zScale); + + m_FrontRightCornerHandle = m_FrontRightCornerHandle.transform; + localPosition = m_FrontLeftCornerHandle.localPosition; + localPosition.x = halfWidth; + m_FrontRightCornerHandle.localPosition = localPosition; + m_FrontRightCornerHandle.localRotation = m_FrontLeftCornerHandle.localRotation; + m_FrontRightCornerHandle.localScale = m_FrontLeftCornerHandle.localScale; + } + + void OnHandleHoverStarted(BaseHandle handle, HandleEventData eventData) + { + var rayOrigin = eventData.rayOrigin; + if (m_HovereringRayOrigins.Count == 0 && m_DragState == null) + IncreaseFrameThickness(rayOrigin); + + m_HovereringRayOrigins.Add(rayOrigin); + } + + ResizeDirection GetResizeDirectionForLocalPosition(Vector3 localPosition) + { + var direction = localPosition.z > 0 ? ResizeDirection.Back : ResizeDirection.Front; + var xDirection = localPosition.x > 0 ? ResizeDirection.Right : ResizeDirection.Left; + + var zDistance = bounds.extents.z - Mathf.Abs(localPosition.z); + if (localPosition.z < 0) + zDistance += m_FrontZOffset; + + var cornerZ = zDistance < m_ResizeCornerSize; + var cornerX = bounds.extents.x - Mathf.Abs(localPosition.x) < m_ResizeCornerSize; + + if (cornerZ && cornerX) + direction |= xDirection; + else if (cornerX) + direction = xDirection; + + return direction; + } + + Image GetResizeIconForDirection(ResizeDirection direction) + { + switch (direction) + { + default: + return m_FrontResizeIcon; + case ResizeDirection.Back: + return m_BackResizeIcon; + case ResizeDirection.Left: + return m_LeftResizeIcon; + case ResizeDirection.Right: + return m_RightResizeIcon; + case ResizeDirection.Front | ResizeDirection.Left: + return m_FrontLeftResizeIcon; + case ResizeDirection.Front | ResizeDirection.Right: + return m_FrontRightResizeIcon; + case ResizeDirection.Back | ResizeDirection.Left: + return m_BackLeftResizeIcon; + case ResizeDirection.Back | ResizeDirection.Right: + return m_BackRightResizeIcon; + } + } + + void OnHandleHoverEnded(BaseHandle handle, HandleEventData eventData) + { + var rayOrigin = eventData.rayOrigin; + if (m_HovereringRayOrigins.Remove(rayOrigin)) + { + Image lastResizeIcon; + if (m_LastResizeIcons.TryGetValue(rayOrigin, out lastResizeIcon)) + { + lastResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true); + m_LastResizeIcons.Remove(rayOrigin); + } + } + + if (m_HovereringRayOrigins.Count == 0) + ResetFrameThickness(); + } + + void Update() + { + if (!m_DynamicFaceAdjustment) + return; + + var currentXRotation = transform.rotation.eulerAngles.x; + if (Mathf.Approximately(currentXRotation, m_PreviousXRotation)) + return; // Exit if no x rotation change occurred for this frame + + m_PreviousXRotation = currentXRotation; + + // a second additional value added to the y offset of the front panel when it is in mid-reveal, + // lerped in at the middle of the rotation/reveal, and lerped out at the beginning & end of the rotation/reveal + const int kRevealCompensationBlendShapeIndex = 5; + const float kLerpPadding = 1.2f; // pad lerp values increasingly as it increases, displaying the "front face reveal" sooner + const float kCorrectiveRevealShapeMultiplier = 1.85f; + var angledAmount = Mathf.Clamp(Mathf.DeltaAngle(currentXRotation, 0f), 0f, 90f); + var midRevealCorrectiveShapeAmount = Mathf.PingPong(angledAmount * kCorrectiveRevealShapeMultiplier, 90); + + // add lerp padding to reach and maintain the target value sooner + m_LerpAmount = angledAmount / 90f; + var paddedLerp = m_LerpAmount * kLerpPadding; + + // offset front panel according to workspace rotation angle + const float kAdditionalFrontPanelLerpPadding = 1.1f; + const float kFrontPanelYOffset = 0.03f; + const float kFrontPanelZStartOffset = 0.0084f; + const float kFrontPanelZEndOffset = -0.05f; + m_FrontPanel.localRotation = Quaternion.Euler(Vector3.Lerp(k_BaseFrontPanelRotation, k_MaxFrontPanelRotation, paddedLerp * kAdditionalFrontPanelLerpPadding)); + m_FrontPanel.localPosition = Vector3.Lerp(Vector3.forward * kFrontPanelZStartOffset, new Vector3(0, kFrontPanelYOffset, kFrontPanelZEndOffset), paddedLerp); + + m_FrontZOffset = (k_FrontFrameZOffset + m_FrontFrameHandleSize) * Mathf.Clamp01(paddedLerp * kAdditionalFrontPanelLerpPadding); + var frameBounds = adjustedBounds; + m_FrameCollider.size = frameBounds.size; + m_FrameCollider.center = frameBounds.center; + + AdjustHandlesAndIcons(); + + // change blendshapes according to workspace rotation angle + m_Frame.SetBlendShapeWeight(k_AngledFaceBlendShapeIndex, angledAmount * kLerpPadding); + m_Frame.SetBlendShapeWeight(kRevealCompensationBlendShapeIndex, midRevealCorrectiveShapeAmount); + } + + public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeControl) + { + var moveResizeLeft = input.moveResizeLeft; + var moveResizeRight = input.moveResizeRight; + + if (m_DragState != null) + { + var rayOrigin = m_DragState.rayOrigin; + + if ((rayOrigin == leftRayOrigin && moveResizeLeft.wasJustReleased) + || (rayOrigin == rightRayOrigin && moveResizeRight.wasJustReleased)) + { + m_DragState = null; + m_LastResizeIcons.Clear(); + + foreach (var smoothMotion in GetComponentsInChildren()) + { + smoothMotion.enabled = true; + } + + if (m_HovereringRayOrigins.Contains(rayOrigin)) + { + var localPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rayOrigin)); + var direction = GetResizeDirectionForLocalPosition(localPosition); + GetResizeIconForDirection(direction); + } + + highlightsVisible = false; + } + else + { + m_DragState.OnDragging(); + } + + return; + } + + Transform dragRayOrigin = null; + Image dragResizeIcon = null; + var resizing = false; + + for (int i = 0; i < m_HovereringRayOrigins.Count; i++) + { + var rayOrigin = m_HovereringRayOrigins[i]; + Image lastResizeIcon; + m_LastResizeIcons.TryGetValue(rayOrigin, out lastResizeIcon); + if (rayOrigin == leftRayOrigin && moveResizeLeft.wasJustPressed) + { + consumeControl(moveResizeLeft); + dragRayOrigin = rayOrigin; + dragResizeIcon = lastResizeIcon; + resizing = true; + } + + if (rayOrigin == rightRayOrigin && moveResizeRight.wasJustPressed) + { + consumeControl(moveResizeRight); + dragRayOrigin = rayOrigin; + dragResizeIcon = lastResizeIcon; + resizing = true; + } + + const float kVisibleOpacity = 0.75f; + var localPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rayOrigin)); + var direction = GetResizeDirectionForLocalPosition(localPosition); + var resizeIcon = GetResizeIconForDirection(direction); + + if (lastResizeIcon != null) + { + if (resizeIcon != lastResizeIcon) + { + resizeIcon.CrossFadeAlpha(kVisibleOpacity, k_ResizeIconCrossfadeDuration, true); + lastResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true); + } + } + else + { + resizeIcon.CrossFadeAlpha(kVisibleOpacity, k_ResizeIconCrossfadeDuration, true); + } + + m_LastResizeIcons[rayOrigin] = resizeIcon; + + var iconTransform = resizeIcon.transform; + var iconPosition = iconTransform.localPosition; + var smoothFollow = lastResizeIcon == null ? 1 : k_ResizeIconSmoothFollow * Time.deltaTime; + var localDirection = localPosition - transform.InverseTransformPoint(rayOrigin.position); + switch (direction) + { + case ResizeDirection.Front: + case ResizeDirection.Back: + var iconPositionX = iconPosition.x; + var positionOffsetX = Mathf.Sign(localDirection.x) * m_ResizeHandleMargin; + var tergetPositionX = localPosition.x + positionOffsetX; + if (Mathf.Abs(tergetPositionX) > bounds.extents.x - m_ResizeCornerSize) + tergetPositionX = localPosition.x - positionOffsetX; + + iconPosition.x = Mathf.Lerp(iconPositionX, tergetPositionX, smoothFollow); + break; + case ResizeDirection.Left: + case ResizeDirection.Right: + var iconPositionY = iconPosition.y; + var positionOffsetY = Mathf.Sign(localDirection.z) * m_ResizeHandleMargin; + var tergetPositionY = localPosition.z + positionOffsetY; + if (Mathf.Abs(tergetPositionY) > bounds.extents.z - m_ResizeCornerSize) + tergetPositionY = localPosition.z - positionOffsetY; + + iconPosition.y = Mathf.Lerp(iconPositionY, tergetPositionY, smoothFollow); + break; + } + iconTransform.localPosition = iconPosition; + } + + var adjustedBounds = this.adjustedBounds; + if (!dragRayOrigin) + { + var leftPosition = transform.InverseTransformPoint(leftRayOrigin.position); + var leftPointerPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(leftRayOrigin)); + if (moveResizeLeft.wasJustPressed && (adjustedBounds.Contains(leftPosition) || adjustedBounds.Contains(leftPointerPosition))) + { + dragRayOrigin = leftRayOrigin; + m_LastResizeIcons.TryGetValue(dragRayOrigin, out dragResizeIcon); + consumeControl(moveResizeLeft); + } + + var rightPosition = transform.InverseTransformPoint(rightRayOrigin.position); + var rightPointerPosition = transform.InverseTransformPoint(GetPointerPositionForRayOrigin(rightRayOrigin)); + if (moveResizeRight.wasJustPressed && (adjustedBounds.Contains(rightPosition) || adjustedBounds.Contains(rightPointerPosition))) + { + dragRayOrigin = rightRayOrigin; + m_LastResizeIcons.TryGetValue(dragRayOrigin, out dragResizeIcon); + consumeControl(moveResizeRight); + } + } + + if (dragRayOrigin) + { + m_DragState = new DragState(this, dragRayOrigin, resizing); + if (dragResizeIcon != null) + dragResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true); + + ResetFrameThickness(); + + foreach (var smoothMotion in GetComponentsInChildren()) + { + smoothMotion.enabled = false; + } + + highlightsVisible = true; + } + } + + Vector3 GetPointerPositionForRayOrigin(Transform rayOrigin) + { + return rayOrigin.position + rayOrigin.forward * this.GetPointerLength(rayOrigin); + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_TopFaceMaterial); + ObjectUtils.Destroy(m_FrontFaceMaterial); + + m_CloseButton.clicked -= OnCloseClicked; + m_CloseButton.hovered -= OnButtonHovered; + m_ResizeButton.clicked -= OnResetSizeClicked; + m_ResizeButton.hovered -= OnButtonHovered; + } + + void OnCloseClicked(Transform rayOrigin) + { + if (closeClicked != null) + closeClicked(rayOrigin); + } + + void OnResetSizeClicked(Transform rayOrigin) + { + if (resetSizeClicked != null) + resetSizeClicked(rayOrigin); + } + + void OnButtonHovered(Transform rayOrigin) + { + if (buttonHovered != null) + buttonHovered(rayOrigin); + } + + void IncreaseFrameThickness(Transform rayOrigin = null) + { + this.StopCoroutine(ref m_FrameThicknessCoroutine); + const float kTargetBlendAmount = 0f; + m_FrameThicknessCoroutine = StartCoroutine(ChangeFrameThickness(kTargetBlendAmount, rayOrigin)); + } + + void ResetFrameThickness() + { + this.StopCoroutine(ref m_FrameThicknessCoroutine); + const float kTargetBlendAmount = 50f; + m_FrameThicknessCoroutine = StartCoroutine(ChangeFrameThickness(kTargetBlendAmount, null)); + } + + IEnumerator ChangeFrameThickness(float targetBlendAmount, Transform rayOrigin) + { + const float kTargetDuration = 0.25f; + var currentDuration = 0f; + var currentBlendAmount = m_Frame.GetBlendShapeWeight(k_ThinFrameBlendShapeIndex); + var currentVelocity = 0f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + currentBlendAmount = MathUtilsExt.SmoothDamp(currentBlendAmount, targetBlendAmount, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_Frame.SetBlendShapeWeight(k_ThinFrameBlendShapeIndex, currentBlendAmount); + yield return null; + } + + // If hovering the frame, and not moving, perform haptic feedback + if (hoveringFrame != null && m_HovereringRayOrigins.Count > 0 && m_DragState == null && Mathf.Approximately(targetBlendAmount, 0f)) + hoveringFrame(rayOrigin); + + m_FrameThicknessCoroutine = null; + } + + IEnumerator ShowTopFace() + { + const string kMaterialHighlightAlphaProperty = "_Alpha"; + const float kTargetAlpha = 1f; + const float kTargetDuration = 0.35f; + var currentDuration = 0f; + var currentAlpha = m_TopFaceMaterial.GetFloat(kMaterialHighlightAlphaProperty); + var currentVelocity = 0f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_TopFaceMaterial.SetFloat(kMaterialHighlightAlphaProperty, currentAlpha); + yield return null; + } + + m_TopFaceVisibleCoroutine = null; + } + + IEnumerator HideTopFace() + { + const string kMaterialHighlightAlphaProperty = "_Alpha"; + const float kTargetAlpha = 0f; + const float kTargetDuration = 0.2f; + var currentDuration = 0f; + var currentAlpha = m_TopFaceMaterial.GetFloat(kMaterialHighlightAlphaProperty); + var currentVelocity = 0f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_TopFaceMaterial.SetFloat(kMaterialHighlightAlphaProperty, currentAlpha); + yield return null; + } + + m_TopFaceVisibleCoroutine = null; + } + + void OnMoving(Transform rayOrigin) + { + if (moving != null) + moving(rayOrigin); + } + + void OnResizing(Transform rayOrigin) + { + if (resizing != null) + resizing(rayOrigin); + } + } } + #endif diff --git a/Workspaces/Common/Scripts/DraggableListItem.cs b/Workspaces/Common/Scripts/DraggableListItem.cs index 5fd1bb8ee..b7f8571a0 100644 --- a/Workspaces/Common/Scripts/DraggableListItem.cs +++ b/Workspaces/Common/Scripts/DraggableListItem.cs @@ -9,104 +9,99 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - class DraggableListItem : ListViewItem, IGetPreviewOrigin, IUsesViewerScale - where TData : ListViewItemData - { - const float k_MagnetizeDuration = 0.5f; - protected const float k_DragDeadzone = 0.025f; - - protected Transform m_DragObject; - - protected float m_DragLerp; - - readonly Dictionary m_DragStarts = new Dictionary(); - bool m_DirectGrab; - - protected virtual bool singleClickDrag { get { return true; } } - - public Action setRowGrabbed { protected get; set; } - public Func> getGrabbedRow { protected get; set; } - - protected virtual void OnDragStarted(BaseHandle handle, HandleEventData eventData) - { - if (singleClickDrag) - { - m_DragObject = handle.transform; - m_DragLerp = 0; - StartCoroutine(Magnetize()); - } - else - { - // Cache eventData.direct because it is always true while dragging - m_DirectGrab = eventData.direct; - m_DragObject = null; - m_DragStarts[eventData.rayOrigin] = eventData.rayOrigin.position; - } - } - - // Smoothly interpolate grabbed object into position, instead of "popping." - protected virtual IEnumerator Magnetize() - { - var startTime = Time.realtimeSinceStartup; - var currTime = 0f; - while (currTime < k_MagnetizeDuration) - { - currTime = Time.realtimeSinceStartup - startTime; - m_DragLerp = currTime / k_MagnetizeDuration; - yield return null; - } - m_DragLerp = 1; - OnMagnetizeEnded(); - } - - protected virtual void OnDragging(BaseHandle handle, HandleEventData eventData) - { - if (singleClickDrag) - { - if (m_DragObject) - { - var previewOrigin = this.GetPreviewOriginForRayOrigin(eventData.rayOrigin); - MathUtilsExt.LerpTransform(m_DragObject, previewOrigin.position, previewOrigin.rotation, m_DragLerp); - } - } - else - { - // Only allow direct grabbing - if (!m_DirectGrab) - return; - - var rayOrigin = eventData.rayOrigin; - var dragStart = m_DragStarts[rayOrigin]; - var dragVector = rayOrigin.position - dragStart; - var distance = dragVector.magnitude; - - if (m_DragObject == null && distance > k_DragDeadzone * this.GetViewerScale()) - { - m_DragObject = handle.transform; - OnGrabDragStart(handle, eventData, dragStart); - } - - if (m_DragObject) - OnGrabDragging(handle, eventData, dragStart); - } - } - - protected virtual void OnGrabDragStart(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) - { - } - - protected virtual void OnGrabDragging(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) - { - } - - protected virtual void OnDragEnded(BaseHandle handle, HandleEventData eventData) - { - m_DragObject = null; - } - - protected virtual void OnMagnetizeEnded() - { - } - } + class DraggableListItem : ListViewItem, IGetPreviewOrigin, IUsesViewerScale + where TData : ListViewItemData + { + const float k_MagnetizeDuration = 0.5f; + protected const float k_DragDeadzone = 0.025f; + + protected Transform m_DragObject; + + protected float m_DragLerp; + + readonly Dictionary m_DragStarts = new Dictionary(); + bool m_DirectGrab; + + protected virtual bool singleClickDrag { get { return true; } } + + public Action setRowGrabbed { protected get; set; } + public Func> getGrabbedRow { protected get; set; } + + protected virtual void OnDragStarted(BaseHandle handle, HandleEventData eventData) + { + if (singleClickDrag) + { + m_DragObject = handle.transform; + m_DragLerp = 0; + StartCoroutine(Magnetize()); + } + else + { + // Cache eventData.direct because it is always true while dragging + m_DirectGrab = eventData.direct; + m_DragObject = null; + m_DragStarts[eventData.rayOrigin] = eventData.rayOrigin.position; + } + } + + // Smoothly interpolate grabbed object into position, instead of "popping." + protected virtual IEnumerator Magnetize() + { + var startTime = Time.realtimeSinceStartup; + var currTime = 0f; + while (currTime < k_MagnetizeDuration) + { + currTime = Time.realtimeSinceStartup - startTime; + m_DragLerp = currTime / k_MagnetizeDuration; + yield return null; + } + m_DragLerp = 1; + OnMagnetizeEnded(); + } + + protected virtual void OnDragging(BaseHandle handle, HandleEventData eventData) + { + if (singleClickDrag) + { + if (m_DragObject) + { + var previewOrigin = this.GetPreviewOriginForRayOrigin(eventData.rayOrigin); + MathUtilsExt.LerpTransform(m_DragObject, previewOrigin.position, previewOrigin.rotation, m_DragLerp); + } + } + else + { + // Only allow direct grabbing + if (!m_DirectGrab) + return; + + var rayOrigin = eventData.rayOrigin; + var dragStart = m_DragStarts[rayOrigin]; + var dragVector = rayOrigin.position - dragStart; + var distance = dragVector.magnitude; + + if (m_DragObject == null && distance > k_DragDeadzone * this.GetViewerScale()) + { + m_DragObject = handle.transform; + OnGrabDragStart(handle, eventData, dragStart); + } + + if (m_DragObject) + OnGrabDragging(handle, eventData, dragStart); + } + } + + protected virtual void OnGrabDragStart(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) {} + + protected virtual void OnGrabDragging(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) {} + + protected virtual void OnDragEnded(BaseHandle handle, HandleEventData eventData) + { + m_DragObject = null; + } + + protected virtual void OnMagnetizeEnded() {} + } } -#endif \ No newline at end of file + +#endif diff --git a/Workspaces/Common/Scripts/EditorWindowWorkspace.cs b/Workspaces/Common/Scripts/EditorWindowWorkspace.cs index eff1b26de..5affa6560 100644 --- a/Workspaces/Common/Scripts/EditorWindowWorkspace.cs +++ b/Workspaces/Common/Scripts/EditorWindowWorkspace.cs @@ -5,65 +5,66 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - abstract class EditorWindowWorkspace : Workspace - { - [SerializeField] - GameObject m_CaptureWindowPrefab; + abstract class EditorWindowWorkspace : Workspace + { + [SerializeField] + GameObject m_CaptureWindowPrefab; - Transform m_CaptureWindow; + Transform m_CaptureWindow; - EditorWindowCapture m_Capture; + EditorWindowCapture m_Capture; - public override void Setup() - { - // Initial bounds must be set before the base.Setup() is called - minBounds = new Vector3(0.727f, MinBounds.y, 0.4f); - m_CustomStartingBounds = minBounds; + public override void Setup() + { + // Initial bounds must be set before the base.Setup() is called + minBounds = new Vector3(0.727f, MinBounds.y, 0.4f); + m_CustomStartingBounds = minBounds; - base.Setup(); + base.Setup(); - preventResize = true; + preventResize = true; - m_CaptureWindow = this.InstantiateUI(m_CaptureWindowPrefab).transform; - m_CaptureWindow.SetParent(m_WorkspaceUI.topFaceContainer, false); - m_CaptureWindow.localPosition = new Vector3(0f, -0.007f, -0.5f); - m_CaptureWindow.localRotation = Quaternion.Euler(90f, 0f, 0f); - m_CaptureWindow.localScale = new Vector3(1f, 1f, 1f); + m_CaptureWindow = this.InstantiateUI(m_CaptureWindowPrefab).transform; + m_CaptureWindow.SetParent(m_WorkspaceUI.topFaceContainer, false); + m_CaptureWindow.localPosition = new Vector3(0f, -0.007f, -0.5f); + m_CaptureWindow.localRotation = Quaternion.Euler(90f, 0f, 0f); + m_CaptureWindow.localScale = new Vector3(1f, 1f, 1f); - var bounds = contentBounds; - var size = bounds.size; - size.z = 0.1f; - bounds.size = size; - contentBounds = bounds; + var bounds = contentBounds; + var size = bounds.size; + size.z = 0.1f; + bounds.size = size; + contentBounds = bounds; - var handle = m_CaptureWindow.GetComponent(); - handle.hovering += OnHovering; - handle.dragStarted += OnDragStarted; - handle.dragging += OnDragging; - handle.dragEnded += OnDragEnded; + var handle = m_CaptureWindow.GetComponent(); + handle.hovering += OnHovering; + handle.dragStarted += OnDragStarted; + handle.dragging += OnDragging; + handle.dragEnded += OnDragEnded; - m_Capture = m_CaptureWindow.GetComponent(); - } + m_Capture = m_CaptureWindow.GetComponent(); + } - void OnHovering(BaseHandle handle, HandleEventData eventData) - { - m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseMove); - } + void OnHovering(BaseHandle handle, HandleEventData eventData) + { + m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseMove); + } - void OnDragStarted(BaseHandle handle, HandleEventData eventData) - { - m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseDown); - } + void OnDragStarted(BaseHandle handle, HandleEventData eventData) + { + m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseDown); + } - void OnDragging(BaseHandle handle, HandleEventData eventData) - { - m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseDrag); - } + void OnDragging(BaseHandle handle, HandleEventData eventData) + { + m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseDrag); + } - void OnDragEnded(BaseHandle handle, HandleEventData eventData) - { - m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseUp); - } - } + void OnDragEnded(BaseHandle handle, HandleEventData eventData) + { + m_Capture.SendEvent(eventData.rayOrigin, transform, EventType.MouseUp); + } + } } + #endif diff --git a/Workspaces/Common/Scripts/FilterButtonUI.cs b/Workspaces/Common/Scripts/FilterButtonUI.cs index f5b137088..38382c205 100644 --- a/Workspaces/Common/Scripts/FilterButtonUI.cs +++ b/Workspaces/Common/Scripts/FilterButtonUI.cs @@ -8,89 +8,90 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class FilterButtonUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IRayEnterHandler - { - const float k_HoverAlpha = 1; - const float k_NormalAlpha = 0.95f; - - public Button button - { - get { return m_Button; } - } - - [SerializeField] - Button m_Button; - - [SerializeField] - Image m_EyePanel; - - [SerializeField] - Image m_Eye; - - [SerializeField] - Image m_TextPanel; - - Transform m_InteractingRayOrigin; - - public Text text - { - get { return m_Text; } - } - - [SerializeField] - Text m_Text; - - public Color color - { - set - { - m_Eye.color = value; - m_Text.color = value; - } - } - - public event Action hovered; - public event Action clicked; - - void Awake() - { - m_Button.onClick.AddListener(OnButtonClicked); - } - - void OnDestroy() - { - m_Button.onClick.RemoveAllListeners(); - } - - public void OnPointerEnter(PointerEventData eventData) - { - var c = m_EyePanel.color; - c.a = k_HoverAlpha; - m_EyePanel.color = c; - m_TextPanel.color = c; - } - - public void OnPointerExit(PointerEventData eventData) - { - var c = m_EyePanel.color; - c.a = k_NormalAlpha; - m_EyePanel.color = c; - m_TextPanel.color = c; - } - - public void OnRayEnter(RayEventData eventData) - { - m_InteractingRayOrigin = eventData.rayOrigin; - - if (hovered != null) - hovered(eventData.rayOrigin); - } - - void OnButtonClicked() - { - if (clicked != null) - clicked(m_InteractingRayOrigin); - } - } + sealed class FilterButtonUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IRayEnterHandler + { + const float k_HoverAlpha = 1; + const float k_NormalAlpha = 0.95f; + + public Button button + { + get { return m_Button; } + } + + [SerializeField] + Button m_Button; + + [SerializeField] + Image m_EyePanel; + + [SerializeField] + Image m_Eye; + + [SerializeField] + Image m_TextPanel; + + Transform m_InteractingRayOrigin; + + public Text text + { + get { return m_Text; } + } + + [SerializeField] + Text m_Text; + + public Color color + { + set + { + m_Eye.color = value; + m_Text.color = value; + } + } + + public event Action hovered; + public event Action clicked; + + void Awake() + { + m_Button.onClick.AddListener(OnButtonClicked); + } + + void OnDestroy() + { + m_Button.onClick.RemoveAllListeners(); + } + + public void OnPointerEnter(PointerEventData eventData) + { + var c = m_EyePanel.color; + c.a = k_HoverAlpha; + m_EyePanel.color = c; + m_TextPanel.color = c; + } + + public void OnPointerExit(PointerEventData eventData) + { + var c = m_EyePanel.color; + c.a = k_NormalAlpha; + m_EyePanel.color = c; + m_TextPanel.color = c; + } + + public void OnRayEnter(RayEventData eventData) + { + m_InteractingRayOrigin = eventData.rayOrigin; + + if (hovered != null) + hovered(eventData.rayOrigin); + } + + void OnButtonClicked() + { + if (clicked != null) + clicked(m_InteractingRayOrigin); + } + } } + #endif diff --git a/Workspaces/Common/Scripts/FilterUI.cs b/Workspaces/Common/Scripts/FilterUI.cs index 9741d3cbf..5bc83ee45 100644 --- a/Workspaces/Common/Scripts/FilterUI.cs +++ b/Workspaces/Common/Scripts/FilterUI.cs @@ -9,275 +9,273 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class FilterUI : MonoBehaviour, IUsesStencilRef - { - const string k_AllText = "All"; - - public Text summaryText - { - get { return m_SummaryText; } - } - - [SerializeField] - Text m_SummaryText; - - public Text descriptionText - { - get { return m_DescriptionText; } - } - - [SerializeField] - Text m_DescriptionText; - - [SerializeField] - RectTransform m_ButtonList; - - [SerializeField] - GameObject m_ButtonPrefab; - - [SerializeField] - Color m_ActiveColor; - - [SerializeField] - Color m_DisableColor; - - [SerializeField] - CanvasGroup m_CanvasGroup; - - [SerializeField] - GridLayoutGroup m_ButtonListGrid; - - [SerializeField] - CanvasGroup m_ButtonListCanvasGroup; - - [SerializeField] - MeshRenderer m_Background; - - [SerializeField] - WorkspaceButton m_VisibilityButton; - - [SerializeField] - WorkspaceButton m_SummaryButton; - - public string searchQuery - { - get { return m_SearchQuery; } - } - - string m_SearchQuery = string.Empty; - - FilterButtonUI[] m_VisibilityButtons; - Coroutine m_ShowUICoroutine; - Coroutine m_HideUICoroutine; - Coroutine m_ShowButtonListCoroutine; - Coroutine m_HideButtonListCoroutine; - float m_HiddenButtonListYSpacing; - List m_FilterTypes; - Material m_BackgroundMaterial; - - public List filterList - { - set - { - // Clean up old buttons - if (m_VisibilityButtons != null) - foreach (var button in m_VisibilityButtons) - ObjectUtils.Destroy(button.gameObject); - - m_FilterTypes = value; - m_FilterTypes.Insert(0, k_AllText); - - // Generate new button list - m_VisibilityButtons = new FilterButtonUI[m_FilterTypes.Count]; - for (int i = 0; i < m_VisibilityButtons.Length; i++) - { - var button = ObjectUtils.Instantiate(m_ButtonPrefab, m_ButtonList, false).GetComponent(); - m_VisibilityButtons[i] = button; - - button.button.onClick.AddListener(() => - { - OnFilterClick(button); - }); - - button.clicked += OnClicked; - button.hovered += OnHovered; - button.text.text = m_FilterTypes[i]; - } - } - } - - public byte stencilRef { get; set; } - - public event Action buttonHovered; - public event Action buttonClicked; - - void Awake() - { - m_HiddenButtonListYSpacing = -m_ButtonListGrid.cellSize.y; - } - - void Start() - { - m_BackgroundMaterial = MaterialUtils.GetMaterialClone(m_Background); - m_BackgroundMaterial.SetInt("_StencilRef", stencilRef); - - m_VisibilityButton.clicked += OnVisibilityButtonClicked; - m_VisibilityButton.hovered += OnHovered; - m_SummaryButton.clicked += OnVisibilityButtonClicked; - m_SummaryButton.hovered += OnHovered; - } - - void OnDestroy() - { - ObjectUtils.Destroy(m_BackgroundMaterial); - } - - public void SetListVisibility(bool show) - { - if (show) - { - this.StopCoroutine(ref m_HideUICoroutine); - m_HideUICoroutine = StartCoroutine(HideUIContent()); - - this.StopCoroutine(ref m_ShowButtonListCoroutine); - m_ShowButtonListCoroutine = StartCoroutine(ShowButtonList()); - } - else - { - this.StopCoroutine(ref m_ShowUICoroutine); - m_ShowUICoroutine = StartCoroutine(ShowUIContent()); - - this.StopCoroutine(ref m_HideButtonListCoroutine); - m_HideButtonListCoroutine = StartCoroutine(HideButtonList()); - - OnClicked(null); - } - } - - public void OnFilterClick(FilterButtonUI clickedButton) - { - for (int i = 0; i < m_VisibilityButtons.Length; i++) - if (clickedButton == m_VisibilityButtons[i]) - m_SearchQuery = i == 0 ? string.Empty : "t:" + m_FilterTypes[i]; - - foreach (FilterButtonUI button in m_VisibilityButtons) - { - if (button == clickedButton) - button.color = m_ActiveColor; - else - button.color = m_SearchQuery.Contains("t:") ? m_DisableColor : m_ActiveColor; - } - - switch (clickedButton.text.text) - { - case k_AllText: - m_SummaryText.text = clickedButton.text.text; - m_DescriptionText.text = "All objects are visible"; - break; - - default: - m_SummaryText.text = clickedButton.text.text + "s"; - m_DescriptionText.text = "Only " + m_SummaryText.text + " are visible"; - break; - } - } - - IEnumerator ShowUIContent() - { - var currentAlpha = m_CanvasGroup.alpha; - var kTargetAlpha = 1f; - var transitionAmount = Time.deltaTime; - while (transitionAmount < 1) - { - m_CanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); - transitionAmount = transitionAmount + Time.deltaTime; - yield return null; - } - - m_CanvasGroup.alpha = kTargetAlpha; - m_ShowUICoroutine = null; - } - - IEnumerator HideUIContent() - { - var currentAlpha = m_CanvasGroup.alpha; - var kTargetAlpha = 0f; - var transitionAmount = Time.deltaTime; - var kSpeedMultiplier = 3; - while (transitionAmount < 1) - { - m_CanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); - transitionAmount = transitionAmount + Time.deltaTime * kSpeedMultiplier; - yield return null; - } - - m_CanvasGroup.alpha = kTargetAlpha; - m_HideUICoroutine = null; - } - - IEnumerator ShowButtonList() - { - m_ButtonList.gameObject.SetActive(true); - - const float kTargetDuration = 0.5f; - var currentAlpha = m_ButtonListCanvasGroup.alpha; - var kTargetAlpha = 1f; - var transitionAmount = 0f; - var velocity = 0f; - var currentDuration = 0f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - transitionAmount = MathUtilsExt.SmoothDamp(transitionAmount, 1f, ref velocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_ButtonListGrid.spacing = new Vector2(0f, Mathf.Lerp(m_HiddenButtonListYSpacing, 0f, transitionAmount)); - m_ButtonListCanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); - yield return null; - } - - m_ButtonListGrid.spacing = new Vector2(0f, 0f); - m_ButtonListCanvasGroup.alpha = 1f; - m_ShowButtonListCoroutine = null; - } - - IEnumerator HideButtonList() - { - const float kTargetDuration = 0.25f; - var currentAlpha = m_ButtonListCanvasGroup.alpha; - var kTargetAlpha = 0f; - var transitionAmount = 0f; - var currentSpacing = m_ButtonListGrid.spacing.y; - var velocity = 0f; - var currentDuration = 0f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - transitionAmount = MathUtilsExt.SmoothDamp(transitionAmount, 1f, ref velocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_ButtonListGrid.spacing = new Vector2(0f, Mathf.Lerp(currentSpacing, m_HiddenButtonListYSpacing, transitionAmount)); - m_ButtonListCanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); - yield return null; - } - - m_ButtonList.gameObject.SetActive(false); - m_HideButtonListCoroutine = null; - } - - void OnVisibilityButtonClicked(Transform rayOrigin) - { - SetListVisibility(true); - OnClicked(rayOrigin); - } - - void OnClicked(Transform rayOrigin) - { - if (buttonClicked != null) - buttonClicked(rayOrigin); - } - - void OnHovered(Transform rayOrigin) - { - if (buttonHovered != null) - buttonHovered(rayOrigin); - } - } + sealed class FilterUI : MonoBehaviour, IUsesStencilRef + { + const string k_AllText = "All"; + + public Text summaryText + { + get { return m_SummaryText; } + } + + [SerializeField] + Text m_SummaryText; + + public Text descriptionText + { + get { return m_DescriptionText; } + } + + [SerializeField] + Text m_DescriptionText; + + [SerializeField] + RectTransform m_ButtonList; + + [SerializeField] + GameObject m_ButtonPrefab; + + [SerializeField] + Color m_ActiveColor; + + [SerializeField] + Color m_DisableColor; + + [SerializeField] + CanvasGroup m_CanvasGroup; + + [SerializeField] + GridLayoutGroup m_ButtonListGrid; + + [SerializeField] + CanvasGroup m_ButtonListCanvasGroup; + + [SerializeField] + MeshRenderer m_Background; + + [SerializeField] + WorkspaceButton m_VisibilityButton; + + [SerializeField] + WorkspaceButton m_SummaryButton; + + public string searchQuery + { + get { return m_SearchQuery; } + } + + string m_SearchQuery = string.Empty; + + FilterButtonUI[] m_VisibilityButtons; + Coroutine m_ShowUICoroutine; + Coroutine m_HideUICoroutine; + Coroutine m_ShowButtonListCoroutine; + Coroutine m_HideButtonListCoroutine; + float m_HiddenButtonListYSpacing; + List m_FilterTypes; + Material m_BackgroundMaterial; + + public List filterList + { + set + { + // Clean up old buttons + if (m_VisibilityButtons != null) + foreach (var button in m_VisibilityButtons) + ObjectUtils.Destroy(button.gameObject); + + m_FilterTypes = value; + m_FilterTypes.Insert(0, k_AllText); + + // Generate new button list + m_VisibilityButtons = new FilterButtonUI[m_FilterTypes.Count]; + for (int i = 0; i < m_VisibilityButtons.Length; i++) + { + var button = ObjectUtils.Instantiate(m_ButtonPrefab, m_ButtonList, false).GetComponent(); + m_VisibilityButtons[i] = button; + + button.button.onClick.AddListener(() => { OnFilterClick(button); }); + + button.clicked += OnClicked; + button.hovered += OnHovered; + button.text.text = m_FilterTypes[i]; + } + } + } + + public byte stencilRef { get; set; } + + public event Action buttonHovered; + public event Action buttonClicked; + + void Awake() + { + m_HiddenButtonListYSpacing = -m_ButtonListGrid.cellSize.y; + } + + void Start() + { + m_BackgroundMaterial = MaterialUtils.GetMaterialClone(m_Background); + m_BackgroundMaterial.SetInt("_StencilRef", stencilRef); + + m_VisibilityButton.clicked += OnVisibilityButtonClicked; + m_VisibilityButton.hovered += OnHovered; + m_SummaryButton.clicked += OnVisibilityButtonClicked; + m_SummaryButton.hovered += OnHovered; + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_BackgroundMaterial); + } + + public void SetListVisibility(bool show) + { + if (show) + { + this.StopCoroutine(ref m_HideUICoroutine); + m_HideUICoroutine = StartCoroutine(HideUIContent()); + + this.StopCoroutine(ref m_ShowButtonListCoroutine); + m_ShowButtonListCoroutine = StartCoroutine(ShowButtonList()); + } + else + { + this.StopCoroutine(ref m_ShowUICoroutine); + m_ShowUICoroutine = StartCoroutine(ShowUIContent()); + + this.StopCoroutine(ref m_HideButtonListCoroutine); + m_HideButtonListCoroutine = StartCoroutine(HideButtonList()); + + OnClicked(null); + } + } + + public void OnFilterClick(FilterButtonUI clickedButton) + { + for (int i = 0; i < m_VisibilityButtons.Length; i++) + if (clickedButton == m_VisibilityButtons[i]) + m_SearchQuery = i == 0 ? string.Empty : "t:" + m_FilterTypes[i]; + + foreach (FilterButtonUI button in m_VisibilityButtons) + { + if (button == clickedButton) + button.color = m_ActiveColor; + else + button.color = m_SearchQuery.Contains("t:") ? m_DisableColor : m_ActiveColor; + } + + switch (clickedButton.text.text) + { + case k_AllText: + m_SummaryText.text = clickedButton.text.text; + m_DescriptionText.text = "All objects are visible"; + break; + + default: + m_SummaryText.text = clickedButton.text.text + "s"; + m_DescriptionText.text = "Only " + m_SummaryText.text + " are visible"; + break; + } + } + + IEnumerator ShowUIContent() + { + var currentAlpha = m_CanvasGroup.alpha; + var kTargetAlpha = 1f; + var transitionAmount = Time.deltaTime; + while (transitionAmount < 1) + { + m_CanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); + transitionAmount = transitionAmount + Time.deltaTime; + yield return null; + } + + m_CanvasGroup.alpha = kTargetAlpha; + m_ShowUICoroutine = null; + } + + IEnumerator HideUIContent() + { + var currentAlpha = m_CanvasGroup.alpha; + var kTargetAlpha = 0f; + var transitionAmount = Time.deltaTime; + var kSpeedMultiplier = 3; + while (transitionAmount < 1) + { + m_CanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); + transitionAmount = transitionAmount + Time.deltaTime * kSpeedMultiplier; + yield return null; + } + + m_CanvasGroup.alpha = kTargetAlpha; + m_HideUICoroutine = null; + } + + IEnumerator ShowButtonList() + { + m_ButtonList.gameObject.SetActive(true); + + const float kTargetDuration = 0.5f; + var currentAlpha = m_ButtonListCanvasGroup.alpha; + var kTargetAlpha = 1f; + var transitionAmount = 0f; + var velocity = 0f; + var currentDuration = 0f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + transitionAmount = MathUtilsExt.SmoothDamp(transitionAmount, 1f, ref velocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_ButtonListGrid.spacing = new Vector2(0f, Mathf.Lerp(m_HiddenButtonListYSpacing, 0f, transitionAmount)); + m_ButtonListCanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); + yield return null; + } + + m_ButtonListGrid.spacing = new Vector2(0f, 0f); + m_ButtonListCanvasGroup.alpha = 1f; + m_ShowButtonListCoroutine = null; + } + + IEnumerator HideButtonList() + { + const float kTargetDuration = 0.25f; + var currentAlpha = m_ButtonListCanvasGroup.alpha; + var kTargetAlpha = 0f; + var transitionAmount = 0f; + var currentSpacing = m_ButtonListGrid.spacing.y; + var velocity = 0f; + var currentDuration = 0f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + transitionAmount = MathUtilsExt.SmoothDamp(transitionAmount, 1f, ref velocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_ButtonListGrid.spacing = new Vector2(0f, Mathf.Lerp(currentSpacing, m_HiddenButtonListYSpacing, transitionAmount)); + m_ButtonListCanvasGroup.alpha = Mathf.Lerp(currentAlpha, kTargetAlpha, transitionAmount); + yield return null; + } + + m_ButtonList.gameObject.SetActive(false); + m_HideButtonListCoroutine = null; + } + + void OnVisibilityButtonClicked(Transform rayOrigin) + { + SetListVisibility(true); + OnClicked(rayOrigin); + } + + void OnClicked(Transform rayOrigin) + { + if (buttonClicked != null) + buttonClicked(rayOrigin); + } + + void OnHovered(Transform rayOrigin) + { + if (buttonHovered != null) + buttonHovered(rayOrigin); + } + } } + #endif diff --git a/Workspaces/Common/Scripts/NestedListViewController.cs b/Workspaces/Common/Scripts/NestedListViewController.cs index acbd98040..0ba88a391 100644 --- a/Workspaces/Common/Scripts/NestedListViewController.cs +++ b/Workspaces/Common/Scripts/NestedListViewController.cs @@ -3,163 +3,163 @@ namespace ListView { - class NestedListViewController : ListViewController - where TData : ListViewItemNestedData - where TItem : ListViewItem - { - - protected override float listHeight { get { return m_ExpandedDataLength; } } - - protected float m_ExpandedDataLength; - - protected readonly Dictionary m_ExpandStates = new Dictionary(); - - public override List data - { - get { return base.data; } - set - { - m_Data = value; - - // Update visible rows - var items = new Dictionary(m_ListItems); - foreach (var row in items) - { - var index = row.Key; - var newData = GetRowRecursive(m_Data, index); - if (newData != null) - row.Value.Setup(newData); - else - Recycle(index); - } - } - } - - static TData GetRowRecursive(List data, TIndex index) - { - foreach (var datum in data) - { - if (datum.index.Equals(index)) - return datum; - - if (datum.children != null) - { - var result = GetRowRecursive(datum.children, index); - if (result != null) - return result; - } - } - return null; - } - - protected void RecycleRecursively(TData data) - { - Recycle(data.index); - - if (data.children != null) - { - foreach (var child in data.children) - { - RecycleRecursively(child); - } - } - } - - protected override void UpdateItems() - { - var doneSettling = true; - var count = 0f; - var order = 0; - - UpdateRecursively(m_Data, ref order, ref count, ref doneSettling); - m_ExpandedDataLength = count; - - if (m_Settling && doneSettling) - EndSettling(); - } - - protected virtual void UpdateRecursively(List data, ref int order, ref float offset, ref bool doneSettling, int depth = 0) - { - for (int i = 0; i < data.Count; i++) - { - var datum = data[i]; - - var index = datum.index; - bool expanded; - if (!m_ExpandStates.TryGetValue(index, out expanded)) - m_ExpandStates[index] = false; - - var itemSize = m_ItemSize.Value; - - if (offset + scrollOffset + itemSize.z < 0 || offset + scrollOffset > m_Size.z) - Recycle(index); - else - UpdateNestedItem(datum, order++, offset, depth, ref doneSettling); - - offset += itemSize.z; - - if (datum.children != null) - { - if (expanded) - UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling, depth + 1); - else - RecycleChildren(datum); - } - } - } - - protected virtual void UpdateNestedItem(TData data, int order, float count, int depth, ref bool doneSettling) - { - UpdateVisibleItem(data, order, count, ref doneSettling); - } - - protected void RecycleChildren(TData data) - { - foreach (var child in data.children) - { - Recycle(child.index); - - if (child.children != null) - RecycleChildren(child); - } - } - - protected bool GetExpanded(TIndex index) - { - bool expanded; - m_ExpandStates.TryGetValue(index, out expanded); - return expanded; - } - - protected void SetExpanded(TIndex index, bool expanded) - { - m_ExpandStates[index] = expanded; - StartSettling(); - } - - protected void ScrollToIndex(TData container, TIndex targetIndex, ref float scrollHeight) - { - var index = container.index; - if (index.Equals(targetIndex)) - { - if (-scrollOffset > scrollHeight || -scrollOffset + m_Size.z < scrollHeight) - scrollOffset = -scrollHeight; - return; - } - - scrollHeight += itemSize.z; - - if (GetExpanded(index)) - { - if (container.children != null) - { - foreach (var child in container.children) - { - ScrollToIndex(child, targetIndex, ref scrollHeight); - } - } - } - } - } + class NestedListViewController : ListViewController + where TData : ListViewItemNestedData + where TItem : ListViewItem + { + protected override float listHeight { get { return m_ExpandedDataLength; } } + + protected float m_ExpandedDataLength; + + protected readonly Dictionary m_ExpandStates = new Dictionary(); + + public override List data + { + get { return base.data; } + set + { + m_Data = value; + + // Update visible rows + var items = new Dictionary(m_ListItems); + foreach (var row in items) + { + var index = row.Key; + var newData = GetRowRecursive(m_Data, index); + if (newData != null) + row.Value.Setup(newData); + else + Recycle(index); + } + } + } + + static TData GetRowRecursive(List data, TIndex index) + { + foreach (var datum in data) + { + if (datum.index.Equals(index)) + return datum; + + if (datum.children != null) + { + var result = GetRowRecursive(datum.children, index); + if (result != null) + return result; + } + } + return null; + } + + protected void RecycleRecursively(TData data) + { + Recycle(data.index); + + if (data.children != null) + { + foreach (var child in data.children) + { + RecycleRecursively(child); + } + } + } + + protected override void UpdateItems() + { + var doneSettling = true; + var count = 0f; + var order = 0; + + UpdateRecursively(m_Data, ref order, ref count, ref doneSettling); + m_ExpandedDataLength = count; + + if (m_Settling && doneSettling) + EndSettling(); + } + + protected virtual void UpdateRecursively(List data, ref int order, ref float offset, ref bool doneSettling, int depth = 0) + { + for (int i = 0; i < data.Count; i++) + { + var datum = data[i]; + + var index = datum.index; + bool expanded; + if (!m_ExpandStates.TryGetValue(index, out expanded)) + m_ExpandStates[index] = false; + + var itemSize = m_ItemSize.Value; + + if (offset + scrollOffset + itemSize.z < 0 || offset + scrollOffset > m_Size.z) + Recycle(index); + else + UpdateNestedItem(datum, order++, offset, depth, ref doneSettling); + + offset += itemSize.z; + + if (datum.children != null) + { + if (expanded) + UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling, depth + 1); + else + RecycleChildren(datum); + } + } + } + + protected virtual void UpdateNestedItem(TData data, int order, float count, int depth, ref bool doneSettling) + { + UpdateVisibleItem(data, order, count, ref doneSettling); + } + + protected void RecycleChildren(TData data) + { + foreach (var child in data.children) + { + Recycle(child.index); + + if (child.children != null) + RecycleChildren(child); + } + } + + protected bool GetExpanded(TIndex index) + { + bool expanded; + m_ExpandStates.TryGetValue(index, out expanded); + return expanded; + } + + protected void SetExpanded(TIndex index, bool expanded) + { + m_ExpandStates[index] = expanded; + StartSettling(); + } + + protected void ScrollToIndex(TData container, TIndex targetIndex, ref float scrollHeight) + { + var index = container.index; + if (index.Equals(targetIndex)) + { + if (-scrollOffset > scrollHeight || -scrollOffset + m_Size.z < scrollHeight) + scrollOffset = -scrollHeight; + return; + } + + scrollHeight += itemSize.z; + + if (GetExpanded(index)) + { + if (container.children != null) + { + foreach (var child in container.children) + { + ScrollToIndex(child, targetIndex, ref scrollHeight); + } + } + } + } + } } + #endif diff --git a/Workspaces/Common/Scripts/WorkspaceButton.cs b/Workspaces/Common/Scripts/WorkspaceButton.cs index 9d710c166..802ba6b2e 100644 --- a/Workspaces/Common/Scripts/WorkspaceButton.cs +++ b/Workspaces/Common/Scripts/WorkspaceButton.cs @@ -10,478 +10,483 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class WorkspaceButton : MonoBehaviour, IRayEnterHandler, IRayExitHandler, IUsesStencilRef - { - const float k_IconHighlightedLocalZOffset = -0.0015f; - const string k_MaterialAlphaProperty = "_Alpha"; - const string k_MaterialColorTopProperty = "_ColorTop"; - const string k_MaterialColorBottomProperty = "_ColorBottom"; - - public event Action clicked; - public event Action hovered; - - public bool autoHighlight - { - get { return m_AutoHighlight; } - set { m_AutoHighlight = value; } - } - [SerializeField] - bool m_AutoHighlight = true; - - public Sprite iconSprite - { - set - { - m_IconSprite = value; - m_Icon.sprite = m_IconSprite; - } - } - Sprite m_IconSprite; - - public Color customHighlightColor - { - get { return m_CustomHighlightColor; } - set { m_CustomHighlightColor = value; } - } - [Header("Extras")] - [SerializeField] - Color m_CustomHighlightColor = UnityBrandColorScheme.light; - - public bool pressed - { - get { return m_Pressed; } - set - { - if (m_Highlighted && value != m_Pressed && value) // proceed only if value is true after previously being false - { - m_Pressed = value; - - this.StopCoroutine(ref m_IconHighlightCoroutine); - - m_IconHighlightCoroutine = StartCoroutine(IconContainerContentsBeginHighlight(true)); - } - } - } - bool m_Pressed; - - public bool highlighted - { - set - { - if (m_Highlighted == value) - return; - else - { - // Stop any existing icon highlight coroutines - this.StopCoroutine(ref m_IconHighlightCoroutine); - - m_Highlighted = value; - - // Stop any existing begin/end highlight coroutine - this.StopCoroutine(ref m_HighlightCoroutine); - - if (!gameObject.activeInHierarchy) - return; - - m_HighlightCoroutine = m_Highlighted ? StartCoroutine(BeginHighlight()) : StartCoroutine(EndHighlight()); - } - } - } - bool m_Highlighted; - - public bool alternateIconVisible - { - set - { - if (m_AlternateIconSprite) // Only allow sprite swapping if an alternate sprite exists - m_Icon.sprite = value ? m_AlternateIconSprite : m_OriginalIconSprite; // If true, set the icon sprite back to the original sprite - } - get - { - return m_Icon.sprite == m_AlternateIconSprite; - } - } - [SerializeField] - Sprite m_AlternateIconSprite; - - public MeshRenderer buttonMeshRenderer { get { return m_ButtonMeshRenderer; } } - [SerializeField] - MeshRenderer m_ButtonMeshRenderer; - - [SerializeField] - CanvasGroup m_CanvasGroup; - - [SerializeField] - Image m_Icon; - - [SerializeField] - Transform m_IconContainer; - - [SerializeField] - Button m_Button; - - [SerializeField] - bool m_SwapIconsOnClick = true; - - [SerializeField] - Graphic[] m_HighlightItems; - - [SerializeField] - bool m_GrayscaleGradient; - - [Header("Animated Reveal Settings")] - [SerializeField] - bool m_AnimatedReveal; - - [Tooltip("Default value is 0.25")] - [SerializeField] - [Range(0f, 2f)] - float m_DelayBeforeReveal = 0.25f; - - GradientPair m_OriginalGradientPair; - GradientPair m_HighlightGradientPair; - Vector3 m_IconDirection; - Material m_ButtonMaterial; - Material m_ButtonMaskMaterial; - Vector3 m_OriginalIconLocalPosition; - Vector3 m_HiddenLocalScale; - Vector3 m_IconHighlightedLocalPosition; - Vector3 m_IconPressedLocalPosition; - Vector3 m_IconLookDirection; - Color m_OriginalColor; - Sprite m_OriginalIconSprite; - float m_VisibleLocalZScale; - Transform m_InteractingRayOrigin; - - // The initial button reveal coroutines, before highlighting - Coroutine m_VisibilityCoroutine; - Coroutine m_ContentVisibilityCoroutine; - - // The already visible, highlight coroutines - Coroutine m_HighlightCoroutine; - Coroutine m_IconHighlightCoroutine; - - public Button button { get { return m_Button; } } - - public byte stencilRef { get; set; } - - public void InstantClearState() - { - this.StopCoroutine(ref m_IconHighlightCoroutine); - this.StopCoroutine(ref m_HighlightCoroutine); - - ResetColors(); - m_InteractingRayOrigin = null; - } - - public void SetMaterialColors(GradientPair gradientPair) - { - m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, gradientPair.a); - m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, gradientPair.b); - } - - public void ResetColors() - { - m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalGradientPair.a); - m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalGradientPair.b); - } - - void Awake() - { - m_OriginalColor = m_Icon.color; - m_ButtonMaterial = Instantiate(m_ButtonMeshRenderer.sharedMaterials[0]); - m_ButtonMaskMaterial = Instantiate(m_ButtonMeshRenderer.sharedMaterials[1]); - m_ButtonMeshRenderer.materials = new Material[] { m_ButtonMaterial, m_ButtonMaskMaterial }; - m_OriginalGradientPair = new GradientPair(m_ButtonMaterial.GetColor(k_MaterialColorTopProperty), m_ButtonMaterial.GetColor(k_MaterialColorBottomProperty)); - m_HiddenLocalScale = new Vector3(transform.localScale.x, transform.localScale.y, 0f); - m_VisibleLocalZScale = transform.localScale.z; - - m_OriginalIconLocalPosition = m_IconContainer.localPosition; - m_IconHighlightedLocalPosition = m_OriginalIconLocalPosition + Vector3.forward * k_IconHighlightedLocalZOffset; - m_IconPressedLocalPosition = m_OriginalIconLocalPosition + Vector3.back * k_IconHighlightedLocalZOffset; - - m_HighlightGradientPair = m_GrayscaleGradient ? UnityBrandColorScheme.grayscaleSessionGradient : UnityBrandColorScheme.sessionGradient; - - m_OriginalIconSprite = m_Icon.sprite; - - if (m_Button) - { - // Hookup button OnClick event if there is an alternate icon sprite set - if (m_SwapIconsOnClick && m_AlternateIconSprite) - m_Button.onClick.AddListener(SwapIconSprite); - - m_Button.onClick.AddListener(OnButtonClicked); - } - } - - void Start() - { - const string kStencilRef = "_StencilRef"; - m_ButtonMaterial.SetInt(kStencilRef, stencilRef); - m_ButtonMaskMaterial.SetInt(kStencilRef, stencilRef); - } - - void OnEnable() - { - if (m_AnimatedReveal) - { - this.StopCoroutine(ref m_VisibilityCoroutine); - m_VisibilityCoroutine = StartCoroutine(AnimateShow()); - } - } - - void OnDestroy() - { - ObjectUtils.Destroy(m_ButtonMaterial); - ObjectUtils.Destroy(m_ButtonMaskMaterial); - - if (m_Button) - m_Button.onClick.RemoveAllListeners(); - } - - void OnDisable() - { - InstantClearState(); - } - - IEnumerator AnimateShow() - { - m_CanvasGroup.interactable = false; - m_ButtonMaterial.SetFloat(k_MaterialAlphaProperty, 0f); - - this.StopCoroutine(ref m_ContentVisibilityCoroutine); - m_ContentVisibilityCoroutine = StartCoroutine(ShowContent()); - - const float kInitialRevealDuration = 0.5f; - const float kScaleRevealDuration = 0.25f; - var delay = 0f; - var scale = m_HiddenLocalScale; - var smoothVelocity = Vector3.zero; - var hiddenLocalYScale = new Vector3(m_HiddenLocalScale.x, 0f, 0f); - var currentDuration = 0f; - var totalDuration = m_DelayBeforeReveal + kInitialRevealDuration + kScaleRevealDuration; - var visibleLocalScale = new Vector3(transform.localScale.x, transform.localScale.y, m_VisibleLocalZScale); - while (currentDuration < totalDuration) - { - currentDuration += Time.deltaTime; - transform.localScale = scale; - m_ButtonMaterial.SetFloat(k_MaterialAlphaProperty, scale.z); - - // Perform initial delay - while (delay < m_DelayBeforeReveal) - { - delay += Time.deltaTime; - yield return null; - } - - // Perform the button vertical button reveal, after the initial wait - while (delay < kInitialRevealDuration + m_DelayBeforeReveal) - { - delay += Time.deltaTime; - var shapedDelayLerp = delay / m_DelayBeforeReveal; - transform.localScale = Vector3.Lerp(hiddenLocalYScale, m_HiddenLocalScale, shapedDelayLerp * shapedDelayLerp); - yield return null; - } - - // Perform the button depth reveal - scale = MathUtilsExt.SmoothDamp(scale, visibleLocalScale, ref smoothVelocity, kScaleRevealDuration, Mathf.Infinity, Time.deltaTime); - yield return null; - } - - m_ButtonMaterial.SetFloat(k_MaterialAlphaProperty, 1); - m_VisibilityCoroutine = null; - } - - IEnumerator ShowContent() - { - m_CanvasGroup.interactable = true; - - const float kTargetAlpha = 1f; - const float kRevealDuration = 0.4f; - const float kInitialDelayLengthenMultipler = 5f; // used to scale up the initial delay based on the m_InitialDelay value - var delay = 0f; - var targetDelay = Mathf.Clamp(m_DelayBeforeReveal * kInitialDelayLengthenMultipler, 0f, 2.5f); // scale the target delay, with a maximum clamp - var alpha = 0f; - var opacitySmoothVelocity = 1f; - var currentDuration = 0f; - var targetDuration = targetDelay + kRevealDuration; - while (currentDuration < targetDuration) - { - currentDuration += Time.deltaTime; - m_CanvasGroup.alpha = alpha; - - while (delay < targetDelay) - { - delay += Time.deltaTime; - yield return null; - } - - alpha = MathUtilsExt.SmoothDamp(alpha, kTargetAlpha, ref opacitySmoothVelocity, targetDuration, Mathf.Infinity, Time.deltaTime); - yield return null; - } - - m_CanvasGroup.alpha = 1; - m_ContentVisibilityCoroutine = null; - } - - IEnumerator BeginHighlight() - { - this.StopCoroutine(ref m_IconHighlightCoroutine); - m_IconHighlightCoroutine = StartCoroutine(IconContainerContentsBeginHighlight()); - - const float kTargetTransitionAmount = 1f; - var transitionAmount = Time.deltaTime; - var topColor = Color.clear; - var bottomColor = Color.clear; - var currentTopColor = m_ButtonMaterial.GetColor(k_MaterialColorTopProperty); - var currentBottomColor = m_ButtonMaterial.GetColor(k_MaterialColorBottomProperty); - var topHighlightColor = m_HighlightGradientPair.a; - var bottomHighlightColor = m_HighlightGradientPair.b; - var currentLocalScale = transform.localScale; - var highlightedLocalScale = new Vector3(transform.localScale.x, transform.localScale.y, m_VisibleLocalZScale * 2); - var transitionAmountMultiplier = 5; - while (transitionAmount < kTargetTransitionAmount) - { - transitionAmount += Time.deltaTime * transitionAmountMultiplier; - var shapedTransitionAmount = Mathf.Pow(transitionAmount, 2); - transform.localScale = Vector3.Lerp(currentLocalScale, highlightedLocalScale, shapedTransitionAmount); - - topColor = Color.Lerp(currentTopColor, topHighlightColor, shapedTransitionAmount); - bottomColor = Color.Lerp(currentBottomColor, bottomHighlightColor, shapedTransitionAmount); - m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topColor); - m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomColor); - yield return null; - } - - m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topHighlightColor); - m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomHighlightColor); - transform.localScale = highlightedLocalScale; - m_HighlightCoroutine = null; - } - - IEnumerator EndHighlight() - { - this.StopCoroutine(ref m_IconHighlightCoroutine); - m_IconHighlightCoroutine = StartCoroutine(IconContainerContentsEndHighlight()); - - const float kTargetTransitionAmount = 1f; - var transitionAmount = Time.deltaTime; - var topColor = Color.clear; - var bottomColor = Color.clear; - var currentTopColor = m_ButtonMaterial.GetColor(k_MaterialColorTopProperty); - var currentBottomColor = m_ButtonMaterial.GetColor(k_MaterialColorBottomProperty); - var topOriginalColor = m_OriginalGradientPair.a; - var bottomOriginalColor = m_OriginalGradientPair.b; - var currentLocalScale = transform.localScale; - var targetScale = new Vector3(transform.localScale.x, transform.localScale.y, m_VisibleLocalZScale); - while (transitionAmount < kTargetTransitionAmount) - { - transitionAmount += Time.deltaTime * 3; - var shapedTransitionAmount = Mathf.Pow(transitionAmount, 2); - topColor = Color.Lerp(currentTopColor, topOriginalColor, shapedTransitionAmount); - bottomColor = Color.Lerp(currentBottomColor, bottomOriginalColor, shapedTransitionAmount); - - m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topColor); - m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomColor); - - transform.localScale = Vector3.Lerp(currentLocalScale, targetScale, shapedTransitionAmount); - yield return null; - } - - m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topOriginalColor); - m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomOriginalColor); - transform.localScale = targetScale; - m_HighlightCoroutine = null; - } - - IEnumerator IconContainerContentsBeginHighlight(bool pressed = false) - { - var currentPosition = m_IconContainer.localPosition; - var targetPosition = pressed == false ? m_IconHighlightedLocalPosition : m_IconPressedLocalPosition; // forward for highlight, backward for press - var transitionAmount = Time.deltaTime; - var transitionAddMultiplier = !pressed ? 4 : 7; // Faster transition in for highlight; slower for pressed highlight - while (transitionAmount < 1) - { - transitionAmount += Time.deltaTime * transitionAddMultiplier; - - foreach (var graphic in m_HighlightItems) - { - if (graphic) - graphic.color = Color.Lerp(m_OriginalColor, customHighlightColor, transitionAmount); - } - - m_IconContainer.localPosition = Vector3.Lerp(currentPosition, targetPosition, transitionAmount); - yield return null; - } - - foreach (var graphic in m_HighlightItems) - { - if (graphic) - graphic.color = m_CustomHighlightColor; - } - - m_IconContainer.localPosition = targetPosition; - m_IconHighlightCoroutine = null; - } - - IEnumerator IconContainerContentsEndHighlight() - { - var currentPosition = m_IconContainer.localPosition; - var transitionAmount = 1f; - const float kTransitionSubtractMultiplier = 5f; - while (transitionAmount > 0) - { - transitionAmount -= Time.deltaTime * kTransitionSubtractMultiplier; - - foreach (var graphic in m_HighlightItems) - { - if (graphic != null) - graphic.color = Color.Lerp(m_OriginalColor, customHighlightColor, transitionAmount); - } - - m_IconContainer.localPosition = Vector3.Lerp(m_OriginalIconLocalPosition, currentPosition, transitionAmount); - yield return null; - } - - foreach (var graphic in m_HighlightItems) - { - if (graphic != null) - graphic.color = m_OriginalColor; - } - - m_IconContainer.localPosition = m_OriginalIconLocalPosition; - m_IconHighlightCoroutine = null; - } - - public void OnRayEnter(RayEventData eventData) - { - m_InteractingRayOrigin = eventData.rayOrigin; - if (hovered != null) - hovered(m_InteractingRayOrigin); - - if (autoHighlight) - highlighted = true; - } - - public void OnRayExit(RayEventData eventData) - { - m_InteractingRayOrigin = null; - - if (autoHighlight) - highlighted = false; - } - - void SwapIconSprite() - { - // Alternate between the main icon and the alternate icon when the button is clicked - alternateIconVisible = !alternateIconVisible; - } - - void OnButtonClicked() - { - if (clicked != null) - clicked(m_InteractingRayOrigin); - } - } + sealed class WorkspaceButton : MonoBehaviour, IRayEnterHandler, IRayExitHandler, IUsesStencilRef + { + const float k_IconHighlightedLocalZOffset = -0.0015f; + const string k_MaterialAlphaProperty = "_Alpha"; + const string k_MaterialColorTopProperty = "_ColorTop"; + const string k_MaterialColorBottomProperty = "_ColorBottom"; + + public event Action clicked; + public event Action hovered; + + public bool autoHighlight + { + get { return m_AutoHighlight; } + set { m_AutoHighlight = value; } + } + + [SerializeField] + bool m_AutoHighlight = true; + + public Sprite iconSprite + { + set + { + m_IconSprite = value; + m_Icon.sprite = m_IconSprite; + } + } + + Sprite m_IconSprite; + + public Color customHighlightColor + { + get { return m_CustomHighlightColor; } + set { m_CustomHighlightColor = value; } + } + + [Header("Extras")] + [SerializeField] + Color m_CustomHighlightColor = UnityBrandColorScheme.light; + + public bool pressed + { + get { return m_Pressed; } + set + { + if (m_Highlighted && value != m_Pressed && value) // proceed only if value is true after previously being false + { + m_Pressed = value; + + this.StopCoroutine(ref m_IconHighlightCoroutine); + + m_IconHighlightCoroutine = StartCoroutine(IconContainerContentsBeginHighlight(true)); + } + } + } + + bool m_Pressed; + + public bool highlighted + { + set + { + if (m_Highlighted == value) + return; + else + { + // Stop any existing icon highlight coroutines + this.StopCoroutine(ref m_IconHighlightCoroutine); + + m_Highlighted = value; + + // Stop any existing begin/end highlight coroutine + this.StopCoroutine(ref m_HighlightCoroutine); + + if (!gameObject.activeInHierarchy) + return; + + m_HighlightCoroutine = m_Highlighted ? StartCoroutine(BeginHighlight()) : StartCoroutine(EndHighlight()); + } + } + } + + bool m_Highlighted; + + public bool alternateIconVisible + { + set + { + if (m_AlternateIconSprite) // Only allow sprite swapping if an alternate sprite exists + m_Icon.sprite = value ? m_AlternateIconSprite : m_OriginalIconSprite; // If true, set the icon sprite back to the original sprite + } + get { return m_Icon.sprite == m_AlternateIconSprite; } + } + + [SerializeField] + Sprite m_AlternateIconSprite; + + public MeshRenderer buttonMeshRenderer { get { return m_ButtonMeshRenderer; } } + + [SerializeField] + MeshRenderer m_ButtonMeshRenderer; + + [SerializeField] + CanvasGroup m_CanvasGroup; + + [SerializeField] + Image m_Icon; + + [SerializeField] + Transform m_IconContainer; + + [SerializeField] + Button m_Button; + + [SerializeField] + bool m_SwapIconsOnClick = true; + + [SerializeField] + Graphic[] m_HighlightItems; + + [SerializeField] + bool m_GrayscaleGradient; + + [Header("Animated Reveal Settings")] + [SerializeField] + bool m_AnimatedReveal; + + [Tooltip("Default value is 0.25")] + [SerializeField] + [Range(0f, 2f)] + float m_DelayBeforeReveal = 0.25f; + + GradientPair m_OriginalGradientPair; + GradientPair m_HighlightGradientPair; + Vector3 m_IconDirection; + Material m_ButtonMaterial; + Material m_ButtonMaskMaterial; + Vector3 m_OriginalIconLocalPosition; + Vector3 m_HiddenLocalScale; + Vector3 m_IconHighlightedLocalPosition; + Vector3 m_IconPressedLocalPosition; + Vector3 m_IconLookDirection; + Color m_OriginalColor; + Sprite m_OriginalIconSprite; + float m_VisibleLocalZScale; + Transform m_InteractingRayOrigin; + + // The initial button reveal coroutines, before highlighting + Coroutine m_VisibilityCoroutine; + Coroutine m_ContentVisibilityCoroutine; + + // The already visible, highlight coroutines + Coroutine m_HighlightCoroutine; + Coroutine m_IconHighlightCoroutine; + + public Button button { get { return m_Button; } } + + public byte stencilRef { get; set; } + + public void InstantClearState() + { + this.StopCoroutine(ref m_IconHighlightCoroutine); + this.StopCoroutine(ref m_HighlightCoroutine); + + ResetColors(); + m_InteractingRayOrigin = null; + } + + public void SetMaterialColors(GradientPair gradientPair) + { + m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, gradientPair.a); + m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, gradientPair.b); + } + + public void ResetColors() + { + m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, m_OriginalGradientPair.a); + m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, m_OriginalGradientPair.b); + } + + void Awake() + { + m_OriginalColor = m_Icon.color; + m_ButtonMaterial = Instantiate(m_ButtonMeshRenderer.sharedMaterials[0]); + m_ButtonMaskMaterial = Instantiate(m_ButtonMeshRenderer.sharedMaterials[1]); + m_ButtonMeshRenderer.materials = new Material[] { m_ButtonMaterial, m_ButtonMaskMaterial }; + m_OriginalGradientPair = new GradientPair(m_ButtonMaterial.GetColor(k_MaterialColorTopProperty), m_ButtonMaterial.GetColor(k_MaterialColorBottomProperty)); + m_HiddenLocalScale = new Vector3(transform.localScale.x, transform.localScale.y, 0f); + m_VisibleLocalZScale = transform.localScale.z; + + m_OriginalIconLocalPosition = m_IconContainer.localPosition; + m_IconHighlightedLocalPosition = m_OriginalIconLocalPosition + Vector3.forward * k_IconHighlightedLocalZOffset; + m_IconPressedLocalPosition = m_OriginalIconLocalPosition + Vector3.back * k_IconHighlightedLocalZOffset; + + m_HighlightGradientPair = m_GrayscaleGradient ? UnityBrandColorScheme.grayscaleSessionGradient : UnityBrandColorScheme.sessionGradient; + + m_OriginalIconSprite = m_Icon.sprite; + + if (m_Button) + { + // Hookup button OnClick event if there is an alternate icon sprite set + if (m_SwapIconsOnClick && m_AlternateIconSprite) + m_Button.onClick.AddListener(SwapIconSprite); + + m_Button.onClick.AddListener(OnButtonClicked); + } + } + + void Start() + { + const string kStencilRef = "_StencilRef"; + m_ButtonMaterial.SetInt(kStencilRef, stencilRef); + m_ButtonMaskMaterial.SetInt(kStencilRef, stencilRef); + } + + void OnEnable() + { + if (m_AnimatedReveal) + { + this.StopCoroutine(ref m_VisibilityCoroutine); + m_VisibilityCoroutine = StartCoroutine(AnimateShow()); + } + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_ButtonMaterial); + ObjectUtils.Destroy(m_ButtonMaskMaterial); + + if (m_Button) + m_Button.onClick.RemoveAllListeners(); + } + + void OnDisable() + { + InstantClearState(); + } + + IEnumerator AnimateShow() + { + m_CanvasGroup.interactable = false; + m_ButtonMaterial.SetFloat(k_MaterialAlphaProperty, 0f); + + this.StopCoroutine(ref m_ContentVisibilityCoroutine); + m_ContentVisibilityCoroutine = StartCoroutine(ShowContent()); + + const float kInitialRevealDuration = 0.5f; + const float kScaleRevealDuration = 0.25f; + var delay = 0f; + var scale = m_HiddenLocalScale; + var smoothVelocity = Vector3.zero; + var hiddenLocalYScale = new Vector3(m_HiddenLocalScale.x, 0f, 0f); + var currentDuration = 0f; + var totalDuration = m_DelayBeforeReveal + kInitialRevealDuration + kScaleRevealDuration; + var visibleLocalScale = new Vector3(transform.localScale.x, transform.localScale.y, m_VisibleLocalZScale); + while (currentDuration < totalDuration) + { + currentDuration += Time.deltaTime; + transform.localScale = scale; + m_ButtonMaterial.SetFloat(k_MaterialAlphaProperty, scale.z); + + // Perform initial delay + while (delay < m_DelayBeforeReveal) + { + delay += Time.deltaTime; + yield return null; + } + + // Perform the button vertical button reveal, after the initial wait + while (delay < kInitialRevealDuration + m_DelayBeforeReveal) + { + delay += Time.deltaTime; + var shapedDelayLerp = delay / m_DelayBeforeReveal; + transform.localScale = Vector3.Lerp(hiddenLocalYScale, m_HiddenLocalScale, shapedDelayLerp * shapedDelayLerp); + yield return null; + } + + // Perform the button depth reveal + scale = MathUtilsExt.SmoothDamp(scale, visibleLocalScale, ref smoothVelocity, kScaleRevealDuration, Mathf.Infinity, Time.deltaTime); + yield return null; + } + + m_ButtonMaterial.SetFloat(k_MaterialAlphaProperty, 1); + m_VisibilityCoroutine = null; + } + + IEnumerator ShowContent() + { + m_CanvasGroup.interactable = true; + + const float kTargetAlpha = 1f; + const float kRevealDuration = 0.4f; + const float kInitialDelayLengthenMultipler = 5f; // used to scale up the initial delay based on the m_InitialDelay value + var delay = 0f; + var targetDelay = Mathf.Clamp(m_DelayBeforeReveal * kInitialDelayLengthenMultipler, 0f, 2.5f); // scale the target delay, with a maximum clamp + var alpha = 0f; + var opacitySmoothVelocity = 1f; + var currentDuration = 0f; + var targetDuration = targetDelay + kRevealDuration; + while (currentDuration < targetDuration) + { + currentDuration += Time.deltaTime; + m_CanvasGroup.alpha = alpha; + + while (delay < targetDelay) + { + delay += Time.deltaTime; + yield return null; + } + + alpha = MathUtilsExt.SmoothDamp(alpha, kTargetAlpha, ref opacitySmoothVelocity, targetDuration, Mathf.Infinity, Time.deltaTime); + yield return null; + } + + m_CanvasGroup.alpha = 1; + m_ContentVisibilityCoroutine = null; + } + + IEnumerator BeginHighlight() + { + this.StopCoroutine(ref m_IconHighlightCoroutine); + m_IconHighlightCoroutine = StartCoroutine(IconContainerContentsBeginHighlight()); + + const float kTargetTransitionAmount = 1f; + var transitionAmount = Time.deltaTime; + var topColor = Color.clear; + var bottomColor = Color.clear; + var currentTopColor = m_ButtonMaterial.GetColor(k_MaterialColorTopProperty); + var currentBottomColor = m_ButtonMaterial.GetColor(k_MaterialColorBottomProperty); + var topHighlightColor = m_HighlightGradientPair.a; + var bottomHighlightColor = m_HighlightGradientPair.b; + var currentLocalScale = transform.localScale; + var highlightedLocalScale = new Vector3(transform.localScale.x, transform.localScale.y, m_VisibleLocalZScale * 2); + var transitionAmountMultiplier = 5; + while (transitionAmount < kTargetTransitionAmount) + { + transitionAmount += Time.deltaTime * transitionAmountMultiplier; + var shapedTransitionAmount = Mathf.Pow(transitionAmount, 2); + transform.localScale = Vector3.Lerp(currentLocalScale, highlightedLocalScale, shapedTransitionAmount); + + topColor = Color.Lerp(currentTopColor, topHighlightColor, shapedTransitionAmount); + bottomColor = Color.Lerp(currentBottomColor, bottomHighlightColor, shapedTransitionAmount); + m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topColor); + m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomColor); + yield return null; + } + + m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topHighlightColor); + m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomHighlightColor); + transform.localScale = highlightedLocalScale; + m_HighlightCoroutine = null; + } + + IEnumerator EndHighlight() + { + this.StopCoroutine(ref m_IconHighlightCoroutine); + m_IconHighlightCoroutine = StartCoroutine(IconContainerContentsEndHighlight()); + + const float kTargetTransitionAmount = 1f; + var transitionAmount = Time.deltaTime; + var topColor = Color.clear; + var bottomColor = Color.clear; + var currentTopColor = m_ButtonMaterial.GetColor(k_MaterialColorTopProperty); + var currentBottomColor = m_ButtonMaterial.GetColor(k_MaterialColorBottomProperty); + var topOriginalColor = m_OriginalGradientPair.a; + var bottomOriginalColor = m_OriginalGradientPair.b; + var currentLocalScale = transform.localScale; + var targetScale = new Vector3(transform.localScale.x, transform.localScale.y, m_VisibleLocalZScale); + while (transitionAmount < kTargetTransitionAmount) + { + transitionAmount += Time.deltaTime * 3; + var shapedTransitionAmount = Mathf.Pow(transitionAmount, 2); + topColor = Color.Lerp(currentTopColor, topOriginalColor, shapedTransitionAmount); + bottomColor = Color.Lerp(currentBottomColor, bottomOriginalColor, shapedTransitionAmount); + + m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topColor); + m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomColor); + + transform.localScale = Vector3.Lerp(currentLocalScale, targetScale, shapedTransitionAmount); + yield return null; + } + + m_ButtonMaterial.SetColor(k_MaterialColorTopProperty, topOriginalColor); + m_ButtonMaterial.SetColor(k_MaterialColorBottomProperty, bottomOriginalColor); + transform.localScale = targetScale; + m_HighlightCoroutine = null; + } + + IEnumerator IconContainerContentsBeginHighlight(bool pressed = false) + { + var currentPosition = m_IconContainer.localPosition; + var targetPosition = pressed == false ? m_IconHighlightedLocalPosition : m_IconPressedLocalPosition; // forward for highlight, backward for press + var transitionAmount = Time.deltaTime; + var transitionAddMultiplier = !pressed ? 4 : 7; // Faster transition in for highlight; slower for pressed highlight + while (transitionAmount < 1) + { + transitionAmount += Time.deltaTime * transitionAddMultiplier; + + foreach (var graphic in m_HighlightItems) + { + if (graphic) + graphic.color = Color.Lerp(m_OriginalColor, customHighlightColor, transitionAmount); + } + + m_IconContainer.localPosition = Vector3.Lerp(currentPosition, targetPosition, transitionAmount); + yield return null; + } + + foreach (var graphic in m_HighlightItems) + { + if (graphic) + graphic.color = m_CustomHighlightColor; + } + + m_IconContainer.localPosition = targetPosition; + m_IconHighlightCoroutine = null; + } + + IEnumerator IconContainerContentsEndHighlight() + { + var currentPosition = m_IconContainer.localPosition; + var transitionAmount = 1f; + const float kTransitionSubtractMultiplier = 5f; + while (transitionAmount > 0) + { + transitionAmount -= Time.deltaTime * kTransitionSubtractMultiplier; + + foreach (var graphic in m_HighlightItems) + { + if (graphic != null) + graphic.color = Color.Lerp(m_OriginalColor, customHighlightColor, transitionAmount); + } + + m_IconContainer.localPosition = Vector3.Lerp(m_OriginalIconLocalPosition, currentPosition, transitionAmount); + yield return null; + } + + foreach (var graphic in m_HighlightItems) + { + if (graphic != null) + graphic.color = m_OriginalColor; + } + + m_IconContainer.localPosition = m_OriginalIconLocalPosition; + m_IconHighlightCoroutine = null; + } + + public void OnRayEnter(RayEventData eventData) + { + m_InteractingRayOrigin = eventData.rayOrigin; + if (hovered != null) + hovered(m_InteractingRayOrigin); + + if (autoHighlight) + highlighted = true; + } + + public void OnRayExit(RayEventData eventData) + { + m_InteractingRayOrigin = null; + + if (autoHighlight) + highlighted = false; + } + + void SwapIconSprite() + { + // Alternate between the main icon and the alternate icon when the button is clicked + alternateIconVisible = !alternateIconVisible; + } + + void OnButtonClicked() + { + if (clicked != null) + clicked(m_InteractingRayOrigin); + } + } } + #endif diff --git a/Workspaces/Common/Scripts/WorkspaceHighlight.cs b/Workspaces/Common/Scripts/WorkspaceHighlight.cs index f085d9bcd..60cffa5c1 100644 --- a/Workspaces/Common/Scripts/WorkspaceHighlight.cs +++ b/Workspaces/Common/Scripts/WorkspaceHighlight.cs @@ -6,88 +6,90 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class WorkspaceHighlight : MonoBehaviour - { - const string k_TopColorProperty = "_ColorTop"; - const string k_BottomColorProperty = "_ColorBottom"; - const string k_AlphaProperty = "_Alpha"; + sealed class WorkspaceHighlight : MonoBehaviour + { + const string k_TopColorProperty = "_ColorTop"; + const string k_BottomColorProperty = "_ColorBottom"; + const string k_AlphaProperty = "_Alpha"; - Coroutine m_HighlightCoroutine; - Material m_TopHighlightMaterial; + Coroutine m_HighlightCoroutine; + Material m_TopHighlightMaterial; - [SerializeField] - MeshRenderer m_TopHighlightRenderer; + [SerializeField] + MeshRenderer m_TopHighlightRenderer; - public bool visible - { - get { return m_HighlightVisible; } - set - { - if (m_HighlightVisible == value) - return; + public bool visible + { + get { return m_HighlightVisible; } + set + { + if (m_HighlightVisible == value) + return; - m_HighlightVisible = value; + m_HighlightVisible = value; - this.StopCoroutine(ref m_HighlightCoroutine); + this.StopCoroutine(ref m_HighlightCoroutine); - if (m_HighlightVisible) - m_HighlightCoroutine = StartCoroutine(ShowHighlight()); - else - m_HighlightCoroutine = StartCoroutine(HideHighlight()); - } - } - bool m_HighlightVisible; + if (m_HighlightVisible) + m_HighlightCoroutine = StartCoroutine(ShowHighlight()); + else + m_HighlightCoroutine = StartCoroutine(HideHighlight()); + } + } - void Awake() - { - m_TopHighlightMaterial = MaterialUtils.GetMaterialClone(m_TopHighlightRenderer); - m_TopHighlightMaterial.SetColor(k_TopColorProperty, UnityBrandColorScheme.sessionGradient.a); - m_TopHighlightMaterial.SetColor(k_BottomColorProperty, UnityBrandColorScheme.sessionGradient.b); - m_TopHighlightMaterial.SetFloat(k_AlphaProperty, 0f); // hide the highlight initially - } + bool m_HighlightVisible; - void OnDestroy() - { - ObjectUtils.Destroy(m_TopHighlightMaterial); - } + void Awake() + { + m_TopHighlightMaterial = MaterialUtils.GetMaterialClone(m_TopHighlightRenderer); + m_TopHighlightMaterial.SetColor(k_TopColorProperty, UnityBrandColorScheme.sessionGradient.a); + m_TopHighlightMaterial.SetColor(k_BottomColorProperty, UnityBrandColorScheme.sessionGradient.b); + m_TopHighlightMaterial.SetFloat(k_AlphaProperty, 0f); // hide the highlight initially + } - IEnumerator ShowHighlight() - { - const float kTargetAlpha = 1f; - var currentAlpha = m_TopHighlightMaterial.GetFloat(k_AlphaProperty); - var smoothVelocity = 0f; - var currentDuration = 0f; - const float kTargetDuration = 0.3f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_TopHighlightMaterial.SetFloat(k_AlphaProperty, currentAlpha); - yield return null; - } + void OnDestroy() + { + ObjectUtils.Destroy(m_TopHighlightMaterial); + } - m_TopHighlightMaterial.SetFloat(k_AlphaProperty, kTargetAlpha); // set value after loop because precision matters in this case - m_HighlightCoroutine = null; - } + IEnumerator ShowHighlight() + { + const float kTargetAlpha = 1f; + var currentAlpha = m_TopHighlightMaterial.GetFloat(k_AlphaProperty); + var smoothVelocity = 0f; + var currentDuration = 0f; + const float kTargetDuration = 0.3f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_TopHighlightMaterial.SetFloat(k_AlphaProperty, currentAlpha); + yield return null; + } - IEnumerator HideHighlight() - { - const float kTargetAlpha = 0f; - var currentAlpha = m_TopHighlightMaterial.GetFloat(k_AlphaProperty); - var smoothVelocity = 0f; - var currentDuration = 0f; - const float kTargetDuration = 0.35f; - while (currentDuration < kTargetDuration) - { - currentDuration += Time.deltaTime; - currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); - m_TopHighlightMaterial.SetFloat(k_AlphaProperty, currentAlpha); - yield return null; - } + m_TopHighlightMaterial.SetFloat(k_AlphaProperty, kTargetAlpha); // set value after loop because precision matters in this case + m_HighlightCoroutine = null; + } - m_TopHighlightMaterial.SetFloat(k_AlphaProperty, kTargetAlpha); // set value after loop because precision matters in this case - m_HighlightCoroutine = null; - } - } + IEnumerator HideHighlight() + { + const float kTargetAlpha = 0f; + var currentAlpha = m_TopHighlightMaterial.GetFloat(k_AlphaProperty); + var smoothVelocity = 0f; + var currentDuration = 0f; + const float kTargetDuration = 0.35f; + while (currentDuration < kTargetDuration) + { + currentDuration += Time.deltaTime; + currentAlpha = MathUtilsExt.SmoothDamp(currentAlpha, kTargetAlpha, ref smoothVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime); + m_TopHighlightMaterial.SetFloat(k_AlphaProperty, currentAlpha); + yield return null; + } + + m_TopHighlightMaterial.SetFloat(k_AlphaProperty, kTargetAlpha); // set value after loop because precision matters in this case + m_HighlightCoroutine = null; + } + } } + #endif diff --git a/Workspaces/Common/Scripts/ZoomSliderUI.cs b/Workspaces/Common/Scripts/ZoomSliderUI.cs index ab024b40b..3c0508bbc 100644 --- a/Workspaces/Common/Scripts/ZoomSliderUI.cs +++ b/Workspaces/Common/Scripts/ZoomSliderUI.cs @@ -5,19 +5,21 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class ZoomSliderUI : MonoBehaviour - { - public Slider zoomSlider { get { return m_ZoomSlider; } } - [SerializeField] - Slider m_ZoomSlider; + sealed class ZoomSliderUI : MonoBehaviour + { + public Slider zoomSlider { get { return m_ZoomSlider; } } - public event Action sliding; + [SerializeField] + Slider m_ZoomSlider; - public void ZoomSlider(float value) - { - if (sliding != null) - sliding(value); - } - } + public event Action sliding; + + public void ZoomSlider(float value) + { + if (sliding != null) + sliding(value); + } + } } + #endif diff --git a/Workspaces/ConsoleWorkspace/ConsoleWorkspace.cs b/Workspaces/ConsoleWorkspace/ConsoleWorkspace.cs index 3469696ee..71d4144d0 100644 --- a/Workspaces/ConsoleWorkspace/ConsoleWorkspace.cs +++ b/Workspaces/ConsoleWorkspace/ConsoleWorkspace.cs @@ -1,9 +1,10 @@ -#if UNITY_EDITOR + +#if UNITY_EDITOR + namespace UnityEditor.Experimental.EditorVR.Workspaces { - [MainMenuItem("Console", "Workspaces", "View errors, warnings and other messages")] - sealed class ConsoleWorkspace : EditorWindowWorkspace - { - } + [MainMenuItem("Console", "Workspaces", "View errors, warnings and other messages")] + sealed class ConsoleWorkspace : EditorWindowWorkspace {} } + #endif diff --git a/Workspaces/HierarchyWorkspace/HierarchyWorkspace.cs b/Workspaces/HierarchyWorkspace/HierarchyWorkspace.cs index a5f0ed0f3..5eb3859ff 100644 --- a/Workspaces/HierarchyWorkspace/HierarchyWorkspace.cs +++ b/Workspaces/HierarchyWorkspace/HierarchyWorkspace.cs @@ -7,243 +7,245 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - [MainMenuItem("Hierarchy", "Workspaces", "View all GameObjects in your scene(s)")] - class HierarchyWorkspace : Workspace, IFilterUI, IUsesHierarchyData, ISelectionChanged, IMoveCameraRig - { - protected const string k_LockedQuery = "t:" + k_Locked; - const string k_Locked = "Locked"; - - [SerializeField] - GameObject m_ContentPrefab; - - [SerializeField] - GameObject m_FilterPrefab; - - [SerializeField] - GameObject m_FocusPrefab; - - [SerializeField] - GameObject m_CreateEmptyPrefab; - - HierarchyUI m_HierarchyUI; - protected FilterUI m_FilterUI; - - HierarchyData m_SelectedRow; - - bool m_Scrolling; - - public List hierarchyData - { - set - { - m_HierarchyData = value; - - if (m_HierarchyUI) - m_HierarchyUI.listView.data = value; - } - } - protected List m_HierarchyData; - - public virtual List filterList - { - set - { - m_FilterList = value; - m_FilterList.Sort(); - m_FilterList.Insert(0, k_Locked); - - if (m_FilterUI) - m_FilterUI.filterList = value; - } - } - protected List m_FilterList; - - public virtual string searchQuery { get { return m_FilterUI.searchQuery; } } - - public override void Setup() - { - // Initial bounds must be set before the base.Setup() is called - minBounds = new Vector3(0.522f, MinBounds.y, 0.5f); - m_CustomStartingBounds = minBounds; - - base.Setup(); - - var contentPrefab = ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false); - m_HierarchyUI = contentPrefab.GetComponent(); - m_HierarchyUI.listView.lockedQueryString = k_LockedQuery; - hierarchyData = m_HierarchyData; - - if (m_FilterPrefab) - { - m_FilterUI = ObjectUtils.Instantiate(m_FilterPrefab, m_WorkspaceUI.frontPanel, false).GetComponent(); - foreach (var mb in m_FilterUI.GetComponentsInChildren()) - { - this.ConnectInterfaces(mb); - } - m_FilterUI.filterList = m_FilterList; - } - - if (m_FocusPrefab) - { - var focusUI = ObjectUtils.Instantiate(m_FocusPrefab, m_WorkspaceUI.frontPanel, false); - foreach (var mb in focusUI.GetComponentsInChildren()) - { - this.ConnectInterfaces(mb); - } - var button = focusUI.GetComponentInChildren(true); - button.clicked += FocusSelection; - button.hovered += OnButtonHovered; - } - - if (m_CreateEmptyPrefab) - { - var createEmptyUI = ObjectUtils.Instantiate(m_CreateEmptyPrefab, m_WorkspaceUI.frontPanel, false); - foreach (var mb in createEmptyUI.GetComponentsInChildren()) - { - this.ConnectInterfaces(mb); - } - var button = createEmptyUI.GetComponentInChildren(true); - button.clicked += CreateEmptyGameObject; - button.clicked += OnButtonClicked; - button.hovered += OnButtonHovered; - } - - var listView = m_HierarchyUI.listView; - listView.selectRow = SelectRow; - listView.matchesFilter = this.MatchesFilter; - listView.getSearchQuery = () => searchQuery; - this.ConnectInterfaces(listView); - - var scrollHandle = m_HierarchyUI.scrollHandle; - scrollHandle.dragStarted += OnScrollDragStarted; - scrollHandle.dragging += OnScrollDragging; - scrollHandle.dragEnded += OnScrollDragEnded; - scrollHandle.hoverStarted += OnScrollHoverStarted; - scrollHandle.hoverEnded += OnScrollHoverEnded; - - contentBounds = new Bounds(Vector3.zero, m_CustomStartingBounds.Value); - - var scrollHandleTransform = m_HierarchyUI.scrollHandle.transform; - scrollHandleTransform.SetParent(m_WorkspaceUI.topFaceContainer); - scrollHandleTransform.localScale = new Vector3(1.03f, 0.02f, 1.02f); // Extra space for scrolling - scrollHandleTransform.localPosition = new Vector3(0f, -0.015f, 0f); // Offset from content for collision purposes - - m_FilterUI.buttonClicked += OnButtonClicked; - m_FilterUI.buttonHovered += OnButtonHovered; - - // Propagate initial bounds - OnBoundsChanged(); - } - - protected override void OnDestroy() - { - m_FilterUI.buttonClicked -= OnButtonClicked; - m_FilterUI.buttonHovered -= OnButtonHovered; - - base.OnDestroy(); - } - - protected override void OnBoundsChanged() - { - var size = contentBounds.size; - var listView = m_HierarchyUI.listView; - size.y = float.MaxValue; // Add height for dropdowns - size.x -= FaceMargin * 2; // Shrink the content width, so that there is space allowed to grab and scroll - size.z -= FaceMargin * 2; // Reduce the height of the inspector contents as to fit within the bounds of the workspace - listView.size = size; - } - - static void SelectRow(int index) - { - var gameObject = EditorUtility.InstanceIDToObject(index) as GameObject; - if (gameObject && Selection.activeGameObject != gameObject) - Selection.activeGameObject = gameObject; - else - Selection.activeGameObject = null; - } - - void OnScrollDragStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - m_Scrolling = true; - - m_WorkspaceUI.topHighlight.visible = true; - m_WorkspaceUI.amplifyTopHighlight = false; - - m_HierarchyUI.listView.OnBeginScrolling(); - } - - void OnScrollDragging(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - m_HierarchyUI.listView.scrollOffset -= Vector3.Dot(eventData.deltaPosition, handle.transform.forward) / this.GetViewerScale(); - } - - void OnScrollDragEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - m_Scrolling = false; - - m_WorkspaceUI.topHighlight.visible = false; - - m_HierarchyUI.listView.OnScrollEnded(); - } - - void OnScrollHoverStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - if (!m_Scrolling) - { - m_WorkspaceUI.topHighlight.visible = true; - m_WorkspaceUI.amplifyTopHighlight = true; - } - } - - void OnScrollHoverEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - if (!m_Scrolling) - { - m_WorkspaceUI.topHighlight.visible = false; - m_WorkspaceUI.amplifyTopHighlight = false; - } - } - - public void OnSelectionChanged() - { - m_HierarchyUI.listView.SelectRow(Selection.activeInstanceID); - } - - void FocusSelection(Transform rayOrigin) - { - if (Selection.gameObjects.Length == 0) - return; - - var mainCamera = CameraUtils.GetMainCamera().transform; - var bounds = ObjectUtils.GetBounds(Selection.transforms); - - var size = bounds.size; - size.y = 0; - var maxSize = size.MaxComponent(); - - const float kExtraDistance = 0.25f; // Add some extra distance so selection isn't in your face - maxSize += kExtraDistance; - - var viewDirection = mainCamera.transform.forward; - viewDirection.y = 0; - viewDirection.Normalize(); - - var cameraDiff = mainCamera.position - CameraUtils.GetCameraRig().position; - cameraDiff.y = 0; - - this.MoveCameraRig(bounds.center - cameraDiff - viewDirection * maxSize); - - OnButtonClicked(rayOrigin); - } - - static void CreateEmptyGameObject(Transform rayOrigin) - { - var camera = CameraUtils.GetMainCamera().transform; - var go = new GameObject(); - go.transform.position = camera.position + camera.forward; - Selection.activeGameObject = go; - } - } + [MainMenuItem("Hierarchy", "Workspaces", "View all GameObjects in your scene(s)")] + class HierarchyWorkspace : Workspace, IFilterUI, IUsesHierarchyData, ISelectionChanged, IMoveCameraRig + { + protected const string k_LockedQuery = "t:" + k_Locked; + const string k_Locked = "Locked"; + + [SerializeField] + GameObject m_ContentPrefab; + + [SerializeField] + GameObject m_FilterPrefab; + + [SerializeField] + GameObject m_FocusPrefab; + + [SerializeField] + GameObject m_CreateEmptyPrefab; + + HierarchyUI m_HierarchyUI; + protected FilterUI m_FilterUI; + + HierarchyData m_SelectedRow; + + bool m_Scrolling; + + public List hierarchyData + { + set + { + m_HierarchyData = value; + + if (m_HierarchyUI) + m_HierarchyUI.listView.data = value; + } + } + + protected List m_HierarchyData; + + public virtual List filterList + { + set + { + m_FilterList = value; + m_FilterList.Sort(); + m_FilterList.Insert(0, k_Locked); + + if (m_FilterUI) + m_FilterUI.filterList = value; + } + } + + protected List m_FilterList; + + public virtual string searchQuery { get { return m_FilterUI.searchQuery; } } + + public override void Setup() + { + // Initial bounds must be set before the base.Setup() is called + minBounds = new Vector3(0.522f, MinBounds.y, 0.5f); + m_CustomStartingBounds = minBounds; + + base.Setup(); + + var contentPrefab = ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false); + m_HierarchyUI = contentPrefab.GetComponent(); + m_HierarchyUI.listView.lockedQueryString = k_LockedQuery; + hierarchyData = m_HierarchyData; + + if (m_FilterPrefab) + { + m_FilterUI = ObjectUtils.Instantiate(m_FilterPrefab, m_WorkspaceUI.frontPanel, false).GetComponent(); + foreach (var mb in m_FilterUI.GetComponentsInChildren()) + { + this.ConnectInterfaces(mb); + } + m_FilterUI.filterList = m_FilterList; + } + + if (m_FocusPrefab) + { + var focusUI = ObjectUtils.Instantiate(m_FocusPrefab, m_WorkspaceUI.frontPanel, false); + foreach (var mb in focusUI.GetComponentsInChildren()) + { + this.ConnectInterfaces(mb); + } + var button = focusUI.GetComponentInChildren(true); + button.clicked += FocusSelection; + button.hovered += OnButtonHovered; + } + + if (m_CreateEmptyPrefab) + { + var createEmptyUI = ObjectUtils.Instantiate(m_CreateEmptyPrefab, m_WorkspaceUI.frontPanel, false); + foreach (var mb in createEmptyUI.GetComponentsInChildren()) + { + this.ConnectInterfaces(mb); + } + var button = createEmptyUI.GetComponentInChildren(true); + button.clicked += CreateEmptyGameObject; + button.clicked += OnButtonClicked; + button.hovered += OnButtonHovered; + } + + var listView = m_HierarchyUI.listView; + listView.selectRow = SelectRow; + listView.matchesFilter = this.MatchesFilter; + listView.getSearchQuery = () => searchQuery; + this.ConnectInterfaces(listView); + + var scrollHandle = m_HierarchyUI.scrollHandle; + scrollHandle.dragStarted += OnScrollDragStarted; + scrollHandle.dragging += OnScrollDragging; + scrollHandle.dragEnded += OnScrollDragEnded; + scrollHandle.hoverStarted += OnScrollHoverStarted; + scrollHandle.hoverEnded += OnScrollHoverEnded; + + contentBounds = new Bounds(Vector3.zero, m_CustomStartingBounds.Value); + + var scrollHandleTransform = m_HierarchyUI.scrollHandle.transform; + scrollHandleTransform.SetParent(m_WorkspaceUI.topFaceContainer); + scrollHandleTransform.localScale = new Vector3(1.03f, 0.02f, 1.02f); // Extra space for scrolling + scrollHandleTransform.localPosition = new Vector3(0f, -0.015f, 0f); // Offset from content for collision purposes + + m_FilterUI.buttonClicked += OnButtonClicked; + m_FilterUI.buttonHovered += OnButtonHovered; + + // Propagate initial bounds + OnBoundsChanged(); + } + + protected override void OnDestroy() + { + m_FilterUI.buttonClicked -= OnButtonClicked; + m_FilterUI.buttonHovered -= OnButtonHovered; + + base.OnDestroy(); + } + + protected override void OnBoundsChanged() + { + var size = contentBounds.size; + var listView = m_HierarchyUI.listView; + size.y = float.MaxValue; // Add height for dropdowns + size.x -= FaceMargin * 2; // Shrink the content width, so that there is space allowed to grab and scroll + size.z -= FaceMargin * 2; // Reduce the height of the inspector contents as to fit within the bounds of the workspace + listView.size = size; + } + + static void SelectRow(int index) + { + var gameObject = EditorUtility.InstanceIDToObject(index) as GameObject; + if (gameObject && Selection.activeGameObject != gameObject) + Selection.activeGameObject = gameObject; + else + Selection.activeGameObject = null; + } + + void OnScrollDragStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + m_Scrolling = true; + + m_WorkspaceUI.topHighlight.visible = true; + m_WorkspaceUI.amplifyTopHighlight = false; + + m_HierarchyUI.listView.OnBeginScrolling(); + } + + void OnScrollDragging(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + m_HierarchyUI.listView.scrollOffset -= Vector3.Dot(eventData.deltaPosition, handle.transform.forward) / this.GetViewerScale(); + } + + void OnScrollDragEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + m_Scrolling = false; + + m_WorkspaceUI.topHighlight.visible = false; + + m_HierarchyUI.listView.OnScrollEnded(); + } + + void OnScrollHoverStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + if (!m_Scrolling) + { + m_WorkspaceUI.topHighlight.visible = true; + m_WorkspaceUI.amplifyTopHighlight = true; + } + } + + void OnScrollHoverEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + if (!m_Scrolling) + { + m_WorkspaceUI.topHighlight.visible = false; + m_WorkspaceUI.amplifyTopHighlight = false; + } + } + + public void OnSelectionChanged() + { + m_HierarchyUI.listView.SelectRow(Selection.activeInstanceID); + } + + void FocusSelection(Transform rayOrigin) + { + if (Selection.gameObjects.Length == 0) + return; + + var mainCamera = CameraUtils.GetMainCamera().transform; + var bounds = ObjectUtils.GetBounds(Selection.transforms); + + var size = bounds.size; + size.y = 0; + var maxSize = size.MaxComponent(); + + const float kExtraDistance = 0.25f; // Add some extra distance so selection isn't in your face + maxSize += kExtraDistance; + + var viewDirection = mainCamera.transform.forward; + viewDirection.y = 0; + viewDirection.Normalize(); + + var cameraDiff = mainCamera.position - CameraUtils.GetCameraRig().position; + cameraDiff.y = 0; + + this.MoveCameraRig(bounds.center - cameraDiff - viewDirection * maxSize); + + OnButtonClicked(rayOrigin); + } + + static void CreateEmptyGameObject(Transform rayOrigin) + { + var camera = CameraUtils.GetMainCamera().transform; + var go = new GameObject(); + go.transform.position = camera.position + camera.forward; + Selection.activeGameObject = go; + } + } } #endif diff --git a/Workspaces/HierarchyWorkspace/Scripts/HierarchyListItem.cs b/Workspaces/HierarchyWorkspace/Scripts/HierarchyListItem.cs index 760aaf483..8691df52b 100644 --- a/Workspaces/HierarchyWorkspace/Scripts/HierarchyListItem.cs +++ b/Workspaces/HierarchyWorkspace/Scripts/HierarchyListItem.cs @@ -9,550 +9,546 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class HierarchyListItem : DraggableListItem, IUsesViewerBody, IGetFieldGrabOrigin - { - const float k_Margin = 0.01f; - const float k_Indent = 0.02f; + sealed class HierarchyListItem : DraggableListItem, IUsesViewerBody, IGetFieldGrabOrigin + { + const float k_Margin = 0.01f; + const float k_Indent = 0.02f; - const float k_ExpandArrowRotateSpeed = 0.4f; + const float k_ExpandArrowRotateSpeed = 0.4f; - [SerializeField] - Text m_Text; + [SerializeField] + Text m_Text; - [SerializeField] - Text m_SceneText; + [SerializeField] + Text m_SceneText; - [SerializeField] - BaseHandle m_Lock; + [SerializeField] + BaseHandle m_Lock; - [SerializeField] - BaseHandle m_Cube; + [SerializeField] + BaseHandle m_Cube; - [SerializeField] - BaseHandle m_ExpandArrow; + [SerializeField] + BaseHandle m_ExpandArrow; - [SerializeField] - Transform m_SceneIcon; + [SerializeField] + Transform m_SceneIcon; - [SerializeField] - BaseHandle m_DropZone; + [SerializeField] + BaseHandle m_DropZone; - [SerializeField] - Material m_NoClipExpandArrow; + [SerializeField] + Material m_NoClipExpandArrow; - [SerializeField] - Material m_NoClipBackingCube; + [SerializeField] + Material m_NoClipBackingCube; - [SerializeField] - Material m_NoClipText; + [SerializeField] + Material m_NoClipText; - [SerializeField] - Color m_HoverColor; + [SerializeField] + Color m_HoverColor; - [SerializeField] - Color m_SelectedColor; + [SerializeField] + Color m_SelectedColor; - [SerializeField] - Color m_SelectedHoverColor; + [SerializeField] + Color m_SelectedHoverColor; - [SerializeField] - Color m_PrefabTextColor; + [SerializeField] + Color m_PrefabTextColor; - [SerializeField] - Color m_SelectedPrefabTextColor; + [SerializeField] + Color m_SelectedPrefabTextColor; - [Tooltip("The fraction of the cube height to use for stacking grabbed rows")] - [SerializeField] - float m_StackingFraction = 0.3f; + [Tooltip("The fraction of the cube height to use for stacking grabbed rows")] + [SerializeField] + float m_StackingFraction = 0.3f; - Color m_NormalColor; - Color m_NormalTextColor; - Renderer m_CubeRenderer; - Transform m_CubeTransform; - Transform m_DropZoneTransform; + Color m_NormalColor; + Color m_NormalTextColor; + Renderer m_CubeRenderer; + Transform m_CubeTransform; + Transform m_DropZoneTransform; - float m_DropZoneHighlightAlpha; + float m_DropZoneHighlightAlpha; - readonly Dictionary m_OldMaterials = new Dictionary(); - readonly List m_VisibleChildren = new List(); + readonly Dictionary m_OldMaterials = new Dictionary(); + readonly List m_VisibleChildren = new List(); - Renderer m_ExpandArrowRenderer; - Material m_ExpandArrowMaterial; + Renderer m_ExpandArrowRenderer; + Material m_ExpandArrowMaterial; - Renderer m_LockRenderer; - Material m_LockIconMaterial; - Material m_UnlockIconMaterial; + Renderer m_LockRenderer; + Material m_LockIconMaterial; + Material m_UnlockIconMaterial; - bool m_HoveringLock; + bool m_HoveringLock; - public bool hovering { get; private set; } - public Transform hoveringRayOrigin { get; private set; } + public bool hovering { get; private set; } + public Transform hoveringRayOrigin { get; private set; } - public Material cubeMaterial { get; private set; } - public Material dropZoneMaterial { get; private set; } + public Material cubeMaterial { get; private set; } + public Material dropZoneMaterial { get; private set; } - public Action selectRow { private get; set; } + public Action selectRow { private get; set; } - public Action toggleLock { private get; set; } + public Action toggleLock { private get; set; } - public Action toggleExpanded { private get; set; } - public Action setExpanded { private get; set; } - public Func isExpanded { private get; set; } + public Action toggleExpanded { private get; set; } + public Action setExpanded { private get; set; } + public Func isExpanded { private get; set; } - protected override bool singleClickDrag { get { return false; } } + protected override bool singleClickDrag { get { return false; } } - public int extraSpace { get; private set; } + public int extraSpace { get; private set; } - public bool isStillSettling { private set; get; } + public bool isStillSettling { private set; get; } - public override void Setup(HierarchyData data) - { - base.Setup(data); + public override void Setup(HierarchyData data) + { + base.Setup(data); - // First time setup - if (cubeMaterial == null) - { - // Cube material might change for hover state, so we always instance it - m_CubeRenderer = m_Cube.GetComponent(); - cubeMaterial = MaterialUtils.GetMaterialClone(m_CubeRenderer); - m_NormalColor = cubeMaterial.color; + // First time setup + if (cubeMaterial == null) + { + // Cube material might change for hover state, so we always instance it + m_CubeRenderer = m_Cube.GetComponent(); + cubeMaterial = MaterialUtils.GetMaterialClone(m_CubeRenderer); + m_NormalColor = cubeMaterial.color; - m_LockRenderer = m_Lock.GetComponent(); - m_Lock.hoverStarted += (bh, ed) => { m_HoveringLock = true; }; - m_Lock.hoverEnded += (bh, ed) => { m_HoveringLock = false; }; - m_Lock.dragEnded += ToggleLock; + m_LockRenderer = m_Lock.GetComponent(); + m_Lock.hoverStarted += (bh, ed) => { m_HoveringLock = true; }; + m_Lock.hoverEnded += (bh, ed) => { m_HoveringLock = false; }; + m_Lock.dragEnded += ToggleLock; - m_ExpandArrowRenderer = m_ExpandArrow.GetComponent(); - m_ExpandArrow.dragEnded += ToggleExpanded; - m_Cube.dragStarted += OnDragStarted; - m_Cube.dragging += OnDragging; - m_Cube.dragEnded += OnDragEnded; - - m_Cube.hoverStarted += OnHoverStarted; - m_Cube.hoverEnded += OnHoverEnded; - - m_Cube.click += OnClick; - - m_Cube.getDropObject = GetDropObject; - m_Cube.canDrop = CanDrop; - m_Cube.receiveDrop = ReceiveDrop; - - var dropZoneRenderer = m_DropZone.GetComponent(); - dropZoneMaterial = MaterialUtils.GetMaterialClone(dropZoneRenderer); - var color = dropZoneMaterial.color; - m_DropZoneHighlightAlpha = color.a; - color.a = 0; - dropZoneMaterial.color = color; - - m_DropZone.dropHoverStarted += OnDropHoverStarted; - m_DropZone.dropHoverEnded += OnDropHoverEnded; - - m_DropZone.canDrop = CanDrop; - m_DropZone.receiveDrop = ReceiveDrop; - m_DropZone.getDropObject = GetDropObject; - - m_NormalTextColor = m_Text.color; - } - - m_CubeTransform = m_Cube.transform; - m_DropZoneTransform = m_DropZone.transform; - - var name = data.name; - if (data.gameObject == null) - { - m_SceneText.text = string.IsNullOrEmpty(name) ? "Untitled" : name; - m_SceneIcon.gameObject.SetActive(true); - m_SceneText.gameObject.SetActive(true); - m_Text.gameObject.SetActive(false); - } - else - { - m_Text.text = name; - m_SceneIcon.gameObject.SetActive(false); - m_SceneText.gameObject.SetActive(false); - m_Text.gameObject.SetActive(true); - } - - hovering = false; - } - - public void SetMaterials(Material textMaterial, Material expandArrowMaterial, Material lockIconMaterial, Material unlockIconMaterial) - { - m_Text.material = textMaterial; - m_SceneText.material = textMaterial; - m_ExpandArrowMaterial = expandArrowMaterial; - m_ExpandArrowRenderer.sharedMaterial = expandArrowMaterial; - m_LockIconMaterial = lockIconMaterial; - m_UnlockIconMaterial = unlockIconMaterial; - m_LockRenderer.sharedMaterial = unlockIconMaterial; - } - - public void UpdateSelf(float width, int depth, bool? expanded, bool selected, bool locked) - { - var cubeScale = m_CubeTransform.localScale; - cubeScale.x = width; - m_CubeTransform.localScale = cubeScale; - - var expandArrowTransform = m_ExpandArrow.transform; - - var arrowWidth = expandArrowTransform.localScale.x * 0.5f; - var halfWidth = width * 0.5f; - var indent = k_Indent * depth; - const float doubleMargin = k_Margin * 2; - expandArrowTransform.localPosition = new Vector3(k_Margin + indent - halfWidth, expandArrowTransform.localPosition.y, 0); - - m_LockRenderer.sharedMaterial = (!locked && m_HoveringLock) || (locked && !m_HoveringLock) ? m_LockIconMaterial : m_UnlockIconMaterial; - var lockIconTransform = m_Lock.transform; - var lockWidth = lockIconTransform.localScale.x * 0.5f; - - // Text is next to arrow, with a margin and indent, rotated toward camera - var gameObject = data.gameObject; - if (gameObject == null) - indent = k_Indent; - - var textTransform = gameObject ? m_Text.transform : m_SceneText.transform; - var textRectTransform = gameObject ? m_Text.rectTransform : m_SceneText.rectTransform; - textRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, (width - doubleMargin - indent) * 1 / textTransform.localScale.x); - textTransform.localPosition = new Vector3(doubleMargin + indent + arrowWidth - halfWidth, textTransform.localPosition.y, 0); - lockIconTransform.localPosition = new Vector3(halfWidth - lockWidth - k_Margin, lockIconTransform.localPosition.y, 0); - var sceneIconPosition = m_SceneIcon.localPosition; - m_SceneIcon.localPosition = new Vector3(-halfWidth + k_Margin + arrowWidth + k_Indent, sceneIconPosition.y, sceneIconPosition.z); - - var localRotation = CameraUtils.LocalRotateTowardCamera(transform.parent); - textTransform.localRotation = localRotation; - lockIconTransform.localRotation = localRotation; - m_SceneIcon.localRotation = localRotation; - - var dropZoneScale = m_DropZoneTransform.localScale; - dropZoneScale.x = width - indent; - m_DropZoneTransform.localScale = dropZoneScale; - var dropZonePosition = m_DropZoneTransform.localPosition; - dropZonePosition.x = indent * 0.5f; - m_DropZoneTransform.localPosition = dropZonePosition; - - UpdateArrow(expanded); - - var isPrefab = gameObject && PrefabUtility.GetPrefabType(gameObject) == PrefabType.PrefabInstance; - // Set selected/hover/normal color - if (selected) - { - cubeMaterial.color = hovering ? m_SelectedHoverColor : m_SelectedColor; - m_Text.color = isPrefab ? m_SelectedPrefabTextColor : m_NormalTextColor; - } - else if (hovering) - { - cubeMaterial.color = m_HoverColor; - m_Text.color = isPrefab ? m_PrefabTextColor : m_NormalTextColor; - } - else - { - cubeMaterial.color = m_NormalColor; - m_Text.color = isPrefab ? m_PrefabTextColor : m_NormalTextColor; - } - } - - public void UpdateArrow(bool? expanded, bool immediate = false) - { - if (!expanded.HasValue) - { - m_ExpandArrow.gameObject.SetActive(false); - return; - } - - m_ExpandArrow.gameObject.SetActive(data.children != null); - var expandArrowTransform = m_ExpandArrow.transform; - - // Rotate arrow for expand state - expandArrowTransform.localRotation = Quaternion.Lerp(expandArrowTransform.localRotation, - Quaternion.AngleAxis(90f, Vector3.right) * (expanded.Value ? Quaternion.AngleAxis(90f, Vector3.back) : Quaternion.identity), - immediate ? 1f : k_ExpandArrowRotateSpeed); - } - - void OnClick(BaseHandle handle, PointerEventData pointerEventData) - { - SelectFolder(); - toggleExpanded(data.index); - } - - protected override void OnGrabDragStart(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) - { - // handle will be the backing cube, not the whole row object - var row = handle.transform.parent; - if (row) - { - m_DragObject = row; - StartCoroutine(Magnetize()); - isStillSettling = true; - - m_VisibleChildren.Clear(); - OnGrabRecursive(m_VisibleChildren, eventData.rayOrigin); - startSettling(null); - } - else - { - m_DragObject = null; - } - } - - void OnGrabRecursive(List visibleChildren, Transform rayOrigin) - { - m_OldMaterials.Clear(); - var graphics = GetComponentsInChildren(true); - foreach (var graphic in graphics) - { - m_OldMaterials[graphic] = graphic.material; - graphic.material = null; - } - - m_ExpandArrowRenderer.sharedMaterial = m_NoClipExpandArrow; - m_CubeRenderer.sharedMaterial = m_NoClipBackingCube; - m_Text.transform.localRotation = Quaternion.AngleAxis(90, Vector3.right); - m_Text.material = m_NoClipText; - - m_DropZone.gameObject.SetActive(false); - m_Cube.GetComponent().enabled = false; - - setRowGrabbed(data.index, rayOrigin, true); - - if (data.children != null) - { - foreach (var child in data.children) - { - var item = getListItem(child.index) as HierarchyListItem; - if (item) - { - visibleChildren.Add(item); - item.OnGrabRecursive(visibleChildren, rayOrigin); - } - } - } - } - - protected override void OnGrabDragging(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) - { - if (m_DragObject) - { - var fieldGrabOrigin = this.GetFieldGrabOriginForRayOrigin(eventData.rayOrigin); - MagnetizeTransform(fieldGrabOrigin, m_DragObject); - var offset = 0f; - foreach (var child in m_VisibleChildren) - { - offset += m_CubeRenderer.bounds.size.y * m_StackingFraction; - MagnetizeTransform(fieldGrabOrigin, child.transform, offset); - } - } - } - - void MagnetizeTransform(Transform fieldGrabOrigin, Transform transform, float stackingOffset = 0) - { - var rotation = MathUtilsExt.ConstrainYawRotation(CameraUtils.GetMainCamera().transform.rotation) - * Quaternion.AngleAxis(90, Vector3.left); - var stackingDirection = rotation * Vector3.one; - MathUtilsExt.LerpTransform(transform, fieldGrabOrigin.position - stackingDirection * stackingOffset, rotation, m_DragLerp); - } - - protected override void OnMagnetizeEnded() - { - base.OnMagnetizeEnded(); - isStillSettling = false; - } - - protected override void OnDragEnded(BaseHandle handle, HandleEventData eventData) - { - if (m_DragObject) - { - if (this.IsOverShoulder(transform)) - { - ObjectUtils.Destroy(EditorUtility.InstanceIDToObject(data.index)); - } - - // OnHierarchyChanged doesn't happen until next frame--delay un-grab so the object doesn't start moving to the wrong spot - EditorApplication.delayCall += () => - { - OnDragEndRecursive(eventData.rayOrigin); - }; - - isStillSettling = true; - startSettling(OnDragEndAfterSettling); - } - - base.OnDragEnded(handle, eventData); - } - - void OnDragEndRecursive(Transform rayOrigin) - { - isStillSettling = false; - setRowGrabbed(data.index, rayOrigin, false); - - foreach (var child in m_VisibleChildren) - { - child.OnDragEndRecursive(rayOrigin); - } - } - - void OnDragEndAfterSettling() - { - ResetAfterSettling(); - foreach (var child in m_VisibleChildren) - { - child.ResetAfterSettling(); - } - } - - void ResetAfterSettling() - { - foreach (var kvp in m_OldMaterials) - { - kvp.Key.material = kvp.Value; - } - - m_CubeRenderer.sharedMaterial = cubeMaterial; - m_ExpandArrowRenderer.sharedMaterial = m_ExpandArrowMaterial; - m_DropZone.gameObject.SetActive(true); - m_Cube.GetComponent().enabled = true; - hovering = false; - } - - void ToggleLock(BaseHandle handle, HandleEventData eventData) - { - if (toggleLock != null) - toggleLock(data.index); - } - - void ToggleExpanded(BaseHandle handle, HandleEventData eventData) - { - toggleExpanded(data.index); - } - - void SelectFolder() - { - selectRow(data.index); - } - - void OnHoverStarted(BaseHandle handle, HandleEventData eventData) - { - hovering = true; - hoveringRayOrigin = eventData.rayOrigin; - } - - void OnHoverEnded(BaseHandle handle, HandleEventData eventData) - { - hovering = false; - hoveringRayOrigin = eventData.rayOrigin; - } - - void OnDropHoverStarted(BaseHandle handle) - { - var color = dropZoneMaterial.color; - color.a = m_DropZoneHighlightAlpha; - dropZoneMaterial.color = color; - - startSettling(null); - extraSpace = 1; - } - - void OnDropHoverEnded(BaseHandle handle) - { - var color = dropZoneMaterial.color; - color.a = 0; - dropZoneMaterial.color = color; - - startSettling(null); - extraSpace = 0; - } - - object GetDropObject(BaseHandle handle) - { - return m_DragObject ? data : null; - } - - bool CanDrop(BaseHandle handle, object dropObject) - { - if (this.IsOverShoulder(handle.transform)) - return false; - - var dropData = dropObject as HierarchyData; - if (dropData == null) - return false; - - // Dropping on own zone would otherwise move object down - if (dropObject == data) - return false; - - if (handle == m_Cube) - return true; - - var index = data.index; - if (isExpanded(index)) - return true; - - var gameObject = data.gameObject; - var dropGameObject = dropData.gameObject; - var transform = gameObject.transform; - var dropTransform = dropGameObject.transform; - - var siblings = transform.parent == null && dropTransform.parent == null - || transform.parent && dropTransform.parent == transform.parent; - - // Dropping on previous sibling's zone has no effect - if (siblings && transform.GetSiblingIndex() == dropTransform.GetSiblingIndex() - 1) - return false; - - return true; - } - - void ReceiveDrop(BaseHandle handle, object dropObject) - { - if (this.IsOverShoulder(handle.transform)) - return; - - var dropData = dropObject as HierarchyData; - if (dropData != null) - { - var index = data.index; - var gameObject = data.gameObject; - var dropGameObject = dropData.gameObject; - var transform = gameObject.transform; - var dropTransform = dropGameObject.transform; - - // OnHierarchyChanged doesn't happen until next frame--delay removal of the extra space - EditorApplication.delayCall += () => - { - extraSpace = 0; - }; - - if (handle == m_Cube) - { - dropTransform.SetParent(transform); - dropTransform.SetAsLastSibling(); - - EditorApplication.delayCall += () => { setExpanded(index, true); }; - } - else if (handle == m_DropZone) - { - if (isExpanded(index)) - { - dropTransform.SetParent(transform); - dropTransform.SetAsFirstSibling(); - } - else - { - var targetIndex = transform.GetSiblingIndex() + 1; - if (dropTransform.parent == transform.parent && dropTransform.GetSiblingIndex() < targetIndex) - targetIndex--; - - dropTransform.SetParent(transform.parent); - dropTransform.SetSiblingIndex(targetIndex); - } - } - } - } - - void OnDestroy() - { - ObjectUtils.Destroy(cubeMaterial); - ObjectUtils.Destroy(dropZoneMaterial); - } - } + m_ExpandArrowRenderer = m_ExpandArrow.GetComponent(); + m_ExpandArrow.dragEnded += ToggleExpanded; + m_Cube.dragStarted += OnDragStarted; + m_Cube.dragging += OnDragging; + m_Cube.dragEnded += OnDragEnded; + + m_Cube.hoverStarted += OnHoverStarted; + m_Cube.hoverEnded += OnHoverEnded; + + m_Cube.click += OnClick; + + m_Cube.getDropObject = GetDropObject; + m_Cube.canDrop = CanDrop; + m_Cube.receiveDrop = ReceiveDrop; + + var dropZoneRenderer = m_DropZone.GetComponent(); + dropZoneMaterial = MaterialUtils.GetMaterialClone(dropZoneRenderer); + var color = dropZoneMaterial.color; + m_DropZoneHighlightAlpha = color.a; + color.a = 0; + dropZoneMaterial.color = color; + + m_DropZone.dropHoverStarted += OnDropHoverStarted; + m_DropZone.dropHoverEnded += OnDropHoverEnded; + + m_DropZone.canDrop = CanDrop; + m_DropZone.receiveDrop = ReceiveDrop; + m_DropZone.getDropObject = GetDropObject; + + m_NormalTextColor = m_Text.color; + } + + m_CubeTransform = m_Cube.transform; + m_DropZoneTransform = m_DropZone.transform; + + var name = data.name; + if (data.gameObject == null) + { + m_SceneText.text = string.IsNullOrEmpty(name) ? "Untitled" : name; + m_SceneIcon.gameObject.SetActive(true); + m_SceneText.gameObject.SetActive(true); + m_Text.gameObject.SetActive(false); + } + else + { + m_Text.text = name; + m_SceneIcon.gameObject.SetActive(false); + m_SceneText.gameObject.SetActive(false); + m_Text.gameObject.SetActive(true); + } + + hovering = false; + } + + public void SetMaterials(Material textMaterial, Material expandArrowMaterial, Material lockIconMaterial, Material unlockIconMaterial) + { + m_Text.material = textMaterial; + m_SceneText.material = textMaterial; + m_ExpandArrowMaterial = expandArrowMaterial; + m_ExpandArrowRenderer.sharedMaterial = expandArrowMaterial; + m_LockIconMaterial = lockIconMaterial; + m_UnlockIconMaterial = unlockIconMaterial; + m_LockRenderer.sharedMaterial = unlockIconMaterial; + } + + public void UpdateSelf(float width, int depth, bool? expanded, bool selected, bool locked) + { + var cubeScale = m_CubeTransform.localScale; + cubeScale.x = width; + m_CubeTransform.localScale = cubeScale; + + var expandArrowTransform = m_ExpandArrow.transform; + + var arrowWidth = expandArrowTransform.localScale.x * 0.5f; + var halfWidth = width * 0.5f; + var indent = k_Indent * depth; + const float doubleMargin = k_Margin * 2; + expandArrowTransform.localPosition = new Vector3(k_Margin + indent - halfWidth, expandArrowTransform.localPosition.y, 0); + + m_LockRenderer.sharedMaterial = (!locked && m_HoveringLock) || (locked && !m_HoveringLock) ? m_LockIconMaterial : m_UnlockIconMaterial; + var lockIconTransform = m_Lock.transform; + var lockWidth = lockIconTransform.localScale.x * 0.5f; + + // Text is next to arrow, with a margin and indent, rotated toward camera + var gameObject = data.gameObject; + if (gameObject == null) + indent = k_Indent; + + var textTransform = gameObject ? m_Text.transform : m_SceneText.transform; + var textRectTransform = gameObject ? m_Text.rectTransform : m_SceneText.rectTransform; + textRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, (width - doubleMargin - indent) * 1 / textTransform.localScale.x); + textTransform.localPosition = new Vector3(doubleMargin + indent + arrowWidth - halfWidth, textTransform.localPosition.y, 0); + lockIconTransform.localPosition = new Vector3(halfWidth - lockWidth - k_Margin, lockIconTransform.localPosition.y, 0); + var sceneIconPosition = m_SceneIcon.localPosition; + m_SceneIcon.localPosition = new Vector3(-halfWidth + k_Margin + arrowWidth + k_Indent, sceneIconPosition.y, sceneIconPosition.z); + + var localRotation = CameraUtils.LocalRotateTowardCamera(transform.parent); + textTransform.localRotation = localRotation; + lockIconTransform.localRotation = localRotation; + m_SceneIcon.localRotation = localRotation; + + var dropZoneScale = m_DropZoneTransform.localScale; + dropZoneScale.x = width - indent; + m_DropZoneTransform.localScale = dropZoneScale; + var dropZonePosition = m_DropZoneTransform.localPosition; + dropZonePosition.x = indent * 0.5f; + m_DropZoneTransform.localPosition = dropZonePosition; + + UpdateArrow(expanded); + + var isPrefab = gameObject && PrefabUtility.GetPrefabType(gameObject) == PrefabType.PrefabInstance; + + // Set selected/hover/normal color + if (selected) + { + cubeMaterial.color = hovering ? m_SelectedHoverColor : m_SelectedColor; + m_Text.color = isPrefab ? m_SelectedPrefabTextColor : m_NormalTextColor; + } + else if (hovering) + { + cubeMaterial.color = m_HoverColor; + m_Text.color = isPrefab ? m_PrefabTextColor : m_NormalTextColor; + } + else + { + cubeMaterial.color = m_NormalColor; + m_Text.color = isPrefab ? m_PrefabTextColor : m_NormalTextColor; + } + } + + public void UpdateArrow(bool? expanded, bool immediate = false) + { + if (!expanded.HasValue) + { + m_ExpandArrow.gameObject.SetActive(false); + return; + } + + m_ExpandArrow.gameObject.SetActive(data.children != null); + var expandArrowTransform = m_ExpandArrow.transform; + + // Rotate arrow for expand state + expandArrowTransform.localRotation = Quaternion.Lerp(expandArrowTransform.localRotation, + Quaternion.AngleAxis(90f, Vector3.right) * (expanded.Value ? Quaternion.AngleAxis(90f, Vector3.back) : Quaternion.identity), + immediate ? 1f : k_ExpandArrowRotateSpeed); + } + + void OnClick(BaseHandle handle, PointerEventData pointerEventData) + { + SelectFolder(); + toggleExpanded(data.index); + } + + protected override void OnGrabDragStart(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) + { + // handle will be the backing cube, not the whole row object + var row = handle.transform.parent; + if (row) + { + m_DragObject = row; + StartCoroutine(Magnetize()); + isStillSettling = true; + + m_VisibleChildren.Clear(); + OnGrabRecursive(m_VisibleChildren, eventData.rayOrigin); + startSettling(null); + } + else + { + m_DragObject = null; + } + } + + void OnGrabRecursive(List visibleChildren, Transform rayOrigin) + { + m_OldMaterials.Clear(); + var graphics = GetComponentsInChildren(true); + foreach (var graphic in graphics) + { + m_OldMaterials[graphic] = graphic.material; + graphic.material = null; + } + + m_ExpandArrowRenderer.sharedMaterial = m_NoClipExpandArrow; + m_CubeRenderer.sharedMaterial = m_NoClipBackingCube; + m_Text.transform.localRotation = Quaternion.AngleAxis(90, Vector3.right); + m_Text.material = m_NoClipText; + + m_DropZone.gameObject.SetActive(false); + m_Cube.GetComponent().enabled = false; + + setRowGrabbed(data.index, rayOrigin, true); + + if (data.children != null) + { + foreach (var child in data.children) + { + var item = getListItem(child.index) as HierarchyListItem; + if (item) + { + visibleChildren.Add(item); + item.OnGrabRecursive(visibleChildren, rayOrigin); + } + } + } + } + + protected override void OnGrabDragging(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) + { + if (m_DragObject) + { + var fieldGrabOrigin = this.GetFieldGrabOriginForRayOrigin(eventData.rayOrigin); + MagnetizeTransform(fieldGrabOrigin, m_DragObject); + var offset = 0f; + foreach (var child in m_VisibleChildren) + { + offset += m_CubeRenderer.bounds.size.y * m_StackingFraction; + MagnetizeTransform(fieldGrabOrigin, child.transform, offset); + } + } + } + + void MagnetizeTransform(Transform fieldGrabOrigin, Transform transform, float stackingOffset = 0) + { + var rotation = MathUtilsExt.ConstrainYawRotation(CameraUtils.GetMainCamera().transform.rotation) + * Quaternion.AngleAxis(90, Vector3.left); + var stackingDirection = rotation * Vector3.one; + MathUtilsExt.LerpTransform(transform, fieldGrabOrigin.position - stackingDirection * stackingOffset, rotation, m_DragLerp); + } + + protected override void OnMagnetizeEnded() + { + base.OnMagnetizeEnded(); + isStillSettling = false; + } + + protected override void OnDragEnded(BaseHandle handle, HandleEventData eventData) + { + if (m_DragObject) + { + if (this.IsOverShoulder(transform)) + { + ObjectUtils.Destroy(EditorUtility.InstanceIDToObject(data.index)); + } + + // OnHierarchyChanged doesn't happen until next frame--delay un-grab so the object doesn't start moving to the wrong spot + EditorApplication.delayCall += () => { OnDragEndRecursive(eventData.rayOrigin); }; + + isStillSettling = true; + startSettling(OnDragEndAfterSettling); + } + + base.OnDragEnded(handle, eventData); + } + + void OnDragEndRecursive(Transform rayOrigin) + { + isStillSettling = false; + setRowGrabbed(data.index, rayOrigin, false); + + foreach (var child in m_VisibleChildren) + { + child.OnDragEndRecursive(rayOrigin); + } + } + + void OnDragEndAfterSettling() + { + ResetAfterSettling(); + foreach (var child in m_VisibleChildren) + { + child.ResetAfterSettling(); + } + } + + void ResetAfterSettling() + { + foreach (var kvp in m_OldMaterials) + { + kvp.Key.material = kvp.Value; + } + + m_CubeRenderer.sharedMaterial = cubeMaterial; + m_ExpandArrowRenderer.sharedMaterial = m_ExpandArrowMaterial; + m_DropZone.gameObject.SetActive(true); + m_Cube.GetComponent().enabled = true; + hovering = false; + } + + void ToggleLock(BaseHandle handle, HandleEventData eventData) + { + if (toggleLock != null) + toggleLock(data.index); + } + + void ToggleExpanded(BaseHandle handle, HandleEventData eventData) + { + toggleExpanded(data.index); + } + + void SelectFolder() + { + selectRow(data.index); + } + + void OnHoverStarted(BaseHandle handle, HandleEventData eventData) + { + hovering = true; + hoveringRayOrigin = eventData.rayOrigin; + } + + void OnHoverEnded(BaseHandle handle, HandleEventData eventData) + { + hovering = false; + hoveringRayOrigin = eventData.rayOrigin; + } + + void OnDropHoverStarted(BaseHandle handle) + { + var color = dropZoneMaterial.color; + color.a = m_DropZoneHighlightAlpha; + dropZoneMaterial.color = color; + + startSettling(null); + extraSpace = 1; + } + + void OnDropHoverEnded(BaseHandle handle) + { + var color = dropZoneMaterial.color; + color.a = 0; + dropZoneMaterial.color = color; + + startSettling(null); + extraSpace = 0; + } + + object GetDropObject(BaseHandle handle) + { + return m_DragObject ? data : null; + } + + bool CanDrop(BaseHandle handle, object dropObject) + { + if (this.IsOverShoulder(handle.transform)) + return false; + + var dropData = dropObject as HierarchyData; + if (dropData == null) + return false; + + // Dropping on own zone would otherwise move object down + if (dropObject == data) + return false; + + if (handle == m_Cube) + return true; + + var index = data.index; + if (isExpanded(index)) + return true; + + var gameObject = data.gameObject; + var dropGameObject = dropData.gameObject; + var transform = gameObject.transform; + var dropTransform = dropGameObject.transform; + + var siblings = transform.parent == null && dropTransform.parent == null + || transform.parent && dropTransform.parent == transform.parent; + + // Dropping on previous sibling's zone has no effect + if (siblings && transform.GetSiblingIndex() == dropTransform.GetSiblingIndex() - 1) + return false; + + return true; + } + + void ReceiveDrop(BaseHandle handle, object dropObject) + { + if (this.IsOverShoulder(handle.transform)) + return; + + var dropData = dropObject as HierarchyData; + if (dropData != null) + { + var index = data.index; + var gameObject = data.gameObject; + var dropGameObject = dropData.gameObject; + var transform = gameObject.transform; + var dropTransform = dropGameObject.transform; + + // OnHierarchyChanged doesn't happen until next frame--delay removal of the extra space + EditorApplication.delayCall += () => { extraSpace = 0; }; + + if (handle == m_Cube) + { + dropTransform.SetParent(transform); + dropTransform.SetAsLastSibling(); + + EditorApplication.delayCall += () => { setExpanded(index, true); }; + } + else if (handle == m_DropZone) + { + if (isExpanded(index)) + { + dropTransform.SetParent(transform); + dropTransform.SetAsFirstSibling(); + } + else + { + var targetIndex = transform.GetSiblingIndex() + 1; + if (dropTransform.parent == transform.parent && dropTransform.GetSiblingIndex() < targetIndex) + targetIndex--; + + dropTransform.SetParent(transform.parent); + dropTransform.SetSiblingIndex(targetIndex); + } + } + } + } + + void OnDestroy() + { + ObjectUtils.Destroy(cubeMaterial); + ObjectUtils.Destroy(dropZoneMaterial); + } + } } + #endif diff --git a/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs b/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs index 515a27ff1..82818264c 100644 --- a/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs +++ b/Workspaces/HierarchyWorkspace/Scripts/HierarchyListViewController.cs @@ -9,426 +9,428 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class HierarchyListViewController : NestedListViewController, IUsesGameObjectLocking, ISetHighlight - { - const float k_ClipMargin = 0.001f; // Give the cubes a margin so that their sides don't get clipped - - [SerializeField] - BaseHandle m_TopDropZone; - - [SerializeField] - BaseHandle m_BottomDropZone; - - [SerializeField] - Material m_TextMaterial; - - [SerializeField] - Material m_ExpandArrowMaterial; - - [SerializeField] - Material m_LockIconMaterial; - - [SerializeField] - Material m_UnlockIconMaterial; - - Material m_TopDropZoneMaterial; - Material m_BottomDropZoneMaterial; - float m_DropZoneAlpha; - float m_BottomDropZoneStartHeight; - float m_VisibleItemHeight; - - int m_SelectedRow; - - readonly List> m_HoveredGameObjects = new List>(); - - public override List data - { - set - { - base.data = value; - - if (m_Data != null && m_Data.Count > 0) - { - // Remove any objects that don't exist any more - var missingKeys = m_Data.Select(d => d.index).Except(m_ExpandStates.Keys); - foreach (var key in missingKeys) - { - m_ExpandStates.Remove(key); - } - - // Expand the scenes by default - foreach (var scene in m_Data) - { - var instanceID = scene.index; - if (!m_ExpandStates.ContainsKey(instanceID)) - m_ExpandStates[instanceID] = true; - } - - foreach (var d in m_Data) - { - if (!m_ExpandStates.ContainsKey(d.index)) - m_ExpandStates[d.index] = false; - } - } - } - } - - public string lockedQueryString { private get; set; } - - public Action selectRow { private get; set; } - - public Func matchesFilter { private get; set; } - public Func getSearchQuery { private get; set; } - - protected override void Setup() - { - base.Setup(); - - m_TextMaterial = Instantiate(m_TextMaterial); - m_ExpandArrowMaterial = Instantiate(m_ExpandArrowMaterial); - m_LockIconMaterial = Instantiate(m_LockIconMaterial); - m_UnlockIconMaterial = Instantiate(m_UnlockIconMaterial); - - m_BottomDropZoneMaterial = MaterialUtils.GetMaterialClone(m_BottomDropZone.GetComponent()); - m_BottomDropZoneStartHeight = m_BottomDropZone.transform.localScale.z; - m_TopDropZoneMaterial = MaterialUtils.GetMaterialClone(m_TopDropZone.GetComponent()); - var color = m_TopDropZoneMaterial.color; - m_DropZoneAlpha = color.a; - color.a = 0; - m_TopDropZoneMaterial.color = color; - m_BottomDropZoneMaterial.color = color; - - var dropZones = new[] { m_BottomDropZone, m_TopDropZone }; - foreach (var dropZone in dropZones) - { - dropZone.canDrop = CanDrop; - dropZone.receiveDrop = RecieveDrop; - dropZone.dropHoverStarted += DropHoverStarted; - dropZone.dropHoverEnded += DropHoverEnded; - } - - m_BottomDropZone.gameObject.SetActive(false); // Don't block scroll interaction - } - - protected override void UpdateItems() - { - var parentMatrix = transform.worldToLocalMatrix; - SetMaterialClip(m_TextMaterial, parentMatrix); - SetMaterialClip(m_ExpandArrowMaterial, parentMatrix); - SetMaterialClip(m_LockIconMaterial, parentMatrix); - SetMaterialClip(m_UnlockIconMaterial, parentMatrix); - - m_VisibleItemHeight = 0; - - base.UpdateItems(); - - UpdateDropZones(); - } - - void UpdateDropZones() - { - var width = m_Size.x - k_ClipMargin; - var dropZoneTransform = m_TopDropZone.transform; - var dropZoneScale = dropZoneTransform.localScale; - dropZoneScale.x = width; - dropZoneTransform.localScale = dropZoneScale; - - var extentsZ = m_Extents.z; - var dropZonePosition = dropZoneTransform.localPosition; - dropZonePosition.z = extentsZ + dropZoneScale.z * 0.5f; - dropZoneTransform.localPosition = dropZonePosition; - - dropZoneTransform = m_BottomDropZone.transform; - dropZoneScale = dropZoneTransform.localScale; - dropZoneScale.x = width; - var itemSize = m_ItemSize.Value.z; - var extraSpace = extentsZ - m_VisibleItemHeight - scrollOffset % itemSize; - dropZoneScale.z = extraSpace; - - dropZoneTransform.localScale = dropZoneScale; - - dropZonePosition = dropZoneTransform.localPosition; - dropZonePosition.z = dropZoneScale.z * 0.5f - extentsZ; - dropZoneTransform.localPosition = dropZonePosition; - - if (extraSpace < m_BottomDropZoneStartHeight) - { - dropZoneScale.z = m_BottomDropZoneStartHeight; - dropZoneTransform.localScale = dropZoneScale; - dropZonePosition.z = -dropZoneScale.z * 0.5f - extentsZ; - } - } - - void UpdateHierarchyItem(HierarchyData data, int order, ref float offset, int depth, bool? expanded, ref bool doneSettling) - { - var index = data.index; - HierarchyListItem item; - if (!m_ListItems.TryGetValue(index, out item)) - item = GetItem(data); - - var go = data.gameObject; - var kvp = new KeyValuePair(item.hoveringRayOrigin, go); - // Multiple rays can hover and unhover, so it's necessary to keep track of when hover state changes, so that - // highlights can be turned on or off - if (item.hovering || m_HoveredGameObjects.Remove(kvp)) - { - this.SetHighlight(go, item.hovering, item.hoveringRayOrigin, force: item.hovering); - - if (item.hovering) - m_HoveredGameObjects.Add(kvp); - } - - var width = m_Size.x - k_ClipMargin; - var locked = this.IsLocked(data.gameObject); - item.UpdateSelf(width, depth, expanded, index == m_SelectedRow, locked); - - SetMaterialClip(item.cubeMaterial, transform.worldToLocalMatrix); - SetMaterialClip(item.dropZoneMaterial, transform.worldToLocalMatrix); - - m_VisibleItemHeight+= itemSize.z; - UpdateItem(item.transform, order, offset + m_ScrollOffset, ref doneSettling); - - var extraSpace = item.extraSpace * itemSize.z; - offset += extraSpace; - m_VisibleItemHeight += extraSpace; - } - - protected override void UpdateRecursively(List data, ref int order, ref float offset, ref bool doneSettling, int depth = 0) - { - for (int i = 0; i < data.Count; i++) - { - var datum = data[i]; - var index = datum.index; - bool expanded; - m_ExpandStates.TryGetValue(index, out expanded); - - var grabbed = m_GrabbedRows.ContainsKey(index); - - if (grabbed) - { - var item = GetListItem(index); - if (item && item.isStillSettling) // "Hang on" to settle state until grabbed object is settled in the list - doneSettling = false; - continue; - } - - var hasChildren = datum.children != null; - - var searchQuery = getSearchQuery(); - - var hasLockedQuery = searchQuery.Contains(lockedQueryString); - if (hasLockedQuery) - searchQuery = searchQuery.Replace(lockedQueryString, string.Empty).Trim(); - - var hasFilterQuery = !string.IsNullOrEmpty(searchQuery); - - var shouldRecycle = offset + scrollOffset + itemSize.z < 0 || offset + scrollOffset > m_Size.z; - - if (hasLockedQuery || hasFilterQuery) - { - var filterTestPass = true; - - if (hasLockedQuery) - filterTestPass = this.IsLocked(datum.gameObject); - - if (hasFilterQuery) - filterTestPass &= datum.types.Any(type => matchesFilter(type)); - - if (!filterTestPass) // If this item doesn't match, then move on to the next item; do not count - { - Recycle(index); - } - else - { - if (shouldRecycle) - Recycle(index); - else - UpdateHierarchyItem(datum, order++, ref offset, 0, null, ref doneSettling); - - offset += itemSize.z; - } - - if (hasChildren) - UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling); - } - else - { - if (shouldRecycle) - Recycle(index); - else - UpdateHierarchyItem(datum, order++, ref offset, depth, expanded, ref doneSettling); - - offset += itemSize.z; - - if (hasChildren) - { - if (expanded) - UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling, depth + 1); - else - RecycleChildren(datum); - } - else - { - m_ExpandStates[index] = false; - } - } - } - } - - protected override HierarchyListItem GetItem(HierarchyData data) - { - var item = base.GetItem(data); - item.SetMaterials(m_TextMaterial, m_ExpandArrowMaterial, m_LockIconMaterial, m_UnlockIconMaterial); - item.selectRow = SelectRow; - - item.setRowGrabbed = SetRowGrabbed; - item.getGrabbedRow = GetGrabbedRow; - - item.toggleLock = ToggleLock; - - item.toggleExpanded = ToggleExpanded; - item.setExpanded = SetExpanded; - item.isExpanded = GetExpanded; - - item.UpdateArrow(GetExpanded(data.index), true); - - return item; - } - - protected override void SetRowGrabbed(int index, Transform rayOrigin, bool grabbed) - { - base.SetRowGrabbed(index, rayOrigin, grabbed); - m_BottomDropZone.gameObject.SetActive(m_GrabbedRows.Count > 0); // Don't block scroll interaction - } - - void ToggleLock(int index) - { - HierarchyListItem listItem; - if (m_ListItems.TryGetValue(index, out listItem)) - { - var data = listItem.data; - var go = data.gameObject; - this.SetLocked(go, !this.IsLocked(go)); - } - } - - void ToggleExpanded(int index) - { - bool expanded; - if (!m_ExpandStates.TryGetValue(index, out expanded)) - m_ExpandStates[index] = true; - else - m_ExpandStates[index] = !expanded; - - StartSettling(); - } - - public void SelectRow(int index) - { - if (data == null) - return; - - m_SelectedRow = index; - - foreach (var datum in data) - { - ExpandToRow(datum, index); - } - - selectRow(index); - - var scrollHeight = 0f; - foreach (var datum in data) - { - ScrollToIndex(datum, index, ref scrollHeight); - } - } - - bool ExpandToRow(HierarchyData container, int rowID) - { - var index = container.index; - if (index == rowID) - { - return true; - } - - var found = false; - if (container.children != null) - { - foreach (var child in container.children) - { - if (ExpandToRow(child, rowID)) - found = true; - } - } - - if (found) - m_ExpandStates[index] = true; - - return found; - } - - static bool CanDrop(BaseHandle handle, object dropObject) - { - return dropObject is HierarchyData; - } - - void RecieveDrop(BaseHandle handle, object dropObject) - { - if (handle == m_TopDropZone) - { - var hierarchyData = dropObject as HierarchyData; - if (hierarchyData != null) - { - var gameObject = hierarchyData.gameObject; - gameObject.transform.SetParent(null); - gameObject.transform.SetAsFirstSibling(); - } - } - - if (handle == m_BottomDropZone) - { - var hierarchyData = dropObject as HierarchyData; - if (hierarchyData != null) - { - var gameObject = hierarchyData.gameObject; - gameObject.transform.SetParent(null); - gameObject.transform.SetAsLastSibling(); - } - } - } - - void DropHoverStarted(BaseHandle handle) - { - var material = handle == m_TopDropZone ? m_TopDropZoneMaterial : m_BottomDropZoneMaterial; - var color = material.color; - color.a = m_DropZoneAlpha; - material.color = color; - } - - void DropHoverEnded(BaseHandle handle) - { - var material = handle == m_TopDropZone ? m_TopDropZoneMaterial : m_BottomDropZoneMaterial; - var color = material.color; - color.a = 0; - material.color = color; - } - - public void OnScroll(float delta) - { - if (m_Settling) - return; - - scrollOffset += delta; - } - - void OnDestroy() - { - ObjectUtils.Destroy(m_TextMaterial); - ObjectUtils.Destroy(m_ExpandArrowMaterial); - ObjectUtils.Destroy(m_LockIconMaterial); - ObjectUtils.Destroy(m_UnlockIconMaterial); - } - } + sealed class HierarchyListViewController : NestedListViewController, IUsesGameObjectLocking, ISetHighlight + { + const float k_ClipMargin = 0.001f; // Give the cubes a margin so that their sides don't get clipped + + [SerializeField] + BaseHandle m_TopDropZone; + + [SerializeField] + BaseHandle m_BottomDropZone; + + [SerializeField] + Material m_TextMaterial; + + [SerializeField] + Material m_ExpandArrowMaterial; + + [SerializeField] + Material m_LockIconMaterial; + + [SerializeField] + Material m_UnlockIconMaterial; + + Material m_TopDropZoneMaterial; + Material m_BottomDropZoneMaterial; + float m_DropZoneAlpha; + float m_BottomDropZoneStartHeight; + float m_VisibleItemHeight; + + int m_SelectedRow; + + readonly List> m_HoveredGameObjects = new List>(); + + public override List data + { + set + { + base.data = value; + + if (m_Data != null && m_Data.Count > 0) + { + // Remove any objects that don't exist any more + var missingKeys = m_Data.Select(d => d.index).Except(m_ExpandStates.Keys); + foreach (var key in missingKeys) + { + m_ExpandStates.Remove(key); + } + + // Expand the scenes by default + foreach (var scene in m_Data) + { + var instanceID = scene.index; + if (!m_ExpandStates.ContainsKey(instanceID)) + m_ExpandStates[instanceID] = true; + } + + foreach (var d in m_Data) + { + if (!m_ExpandStates.ContainsKey(d.index)) + m_ExpandStates[d.index] = false; + } + } + } + } + + public string lockedQueryString { private get; set; } + + public Action selectRow { private get; set; } + + public Func matchesFilter { private get; set; } + public Func getSearchQuery { private get; set; } + + protected override void Setup() + { + base.Setup(); + + m_TextMaterial = Instantiate(m_TextMaterial); + m_ExpandArrowMaterial = Instantiate(m_ExpandArrowMaterial); + m_LockIconMaterial = Instantiate(m_LockIconMaterial); + m_UnlockIconMaterial = Instantiate(m_UnlockIconMaterial); + + m_BottomDropZoneMaterial = MaterialUtils.GetMaterialClone(m_BottomDropZone.GetComponent()); + m_BottomDropZoneStartHeight = m_BottomDropZone.transform.localScale.z; + m_TopDropZoneMaterial = MaterialUtils.GetMaterialClone(m_TopDropZone.GetComponent()); + var color = m_TopDropZoneMaterial.color; + m_DropZoneAlpha = color.a; + color.a = 0; + m_TopDropZoneMaterial.color = color; + m_BottomDropZoneMaterial.color = color; + + var dropZones = new[] { m_BottomDropZone, m_TopDropZone }; + foreach (var dropZone in dropZones) + { + dropZone.canDrop = CanDrop; + dropZone.receiveDrop = RecieveDrop; + dropZone.dropHoverStarted += DropHoverStarted; + dropZone.dropHoverEnded += DropHoverEnded; + } + + m_BottomDropZone.gameObject.SetActive(false); // Don't block scroll interaction + } + + protected override void UpdateItems() + { + var parentMatrix = transform.worldToLocalMatrix; + SetMaterialClip(m_TextMaterial, parentMatrix); + SetMaterialClip(m_ExpandArrowMaterial, parentMatrix); + SetMaterialClip(m_LockIconMaterial, parentMatrix); + SetMaterialClip(m_UnlockIconMaterial, parentMatrix); + + m_VisibleItemHeight = 0; + + base.UpdateItems(); + + UpdateDropZones(); + } + + void UpdateDropZones() + { + var width = m_Size.x - k_ClipMargin; + var dropZoneTransform = m_TopDropZone.transform; + var dropZoneScale = dropZoneTransform.localScale; + dropZoneScale.x = width; + dropZoneTransform.localScale = dropZoneScale; + + var extentsZ = m_Extents.z; + var dropZonePosition = dropZoneTransform.localPosition; + dropZonePosition.z = extentsZ + dropZoneScale.z * 0.5f; + dropZoneTransform.localPosition = dropZonePosition; + + dropZoneTransform = m_BottomDropZone.transform; + dropZoneScale = dropZoneTransform.localScale; + dropZoneScale.x = width; + var itemSize = m_ItemSize.Value.z; + var extraSpace = extentsZ - m_VisibleItemHeight - scrollOffset % itemSize; + dropZoneScale.z = extraSpace; + + dropZoneTransform.localScale = dropZoneScale; + + dropZonePosition = dropZoneTransform.localPosition; + dropZonePosition.z = dropZoneScale.z * 0.5f - extentsZ; + dropZoneTransform.localPosition = dropZonePosition; + + if (extraSpace < m_BottomDropZoneStartHeight) + { + dropZoneScale.z = m_BottomDropZoneStartHeight; + dropZoneTransform.localScale = dropZoneScale; + dropZonePosition.z = -dropZoneScale.z * 0.5f - extentsZ; + } + } + + void UpdateHierarchyItem(HierarchyData data, int order, ref float offset, int depth, bool? expanded, ref bool doneSettling) + { + var index = data.index; + HierarchyListItem item; + if (!m_ListItems.TryGetValue(index, out item)) + item = GetItem(data); + + var go = data.gameObject; + var kvp = new KeyValuePair(item.hoveringRayOrigin, go); + + // Multiple rays can hover and unhover, so it's necessary to keep track of when hover state changes, so that + // highlights can be turned on or off + if (item.hovering || m_HoveredGameObjects.Remove(kvp)) + { + this.SetHighlight(go, item.hovering, item.hoveringRayOrigin, force: item.hovering); + + if (item.hovering) + m_HoveredGameObjects.Add(kvp); + } + + var width = m_Size.x - k_ClipMargin; + var locked = this.IsLocked(data.gameObject); + item.UpdateSelf(width, depth, expanded, index == m_SelectedRow, locked); + + SetMaterialClip(item.cubeMaterial, transform.worldToLocalMatrix); + SetMaterialClip(item.dropZoneMaterial, transform.worldToLocalMatrix); + + m_VisibleItemHeight += itemSize.z; + UpdateItem(item.transform, order, offset + m_ScrollOffset, ref doneSettling); + + var extraSpace = item.extraSpace * itemSize.z; + offset += extraSpace; + m_VisibleItemHeight += extraSpace; + } + + protected override void UpdateRecursively(List data, ref int order, ref float offset, ref bool doneSettling, int depth = 0) + { + for (int i = 0; i < data.Count; i++) + { + var datum = data[i]; + var index = datum.index; + bool expanded; + m_ExpandStates.TryGetValue(index, out expanded); + + var grabbed = m_GrabbedRows.ContainsKey(index); + + if (grabbed) + { + var item = GetListItem(index); + if (item && item.isStillSettling) // "Hang on" to settle state until grabbed object is settled in the list + doneSettling = false; + continue; + } + + var hasChildren = datum.children != null; + + var searchQuery = getSearchQuery(); + + var hasLockedQuery = searchQuery.Contains(lockedQueryString); + if (hasLockedQuery) + searchQuery = searchQuery.Replace(lockedQueryString, string.Empty).Trim(); + + var hasFilterQuery = !string.IsNullOrEmpty(searchQuery); + + var shouldRecycle = offset + scrollOffset + itemSize.z < 0 || offset + scrollOffset > m_Size.z; + + if (hasLockedQuery || hasFilterQuery) + { + var filterTestPass = true; + + if (hasLockedQuery) + filterTestPass = this.IsLocked(datum.gameObject); + + if (hasFilterQuery) + filterTestPass &= datum.types.Any(type => matchesFilter(type)); + + if (!filterTestPass) // If this item doesn't match, then move on to the next item; do not count + { + Recycle(index); + } + else + { + if (shouldRecycle) + Recycle(index); + else + UpdateHierarchyItem(datum, order++, ref offset, 0, null, ref doneSettling); + + offset += itemSize.z; + } + + if (hasChildren) + UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling); + } + else + { + if (shouldRecycle) + Recycle(index); + else + UpdateHierarchyItem(datum, order++, ref offset, depth, expanded, ref doneSettling); + + offset += itemSize.z; + + if (hasChildren) + { + if (expanded) + UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling, depth + 1); + else + RecycleChildren(datum); + } + else + { + m_ExpandStates[index] = false; + } + } + } + } + + protected override HierarchyListItem GetItem(HierarchyData data) + { + var item = base.GetItem(data); + item.SetMaterials(m_TextMaterial, m_ExpandArrowMaterial, m_LockIconMaterial, m_UnlockIconMaterial); + item.selectRow = SelectRow; + + item.setRowGrabbed = SetRowGrabbed; + item.getGrabbedRow = GetGrabbedRow; + + item.toggleLock = ToggleLock; + + item.toggleExpanded = ToggleExpanded; + item.setExpanded = SetExpanded; + item.isExpanded = GetExpanded; + + item.UpdateArrow(GetExpanded(data.index), true); + + return item; + } + + protected override void SetRowGrabbed(int index, Transform rayOrigin, bool grabbed) + { + base.SetRowGrabbed(index, rayOrigin, grabbed); + m_BottomDropZone.gameObject.SetActive(m_GrabbedRows.Count > 0); // Don't block scroll interaction + } + + void ToggleLock(int index) + { + HierarchyListItem listItem; + if (m_ListItems.TryGetValue(index, out listItem)) + { + var data = listItem.data; + var go = data.gameObject; + this.SetLocked(go, !this.IsLocked(go)); + } + } + + void ToggleExpanded(int index) + { + bool expanded; + if (!m_ExpandStates.TryGetValue(index, out expanded)) + m_ExpandStates[index] = true; + else + m_ExpandStates[index] = !expanded; + + StartSettling(); + } + + public void SelectRow(int index) + { + if (data == null) + return; + + m_SelectedRow = index; + + foreach (var datum in data) + { + ExpandToRow(datum, index); + } + + selectRow(index); + + var scrollHeight = 0f; + foreach (var datum in data) + { + ScrollToIndex(datum, index, ref scrollHeight); + } + } + + bool ExpandToRow(HierarchyData container, int rowID) + { + var index = container.index; + if (index == rowID) + { + return true; + } + + var found = false; + if (container.children != null) + { + foreach (var child in container.children) + { + if (ExpandToRow(child, rowID)) + found = true; + } + } + + if (found) + m_ExpandStates[index] = true; + + return found; + } + + static bool CanDrop(BaseHandle handle, object dropObject) + { + return dropObject is HierarchyData; + } + + void RecieveDrop(BaseHandle handle, object dropObject) + { + if (handle == m_TopDropZone) + { + var hierarchyData = dropObject as HierarchyData; + if (hierarchyData != null) + { + var gameObject = hierarchyData.gameObject; + gameObject.transform.SetParent(null); + gameObject.transform.SetAsFirstSibling(); + } + } + + if (handle == m_BottomDropZone) + { + var hierarchyData = dropObject as HierarchyData; + if (hierarchyData != null) + { + var gameObject = hierarchyData.gameObject; + gameObject.transform.SetParent(null); + gameObject.transform.SetAsLastSibling(); + } + } + } + + void DropHoverStarted(BaseHandle handle) + { + var material = handle == m_TopDropZone ? m_TopDropZoneMaterial : m_BottomDropZoneMaterial; + var color = material.color; + color.a = m_DropZoneAlpha; + material.color = color; + } + + void DropHoverEnded(BaseHandle handle) + { + var material = handle == m_TopDropZone ? m_TopDropZoneMaterial : m_BottomDropZoneMaterial; + var color = material.color; + color.a = 0; + material.color = color; + } + + public void OnScroll(float delta) + { + if (m_Settling) + return; + + scrollOffset += delta; + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_TextMaterial); + ObjectUtils.Destroy(m_ExpandArrowMaterial); + ObjectUtils.Destroy(m_LockIconMaterial); + ObjectUtils.Destroy(m_UnlockIconMaterial); + } + } } + #endif diff --git a/Workspaces/HierarchyWorkspace/Scripts/HierarchyUI.cs b/Workspaces/HierarchyWorkspace/Scripts/HierarchyUI.cs index d2b06c1ad..f17529c92 100644 --- a/Workspaces/HierarchyWorkspace/Scripts/HierarchyUI.cs +++ b/Workspaces/HierarchyWorkspace/Scripts/HierarchyUI.cs @@ -4,16 +4,18 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class HierarchyUI : MonoBehaviour - { - [SerializeField] - HierarchyListViewController m_ListView; + sealed class HierarchyUI : MonoBehaviour + { + [SerializeField] + HierarchyListViewController m_ListView; - [SerializeField] - BaseHandle m_ScrollHandle; + [SerializeField] + BaseHandle m_ScrollHandle; - public HierarchyListViewController listView { get { return m_ListView; } } - public BaseHandle scrollHandle { get { return m_ScrollHandle; } } - } + public HierarchyListViewController listView { get { return m_ListView; } } + + public BaseHandle scrollHandle { get { return m_ScrollHandle; } } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/InspectorWorkspace.cs b/Workspaces/InspectorWorkspace/InspectorWorkspace.cs index ee683aa9c..16d3d4e5a 100644 --- a/Workspaces/InspectorWorkspace/InspectorWorkspace.cs +++ b/Workspaces/InspectorWorkspace/InspectorWorkspace.cs @@ -7,365 +7,366 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - [MainMenuItem("Inspector", "Workspaces", "View and edit GameObject properties")] - sealed class InspectorWorkspace : Workspace, ISelectionChanged - { - public new static readonly Vector3 DefaultBounds = new Vector3(0.3f, 0.1f, 0.5f); - - [SerializeField] - GameObject m_ContentPrefab; - - [SerializeField] - GameObject m_LockPrefab; - - InspectorUI m_InspectorUI; - GameObject m_SelectedObject; - LockUI m_LockUI; - - bool m_Scrolling; - - bool m_IsLocked; - - public override void Setup() - { - // Initial bounds must be set before the base.Setup() is called - minBounds = new Vector3(0.502f, MinBounds.y, 0.3f); - m_CustomStartingBounds = new Vector3(0.502f, MinBounds.y, 0.6f); - - base.Setup(); - var contentPrefab = ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false); - m_InspectorUI = contentPrefab.GetComponent(); - - m_LockUI = ObjectUtils.Instantiate(m_LockPrefab, m_WorkspaceUI.frontPanel, false).GetComponentInChildren(); - this.ConnectInterfaces(m_LockUI); - m_LockUI.clicked += OnLockButtonClicked; - m_LockUI.hovered += OnButtonHovered; - EditorApplication.delayCall += m_LockUI.Setup; // Need to write stencilRef after WorkspaceButton does it - - var listView = m_InspectorUI.listView; - this.ConnectInterfaces(listView); - listView.data = new List(); - listView.arraySizeChanged += OnArraySizeChanged; - - var scrollHandle = m_InspectorUI.scrollHandle; - scrollHandle.dragStarted += OnScrollDragStarted; - scrollHandle.dragging += OnScrollDragging; - scrollHandle.dragEnded += OnScrollDragEnded; - scrollHandle.hoverStarted += OnScrollHoverStarted; - scrollHandle.hoverEnded += OnScrollHoverEnded; - - contentBounds = new Bounds(Vector3.zero, m_CustomStartingBounds.Value); - - var scrollHandleTransform = m_InspectorUI.scrollHandle.transform; - scrollHandleTransform.SetParent(m_WorkspaceUI.topFaceContainer); - scrollHandleTransform.localScale = new Vector3(1.03f, 0.02f, 1.02f); // Extra space for scrolling - scrollHandleTransform.localPosition = new Vector3(0f, -0.01f, 0f); // Offset from content for collision purposes - - if (Selection.activeGameObject) - OnSelectionChanged(); - - Undo.postprocessModifications += OnPostprocessModifications; - Undo.undoRedoPerformed += OnUndoRedo; - - // Propagate initial bounds - OnBoundsChanged(); - } - - void OnUndoRedo() - { - UpdateCurrentObject(true); - } - - void OnScrollDragStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - m_Scrolling = true; - - m_WorkspaceUI.topHighlight.visible = true; - m_WorkspaceUI.amplifyTopHighlight = false; - - m_InspectorUI.listView.OnBeginScrolling(); - } - - void OnScrollDragging(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - m_InspectorUI.listView.scrollOffset += Vector3.Dot(eventData.deltaPosition, handle.transform.forward) / this.GetViewerScale(); - } - - void OnScrollDragEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - m_Scrolling = false; - - m_WorkspaceUI.topHighlight.visible = false; - - m_InspectorUI.listView.OnScrollEnded(); - } - - void OnScrollHoverStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - if (!m_Scrolling) - { - m_WorkspaceUI.topHighlight.visible = true; - m_WorkspaceUI.amplifyTopHighlight = true; - } - } - - void OnScrollHoverEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) - { - if (!m_Scrolling) - { - m_WorkspaceUI.topHighlight.visible = false; - m_WorkspaceUI.amplifyTopHighlight = false; - } - } - - public void OnSelectionChanged() - { - if (m_IsLocked) - return; - - if (Selection.activeGameObject == m_SelectedObject) - return; - - if (Selection.activeGameObject == null) - { - m_InspectorUI.listView.data = new List(); - m_SelectedObject = null; - return; - } - - m_SelectedObject = Selection.activeGameObject; - UpdateInspectorData(m_SelectedObject, true); - } - - void UpdateInspectorData(GameObject selection, bool fullReload) - { - var listView = m_InspectorUI.listView; - if (fullReload) - { - var inspectorData = new List(); - var objectChildren = new List(); - - foreach (var component in selection.GetComponents()) - { - var obj = new SerializedObject(component); - - var componentChildren = new List(); - - var property = obj.GetIterator(); - while (property.NextVisible(true)) - { - if (property.depth == 0) - componentChildren.Add(SerializedPropertyToPropertyData(property, obj)); - } - - var componentData = new InspectorData("InspectorComponentItem", obj, componentChildren); - objectChildren.Add(componentData); - } - - var objectData = new InspectorData("InspectorHeaderItem", new SerializedObject(selection), objectChildren); - inspectorData.Add(objectData); - - listView.data = inspectorData; - } - else - { - listView.OnObjectModified(); - } - } - - UndoPropertyModification[] OnPostprocessModifications(UndoPropertyModification[] modifications) - { - if (!m_SelectedObject || !IncludesCurrentObject(modifications)) - return modifications; - - UpdateCurrentObject(false); - - return modifications; - } - - bool IncludesCurrentObject(UndoPropertyModification[] modifications) - { - foreach (var modification in modifications) - { - if (modification.previousValue.target == m_SelectedObject) - return true; - - if (modification.currentValue.target == m_SelectedObject) - return true; - - foreach (var component in m_SelectedObject.GetComponents()) - { - if (modification.previousValue.target == component) - return true; - - if (modification.currentValue.target == component) - return true; - } - } - - return false; - } - - void UpdateCurrentObject(bool fullReload) - { - if (m_SelectedObject) - UpdateInspectorData(m_SelectedObject, fullReload); - } - - PropertyData SerializedPropertyToPropertyData(SerializedProperty property, SerializedObject obj) - { - string template; - switch (property.propertyType) - { - case SerializedPropertyType.Vector2: - case SerializedPropertyType.Vector3: - case SerializedPropertyType.Vector4: - case SerializedPropertyType.Quaternion: - template = "InspectorVectorItem"; - break; - case SerializedPropertyType.Integer: - goto case SerializedPropertyType.Float; - case SerializedPropertyType.Float: - template = "InspectorNumberItem"; - break; - case SerializedPropertyType.Character: - case SerializedPropertyType.String: - template = "InspectorStringItem"; - break; - case SerializedPropertyType.Bounds: - template = "InspectorBoundsItem"; - break; - case SerializedPropertyType.Boolean: - template = "InspectorBoolItem"; - break; - case SerializedPropertyType.ObjectReference: - template = "InspectorObjectFieldItem"; - break; - case SerializedPropertyType.Color: - template = "InspectorColorItem"; - break; - case SerializedPropertyType.Rect: - template = "InspectorRectItem"; - break; - case SerializedPropertyType.LayerMask: - case SerializedPropertyType.Enum: - template = "InspectorDropDownItem"; - break; - case SerializedPropertyType.Generic: - return GenericProperty(property, obj); - default: - template = "InspectorUnimplementedItem"; - break; - } - - return new PropertyData(template, obj, null, property.Copy()); - } - - PropertyData GenericProperty(SerializedProperty property, SerializedObject obj) - { - var children = GetSubProperties(property, obj); - - var propertyData = property.isArray - ? new PropertyData("InspectorArrayHeaderItem", obj, children, property.Copy()) - : new PropertyData("InspectorGenericItem", obj, children, property.Copy()); - - propertyData.childrenChanging += m_InspectorUI.listView.OnBeforeChildrenChanged; - - return propertyData; - } - - List GetSubProperties(SerializedProperty property, SerializedObject obj) - { - var children = new List(); - var iteratorProperty = property.Copy(); - while (iteratorProperty.NextVisible(true)) - { - if (iteratorProperty.depth == 0) - break; - - switch (iteratorProperty.propertyType) - { - case SerializedPropertyType.ArraySize: - children.Add(new PropertyData("InspectorNumberItem", obj, null, iteratorProperty.Copy())); - break; - default: - children.Add(SerializedPropertyToPropertyData(iteratorProperty, obj)); - break; - } - } - - return children; - } - - void OnArraySizeChanged(List data, PropertyData element) - { - foreach (var d in data) - { - if (FindElementAndUpdateParent(d, element)) - break; - } - } - - bool FindElementAndUpdateParent(InspectorData parent, PropertyData element) - { - if (parent.children != null) - { - foreach (var child in parent.children) - { - if (child == element) - { - var propertyData = (PropertyData)parent; - propertyData.children = GetSubProperties(propertyData.property.Copy(), propertyData.serializedObject); - return true; - } - - if (FindElementAndUpdateParent(child, element)) - return true; - } - } - - return false; - } - - protected override void OnBoundsChanged() - { - var size = contentBounds.size; - var listView = m_InspectorUI.listView; - var bounds = contentBounds; - size.y = float.MaxValue; // Add height for dropdowns - size.x -= FaceMargin * 2; // Shrink the content width, so that there is space allowed to grab and scroll - size.z -= FaceMargin; // Reduce the height of the inspector contents as to fit within the bounds of the workspace - bounds.size = size; - listView.size = bounds.size; - - var listPanel = m_InspectorUI.listPanel; - listPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); - listPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.z); - } - - void SetIsLocked() - { - m_IsLocked = !m_IsLocked; - m_LockUI.UpdateIcon(m_IsLocked); - - if (!m_IsLocked) - OnSelectionChanged(); - - OnButtonClicked(null); - } - - protected override void OnDestroy() - { - Undo.postprocessModifications -= OnPostprocessModifications; - Undo.undoRedoPerformed -= OnUndoRedo; - base.OnDestroy(); - } - - void OnLockButtonClicked(Transform rayOrigin) - { - SetIsLocked(); - OnButtonClicked(rayOrigin); - } - } + [MainMenuItem("Inspector", "Workspaces", "View and edit GameObject properties")] + sealed class InspectorWorkspace : Workspace, ISelectionChanged + { + public new static readonly Vector3 DefaultBounds = new Vector3(0.3f, 0.1f, 0.5f); + + [SerializeField] + GameObject m_ContentPrefab; + + [SerializeField] + GameObject m_LockPrefab; + + InspectorUI m_InspectorUI; + GameObject m_SelectedObject; + LockUI m_LockUI; + + bool m_Scrolling; + + bool m_IsLocked; + + public override void Setup() + { + // Initial bounds must be set before the base.Setup() is called + minBounds = new Vector3(0.502f, MinBounds.y, 0.3f); + m_CustomStartingBounds = new Vector3(0.502f, MinBounds.y, 0.6f); + + base.Setup(); + var contentPrefab = ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false); + m_InspectorUI = contentPrefab.GetComponent(); + + m_LockUI = ObjectUtils.Instantiate(m_LockPrefab, m_WorkspaceUI.frontPanel, false).GetComponentInChildren(); + this.ConnectInterfaces(m_LockUI); + m_LockUI.clicked += OnLockButtonClicked; + m_LockUI.hovered += OnButtonHovered; + EditorApplication.delayCall += m_LockUI.Setup; // Need to write stencilRef after WorkspaceButton does it + + var listView = m_InspectorUI.listView; + this.ConnectInterfaces(listView); + listView.data = new List(); + listView.arraySizeChanged += OnArraySizeChanged; + + var scrollHandle = m_InspectorUI.scrollHandle; + scrollHandle.dragStarted += OnScrollDragStarted; + scrollHandle.dragging += OnScrollDragging; + scrollHandle.dragEnded += OnScrollDragEnded; + scrollHandle.hoverStarted += OnScrollHoverStarted; + scrollHandle.hoverEnded += OnScrollHoverEnded; + + contentBounds = new Bounds(Vector3.zero, m_CustomStartingBounds.Value); + + var scrollHandleTransform = m_InspectorUI.scrollHandle.transform; + scrollHandleTransform.SetParent(m_WorkspaceUI.topFaceContainer); + scrollHandleTransform.localScale = new Vector3(1.03f, 0.02f, 1.02f); // Extra space for scrolling + scrollHandleTransform.localPosition = new Vector3(0f, -0.01f, 0f); // Offset from content for collision purposes + + if (Selection.activeGameObject) + OnSelectionChanged(); + + Undo.postprocessModifications += OnPostprocessModifications; + Undo.undoRedoPerformed += OnUndoRedo; + + // Propagate initial bounds + OnBoundsChanged(); + } + + void OnUndoRedo() + { + UpdateCurrentObject(true); + } + + void OnScrollDragStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + m_Scrolling = true; + + m_WorkspaceUI.topHighlight.visible = true; + m_WorkspaceUI.amplifyTopHighlight = false; + + m_InspectorUI.listView.OnBeginScrolling(); + } + + void OnScrollDragging(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + m_InspectorUI.listView.scrollOffset += Vector3.Dot(eventData.deltaPosition, handle.transform.forward) / this.GetViewerScale(); + } + + void OnScrollDragEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + m_Scrolling = false; + + m_WorkspaceUI.topHighlight.visible = false; + + m_InspectorUI.listView.OnScrollEnded(); + } + + void OnScrollHoverStarted(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + if (!m_Scrolling) + { + m_WorkspaceUI.topHighlight.visible = true; + m_WorkspaceUI.amplifyTopHighlight = true; + } + } + + void OnScrollHoverEnded(BaseHandle handle, HandleEventData eventData = default(HandleEventData)) + { + if (!m_Scrolling) + { + m_WorkspaceUI.topHighlight.visible = false; + m_WorkspaceUI.amplifyTopHighlight = false; + } + } + + public void OnSelectionChanged() + { + if (m_IsLocked) + return; + + if (Selection.activeGameObject == m_SelectedObject) + return; + + if (Selection.activeGameObject == null) + { + m_InspectorUI.listView.data = new List(); + m_SelectedObject = null; + return; + } + + m_SelectedObject = Selection.activeGameObject; + UpdateInspectorData(m_SelectedObject, true); + } + + void UpdateInspectorData(GameObject selection, bool fullReload) + { + var listView = m_InspectorUI.listView; + if (fullReload) + { + var inspectorData = new List(); + var objectChildren = new List(); + + foreach (var component in selection.GetComponents()) + { + var obj = new SerializedObject(component); + + var componentChildren = new List(); + + var property = obj.GetIterator(); + while (property.NextVisible(true)) + { + if (property.depth == 0) + componentChildren.Add(SerializedPropertyToPropertyData(property, obj)); + } + + var componentData = new InspectorData("InspectorComponentItem", obj, componentChildren); + objectChildren.Add(componentData); + } + + var objectData = new InspectorData("InspectorHeaderItem", new SerializedObject(selection), objectChildren); + inspectorData.Add(objectData); + + listView.data = inspectorData; + } + else + { + listView.OnObjectModified(); + } + } + + UndoPropertyModification[] OnPostprocessModifications(UndoPropertyModification[] modifications) + { + if (!m_SelectedObject || !IncludesCurrentObject(modifications)) + return modifications; + + UpdateCurrentObject(false); + + return modifications; + } + + bool IncludesCurrentObject(UndoPropertyModification[] modifications) + { + foreach (var modification in modifications) + { + if (modification.previousValue.target == m_SelectedObject) + return true; + + if (modification.currentValue.target == m_SelectedObject) + return true; + + foreach (var component in m_SelectedObject.GetComponents()) + { + if (modification.previousValue.target == component) + return true; + + if (modification.currentValue.target == component) + return true; + } + } + + return false; + } + + void UpdateCurrentObject(bool fullReload) + { + if (m_SelectedObject) + UpdateInspectorData(m_SelectedObject, fullReload); + } + + PropertyData SerializedPropertyToPropertyData(SerializedProperty property, SerializedObject obj) + { + string template; + switch (property.propertyType) + { + case SerializedPropertyType.Vector2: + case SerializedPropertyType.Vector3: + case SerializedPropertyType.Vector4: + case SerializedPropertyType.Quaternion: + template = "InspectorVectorItem"; + break; + case SerializedPropertyType.Integer: + goto case SerializedPropertyType.Float; + case SerializedPropertyType.Float: + template = "InspectorNumberItem"; + break; + case SerializedPropertyType.Character: + case SerializedPropertyType.String: + template = "InspectorStringItem"; + break; + case SerializedPropertyType.Bounds: + template = "InspectorBoundsItem"; + break; + case SerializedPropertyType.Boolean: + template = "InspectorBoolItem"; + break; + case SerializedPropertyType.ObjectReference: + template = "InspectorObjectFieldItem"; + break; + case SerializedPropertyType.Color: + template = "InspectorColorItem"; + break; + case SerializedPropertyType.Rect: + template = "InspectorRectItem"; + break; + case SerializedPropertyType.LayerMask: + case SerializedPropertyType.Enum: + template = "InspectorDropDownItem"; + break; + case SerializedPropertyType.Generic: + return GenericProperty(property, obj); + default: + template = "InspectorUnimplementedItem"; + break; + } + + return new PropertyData(template, obj, null, property.Copy()); + } + + PropertyData GenericProperty(SerializedProperty property, SerializedObject obj) + { + var children = GetSubProperties(property, obj); + + var propertyData = property.isArray + ? new PropertyData("InspectorArrayHeaderItem", obj, children, property.Copy()) + : new PropertyData("InspectorGenericItem", obj, children, property.Copy()); + + propertyData.childrenChanging += m_InspectorUI.listView.OnBeforeChildrenChanged; + + return propertyData; + } + + List GetSubProperties(SerializedProperty property, SerializedObject obj) + { + var children = new List(); + var iteratorProperty = property.Copy(); + while (iteratorProperty.NextVisible(true)) + { + if (iteratorProperty.depth == 0) + break; + + switch (iteratorProperty.propertyType) + { + case SerializedPropertyType.ArraySize: + children.Add(new PropertyData("InspectorNumberItem", obj, null, iteratorProperty.Copy())); + break; + default: + children.Add(SerializedPropertyToPropertyData(iteratorProperty, obj)); + break; + } + } + + return children; + } + + void OnArraySizeChanged(List data, PropertyData element) + { + foreach (var d in data) + { + if (FindElementAndUpdateParent(d, element)) + break; + } + } + + bool FindElementAndUpdateParent(InspectorData parent, PropertyData element) + { + if (parent.children != null) + { + foreach (var child in parent.children) + { + if (child == element) + { + var propertyData = (PropertyData)parent; + propertyData.children = GetSubProperties(propertyData.property.Copy(), propertyData.serializedObject); + return true; + } + + if (FindElementAndUpdateParent(child, element)) + return true; + } + } + + return false; + } + + protected override void OnBoundsChanged() + { + var size = contentBounds.size; + var listView = m_InspectorUI.listView; + var bounds = contentBounds; + size.y = float.MaxValue; // Add height for dropdowns + size.x -= FaceMargin * 2; // Shrink the content width, so that there is space allowed to grab and scroll + size.z -= FaceMargin; // Reduce the height of the inspector contents as to fit within the bounds of the workspace + bounds.size = size; + listView.size = bounds.size; + + var listPanel = m_InspectorUI.listPanel; + listPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); + listPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.z); + } + + void SetIsLocked() + { + m_IsLocked = !m_IsLocked; + m_LockUI.UpdateIcon(m_IsLocked); + + if (!m_IsLocked) + OnSelectionChanged(); + + OnButtonClicked(null); + } + + protected override void OnDestroy() + { + Undo.postprocessModifications -= OnPostprocessModifications; + Undo.undoRedoPerformed -= OnUndoRedo; + base.OnDestroy(); + } + + void OnLockButtonClicked(Transform rayOrigin) + { + SetIsLocked(); + OnButtonClicked(rayOrigin); + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs b/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs index 19c0f8258..1bde4b348 100644 --- a/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs +++ b/Workspaces/InspectorWorkspace/Scripts/InspectorListViewController.cs @@ -8,281 +8,282 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorListViewController : NestedListViewController, IUsesGameObjectLocking, IUsesStencilRef - { - const string k_MaterialStencilRef = "_StencilRef"; - const float k_ClipMargin = 0.001f; // Give the cubes a margin so that their sides don't get clipped - - [SerializeField] - Material m_RowCubeMaterial; - - [SerializeField] - Material m_BackingCubeMaterial; - - [SerializeField] - Material m_TextMaterial; - - [SerializeField] - Material m_UIMaterial; - - [SerializeField] - Material m_UIMaskMaterial; - [SerializeField] - Material m_NoClipBackingCubeMaterial; - - [SerializeField] - Material m_HighlightMaterial; - - [SerializeField] - Material m_HighlightMaskMaterial; - - [SerializeField] - Material m_NoClipHighlightMaterial; - - [SerializeField] - Material m_NoClipHighlightMaskMaterial; - - readonly Dictionary m_TemplateSizes = new Dictionary(); - - public override List data - { - set - { - base.data = value; - m_ExpandStates.Clear(); - - ExpandComponentRows(data); - } - } - - public byte stencilRef { get; set; } - - public event Action, PropertyData> arraySizeChanged; - - protected override void Setup() - { - base.Setup(); - - m_RowCubeMaterial = Instantiate(m_RowCubeMaterial); - m_BackingCubeMaterial = Instantiate(m_BackingCubeMaterial); - m_TextMaterial = Instantiate(m_TextMaterial); - m_TextMaterial.SetInt(k_MaterialStencilRef, stencilRef); - m_UIMaterial = Instantiate(m_UIMaterial); - m_UIMaterial.SetInt(k_MaterialStencilRef, stencilRef); - m_UIMaskMaterial = Instantiate(m_UIMaskMaterial); - m_UIMaskMaterial.SetInt(k_MaterialStencilRef, stencilRef); - - m_HighlightMaterial = Instantiate(m_HighlightMaterial); - m_HighlightMaterial.SetInt(k_MaterialStencilRef, stencilRef); - m_HighlightMaskMaterial = Instantiate(m_HighlightMaskMaterial); - m_HighlightMaskMaterial.SetInt(k_MaterialStencilRef, stencilRef); - - m_NoClipBackingCubeMaterial = Instantiate(m_NoClipBackingCubeMaterial); - m_NoClipHighlightMaterial = Instantiate(m_NoClipHighlightMaterial); - m_NoClipHighlightMaskMaterial = Instantiate(m_NoClipHighlightMaskMaterial); - - foreach (var template in m_TemplateDictionary) - m_TemplateSizes[template.Key] = GetObjectSize(template.Value.prefab); - - if (data == null) - data = new List(); - } - - protected override void ComputeConditions() - { - // Check if object was deleted - if (data.Count > 0 && !data[0].serializedObject.targetObject) - data = new List(); - - base.ComputeConditions(); - - m_StartPosition = m_Extents.z * Vector3.back; - - var parentMatrix = transform.worldToLocalMatrix; - SetMaterialClip(m_RowCubeMaterial, parentMatrix); - SetMaterialClip(m_BackingCubeMaterial, parentMatrix); - SetMaterialClip(m_TextMaterial, parentMatrix); - SetMaterialClip(m_UIMaterial, parentMatrix); - SetMaterialClip(m_UIMaskMaterial, parentMatrix); - SetMaterialClip(m_HighlightMaterial, parentMatrix); - SetMaterialClip(m_HighlightMaskMaterial, parentMatrix); - } - - public void OnObjectModified() - { - foreach (var item in m_ListItems.Values) - { - item.OnObjectModified(); - } - } - - protected override void UpdateRecursively(List data, ref int order, ref float offset, ref bool doneSettling, int depth = 0) - { - for (int i = 0; i < data.Count; i++) - { - var datum = data[i]; - var serializedObject = datum.serializedObject; - if (serializedObject == null || serializedObject.targetObject == null) - { - Recycle(datum.index); - RecycleChildren(datum); - continue; - } - - var index = datum.index; - bool expanded; - if (!m_ExpandStates.TryGetValue(index, out expanded)) - m_ExpandStates[index] = false; - - m_ItemSize = m_TemplateSizes[datum.template]; - var itemSize = m_ItemSize.Value; - - if (offset + scrollOffset + itemSize.z < 0 || offset + scrollOffset > m_Size.z) - Recycle(index); - else - UpdateItemRecursive(datum, order++, offset, depth, expanded, ref doneSettling); - - offset += itemSize.z; - - if (datum.children != null) - { - if (expanded) - UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling, depth + 1); - else - RecycleChildren(datum); - } - } - } - - void UpdateItemRecursive(InspectorData data, int order, float offset, int depth, bool expanded, ref bool doneSettling) - { - InspectorListItem item; - if (!m_ListItems.TryGetValue(data.index, out item)) - { - item = GetItem(data); - UpdateItem(item.transform, order, offset, true, ref doneSettling); - } - - item.UpdateSelf(m_Size.x - k_ClipMargin, depth, expanded); - item.UpdateClipTexts(transform.worldToLocalMatrix, m_Extents); - - UpdateItem(item.transform, order, offset, false, ref doneSettling); - } - - void UpdateItem(Transform t, int order, float offset, bool dontSettle, ref bool doneSettling) - { - var targetPosition = m_StartPosition + (offset + m_ScrollOffset) * Vector3.forward; - var targetRotation = Quaternion.identity; - - // order is reversed because Inspector draws bottom-to-top, hence the "0" below - UpdateItemTransform(t, 0, targetPosition, targetRotation, dontSettle, ref doneSettling); - } - - protected override InspectorListItem GetItem(InspectorData listData) - { - var item = base.GetItem(listData); - - item.setRowGrabbed = SetRowGrabbed; - item.getGrabbedRow = GetGrabbedRow; - item.toggleExpanded = ToggleExpanded; - - if (!item.setup) - { - var highlightMaterials = new[] { m_HighlightMaterial, m_HighlightMaskMaterial }; - var noClipHighlightMaterials = new[] { m_NoClipHighlightMaterial, m_NoClipHighlightMaskMaterial }; - item.SetMaterials(m_RowCubeMaterial, m_BackingCubeMaterial, m_UIMaterial, m_UIMaskMaterial, m_TextMaterial, m_NoClipBackingCubeMaterial, highlightMaterials, noClipHighlightMaterials); - - var numberItem = item as InspectorNumberItem; - if (numberItem) - numberItem.arraySizeChanged += OnArraySizeChanged; - - item.setup = true; - } - - var headerItem = item as InspectorHeaderItem; - if (headerItem) - { - var go = (GameObject)listData.serializedObject.targetObject; - headerItem.setLocked = locked => this.SetLocked(go, locked); - headerItem.lockToggle.isOn = this.IsLocked(go); - } - - return item; - } - - public void OnBeforeChildrenChanged(ListViewItemNestedData data, List newData) - { - InspectorNumberItem arraySizeItem = null; - var children = data.children; - if (children != null) - { - foreach (var child in children) - { - var index = child.index; - InspectorListItem item; - if (m_ListItems.TryGetValue(index, out item)) - { - var childNumberItem = item as InspectorNumberItem; - if (childNumberItem && childNumberItem.propertyType == SerializedPropertyType.ArraySize) - arraySizeItem = childNumberItem; - else - Recycle(index); - } - } - } - - // Re-use InspectorNumberItem for array Size in case we are dragging the value - if (arraySizeItem) - { - foreach (var child in newData) - { - var propChild = child as PropertyData; - if (propChild != null && propChild.property.propertyType == SerializedPropertyType.ArraySize) - { - m_ListItems[propChild.index] = arraySizeItem; - arraySizeItem.data = propChild; - } - } - } - } - - void ToggleExpanded(int index) - { - m_ExpandStates[index] = !m_ExpandStates[index]; - StartSettling(); - } - - void OnArraySizeChanged(PropertyData element) - { - if (arraySizeChanged != null) - arraySizeChanged(m_Data, element); - } - - void ExpandComponentRows(List data) - { - foreach (var datum in data) - { - var targetObject = datum.serializedObject.targetObject; - m_ExpandStates[datum.index] = targetObject is Component || targetObject is GameObject; - - if (datum.children != null) - ExpandComponentRows(datum.children); - } - } - - void OnDestroy() - { - ObjectUtils.Destroy(m_RowCubeMaterial); - ObjectUtils.Destroy(m_BackingCubeMaterial); - ObjectUtils.Destroy(m_TextMaterial); - ObjectUtils.Destroy(m_UIMaterial); - ObjectUtils.Destroy(m_UIMaskMaterial); - ObjectUtils.Destroy(m_HighlightMaterial); - ObjectUtils.Destroy(m_HighlightMaskMaterial); - ObjectUtils.Destroy(m_NoClipBackingCubeMaterial); - ObjectUtils.Destroy(m_NoClipHighlightMaterial); - ObjectUtils.Destroy(m_NoClipHighlightMaskMaterial); - } - } + sealed class InspectorListViewController : NestedListViewController, IUsesGameObjectLocking, IUsesStencilRef + { + const string k_MaterialStencilRef = "_StencilRef"; + const float k_ClipMargin = 0.001f; // Give the cubes a margin so that their sides don't get clipped + + [SerializeField] + Material m_RowCubeMaterial; + + [SerializeField] + Material m_BackingCubeMaterial; + + [SerializeField] + Material m_TextMaterial; + + [SerializeField] + Material m_UIMaterial; + + [SerializeField] + Material m_UIMaskMaterial; + [SerializeField] + Material m_NoClipBackingCubeMaterial; + + [SerializeField] + Material m_HighlightMaterial; + + [SerializeField] + Material m_HighlightMaskMaterial; + + [SerializeField] + Material m_NoClipHighlightMaterial; + + [SerializeField] + Material m_NoClipHighlightMaskMaterial; + + readonly Dictionary m_TemplateSizes = new Dictionary(); + + public override List data + { + set + { + base.data = value; + m_ExpandStates.Clear(); + + ExpandComponentRows(data); + } + } + + public byte stencilRef { get; set; } + + public event Action, PropertyData> arraySizeChanged; + + protected override void Setup() + { + base.Setup(); + + m_RowCubeMaterial = Instantiate(m_RowCubeMaterial); + m_BackingCubeMaterial = Instantiate(m_BackingCubeMaterial); + m_TextMaterial = Instantiate(m_TextMaterial); + m_TextMaterial.SetInt(k_MaterialStencilRef, stencilRef); + m_UIMaterial = Instantiate(m_UIMaterial); + m_UIMaterial.SetInt(k_MaterialStencilRef, stencilRef); + m_UIMaskMaterial = Instantiate(m_UIMaskMaterial); + m_UIMaskMaterial.SetInt(k_MaterialStencilRef, stencilRef); + + m_HighlightMaterial = Instantiate(m_HighlightMaterial); + m_HighlightMaterial.SetInt(k_MaterialStencilRef, stencilRef); + m_HighlightMaskMaterial = Instantiate(m_HighlightMaskMaterial); + m_HighlightMaskMaterial.SetInt(k_MaterialStencilRef, stencilRef); + + m_NoClipBackingCubeMaterial = Instantiate(m_NoClipBackingCubeMaterial); + m_NoClipHighlightMaterial = Instantiate(m_NoClipHighlightMaterial); + m_NoClipHighlightMaskMaterial = Instantiate(m_NoClipHighlightMaskMaterial); + + foreach (var template in m_TemplateDictionary) + m_TemplateSizes[template.Key] = GetObjectSize(template.Value.prefab); + + if (data == null) + data = new List(); + } + + protected override void ComputeConditions() + { + // Check if object was deleted + if (data.Count > 0 && !data[0].serializedObject.targetObject) + data = new List(); + + base.ComputeConditions(); + + m_StartPosition = m_Extents.z * Vector3.back; + + var parentMatrix = transform.worldToLocalMatrix; + SetMaterialClip(m_RowCubeMaterial, parentMatrix); + SetMaterialClip(m_BackingCubeMaterial, parentMatrix); + SetMaterialClip(m_TextMaterial, parentMatrix); + SetMaterialClip(m_UIMaterial, parentMatrix); + SetMaterialClip(m_UIMaskMaterial, parentMatrix); + SetMaterialClip(m_HighlightMaterial, parentMatrix); + SetMaterialClip(m_HighlightMaskMaterial, parentMatrix); + } + + public void OnObjectModified() + { + foreach (var item in m_ListItems.Values) + { + item.OnObjectModified(); + } + } + + protected override void UpdateRecursively(List data, ref int order, ref float offset, ref bool doneSettling, int depth = 0) + { + for (int i = 0; i < data.Count; i++) + { + var datum = data[i]; + var serializedObject = datum.serializedObject; + if (serializedObject == null || serializedObject.targetObject == null) + { + Recycle(datum.index); + RecycleChildren(datum); + continue; + } + + var index = datum.index; + bool expanded; + if (!m_ExpandStates.TryGetValue(index, out expanded)) + m_ExpandStates[index] = false; + + m_ItemSize = m_TemplateSizes[datum.template]; + var itemSize = m_ItemSize.Value; + + if (offset + scrollOffset + itemSize.z < 0 || offset + scrollOffset > m_Size.z) + Recycle(index); + else + UpdateItemRecursive(datum, order++, offset, depth, expanded, ref doneSettling); + + offset += itemSize.z; + + if (datum.children != null) + { + if (expanded) + UpdateRecursively(datum.children, ref order, ref offset, ref doneSettling, depth + 1); + else + RecycleChildren(datum); + } + } + } + + void UpdateItemRecursive(InspectorData data, int order, float offset, int depth, bool expanded, ref bool doneSettling) + { + InspectorListItem item; + if (!m_ListItems.TryGetValue(data.index, out item)) + { + item = GetItem(data); + UpdateItem(item.transform, order, offset, true, ref doneSettling); + } + + item.UpdateSelf(m_Size.x - k_ClipMargin, depth, expanded); + item.UpdateClipTexts(transform.worldToLocalMatrix, m_Extents); + + UpdateItem(item.transform, order, offset, false, ref doneSettling); + } + + void UpdateItem(Transform t, int order, float offset, bool dontSettle, ref bool doneSettling) + { + var targetPosition = m_StartPosition + (offset + m_ScrollOffset) * Vector3.forward; + var targetRotation = Quaternion.identity; + + // order is reversed because Inspector draws bottom-to-top, hence the "0" below + UpdateItemTransform(t, 0, targetPosition, targetRotation, dontSettle, ref doneSettling); + } + + protected override InspectorListItem GetItem(InspectorData listData) + { + var item = base.GetItem(listData); + + item.setRowGrabbed = SetRowGrabbed; + item.getGrabbedRow = GetGrabbedRow; + item.toggleExpanded = ToggleExpanded; + + if (!item.setup) + { + var highlightMaterials = new[] { m_HighlightMaterial, m_HighlightMaskMaterial }; + var noClipHighlightMaterials = new[] { m_NoClipHighlightMaterial, m_NoClipHighlightMaskMaterial }; + item.SetMaterials(m_RowCubeMaterial, m_BackingCubeMaterial, m_UIMaterial, m_UIMaskMaterial, m_TextMaterial, m_NoClipBackingCubeMaterial, highlightMaterials, noClipHighlightMaterials); + + var numberItem = item as InspectorNumberItem; + if (numberItem) + numberItem.arraySizeChanged += OnArraySizeChanged; + + item.setup = true; + } + + var headerItem = item as InspectorHeaderItem; + if (headerItem) + { + var go = (GameObject)listData.serializedObject.targetObject; + headerItem.setLocked = locked => this.SetLocked(go, locked); + headerItem.lockToggle.isOn = this.IsLocked(go); + } + + return item; + } + + public void OnBeforeChildrenChanged(ListViewItemNestedData data, List newData) + { + InspectorNumberItem arraySizeItem = null; + var children = data.children; + if (children != null) + { + foreach (var child in children) + { + var index = child.index; + InspectorListItem item; + if (m_ListItems.TryGetValue(index, out item)) + { + var childNumberItem = item as InspectorNumberItem; + if (childNumberItem && childNumberItem.propertyType == SerializedPropertyType.ArraySize) + arraySizeItem = childNumberItem; + else + Recycle(index); + } + } + } + + // Re-use InspectorNumberItem for array Size in case we are dragging the value + if (arraySizeItem) + { + foreach (var child in newData) + { + var propChild = child as PropertyData; + if (propChild != null && propChild.property.propertyType == SerializedPropertyType.ArraySize) + { + m_ListItems[propChild.index] = arraySizeItem; + arraySizeItem.data = propChild; + } + } + } + } + + void ToggleExpanded(int index) + { + m_ExpandStates[index] = !m_ExpandStates[index]; + StartSettling(); + } + + void OnArraySizeChanged(PropertyData element) + { + if (arraySizeChanged != null) + arraySizeChanged(m_Data, element); + } + + void ExpandComponentRows(List data) + { + foreach (var datum in data) + { + var targetObject = datum.serializedObject.targetObject; + m_ExpandStates[datum.index] = targetObject is Component || targetObject is GameObject; + + if (datum.children != null) + ExpandComponentRows(datum.children); + } + } + + void OnDestroy() + { + ObjectUtils.Destroy(m_RowCubeMaterial); + ObjectUtils.Destroy(m_BackingCubeMaterial); + ObjectUtils.Destroy(m_TextMaterial); + ObjectUtils.Destroy(m_UIMaterial); + ObjectUtils.Destroy(m_UIMaskMaterial); + ObjectUtils.Destroy(m_HighlightMaterial); + ObjectUtils.Destroy(m_HighlightMaskMaterial); + ObjectUtils.Destroy(m_NoClipBackingCubeMaterial); + ObjectUtils.Destroy(m_NoClipHighlightMaterial); + ObjectUtils.Destroy(m_NoClipHighlightMaskMaterial); + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/InspectorUI.cs b/Workspaces/InspectorWorkspace/Scripts/InspectorUI.cs index 3b1a1e69e..fb052ad72 100644 --- a/Workspaces/InspectorWorkspace/Scripts/InspectorUI.cs +++ b/Workspaces/InspectorWorkspace/Scripts/InspectorUI.cs @@ -4,31 +4,32 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorUI : MonoBehaviour - { - public InspectorListViewController listView - { - get { return m_ListView; } - } + sealed class InspectorUI : MonoBehaviour + { + public InspectorListViewController listView + { + get { return m_ListView; } + } - [SerializeField] - InspectorListViewController m_ListView; + [SerializeField] + InspectorListViewController m_ListView; - public LinearHandle scrollHandle - { - get { return m_ScrollHandle; } - } + public LinearHandle scrollHandle + { + get { return m_ScrollHandle; } + } - [SerializeField] - LinearHandle m_ScrollHandle; + [SerializeField] + LinearHandle m_ScrollHandle; - public RectTransform listPanel - { - get { return m_ListPanel; } - } + public RectTransform listPanel + { + get { return m_ListPanel; } + } - [SerializeField] - RectTransform m_ListPanel; - } + [SerializeField] + RectTransform m_ListPanel; + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorArrayHeaderItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorArrayHeaderItem.cs index 863be44a9..2078a5ae3 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorArrayHeaderItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorArrayHeaderItem.cs @@ -4,24 +4,25 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorArrayHeaderItem : InspectorPropertyItem - { - const float k_ExpandArrowRotateSpeed = 0.4f; - static readonly Quaternion k_ExpandedRotation = Quaternion.AngleAxis(90f, Vector3.forward); - static readonly Quaternion k_NormalRotation = Quaternion.identity; + sealed class InspectorArrayHeaderItem : InspectorPropertyItem + { + const float k_ExpandArrowRotateSpeed = 0.4f; + static readonly Quaternion k_ExpandedRotation = Quaternion.AngleAxis(90f, Vector3.forward); + static readonly Quaternion k_NormalRotation = Quaternion.identity; - [SerializeField] - Button m_ExpandArrow; + [SerializeField] + Button m_ExpandArrow; - public override void UpdateSelf(float width, int depth, bool expanded) - { - base.UpdateSelf(width, depth, expanded); + public override void UpdateSelf(float width, int depth, bool expanded) + { + base.UpdateSelf(width, depth, expanded); - // Rotate arrow for expand state - m_ExpandArrow.transform.localRotation = Quaternion.Lerp(m_ExpandArrow.transform.localRotation, - expanded ? k_ExpandedRotation : k_NormalRotation, - k_ExpandArrowRotateSpeed); - } - } + // Rotate arrow for expand state + m_ExpandArrow.transform.localRotation = Quaternion.Lerp(m_ExpandArrow.transform.localRotation, + expanded ? k_ExpandedRotation : k_NormalRotation, + k_ExpandArrowRotateSpeed); + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoolItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoolItem.cs index b1db63c8d..963001d05 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoolItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoolItem.cs @@ -5,40 +5,41 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorBoolItem : InspectorPropertyItem - { - [SerializeField] - Toggle m_Toggle; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - m_Toggle.isOn = m_SerializedProperty.boolValue; - } - - protected override void FirstTimeSetup() - { - base.FirstTimeSetup(); - - m_Toggle.onValueChanged.AddListener(SetValue); - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - m_Toggle.isOn = m_SerializedProperty.boolValue; - } - - public void SetValue(bool value) - { - if (m_SerializedProperty.boolValue != value) - { - m_SerializedProperty.boolValue = value; - - FinalizeModifications(); - } - } - } + sealed class InspectorBoolItem : InspectorPropertyItem + { + [SerializeField] + Toggle m_Toggle; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + m_Toggle.isOn = m_SerializedProperty.boolValue; + } + + protected override void FirstTimeSetup() + { + base.FirstTimeSetup(); + + m_Toggle.onValueChanged.AddListener(SetValue); + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + m_Toggle.isOn = m_SerializedProperty.boolValue; + } + + public void SetValue(bool value) + { + if (m_SerializedProperty.boolValue != value) + { + m_SerializedProperty.boolValue = value; + + FinalizeModifications(); + } + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoundsItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoundsItem.cs index 658acba77..72bffb927 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoundsItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorBoundsItem.cs @@ -7,143 +7,144 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorBoundsItem : InspectorPropertyItem - { - [SerializeField] - NumericInputField[] m_CenterFields; - - [SerializeField] - NumericInputField[] m_ExtentsFields; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - UpdateInputFields(); - } - - protected override void FirstTimeSetup() - { - base.FirstTimeSetup(); - - for (var i = 0; i < m_CenterFields.Length; i++) - { - var index = i; - m_CenterFields[i].onValueChanged.AddListener(value => - { - if (SetValue(value, index, true)) - data.serializedObject.ApplyModifiedProperties(); - }); - m_ExtentsFields[i].onValueChanged.AddListener(value => - { - if (SetValue(value, index)) - data.serializedObject.ApplyModifiedProperties(); - }); - } - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateInputFields(); - } - - void UpdateInputFields() - { - var bounds = m_SerializedProperty.boundsValue; - - for (var i = 0; i < m_CenterFields.Length; i++) - { - m_CenterFields[i].text = bounds.center[i].ToString(); - m_ExtentsFields[i].text = bounds.extents[i].ToString(); - } - } - - bool SetValue(string input, int index, bool center = false) - { - float value; - if (!float.TryParse(input, out value)) - return false; - - var bounds = m_SerializedProperty.boundsValue; - var vector = center ? bounds.center : bounds.extents; - - if (!Mathf.Approximately(vector[index], value)) - { - vector[index] = value; - if (center) - bounds.center = vector; - else - bounds.extents = vector; - - m_SerializedProperty.boundsValue = bounds; - - UpdateInputFields(); - - return true; - } - - return false; - } - - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - object dropObject = null; - var inputfields = fieldBlock.GetComponentsInChildren(); - - if (inputfields.Length > 3) // If we've grabbed all of the fields - dropObject = m_SerializedProperty.boundsValue; - if (inputfields.Length > 1) // If we've grabbed one vector - { - if (m_CenterFields.Intersect(inputfields).Any()) - dropObject = m_SerializedProperty.boundsValue.center; - else - dropObject = m_SerializedProperty.boundsValue.extents; - } - else if (inputfields.Length > 0) // If we've grabbed a single field - dropObject = inputfields[0].text; - - return dropObject; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return dropObject is string || dropObject is Bounds; - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - var str = dropObject as string; - if (str != null) - { - var inputField = fieldBlock.GetComponentInChildren(); - var index = Array.IndexOf(m_ExtentsFields, inputField); - if (index > -1 && SetValue(str, index)) - { - inputField.text = str; - inputField.ForceUpdateLabel(); - - FinalizeModifications(); - } - - index = Array.IndexOf(m_CenterFields, inputField); - if (index > -1 && SetValue(str, index, true)) - { - inputField.text = str; - inputField.ForceUpdateLabel(); - FinalizeModifications(); - } - } - - if (dropObject is Bounds) - { - m_SerializedProperty.boundsValue = (Bounds)dropObject; - - UpdateInputFields(); - - FinalizeModifications(); - } - } - } + sealed class InspectorBoundsItem : InspectorPropertyItem + { + [SerializeField] + NumericInputField[] m_CenterFields; + + [SerializeField] + NumericInputField[] m_ExtentsFields; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + UpdateInputFields(); + } + + protected override void FirstTimeSetup() + { + base.FirstTimeSetup(); + + for (var i = 0; i < m_CenterFields.Length; i++) + { + var index = i; + m_CenterFields[i].onValueChanged.AddListener(value => + { + if (SetValue(value, index, true)) + data.serializedObject.ApplyModifiedProperties(); + }); + m_ExtentsFields[i].onValueChanged.AddListener(value => + { + if (SetValue(value, index)) + data.serializedObject.ApplyModifiedProperties(); + }); + } + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateInputFields(); + } + + void UpdateInputFields() + { + var bounds = m_SerializedProperty.boundsValue; + + for (var i = 0; i < m_CenterFields.Length; i++) + { + m_CenterFields[i].text = bounds.center[i].ToString(); + m_ExtentsFields[i].text = bounds.extents[i].ToString(); + } + } + + bool SetValue(string input, int index, bool center = false) + { + float value; + if (!float.TryParse(input, out value)) + return false; + + var bounds = m_SerializedProperty.boundsValue; + var vector = center ? bounds.center : bounds.extents; + + if (!Mathf.Approximately(vector[index], value)) + { + vector[index] = value; + if (center) + bounds.center = vector; + else + bounds.extents = vector; + + m_SerializedProperty.boundsValue = bounds; + + UpdateInputFields(); + + return true; + } + + return false; + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + object dropObject = null; + var inputfields = fieldBlock.GetComponentsInChildren(); + + if (inputfields.Length > 3) // If we've grabbed all of the fields + dropObject = m_SerializedProperty.boundsValue; + if (inputfields.Length > 1) // If we've grabbed one vector + { + if (m_CenterFields.Intersect(inputfields).Any()) + dropObject = m_SerializedProperty.boundsValue.center; + else + dropObject = m_SerializedProperty.boundsValue.extents; + } + else if (inputfields.Length > 0) // If we've grabbed a single field + dropObject = inputfields[0].text; + + return dropObject; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return dropObject is string || dropObject is Bounds; + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + var str = dropObject as string; + if (str != null) + { + var inputField = fieldBlock.GetComponentInChildren(); + var index = Array.IndexOf(m_ExtentsFields, inputField); + if (index > -1 && SetValue(str, index)) + { + inputField.text = str; + inputField.ForceUpdateLabel(); + + FinalizeModifications(); + } + + index = Array.IndexOf(m_CenterFields, inputField); + if (index > -1 && SetValue(str, index, true)) + { + inputField.text = str; + inputField.ForceUpdateLabel(); + FinalizeModifications(); + } + } + + if (dropObject is Bounds) + { + m_SerializedProperty.boundsValue = (Bounds)dropObject; + + UpdateInputFields(); + + FinalizeModifications(); + } + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorColorItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorColorItem.cs index f87774c05..eb4f93ad4 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorColorItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorColorItem.cs @@ -6,161 +6,163 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorColorItem : InspectorPropertyItem - { - public override void Setup(InspectorData data) - { - base.Setup(data); - - UpdateInputFields(); - } - - void UpdateInputFields(Color color) - { - for (var i = 0; i < 4; i++) - { - m_InputFields[i].text = color[i].ToString(); - m_InputFields[i].ForceUpdateLabel(); - } - } - - protected override void FirstTimeSetup() - { - base.FirstTimeSetup(); - - for (var i = 0; i < m_InputFields.Length; i++) - { - var index = i; - m_InputFields[i].onValueChanged.AddListener(value => - { - if (SetValue(value, index)) - data.serializedObject.ApplyModifiedProperties(); - }); - } - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateInputFields(); - } - - public bool SetValue(string input, int index) - { - float value; - if (!float.TryParse(input, out value)) - return false; - - var color = m_SerializedProperty.colorValue; - if (!Mathf.Approximately(color[index], value)) - { - color[index] = value; - m_SerializedProperty.colorValue = color; - - UpdateInputFields(); - - return true; - } - - return false; - } - - void UpdateInputFields() - { - var color = m_SerializedProperty.colorValue; - - for (var i = 0; i < 4; i++) - { - m_InputFields[i].text = color[i].ToString(); - m_InputFields[i].ForceUpdateLabel(); - } - } - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - object dropObject = null; - var inputfields = fieldBlock.GetComponentsInChildren(); - if (inputfields.Length > 1) - { - dropObject = m_SerializedProperty.colorValue; - } - else if (inputfields.Length > 0) - dropObject = inputfields[0].text; - - return dropObject; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return dropObject is string || dropObject is Vector2 || dropObject is Vector3 - || dropObject is Vector4 || dropObject is Quaternion || dropObject is Color; - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - var str = dropObject as string; - if (str != null) - { - var inputField = fieldBlock.GetComponentInChildren(); - var index = Array.IndexOf(m_InputFields, inputField); - - if (SetValue(str, index)) - { - inputField.text = str; - inputField.ForceUpdateLabel(); - - FinalizeModifications(); - } - } - - if (dropObject is Color) - { - m_SerializedProperty.colorValue = (Color)dropObject; - - UpdateInputFields(); - - FinalizeModifications(); - } - - var color = m_SerializedProperty.colorValue; - if (dropObject is Vector2) - { - var vector2 = (Vector2)dropObject; - color.r = vector2.x; - color.g = vector2.y; - m_SerializedProperty.colorValue = color; - - UpdateInputFields(); - - FinalizeModifications(); - } - - if (dropObject is Vector3) - { - var vector3 = (Vector3)dropObject; - color.r = vector3.x; - color.g = vector3.y; - color.b = vector3.z; - m_SerializedProperty.colorValue = color; - - UpdateInputFields(); - - FinalizeModifications(); - } - - if (dropObject is Vector4) - { - var vector4 = (Vector4)dropObject; - color.r = vector4.x; - color.g = vector4.y; - color.b = vector4.z; - color.a = vector4.w; - m_SerializedProperty.colorValue = color; - - UpdateInputFields(); - - FinalizeModifications(); - } - } - } + sealed class InspectorColorItem : InspectorPropertyItem + { + public override void Setup(InspectorData data) + { + base.Setup(data); + + UpdateInputFields(); + } + + void UpdateInputFields(Color color) + { + for (var i = 0; i < 4; i++) + { + m_InputFields[i].text = color[i].ToString(); + m_InputFields[i].ForceUpdateLabel(); + } + } + + protected override void FirstTimeSetup() + { + base.FirstTimeSetup(); + + for (var i = 0; i < m_InputFields.Length; i++) + { + var index = i; + m_InputFields[i].onValueChanged.AddListener(value => + { + if (SetValue(value, index)) + data.serializedObject.ApplyModifiedProperties(); + }); + } + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateInputFields(); + } + + public bool SetValue(string input, int index) + { + float value; + if (!float.TryParse(input, out value)) + return false; + + var color = m_SerializedProperty.colorValue; + if (!Mathf.Approximately(color[index], value)) + { + color[index] = value; + m_SerializedProperty.colorValue = color; + + UpdateInputFields(); + + return true; + } + + return false; + } + + void UpdateInputFields() + { + var color = m_SerializedProperty.colorValue; + + for (var i = 0; i < 4; i++) + { + m_InputFields[i].text = color[i].ToString(); + m_InputFields[i].ForceUpdateLabel(); + } + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + object dropObject = null; + var inputfields = fieldBlock.GetComponentsInChildren(); + if (inputfields.Length > 1) + { + dropObject = m_SerializedProperty.colorValue; + } + else if (inputfields.Length > 0) + dropObject = inputfields[0].text; + + return dropObject; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return dropObject is string || dropObject is Vector2 || dropObject is Vector3 + || dropObject is Vector4 || dropObject is Quaternion || dropObject is Color; + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + var str = dropObject as string; + if (str != null) + { + var inputField = fieldBlock.GetComponentInChildren(); + var index = Array.IndexOf(m_InputFields, inputField); + + if (SetValue(str, index)) + { + inputField.text = str; + inputField.ForceUpdateLabel(); + + FinalizeModifications(); + } + } + + if (dropObject is Color) + { + m_SerializedProperty.colorValue = (Color)dropObject; + + UpdateInputFields(); + + FinalizeModifications(); + } + + var color = m_SerializedProperty.colorValue; + if (dropObject is Vector2) + { + var vector2 = (Vector2)dropObject; + color.r = vector2.x; + color.g = vector2.y; + m_SerializedProperty.colorValue = color; + + UpdateInputFields(); + + FinalizeModifications(); + } + + if (dropObject is Vector3) + { + var vector3 = (Vector3)dropObject; + color.r = vector3.x; + color.g = vector3.y; + color.b = vector3.z; + m_SerializedProperty.colorValue = color; + + UpdateInputFields(); + + FinalizeModifications(); + } + + if (dropObject is Vector4) + { + var vector4 = (Vector4)dropObject; + color.r = vector4.x; + color.g = vector4.y; + color.b = vector4.z; + color.a = vector4.w; + m_SerializedProperty.colorValue = color; + + UpdateInputFields(); + + FinalizeModifications(); + } + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorComponentItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorComponentItem.cs index 6dffaf2ea..b056d5e02 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorComponentItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorComponentItem.cs @@ -7,71 +7,71 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorComponentItem : InspectorListItem - { - const float k_ExpandArrowRotateSpeed = 0.4f; - static readonly Quaternion k_ExpandedRotation = Quaternion.AngleAxis(90f, Vector3.forward); - static readonly Quaternion k_NormalRotation = Quaternion.identity; - - [SerializeField] - Button m_ExpandArrow; - - [SerializeField] - RawImage m_Icon; - - [SerializeField] - Toggle m_EnabledToggle; - - [SerializeField] - Text m_NameText; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - var target = data.serializedObject.targetObject; - var type = target.GetType(); - m_NameText.text = type.Name; - - StopAllCoroutines(); - StartCoroutine(ObjectUtils.GetAssetPreview(target, texture => m_Icon.texture = texture)); - - var enabled = EditorUtility.GetObjectEnabled(target); - m_EnabledToggle.gameObject.SetActive(enabled != -1); - m_EnabledToggle.isOn = enabled == 1; - - m_ExpandArrow.gameObject.SetActive(data.children != null); - } - - public override void UpdateSelf(float width, int depth, bool expanded) - { - base.UpdateSelf(width, depth, expanded); - - // Rotate arrow for expand state - m_ExpandArrow.transform.localRotation = Quaternion.Lerp(m_ExpandArrow.transform.localRotation, - expanded ? k_ExpandedRotation : k_NormalRotation, k_ExpandArrowRotateSpeed); - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - var enabled = EditorUtility.GetObjectEnabled(data.serializedObject.targetObject); - m_EnabledToggle.isOn = enabled == 1; - } - - public void SetEnabled(bool value) - { - var serializedObject = data.serializedObject; - var target = serializedObject.targetObject; - if (value != (EditorUtility.GetObjectEnabled(target) == 1)) - { - EditorUtility.SetObjectEnabled(target, value); - - Undo.IncrementCurrentGroup(); - serializedObject.ApplyModifiedProperties(); - } - } - } + sealed class InspectorComponentItem : InspectorListItem + { + const float k_ExpandArrowRotateSpeed = 0.4f; + static readonly Quaternion k_ExpandedRotation = Quaternion.AngleAxis(90f, Vector3.forward); + static readonly Quaternion k_NormalRotation = Quaternion.identity; + + [SerializeField] + Button m_ExpandArrow; + + [SerializeField] + RawImage m_Icon; + + [SerializeField] + Toggle m_EnabledToggle; + + [SerializeField] + Text m_NameText; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + var target = data.serializedObject.targetObject; + var type = target.GetType(); + m_NameText.text = type.Name; + + StopAllCoroutines(); + StartCoroutine(ObjectUtils.GetAssetPreview(target, texture => m_Icon.texture = texture)); + + var enabled = EditorUtility.GetObjectEnabled(target); + m_EnabledToggle.gameObject.SetActive(enabled != -1); + m_EnabledToggle.isOn = enabled == 1; + + m_ExpandArrow.gameObject.SetActive(data.children != null); + } + + public override void UpdateSelf(float width, int depth, bool expanded) + { + base.UpdateSelf(width, depth, expanded); + + // Rotate arrow for expand state + m_ExpandArrow.transform.localRotation = Quaternion.Lerp(m_ExpandArrow.transform.localRotation, + expanded ? k_ExpandedRotation : k_NormalRotation, k_ExpandArrowRotateSpeed); + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + var enabled = EditorUtility.GetObjectEnabled(data.serializedObject.targetObject); + m_EnabledToggle.isOn = enabled == 1; + } + + public void SetEnabled(bool value) + { + var serializedObject = data.serializedObject; + var target = serializedObject.targetObject; + if (value != (EditorUtility.GetObjectEnabled(target) == 1)) + { + EditorUtility.SetObjectEnabled(target, value); + + Undo.IncrementCurrentGroup(); + serializedObject.ApplyModifiedProperties(); + } + } + } } + #endif - \ No newline at end of file diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorDropDownItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorDropDownItem.cs index df19926ea..201776ce3 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorDropDownItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorDropDownItem.cs @@ -8,184 +8,184 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorDropDownItem : InspectorPropertyItem - { - const string k_Nothing = "Nothing"; - const string k_Everything = "Everything"; - - [SerializeField] - DropDown m_DropDown; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - UpdateDropdown(); - } - - protected override void FirstTimeSetup() - { - base.FirstTimeSetup(); - m_DropDown.valueChanged += ValueChanged; - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateDropdown(); - } - - void UpdateDropdown() - { - if (m_SerializedProperty.propertyType == SerializedPropertyType.LayerMask) - { - m_DropDown.multiSelect = true; - - var options = new List { k_Nothing, k_Everything }; - options.AddRange(InternalEditorUtility.layers); - m_DropDown.options = options.ToArray(); - - switch (m_SerializedProperty.intValue) - { - case 0: - m_DropDown.values = new[] { 0 }; - break; - case ~0: - m_DropDown.values = EverythingValues(); - m_DropDown.LabelOverride("Everything"); - break; - default: - m_DropDown.values = LayerMaskToIndices(m_SerializedProperty.intValue); - break; - } - - } - else - { - m_DropDown.multiSelect = false; - m_DropDown.options = m_SerializedProperty.enumDisplayNames; - m_DropDown.value = m_SerializedProperty.enumValueIndex; - } - } - - void ValueChanged(int clicked, int[] values) - { - if (m_SerializedProperty.propertyType == SerializedPropertyType.LayerMask) - { - if (clicked == 0) // Clicked "Nothing" - { - values = new[] { 0 }; - m_DropDown.values = values; - - if (m_SerializedProperty.intValue == 0) - return; - m_SerializedProperty.intValue = 0; - - FinalizeModifications(); - } - else if (clicked == 1) // Clicked "Everything" - { - m_DropDown.values = EverythingValues(); - m_DropDown.LabelOverride("Everything"); - - if (m_SerializedProperty.intValue == ~0) - return; - m_SerializedProperty.intValue = ~0; - - FinalizeModifications(); - } - else - { - // Remove "Everything" and "Nothing" - var list = new List(values); - if (list.Remove(0) || list.Remove(1)) - { - values = list.ToArray(); - m_DropDown.values = values; - } - - var layerMask = IndicesToLayerMask(values); - if (m_SerializedProperty.intValue != layerMask) - { - m_SerializedProperty.intValue = layerMask; - - FinalizeModifications(); - } - } - } - else - { - if (m_SerializedProperty.enumValueIndex != values[0]) - { - m_SerializedProperty.enumValueIndex = values[0]; - - FinalizeModifications(); - } - } - } - - int[] EverythingValues() - { - var values = new int[InternalEditorUtility.layers.Length + 1]; - for (var i = 0; i < values.Length; i++) - values[i] = i + 1; - - return values; - } - - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - return m_DropDown.multiSelect ? (object)m_DropDown.values : m_DropDown.value; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return m_DropDown.multiSelect && dropObject is int[] - || !m_DropDown.multiSelect && dropObject is int; - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - if (m_DropDown.multiSelect && dropObject is int[]) - { - m_DropDown.values = (int[])dropObject; - } - - if (!m_DropDown.multiSelect && dropObject is int) - { - m_DropDown.value = (int)dropObject; - } - } - - static int[] LayerMaskToIndices(int layerMask) - { - var mask = 1; - var layers = new List(); - for (var i = 0; i < 32; i++) - { - if ((layerMask & mask) != 0) - layers.Add(Array.IndexOf(InternalEditorUtility.layers, LayerMask.LayerToName(i)) + 2); - mask <<= 1; - } - return layers.ToArray(); - } - - static int IndicesToLayerMask(int[] indices) - { - var layerMask = 0; - foreach (var index in indices) - { - if (index == 0) // Nothing - return 0; - if (index == 1) // Everything - return ~0; - var realIndex = index - 2; // Account for "Nothing" and "Everything" - if (realIndex >= 0) - layerMask |= 1 << LayerMask.NameToLayer(InternalEditorUtility.layers[realIndex]); - } - - return layerMask; - } - } + sealed class InspectorDropDownItem : InspectorPropertyItem + { + const string k_Nothing = "Nothing"; + const string k_Everything = "Everything"; + + [SerializeField] + DropDown m_DropDown; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + UpdateDropdown(); + } + + protected override void FirstTimeSetup() + { + base.FirstTimeSetup(); + m_DropDown.valueChanged += ValueChanged; + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateDropdown(); + } + + void UpdateDropdown() + { + if (m_SerializedProperty.propertyType == SerializedPropertyType.LayerMask) + { + m_DropDown.multiSelect = true; + + var options = new List { k_Nothing, k_Everything }; + options.AddRange(InternalEditorUtility.layers); + m_DropDown.options = options.ToArray(); + + switch (m_SerializedProperty.intValue) + { + case 0: + m_DropDown.values = new[] { 0 }; + break; + case ~0: + m_DropDown.values = EverythingValues(); + m_DropDown.LabelOverride("Everything"); + break; + default: + m_DropDown.values = LayerMaskToIndices(m_SerializedProperty.intValue); + break; + } + } + else + { + m_DropDown.multiSelect = false; + m_DropDown.options = m_SerializedProperty.enumDisplayNames; + m_DropDown.value = m_SerializedProperty.enumValueIndex; + } + } + + void ValueChanged(int clicked, int[] values) + { + if (m_SerializedProperty.propertyType == SerializedPropertyType.LayerMask) + { + if (clicked == 0) // Clicked "Nothing" + { + values = new[] { 0 }; + m_DropDown.values = values; + + if (m_SerializedProperty.intValue == 0) + return; + m_SerializedProperty.intValue = 0; + + FinalizeModifications(); + } + else if (clicked == 1) // Clicked "Everything" + { + m_DropDown.values = EverythingValues(); + m_DropDown.LabelOverride("Everything"); + + if (m_SerializedProperty.intValue == ~0) + return; + m_SerializedProperty.intValue = ~0; + + FinalizeModifications(); + } + else + { + // Remove "Everything" and "Nothing" + var list = new List(values); + if (list.Remove(0) || list.Remove(1)) + { + values = list.ToArray(); + m_DropDown.values = values; + } + + var layerMask = IndicesToLayerMask(values); + if (m_SerializedProperty.intValue != layerMask) + { + m_SerializedProperty.intValue = layerMask; + + FinalizeModifications(); + } + } + } + else + { + if (m_SerializedProperty.enumValueIndex != values[0]) + { + m_SerializedProperty.enumValueIndex = values[0]; + + FinalizeModifications(); + } + } + } + + int[] EverythingValues() + { + var values = new int[InternalEditorUtility.layers.Length + 1]; + for (var i = 0; i < values.Length; i++) + values[i] = i + 1; + + return values; + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + return m_DropDown.multiSelect ? (object)m_DropDown.values : m_DropDown.value; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return m_DropDown.multiSelect && dropObject is int[] + || !m_DropDown.multiSelect && dropObject is int; + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + if (m_DropDown.multiSelect && dropObject is int[]) + { + m_DropDown.values = (int[])dropObject; + } + + if (!m_DropDown.multiSelect && dropObject is int) + { + m_DropDown.value = (int)dropObject; + } + } + + static int[] LayerMaskToIndices(int layerMask) + { + var mask = 1; + var layers = new List(); + for (var i = 0; i < 32; i++) + { + if ((layerMask & mask) != 0) + layers.Add(Array.IndexOf(InternalEditorUtility.layers, LayerMask.LayerToName(i)) + 2); + mask <<= 1; + } + return layers.ToArray(); + } + + static int IndicesToLayerMask(int[] indices) + { + var layerMask = 0; + foreach (var index in indices) + { + if (index == 0) // Nothing + return 0; + if (index == 1) // Everything + return ~0; + var realIndex = index - 2; // Account for "Nothing" and "Everything" + if (realIndex >= 0) + layerMask |= 1 << LayerMask.NameToLayer(InternalEditorUtility.layers[realIndex]); + } + + return layerMask; + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorHeaderItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorHeaderItem.cs index 728b8b13f..490494090 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorHeaderItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorHeaderItem.cs @@ -10,173 +10,174 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorHeaderItem : InspectorListItem - { - [SerializeField] - RawImage m_Icon; - - [SerializeField] - Toggle m_ActiveToggle; - - [SerializeField] - StandardInputField m_NameField; - - [SerializeField] - Toggle m_StaticToggle; - - public Toggle lockToggle - { - get { return m_LockToggle; } - } - - [SerializeField] - Toggle m_LockToggle; - - [SerializeField] - DropDown m_TagDropDown; - - [SerializeField] - DropDown m_LayerDropDown; - - [SerializeField] - MeshRenderer m_Button; - - GameObject m_TargetGameObject; - - public Action setLocked; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - var target = data.serializedObject.targetObject; - - StopAllCoroutines(); - StartCoroutine(GetAssetPreview()); - - m_TargetGameObject = target as GameObject; - - UpdateHeaderUI(); - } - - IEnumerator GetAssetPreview() - { - m_Icon.texture = null; - - var target = data.serializedObject.targetObject; - m_Icon.texture = AssetPreview.GetAssetPreview(target); - - while (AssetPreview.IsLoadingAssetPreview(target.GetInstanceID())) - { - m_Icon.texture = AssetPreview.GetAssetPreview(target); - yield return null; - } - - if (!m_Icon.texture) - m_Icon.texture = AssetPreview.GetMiniThumbnail(target); - } - - public void SetActive(bool active) - { - if (m_TargetGameObject != null && m_TargetGameObject.activeSelf != active) - m_TargetGameObject.SetActive(active); - } - - public void SetName(string name) - { - var target = data.serializedObject.targetObject; - if (!target.name.Equals(name)) - target.name = name; - } - - public void SetStatic(bool isStatic) - { - if (m_TargetGameObject != null && m_TargetGameObject.isStatic != isStatic) - m_TargetGameObject.isStatic = isStatic; - } - - public void SetLock(bool locked) - { - if (setLocked != null) - setLocked(locked); - } - - void SetTag(int val, int[] values) - { - var tags = UnityEditorInternal.InternalEditorUtility.tags; - var tag = tags[values[0]]; - if (!m_TargetGameObject.tag.Equals(tag)) - m_TargetGameObject.tag = tag; - } - - void SetLayer(int val, int[] values) - { - var layers = UnityEditorInternal.InternalEditorUtility.layers; - var layer = LayerMask.NameToLayer(layers[values[0]]); - if (m_TargetGameObject.layer != layer) - m_TargetGameObject.layer = layer; - } - - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - var inputField = fieldBlock.GetComponentInChildren(); - if (inputField) - return inputField.text; - return null; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - var inputFields = fieldBlock.GetComponentsInChildren(); - return dropObject is string && inputFields.Contains(m_NameField); - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - m_NameField.text = (string)dropObject; - m_NameField.ForceUpdateLabel(); - } - - public override void SetMaterials(Material rowMaterial, Material backingCubeMaterial, Material uiMaterial, Material uiMaskMaterial, Material textMaterial, Material noClipBackingCube, Material[] highlightMaterials, Material[] noClipHighlightMaterials) - { - base.SetMaterials(rowMaterial, backingCubeMaterial, uiMaterial, uiMaskMaterial, textMaterial, noClipBackingCube, highlightMaterials, noClipHighlightMaterials); - m_Button.sharedMaterials = highlightMaterials; - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateHeaderUI(); - } - - public void UpdateHeaderUI() - { - if (m_TargetGameObject) - { - m_ActiveToggle.isOn = m_TargetGameObject.activeSelf; - m_StaticToggle.isOn = m_TargetGameObject.isStatic; - } - - m_NameField.text = m_TargetGameObject.name; - m_NameField.ForceUpdateLabel(); - - if (m_TargetGameObject) - { - var tags = UnityEditorInternal.InternalEditorUtility.tags; - m_TagDropDown.options = tags; - var tagIndex = Array.IndexOf(tags, m_TargetGameObject.tag); - if (tagIndex > -1) - m_TagDropDown.value = tagIndex; - m_TagDropDown.valueChanged += SetTag; - - var layers = UnityEditorInternal.InternalEditorUtility.layers; - m_LayerDropDown.options = layers; - var layerIndex = Array.IndexOf(layers, LayerMask.LayerToName(m_TargetGameObject.layer)); - if (layerIndex > -1) - m_LayerDropDown.value = layerIndex; - m_LayerDropDown.valueChanged += SetLayer; - } - } - } + sealed class InspectorHeaderItem : InspectorListItem + { + [SerializeField] + RawImage m_Icon; + + [SerializeField] + Toggle m_ActiveToggle; + + [SerializeField] + StandardInputField m_NameField; + + [SerializeField] + Toggle m_StaticToggle; + + public Toggle lockToggle + { + get { return m_LockToggle; } + } + + [SerializeField] + Toggle m_LockToggle; + + [SerializeField] + DropDown m_TagDropDown; + + [SerializeField] + DropDown m_LayerDropDown; + + [SerializeField] + MeshRenderer m_Button; + + GameObject m_TargetGameObject; + + public Action setLocked; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + var target = data.serializedObject.targetObject; + + StopAllCoroutines(); + StartCoroutine(GetAssetPreview()); + + m_TargetGameObject = target as GameObject; + + UpdateHeaderUI(); + } + + IEnumerator GetAssetPreview() + { + m_Icon.texture = null; + + var target = data.serializedObject.targetObject; + m_Icon.texture = AssetPreview.GetAssetPreview(target); + + while (AssetPreview.IsLoadingAssetPreview(target.GetInstanceID())) + { + m_Icon.texture = AssetPreview.GetAssetPreview(target); + yield return null; + } + + if (!m_Icon.texture) + m_Icon.texture = AssetPreview.GetMiniThumbnail(target); + } + + public void SetActive(bool active) + { + if (m_TargetGameObject != null && m_TargetGameObject.activeSelf != active) + m_TargetGameObject.SetActive(active); + } + + public void SetName(string name) + { + var target = data.serializedObject.targetObject; + if (!target.name.Equals(name)) + target.name = name; + } + + public void SetStatic(bool isStatic) + { + if (m_TargetGameObject != null && m_TargetGameObject.isStatic != isStatic) + m_TargetGameObject.isStatic = isStatic; + } + + public void SetLock(bool locked) + { + if (setLocked != null) + setLocked(locked); + } + + void SetTag(int val, int[] values) + { + var tags = UnityEditorInternal.InternalEditorUtility.tags; + var tag = tags[values[0]]; + if (!m_TargetGameObject.tag.Equals(tag)) + m_TargetGameObject.tag = tag; + } + + void SetLayer(int val, int[] values) + { + var layers = UnityEditorInternal.InternalEditorUtility.layers; + var layer = LayerMask.NameToLayer(layers[values[0]]); + if (m_TargetGameObject.layer != layer) + m_TargetGameObject.layer = layer; + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + var inputField = fieldBlock.GetComponentInChildren(); + if (inputField) + return inputField.text; + return null; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + var inputFields = fieldBlock.GetComponentsInChildren(); + return dropObject is string && inputFields.Contains(m_NameField); + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + m_NameField.text = (string)dropObject; + m_NameField.ForceUpdateLabel(); + } + + public override void SetMaterials(Material rowMaterial, Material backingCubeMaterial, Material uiMaterial, Material uiMaskMaterial, Material textMaterial, Material noClipBackingCube, Material[] highlightMaterials, Material[] noClipHighlightMaterials) + { + base.SetMaterials(rowMaterial, backingCubeMaterial, uiMaterial, uiMaskMaterial, textMaterial, noClipBackingCube, highlightMaterials, noClipHighlightMaterials); + m_Button.sharedMaterials = highlightMaterials; + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateHeaderUI(); + } + + public void UpdateHeaderUI() + { + if (m_TargetGameObject) + { + m_ActiveToggle.isOn = m_TargetGameObject.activeSelf; + m_StaticToggle.isOn = m_TargetGameObject.isStatic; + } + + m_NameField.text = m_TargetGameObject.name; + m_NameField.ForceUpdateLabel(); + + if (m_TargetGameObject) + { + var tags = UnityEditorInternal.InternalEditorUtility.tags; + m_TagDropDown.options = tags; + var tagIndex = Array.IndexOf(tags, m_TargetGameObject.tag); + if (tagIndex > -1) + m_TagDropDown.value = tagIndex; + m_TagDropDown.valueChanged += SetTag; + + var layers = UnityEditorInternal.InternalEditorUtility.layers; + m_LayerDropDown.options = layers; + var layerIndex = Array.IndexOf(layers, LayerMask.LayerToName(m_TargetGameObject.layer)); + if (layerIndex > -1) + m_LayerDropDown.value = layerIndex; + m_LayerDropDown.valueChanged += SetLayer; + } + } + } } -#endif \ No newline at end of file + +#endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorListItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorListItem.cs index d02a8b49a..fc82c50af 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorListItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorListItem.cs @@ -10,369 +10,367 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - abstract class InspectorListItem : DraggableListItem, ISetHighlight, IGetFieldGrabOrigin - { - const float k_Indent = 0.02f; - const float k_HorizThreshold = 0.85f; + abstract class InspectorListItem : DraggableListItem, ISetHighlight, IGetFieldGrabOrigin + { + const float k_Indent = 0.02f; + const float k_HorizThreshold = 0.85f; - protected CuboidLayout m_CuboidLayout; + protected CuboidLayout m_CuboidLayout; - protected InputField[] m_InputFields; + protected InputField[] m_InputFields; - [SerializeField] - BaseHandle m_Cube; + [SerializeField] + BaseHandle m_Cube; - [SerializeField] - RectTransform m_UIContainer; + [SerializeField] + RectTransform m_UIContainer; - [SerializeField] - Material m_NoClipText; + [SerializeField] + Material m_NoClipText; - [SerializeField] - Material m_DropHighlightMaterial; - - ClipText[] m_ClipTexts; - - Material m_NoClipBackingCube; - Material[] m_NoClipHighlightMaterials; - - bool m_Setup; - bool m_HorizontalDrag; - - Transform m_DragClone; - protected NumericInputField m_DraggedField; - - public bool setup { get; set; } - - public Action toggleExpanded { private get; set; } - - protected override bool singleClickDrag - { - get { return false; } - } - - public override void Setup(InspectorData data) - { - base.Setup(data); - - if (!m_Setup) - { - m_Setup = true; - FirstTimeSetup(); - } - } - - protected virtual void FirstTimeSetup() - { - m_ClipTexts = GetComponentsInChildren(true); - m_CuboidLayout = GetComponentInChildren(true); - if (m_CuboidLayout) - m_CuboidLayout.UpdateObjects(); - - var handles = GetComponentsInChildren(true); - foreach (var handle in handles) - { - // Ignore m_Cube for now (will be used for Reset action) - if (handle.Equals(m_Cube)) - continue; - - // Toggles can't be dragged - if (handle.transform.parent.GetComponentInChildren()) - continue; - - handle.dragStarted += OnDragStarted; - handle.dragging += OnDragging; - handle.dragEnded += OnDragEnded; - - handle.dropHoverStarted += OnDropHoverStarted; - handle.dropHoverEnded += OnDropHoverEnded; - - handle.canDrop = CanDrop; - handle.receiveDrop = ReceiveDrop; - handle.getDropObject = GetDropObject; - } - - m_InputFields = GetComponentsInChildren(true); - } - - public virtual void SetMaterials(Material rowMaterial, Material backingCubeMaterial, Material uiMaterial, Material uiMaskMaterial, Material textMaterial, Material noClipBackingCube, Material[] highlightMaterials, Material[] noClipHighlightMaterials) - { - m_NoClipBackingCube = noClipBackingCube; - m_NoClipHighlightMaterials = noClipHighlightMaterials; - - m_Cube.GetComponent().sharedMaterial = rowMaterial; - - var cuboidLayouts = GetComponentsInChildren(true); - foreach (var cuboidLayout in cuboidLayouts) - { - cuboidLayout.SetMaterials(backingCubeMaterial, highlightMaterials); - } - - var workspaceButtons = GetComponentsInChildren(true); - foreach (var button in workspaceButtons) - { - button.buttonMeshRenderer.sharedMaterials = highlightMaterials; - } - - var graphics = GetComponentsInChildren(true); - foreach (var graphic in graphics) - { - graphic.material = uiMaterial; - } - - // Texts need a specific shader - var texts = GetComponentsInChildren(true); - foreach (var text in texts) - { - text.material = textMaterial; - } - - // Don't clip masks - var masks = GetComponentsInChildren(true); - foreach (var mask in masks) - { - mask.graphic.material = uiMaskMaterial; - } - } - - public virtual void UpdateSelf(float width, int depth, bool expanded) - { - var cubeScale = m_Cube.transform.localScale; - cubeScale.x = width; - m_Cube.transform.localScale = cubeScale; - - if (depth > 0) // Lose one level of indentation because everything is a child of the header - depth--; - - var indent = k_Indent * depth; - m_UIContainer.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, indent, width - indent); - - if (m_CuboidLayout) - m_CuboidLayout.UpdateObjects(); - } - - public virtual void OnObjectModified() - { - if (data.serializedObject.targetObject) // An exception is thrown if the targetObject has been deleted - data.serializedObject.Update(); - } - - public void UpdateClipTexts(Matrix4x4 parentMatrix, Vector3 clipExtents) - { - foreach (var clipText in m_ClipTexts) - { - clipText.clipExtents = clipExtents; - clipText.parentMatrix = parentMatrix; - clipText.UpdateMaterialClip(); - } - } - - protected virtual void OnDropHoverStarted(BaseHandle handle) - { - this.SetHighlight(handle.gameObject, true, material: m_DropHighlightMaterial); - } - - protected virtual void OnDropHoverEnded(BaseHandle handle) - { - this.SetHighlight(handle.gameObject, false, material: m_DropHighlightMaterial); - } - - object GetDropObject(BaseHandle handle) - { - if (!m_DragObject || m_HorizontalDrag) - return null; - - return GetDropObjectForFieldBlock(handle.transform.parent); - } - - bool CanDrop(BaseHandle handle, object dropObject) - { - return CanDropForFieldBlock(handle.transform.parent, dropObject); - } - - void ReceiveDrop(BaseHandle handle, object dropObject) - { - ReceiveDropForFieldBlock(handle.transform.parent, dropObject); - } - - protected override void OnDragStarted(BaseHandle handle, HandleEventData eventData) - { - base.OnDragStarted(handle, eventData); - m_HorizontalDrag = false; - } - - protected override void OnGrabDragStart(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) - { - var dragVector = eventData.rayOrigin.position - dragStart; - var distance = dragVector.magnitude; - m_HorizontalDrag = Mathf.Abs(Vector3.Dot(dragVector, m_DragObject.right)) / distance > k_HorizThreshold; - - var fieldBlock = handle.transform.parent; - if (fieldBlock) - { - if (m_HorizontalDrag) - OnHorizontalDragStart(eventData.rayOrigin, fieldBlock); - else - OnVerticalDragStart(fieldBlock); - } - } - - protected override void OnGrabDragging(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) - { - if (m_HorizontalDrag) - OnHorizontalDragging(eventData.rayOrigin); - else - OnVerticalDragging(eventData.rayOrigin); - } - - protected virtual void OnVerticalDragStart(Transform fieldBlock) - { - var clone = ((GameObject)Instantiate(fieldBlock.gameObject, fieldBlock.parent)).transform; - - // Re-center pivot - clone.GetComponent().pivot = Vector2.one * 0.5f; - - // Re-center backing cube - foreach (Transform child in clone) - { - if (child.GetComponent()) - { - var localPos = child.localPosition; - localPos.x = 0; - localPos.y = 0; - child.localPosition = localPos; - } - } - - var graphics = clone.GetComponentsInChildren(true); - foreach (var graphic in graphics) - { - graphic.raycastTarget = false; - - if (graphic.GetComponent()) - continue; - - graphic.material = null; - } - - var renderers = clone.GetComponentsInChildren(true); - foreach (var renderer in renderers) - { - if (renderer.sharedMaterials.Length > 1) - { - renderer.sharedMaterials = m_NoClipHighlightMaterials; - } - else - { - renderer.sharedMaterial = m_NoClipBackingCube; - } - } - - var texts = clone.GetComponentsInChildren(true); - foreach (var text in texts) - { - text.material = m_NoClipText; - } - - var colliders = clone.GetComponentsInChildren(); - foreach (var collider in colliders) - { - collider.enabled = false; - } - - m_DragClone = clone; - - StartCoroutine(Magnetize()); - } - - protected virtual void OnVerticalDragging(Transform rayOrigin) - { - if (m_DragClone) - { - var fieldGrabOrigin = this.GetFieldGrabOriginForRayOrigin(rayOrigin); - var rotation = MathUtilsExt.ConstrainYawRotation(CameraUtils.GetMainCamera().transform.rotation); - MathUtilsExt.LerpTransform(m_DragClone, fieldGrabOrigin.position, rotation, m_DragLerp); - } - } - - protected virtual void OnHorizontalDragStart(Transform rayOrigin, Transform fieldBlock) - { - // Get RayInputField from direct children - foreach (Transform child in fieldBlock.transform) - { - var inputField = child.GetComponent(); - if (inputField) - { - m_DraggedField = inputField as NumericInputField; - m_DraggedField.BeginSliderDrag(rayOrigin); - break; - } - } - } - - protected virtual void OnHorizontalDragging(Transform rayOrigin) - { - if (m_DraggedField) - m_DraggedField.SliderDrag(rayOrigin); - } - - protected override void OnDragEnded(BaseHandle handle, HandleEventData eventData) - { - if (m_DraggedField) - m_DraggedField.EndSliderDrag(eventData.rayOrigin); - - // Delay call fixes errors when you close the workspace or change data while dragging a field - EditorApplication.delayCall += () => - { - if (m_DragClone) - ObjectUtils.Destroy(m_DragClone.gameObject); - }; - - if (!m_DragObject) - { - InputField inputField = null; - var fieldBlock = handle.transform.parent; - foreach (Transform child in fieldBlock.transform) - { - inputField = child.GetComponent(); - if (inputField) - { - inputField.OpenKeyboard(); - break; - } - } - - foreach (var field in m_InputFields) - { - field.CloseKeyboard(inputField == null); - } - - if (inputField) - inputField.OpenKeyboard(); - } - - base.OnDragEnded(handle, eventData); - } - - protected virtual object GetDropObjectForFieldBlock(Transform fieldBlock) - { - return null; - } - - protected virtual bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return false; - } - - protected virtual void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - } - - public void ToggleExpanded() - { - toggleExpanded(data.index); - } - } + [SerializeField] + Material m_DropHighlightMaterial; + + ClipText[] m_ClipTexts; + + Material m_NoClipBackingCube; + Material[] m_NoClipHighlightMaterials; + + bool m_Setup; + bool m_HorizontalDrag; + + Transform m_DragClone; + protected NumericInputField m_DraggedField; + + public bool setup { get; set; } + + public Action toggleExpanded { private get; set; } + + protected override bool singleClickDrag + { + get { return false; } + } + + public override void Setup(InspectorData data) + { + base.Setup(data); + + if (!m_Setup) + { + m_Setup = true; + FirstTimeSetup(); + } + } + + protected virtual void FirstTimeSetup() + { + m_ClipTexts = GetComponentsInChildren(true); + m_CuboidLayout = GetComponentInChildren(true); + if (m_CuboidLayout) + m_CuboidLayout.UpdateObjects(); + + var handles = GetComponentsInChildren(true); + foreach (var handle in handles) + { + // Ignore m_Cube for now (will be used for Reset action) + if (handle.Equals(m_Cube)) + continue; + + // Toggles can't be dragged + if (handle.transform.parent.GetComponentInChildren()) + continue; + + handle.dragStarted += OnDragStarted; + handle.dragging += OnDragging; + handle.dragEnded += OnDragEnded; + + handle.dropHoverStarted += OnDropHoverStarted; + handle.dropHoverEnded += OnDropHoverEnded; + + handle.canDrop = CanDrop; + handle.receiveDrop = ReceiveDrop; + handle.getDropObject = GetDropObject; + } + + m_InputFields = GetComponentsInChildren(true); + } + + public virtual void SetMaterials(Material rowMaterial, Material backingCubeMaterial, Material uiMaterial, Material uiMaskMaterial, Material textMaterial, Material noClipBackingCube, Material[] highlightMaterials, Material[] noClipHighlightMaterials) + { + m_NoClipBackingCube = noClipBackingCube; + m_NoClipHighlightMaterials = noClipHighlightMaterials; + + m_Cube.GetComponent().sharedMaterial = rowMaterial; + + var cuboidLayouts = GetComponentsInChildren(true); + foreach (var cuboidLayout in cuboidLayouts) + { + cuboidLayout.SetMaterials(backingCubeMaterial, highlightMaterials); + } + + var workspaceButtons = GetComponentsInChildren(true); + foreach (var button in workspaceButtons) + { + button.buttonMeshRenderer.sharedMaterials = highlightMaterials; + } + + var graphics = GetComponentsInChildren(true); + foreach (var graphic in graphics) + { + graphic.material = uiMaterial; + } + + // Texts need a specific shader + var texts = GetComponentsInChildren(true); + foreach (var text in texts) + { + text.material = textMaterial; + } + + // Don't clip masks + var masks = GetComponentsInChildren(true); + foreach (var mask in masks) + { + mask.graphic.material = uiMaskMaterial; + } + } + + public virtual void UpdateSelf(float width, int depth, bool expanded) + { + var cubeScale = m_Cube.transform.localScale; + cubeScale.x = width; + m_Cube.transform.localScale = cubeScale; + + if (depth > 0) // Lose one level of indentation because everything is a child of the header + depth--; + + var indent = k_Indent * depth; + m_UIContainer.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, indent, width - indent); + + if (m_CuboidLayout) + m_CuboidLayout.UpdateObjects(); + } + + public virtual void OnObjectModified() + { + if (data.serializedObject.targetObject) // An exception is thrown if the targetObject has been deleted + data.serializedObject.Update(); + } + + public void UpdateClipTexts(Matrix4x4 parentMatrix, Vector3 clipExtents) + { + foreach (var clipText in m_ClipTexts) + { + clipText.clipExtents = clipExtents; + clipText.parentMatrix = parentMatrix; + clipText.UpdateMaterialClip(); + } + } + + protected virtual void OnDropHoverStarted(BaseHandle handle) + { + this.SetHighlight(handle.gameObject, true, material: m_DropHighlightMaterial); + } + + protected virtual void OnDropHoverEnded(BaseHandle handle) + { + this.SetHighlight(handle.gameObject, false, material: m_DropHighlightMaterial); + } + + object GetDropObject(BaseHandle handle) + { + if (!m_DragObject || m_HorizontalDrag) + return null; + + return GetDropObjectForFieldBlock(handle.transform.parent); + } + + bool CanDrop(BaseHandle handle, object dropObject) + { + return CanDropForFieldBlock(handle.transform.parent, dropObject); + } + + void ReceiveDrop(BaseHandle handle, object dropObject) + { + ReceiveDropForFieldBlock(handle.transform.parent, dropObject); + } + + protected override void OnDragStarted(BaseHandle handle, HandleEventData eventData) + { + base.OnDragStarted(handle, eventData); + m_HorizontalDrag = false; + } + + protected override void OnGrabDragStart(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) + { + var dragVector = eventData.rayOrigin.position - dragStart; + var distance = dragVector.magnitude; + m_HorizontalDrag = Mathf.Abs(Vector3.Dot(dragVector, m_DragObject.right)) / distance > k_HorizThreshold; + + var fieldBlock = handle.transform.parent; + if (fieldBlock) + { + if (m_HorizontalDrag) + OnHorizontalDragStart(eventData.rayOrigin, fieldBlock); + else + OnVerticalDragStart(fieldBlock); + } + } + + protected override void OnGrabDragging(BaseHandle handle, HandleEventData eventData, Vector3 dragStart) + { + if (m_HorizontalDrag) + OnHorizontalDragging(eventData.rayOrigin); + else + OnVerticalDragging(eventData.rayOrigin); + } + + protected virtual void OnVerticalDragStart(Transform fieldBlock) + { + var clone = ((GameObject)Instantiate(fieldBlock.gameObject, fieldBlock.parent)).transform; + + // Re-center pivot + clone.GetComponent().pivot = Vector2.one * 0.5f; + + // Re-center backing cube + foreach (Transform child in clone) + { + if (child.GetComponent()) + { + var localPos = child.localPosition; + localPos.x = 0; + localPos.y = 0; + child.localPosition = localPos; + } + } + + var graphics = clone.GetComponentsInChildren(true); + foreach (var graphic in graphics) + { + graphic.raycastTarget = false; + + if (graphic.GetComponent()) + continue; + + graphic.material = null; + } + + var renderers = clone.GetComponentsInChildren(true); + foreach (var renderer in renderers) + { + if (renderer.sharedMaterials.Length > 1) + { + renderer.sharedMaterials = m_NoClipHighlightMaterials; + } + else + { + renderer.sharedMaterial = m_NoClipBackingCube; + } + } + + var texts = clone.GetComponentsInChildren(true); + foreach (var text in texts) + { + text.material = m_NoClipText; + } + + var colliders = clone.GetComponentsInChildren(); + foreach (var collider in colliders) + { + collider.enabled = false; + } + + m_DragClone = clone; + + StartCoroutine(Magnetize()); + } + + protected virtual void OnVerticalDragging(Transform rayOrigin) + { + if (m_DragClone) + { + var fieldGrabOrigin = this.GetFieldGrabOriginForRayOrigin(rayOrigin); + var rotation = MathUtilsExt.ConstrainYawRotation(CameraUtils.GetMainCamera().transform.rotation); + MathUtilsExt.LerpTransform(m_DragClone, fieldGrabOrigin.position, rotation, m_DragLerp); + } + } + + protected virtual void OnHorizontalDragStart(Transform rayOrigin, Transform fieldBlock) + { + // Get RayInputField from direct children + foreach (Transform child in fieldBlock.transform) + { + var inputField = child.GetComponent(); + if (inputField) + { + m_DraggedField = inputField as NumericInputField; + m_DraggedField.BeginSliderDrag(rayOrigin); + break; + } + } + } + + protected virtual void OnHorizontalDragging(Transform rayOrigin) + { + if (m_DraggedField) + m_DraggedField.SliderDrag(rayOrigin); + } + + protected override void OnDragEnded(BaseHandle handle, HandleEventData eventData) + { + if (m_DraggedField) + m_DraggedField.EndSliderDrag(eventData.rayOrigin); + + // Delay call fixes errors when you close the workspace or change data while dragging a field + EditorApplication.delayCall += () => + { + if (m_DragClone) + ObjectUtils.Destroy(m_DragClone.gameObject); + }; + + if (!m_DragObject) + { + InputField inputField = null; + var fieldBlock = handle.transform.parent; + foreach (Transform child in fieldBlock.transform) + { + inputField = child.GetComponent(); + if (inputField) + { + inputField.OpenKeyboard(); + break; + } + } + + foreach (var field in m_InputFields) + { + field.CloseKeyboard(inputField == null); + } + + if (inputField) + inputField.OpenKeyboard(); + } + + base.OnDragEnded(handle, eventData); + } + + protected virtual object GetDropObjectForFieldBlock(Transform fieldBlock) + { + return null; + } + + protected virtual bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return false; + } + + protected virtual void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) {} + + public void ToggleExpanded() + { + toggleExpanded(data.index); + } + } } #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorNumberItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorNumberItem.cs index 3d96101ae..6540fd603 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorNumberItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorNumberItem.cs @@ -7,189 +7,190 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorNumberItem : InspectorPropertyItem - { - [SerializeField] - NumericInputField m_InputField; - - [SerializeField] - WorkspaceButton[] m_IncrementDecrementButtons; - - public SerializedPropertyType propertyType { get; private set; } - public event Action arraySizeChanged; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - propertyType = m_SerializedProperty.propertyType; - - OnObjectModified(); - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateInputField(); - } - - void UpdateInputField() - { - var val = string.Empty; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.ArraySize: - case SerializedPropertyType.Integer: - val = m_SerializedProperty.intValue.ToString(); - m_InputField.numberType = NumericInputField.NumberType.Int; - break; - case SerializedPropertyType.Float: - val = m_SerializedProperty.floatValue.ToString(); - m_InputField.numberType = NumericInputField.NumberType.Float; - break; - } - - m_InputField.text = val; - m_InputField.ForceUpdateLabel(); - } - - public void SetValue(string input) - { - // Do not increment undo group because NumericInputField does it for us - if (SetValueIfPossible(input)) - data.serializedObject.ApplyModifiedProperties(); - } - - bool SetValueIfPossible(string input) - { - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.ArraySize: - int size; - if (int.TryParse(input, out size) && m_SerializedProperty.intValue != size) - { - if (size < 0) - return false; - - m_SerializedProperty.arraySize = size; - - m_InputField.text = size.ToString(); - m_InputField.ForceUpdateLabel(); - - if (arraySizeChanged != null) - arraySizeChanged((PropertyData)data); - - return true; - } - break; - case SerializedPropertyType.Integer: - int i; - if (int.TryParse(input, out i) && m_SerializedProperty.intValue != i) - { - m_SerializedProperty.intValue = i; - - m_InputField.text = i.ToString(); - m_InputField.ForceUpdateLabel(); - - return true; - } - break; - case SerializedPropertyType.Float: - float f; - if (float.TryParse(input, out f) && !Mathf.Approximately(m_SerializedProperty.floatValue, f)) - { - m_SerializedProperty.floatValue = f; - - m_InputField.text = f.ToString(); - m_InputField.ForceUpdateLabel(); - - return true; - } - break; - } - - return false; - } - - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - return m_InputField.text; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return dropObject is string; - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - if (SetValueIfPossible(dropObject.ToString())) - FinalizeModifications(); - } - - protected override void OnHorizontalDragStart(Transform rayOrigin, Transform fieldBlock) - { - base.OnHorizontalDragStart(rayOrigin, fieldBlock); - foreach (var button in m_IncrementDecrementButtons) - button.alternateIconVisible = true; - } - - protected override void OnDragEnded(BaseHandle handle, HandleEventData eventData) - { - base.OnDragEnded(handle, eventData); - - // Update field value in case drag value was invalid (i.e. array size < 0) - if (m_DraggedField) - { - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.ArraySize: - case SerializedPropertyType.Integer: - m_DraggedField.text = m_SerializedProperty.intValue.ToString(); - m_DraggedField.ForceUpdateLabel(); - break; - case SerializedPropertyType.Float: - m_DraggedField.text = m_SerializedProperty.floatValue.ToString(); - m_DraggedField.ForceUpdateLabel(); - break; - } - } - - foreach (var button in m_IncrementDecrementButtons) - button.alternateIconVisible = false; - } - - public void Increment() - { - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.ArraySize: - case SerializedPropertyType.Integer: - if (SetValueIfPossible((m_SerializedProperty.intValue + 1).ToString())) - FinalizeModifications(); - break; - case SerializedPropertyType.Float: - if (SetValueIfPossible((m_SerializedProperty.floatValue + 1).ToString())) - FinalizeModifications(); - break; - } - } - - public void Decrement() - { - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.ArraySize: - case SerializedPropertyType.Integer: - if (SetValueIfPossible((m_SerializedProperty.intValue - 1).ToString())) - FinalizeModifications(); - break; - case SerializedPropertyType.Float: - if (SetValueIfPossible((m_SerializedProperty.floatValue - 1).ToString())) - FinalizeModifications(); - break; - } - } - } + sealed class InspectorNumberItem : InspectorPropertyItem + { + [SerializeField] + NumericInputField m_InputField; + + [SerializeField] + WorkspaceButton[] m_IncrementDecrementButtons; + + public SerializedPropertyType propertyType { get; private set; } + public event Action arraySizeChanged; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + propertyType = m_SerializedProperty.propertyType; + + OnObjectModified(); + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateInputField(); + } + + void UpdateInputField() + { + var val = string.Empty; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.ArraySize: + case SerializedPropertyType.Integer: + val = m_SerializedProperty.intValue.ToString(); + m_InputField.numberType = NumericInputField.NumberType.Int; + break; + case SerializedPropertyType.Float: + val = m_SerializedProperty.floatValue.ToString(); + m_InputField.numberType = NumericInputField.NumberType.Float; + break; + } + + m_InputField.text = val; + m_InputField.ForceUpdateLabel(); + } + + public void SetValue(string input) + { + // Do not increment undo group because NumericInputField does it for us + if (SetValueIfPossible(input)) + data.serializedObject.ApplyModifiedProperties(); + } + + bool SetValueIfPossible(string input) + { + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.ArraySize: + int size; + if (int.TryParse(input, out size) && m_SerializedProperty.intValue != size) + { + if (size < 0) + return false; + + m_SerializedProperty.arraySize = size; + + m_InputField.text = size.ToString(); + m_InputField.ForceUpdateLabel(); + + if (arraySizeChanged != null) + arraySizeChanged((PropertyData)data); + + return true; + } + break; + case SerializedPropertyType.Integer: + int i; + if (int.TryParse(input, out i) && m_SerializedProperty.intValue != i) + { + m_SerializedProperty.intValue = i; + + m_InputField.text = i.ToString(); + m_InputField.ForceUpdateLabel(); + + return true; + } + break; + case SerializedPropertyType.Float: + float f; + if (float.TryParse(input, out f) && !Mathf.Approximately(m_SerializedProperty.floatValue, f)) + { + m_SerializedProperty.floatValue = f; + + m_InputField.text = f.ToString(); + m_InputField.ForceUpdateLabel(); + + return true; + } + break; + } + + return false; + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + return m_InputField.text; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return dropObject is string; + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + if (SetValueIfPossible(dropObject.ToString())) + FinalizeModifications(); + } + + protected override void OnHorizontalDragStart(Transform rayOrigin, Transform fieldBlock) + { + base.OnHorizontalDragStart(rayOrigin, fieldBlock); + foreach (var button in m_IncrementDecrementButtons) + button.alternateIconVisible = true; + } + + protected override void OnDragEnded(BaseHandle handle, HandleEventData eventData) + { + base.OnDragEnded(handle, eventData); + + // Update field value in case drag value was invalid (i.e. array size < 0) + if (m_DraggedField) + { + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.ArraySize: + case SerializedPropertyType.Integer: + m_DraggedField.text = m_SerializedProperty.intValue.ToString(); + m_DraggedField.ForceUpdateLabel(); + break; + case SerializedPropertyType.Float: + m_DraggedField.text = m_SerializedProperty.floatValue.ToString(); + m_DraggedField.ForceUpdateLabel(); + break; + } + } + + foreach (var button in m_IncrementDecrementButtons) + button.alternateIconVisible = false; + } + + public void Increment() + { + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.ArraySize: + case SerializedPropertyType.Integer: + if (SetValueIfPossible((m_SerializedProperty.intValue + 1).ToString())) + FinalizeModifications(); + break; + case SerializedPropertyType.Float: + if (SetValueIfPossible((m_SerializedProperty.floatValue + 1).ToString())) + FinalizeModifications(); + break; + } + } + + public void Decrement() + { + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.ArraySize: + case SerializedPropertyType.Integer: + if (SetValueIfPossible((m_SerializedProperty.intValue - 1).ToString())) + FinalizeModifications(); + break; + case SerializedPropertyType.Float: + if (SetValueIfPossible((m_SerializedProperty.floatValue - 1).ToString())) + FinalizeModifications(); + break; + } + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorObjectFieldItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorObjectFieldItem.cs index 76430c5cd..7ba288a43 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorObjectFieldItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorObjectFieldItem.cs @@ -8,98 +8,101 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorObjectFieldItem : InspectorPropertyItem - { - [SerializeField] - Text m_FieldLabel; - - [SerializeField] - MeshRenderer m_Button; - - Type m_ObjectType; - string m_ObjectTypeName; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - m_ObjectTypeName = ObjectUtils.NicifySerializedPropertyType(m_SerializedProperty.type); - m_ObjectType = ObjectUtils.TypeNameToType(m_ObjectTypeName); - - OnObjectModified(); - } - - bool SetObject(Object obj) - { - if (!IsAssignable(obj)) - return false; - - if (obj == null && m_SerializedProperty.objectReferenceValue == null) - return true; - - if (m_SerializedProperty.objectReferenceValue != null && m_SerializedProperty.objectReferenceValue.Equals(obj)) - return true; - - m_SerializedProperty.objectReferenceValue = obj; - - FinalizeModifications(); - - OnObjectModified(); - - return true; - } - - public void ClearButton() - { - SetObject(null); - } - - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateUI(); - } - public void UpdateUI() - { - var obj = m_SerializedProperty.objectReferenceValue; - if (obj == null) - { - m_FieldLabel.text = string.Format("None ({0})", m_ObjectTypeName); - return; - } - if (!IsAssignable(obj)) - { - m_FieldLabel.text = "Type Mismatch"; - return; - } - m_FieldLabel.text = string.Format("{0} ({1})", obj.name, obj.GetType().Name); - } - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - return m_SerializedProperty.objectReferenceValue; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - var obj = dropObject as Object; - return obj != null && IsAssignable(obj); - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - SetObject(dropObject as Object); - } - - public override void SetMaterials(Material rowMaterial, Material backingCubeMaterial, Material uiMaterial, Material uiMaskMaterial, Material textMaterial, Material noClipBackingCube, Material[] highlightMaterials, Material[] noClipHighlightMaterials) - { - base.SetMaterials(rowMaterial, backingCubeMaterial, uiMaterial, uiMaskMaterial, textMaterial, noClipBackingCube, highlightMaterials, noClipHighlightMaterials); - m_Button.sharedMaterials = highlightMaterials; - } - - bool IsAssignable(Object obj) - { - return obj == null || obj.GetType().IsAssignableFrom(m_ObjectType); - } - } + sealed class InspectorObjectFieldItem : InspectorPropertyItem + { + [SerializeField] + Text m_FieldLabel; + + [SerializeField] + MeshRenderer m_Button; + + Type m_ObjectType; + string m_ObjectTypeName; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + m_ObjectTypeName = ObjectUtils.NicifySerializedPropertyType(m_SerializedProperty.type); + m_ObjectType = ObjectUtils.TypeNameToType(m_ObjectTypeName); + + OnObjectModified(); + } + + bool SetObject(Object obj) + { + if (!IsAssignable(obj)) + return false; + + if (obj == null && m_SerializedProperty.objectReferenceValue == null) + return true; + + if (m_SerializedProperty.objectReferenceValue != null && m_SerializedProperty.objectReferenceValue.Equals(obj)) + return true; + + m_SerializedProperty.objectReferenceValue = obj; + + FinalizeModifications(); + + OnObjectModified(); + + return true; + } + + public void ClearButton() + { + SetObject(null); + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateUI(); + } + + public void UpdateUI() + { + var obj = m_SerializedProperty.objectReferenceValue; + if (obj == null) + { + m_FieldLabel.text = string.Format("None ({0})", m_ObjectTypeName); + return; + } + if (!IsAssignable(obj)) + { + m_FieldLabel.text = "Type Mismatch"; + return; + } + m_FieldLabel.text = string.Format("{0} ({1})", obj.name, obj.GetType().Name); + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + return m_SerializedProperty.objectReferenceValue; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + var obj = dropObject as Object; + return obj != null && IsAssignable(obj); + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + SetObject(dropObject as Object); + } + + public override void SetMaterials(Material rowMaterial, Material backingCubeMaterial, Material uiMaterial, Material uiMaskMaterial, Material textMaterial, Material noClipBackingCube, Material[] highlightMaterials, Material[] noClipHighlightMaterials) + { + base.SetMaterials(rowMaterial, backingCubeMaterial, uiMaterial, uiMaskMaterial, textMaterial, noClipBackingCube, highlightMaterials, noClipHighlightMaterials); + m_Button.sharedMaterials = highlightMaterials; + } + + bool IsAssignable(Object obj) + { + return obj == null || obj.GetType().IsAssignableFrom(m_ObjectType); + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorPropertyItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorPropertyItem.cs index 195061428..ae5952e4b 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorPropertyItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorPropertyItem.cs @@ -6,63 +6,64 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - abstract class InspectorPropertyItem : InspectorListItem - { - [SerializeField] - Text m_Label; + abstract class InspectorPropertyItem : InspectorListItem + { + [SerializeField] + Text m_Label; - public Transform tooltipTarget - { - get { return m_TooltipTarget; } - } + public Transform tooltipTarget + { + get { return m_TooltipTarget; } + } - [SerializeField] - Transform m_TooltipTarget; + [SerializeField] + Transform m_TooltipTarget; - public Transform tooltipSource - { - get { return m_TooltipSource; } - } + public Transform tooltipSource + { + get { return m_TooltipSource; } + } - [SerializeField] - Transform m_TooltipSource; + [SerializeField] + Transform m_TooltipSource; - public TextAlignment tooltipAlignment - { - get { return TextAlignment.Right; } - } + public TextAlignment tooltipAlignment + { + get { return TextAlignment.Right; } + } - public Action showTooltip { get; set; } - public Action hideTooltip { get; set; } + public Action showTooltip { get; set; } + public Action hideTooltip { get; set; } - public string tooltipText - { - get { return m_SerializedProperty.tooltip; } - } + public string tooltipText + { + get { return m_SerializedProperty.tooltip; } + } - protected SerializedProperty m_SerializedProperty; + protected SerializedProperty m_SerializedProperty; - public override void Setup(InspectorData data) - { - base.Setup(data); + public override void Setup(InspectorData data) + { + base.Setup(data); - m_SerializedProperty = ((PropertyData)data).property; + m_SerializedProperty = ((PropertyData)data).property; - m_Label.text = m_SerializedProperty.displayName; - } + m_Label.text = m_SerializedProperty.displayName; + } - public override void OnObjectModified() - { - base.OnObjectModified(); + public override void OnObjectModified() + { + base.OnObjectModified(); - m_SerializedProperty = data.serializedObject.FindProperty(m_SerializedProperty.propertyPath); - } + m_SerializedProperty = data.serializedObject.FindProperty(m_SerializedProperty.propertyPath); + } - protected void FinalizeModifications() - { - Undo.IncrementCurrentGroup(); - data.serializedObject.ApplyModifiedProperties(); - } - } + protected void FinalizeModifications() + { + Undo.IncrementCurrentGroup(); + data.serializedObject.ApplyModifiedProperties(); + } + } } -#endif \ No newline at end of file + +#endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorRectItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorRectItem.cs index 4609accb7..e04a9a2b9 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorRectItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorRectItem.cs @@ -7,175 +7,177 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorRectItem : InspectorPropertyItem - { - [SerializeField] - NumericInputField[] m_CenterFields; - - [SerializeField] - NumericInputField[] m_SizeFields; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - UpdateInputFields(); - } - - void UpdateInputFields() - { - var rect = m_SerializedProperty.rectValue; - - for (var i = 0; i < m_CenterFields.Length; i++) - { - m_CenterFields[i].text = rect.center[i].ToString(); - m_CenterFields[i].ForceUpdateLabel(); - m_SizeFields[i].text = rect.size[i].ToString(); - m_SizeFields[i].ForceUpdateLabel(); - } - } - - void UpdateInputFields(Rect rect) - { - for (var i = 0; i < m_CenterFields.Length; i++) - { - m_CenterFields[i].text = rect.center[i].ToString(); - m_CenterFields[i].ForceUpdateLabel(); - m_SizeFields[i].text = rect.size[i].ToString(); - m_SizeFields[i].ForceUpdateLabel(); - } - } - - protected override void FirstTimeSetup() - { - base.FirstTimeSetup(); - - for (var i = 0; i < m_CenterFields.Length; i++) - { - var index = i; - m_CenterFields[i].onValueChanged.AddListener(value => - { - if (SetValue(value, index, true)) - data.serializedObject.ApplyModifiedProperties(); - }); - m_SizeFields[i].onValueChanged.AddListener(value => - { - if (SetValue(value, index)) - data.serializedObject.ApplyModifiedProperties(); - }); - } - } - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateInputFields(); - } - - bool SetValue(string input, int index, bool center = false) - { - float value; - if (!float.TryParse(input, out value)) - return false; - - var rect = m_SerializedProperty.rectValue; - var vector = center ? rect.center : rect.size; - - if (!Mathf.Approximately(vector[index], value)) - { - vector[index] = value; - if (center) - rect.center = vector; - else - rect.size = vector; - - UpdateInputFields(rect); - m_SerializedProperty.rectValue = rect; - UpdateInputFields(); - return true; - } - - return false; - } - - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - object dropObject = null; - var inputFields = fieldBlock.GetComponentsInChildren(); - - if (inputFields.Length > 3) // If we've grabbed all of the fields - dropObject = m_SerializedProperty.rectValue; - - if (inputFields.Length > 1) // If we've grabbed one vector - { - if (m_CenterFields.Intersect(inputFields).Any()) - dropObject = m_SerializedProperty.rectValue.center; - else - dropObject = m_SerializedProperty.rectValue.size; - } - else if (inputFields.Length > 0) // If we've grabbed a single field - dropObject = inputFields[0].text; - - return dropObject; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return dropObject is string || dropObject is Rect || dropObject is Vector2 - || dropObject is Vector3 || dropObject is Vector4; - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - var str = dropObject as string; - if (str != null) - { - var inputField = fieldBlock.GetComponentInChildren(); - var index = Array.IndexOf(m_SizeFields, inputField); - if (index > -1 && SetValue(str, index)) - { - inputField.text = str; - inputField.ForceUpdateLabel(); - - FinalizeModifications(); - } - - index = Array.IndexOf(m_CenterFields, inputField); - if (index > -1 && SetValue(str, index, true)) - { - inputField.text = str; - inputField.ForceUpdateLabel(); - - FinalizeModifications(); - } - } - - if (dropObject is Rect) - { - m_SerializedProperty.rectValue = (Rect)dropObject; - - UpdateInputFields(); - FinalizeModifications(); - data.serializedObject.ApplyModifiedProperties(); - } - - if (dropObject is Vector2 || dropObject is Vector3 || dropObject is Vector4) - { - var vector2 = (Vector2)dropObject; - var inputField = fieldBlock.GetComponentInChildren(); - var rect = m_SerializedProperty.rectValue; - - if (m_CenterFields.Contains(inputField)) - rect.center = vector2; - else - rect.size = vector2; - - m_SerializedProperty.rectValue = rect; - - UpdateInputFields(); - FinalizeModifications(); - data.serializedObject.ApplyModifiedProperties(); - } - } - } + sealed class InspectorRectItem : InspectorPropertyItem + { + [SerializeField] + NumericInputField[] m_CenterFields; + + [SerializeField] + NumericInputField[] m_SizeFields; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + UpdateInputFields(); + } + + void UpdateInputFields() + { + var rect = m_SerializedProperty.rectValue; + + for (var i = 0; i < m_CenterFields.Length; i++) + { + m_CenterFields[i].text = rect.center[i].ToString(); + m_CenterFields[i].ForceUpdateLabel(); + m_SizeFields[i].text = rect.size[i].ToString(); + m_SizeFields[i].ForceUpdateLabel(); + } + } + + void UpdateInputFields(Rect rect) + { + for (var i = 0; i < m_CenterFields.Length; i++) + { + m_CenterFields[i].text = rect.center[i].ToString(); + m_CenterFields[i].ForceUpdateLabel(); + m_SizeFields[i].text = rect.size[i].ToString(); + m_SizeFields[i].ForceUpdateLabel(); + } + } + + protected override void FirstTimeSetup() + { + base.FirstTimeSetup(); + + for (var i = 0; i < m_CenterFields.Length; i++) + { + var index = i; + m_CenterFields[i].onValueChanged.AddListener(value => + { + if (SetValue(value, index, true)) + data.serializedObject.ApplyModifiedProperties(); + }); + m_SizeFields[i].onValueChanged.AddListener(value => + { + if (SetValue(value, index)) + data.serializedObject.ApplyModifiedProperties(); + }); + } + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateInputFields(); + } + + bool SetValue(string input, int index, bool center = false) + { + float value; + if (!float.TryParse(input, out value)) + return false; + + var rect = m_SerializedProperty.rectValue; + var vector = center ? rect.center : rect.size; + + if (!Mathf.Approximately(vector[index], value)) + { + vector[index] = value; + if (center) + rect.center = vector; + else + rect.size = vector; + + UpdateInputFields(rect); + m_SerializedProperty.rectValue = rect; + UpdateInputFields(); + return true; + } + + return false; + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + object dropObject = null; + var inputFields = fieldBlock.GetComponentsInChildren(); + + if (inputFields.Length > 3) // If we've grabbed all of the fields + dropObject = m_SerializedProperty.rectValue; + + if (inputFields.Length > 1) // If we've grabbed one vector + { + if (m_CenterFields.Intersect(inputFields).Any()) + dropObject = m_SerializedProperty.rectValue.center; + else + dropObject = m_SerializedProperty.rectValue.size; + } + else if (inputFields.Length > 0) // If we've grabbed a single field + dropObject = inputFields[0].text; + + return dropObject; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return dropObject is string || dropObject is Rect || dropObject is Vector2 + || dropObject is Vector3 || dropObject is Vector4; + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + var str = dropObject as string; + if (str != null) + { + var inputField = fieldBlock.GetComponentInChildren(); + var index = Array.IndexOf(m_SizeFields, inputField); + if (index > -1 && SetValue(str, index)) + { + inputField.text = str; + inputField.ForceUpdateLabel(); + + FinalizeModifications(); + } + + index = Array.IndexOf(m_CenterFields, inputField); + if (index > -1 && SetValue(str, index, true)) + { + inputField.text = str; + inputField.ForceUpdateLabel(); + + FinalizeModifications(); + } + } + + if (dropObject is Rect) + { + m_SerializedProperty.rectValue = (Rect)dropObject; + + UpdateInputFields(); + FinalizeModifications(); + data.serializedObject.ApplyModifiedProperties(); + } + + if (dropObject is Vector2 || dropObject is Vector3 || dropObject is Vector4) + { + var vector2 = (Vector2)dropObject; + var inputField = fieldBlock.GetComponentInChildren(); + var rect = m_SerializedProperty.rectValue; + + if (m_CenterFields.Contains(inputField)) + rect.center = vector2; + else + rect.size = vector2; + + m_SerializedProperty.rectValue = rect; + + UpdateInputFields(); + FinalizeModifications(); + data.serializedObject.ApplyModifiedProperties(); + } + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorStringItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorStringItem.cs index e519701ca..397fa0fbe 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorStringItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorStringItem.cs @@ -5,94 +5,97 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorStringItem : InspectorPropertyItem - { - [SerializeField] - StandardInputField m_InputField; - - public override void Setup(InspectorData data) - { - base.Setup(data); - - UpdateInputField(); - } - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateInputField(); - } - - void UpdateInputField() - { - base.Setup(data); - - var val = string.Empty; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.String: - val = m_SerializedProperty.stringValue; - break; - case SerializedPropertyType.Character: - val = m_SerializedProperty.intValue.ToString(); - break; - } - - m_InputField.text = val; - m_InputField.ForceUpdateLabel(); - } - - public void SetValue(string input) - { - if (SetValueIfPossible(input)) - FinalizeModifications(); - } - bool SetValueIfPossible(string input) - { - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.String: - if (!m_SerializedProperty.stringValue.Equals(input)) - { - m_SerializedProperty.stringValue = input; - - m_InputField.text = input; - m_InputField.ForceUpdateLabel(); - - return true; - } - break; - case SerializedPropertyType.Character: - char c; - if (char.TryParse(input, out c) && c != m_SerializedProperty.intValue) - { - m_SerializedProperty.intValue = c; - - m_InputField.text = input; - m_InputField.ForceUpdateLabel(); - - return true; - } - break; - } - - return false; - } - - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - return m_InputField.text; - } - - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return dropObject is string; - } - - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - if (SetValueIfPossible(dropObject.ToString())) - FinalizeModifications(); - } - } + sealed class InspectorStringItem : InspectorPropertyItem + { + [SerializeField] + StandardInputField m_InputField; + + public override void Setup(InspectorData data) + { + base.Setup(data); + + UpdateInputField(); + } + + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateInputField(); + } + + void UpdateInputField() + { + base.Setup(data); + + var val = string.Empty; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.String: + val = m_SerializedProperty.stringValue; + break; + case SerializedPropertyType.Character: + val = m_SerializedProperty.intValue.ToString(); + break; + } + + m_InputField.text = val; + m_InputField.ForceUpdateLabel(); + } + + public void SetValue(string input) + { + if (SetValueIfPossible(input)) + FinalizeModifications(); + } + + bool SetValueIfPossible(string input) + { + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.String: + if (!m_SerializedProperty.stringValue.Equals(input)) + { + m_SerializedProperty.stringValue = input; + + m_InputField.text = input; + m_InputField.ForceUpdateLabel(); + + return true; + } + break; + case SerializedPropertyType.Character: + char c; + if (char.TryParse(input, out c) && c != m_SerializedProperty.intValue) + { + m_SerializedProperty.intValue = c; + + m_InputField.text = input; + m_InputField.ForceUpdateLabel(); + + return true; + } + break; + } + + return false; + } + + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + return m_InputField.text; + } + + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return dropObject is string; + } + + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + if (SetValueIfPossible(dropObject.ToString())) + FinalizeModifications(); + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorUnimplementedItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorUnimplementedItem.cs index 1e8539fbc..5fbf59f05 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorUnimplementedItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorUnimplementedItem.cs @@ -6,17 +6,18 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorUnimplementedItem : InspectorPropertyItem - { - [SerializeField] - Text m_TypeLabel; + sealed class InspectorUnimplementedItem : InspectorPropertyItem + { + [SerializeField] + Text m_TypeLabel; - public override void Setup(InspectorData data) - { - base.Setup(data); + public override void Setup(InspectorData data) + { + base.Setup(data); - m_TypeLabel.text = ObjectUtils.NicifySerializedPropertyType(m_SerializedProperty.type); - } - } + m_TypeLabel.text = ObjectUtils.NicifySerializedPropertyType(m_SerializedProperty.type); + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorVectorItem.cs b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorVectorItem.cs index b6cf71110..13d095453 100644 --- a/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorVectorItem.cs +++ b/Workspaces/InspectorWorkspace/Scripts/ListItems/InspectorVectorItem.cs @@ -6,327 +6,328 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class InspectorVectorItem : InspectorPropertyItem - { - [SerializeField] - GameObject ZGroup; + sealed class InspectorVectorItem : InspectorPropertyItem + { + [SerializeField] + GameObject ZGroup; - [SerializeField] - GameObject WGroup; + [SerializeField] + GameObject WGroup; - public override void Setup(InspectorData data) - { - base.Setup(data); + public override void Setup(InspectorData data) + { + base.Setup(data); - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - ZGroup.SetActive(false); - WGroup.SetActive(false); - break; - case SerializedPropertyType.Quaternion: - ZGroup.SetActive(true); - WGroup.SetActive(false); - break; - case SerializedPropertyType.Vector3: - ZGroup.SetActive(true); - WGroup.SetActive(false); - break; - case SerializedPropertyType.Vector4: - ZGroup.SetActive(true); - WGroup.SetActive(true); - break; - } - m_CuboidLayout.UpdateObjects(); + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + ZGroup.SetActive(false); + WGroup.SetActive(false); + break; + case SerializedPropertyType.Quaternion: + ZGroup.SetActive(true); + WGroup.SetActive(false); + break; + case SerializedPropertyType.Vector3: + ZGroup.SetActive(true); + WGroup.SetActive(false); + break; + case SerializedPropertyType.Vector4: + ZGroup.SetActive(true); + WGroup.SetActive(true); + break; + } + m_CuboidLayout.UpdateObjects(); - UpdateInputFields(); - } + UpdateInputFields(); + } - void UpdateInputFields() - { - var vector = Vector4.zero; - var count = 4; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - vector = m_SerializedProperty.vector2Value; - count = 2; - break; - case SerializedPropertyType.Quaternion: - vector = m_SerializedProperty.quaternionValue.eulerAngles; - count = 3; - break; - case SerializedPropertyType.Vector3: - vector = m_SerializedProperty.vector3Value; - count = 3; - break; - case SerializedPropertyType.Vector4: - vector = m_SerializedProperty.vector4Value; - break; - } + void UpdateInputFields() + { + var vector = Vector4.zero; + var count = 4; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + vector = m_SerializedProperty.vector2Value; + count = 2; + break; + case SerializedPropertyType.Quaternion: + vector = m_SerializedProperty.quaternionValue.eulerAngles; + count = 3; + break; + case SerializedPropertyType.Vector3: + vector = m_SerializedProperty.vector3Value; + count = 3; + break; + case SerializedPropertyType.Vector4: + vector = m_SerializedProperty.vector4Value; + break; + } - for (var i = 0; i < count; i++) - { - m_InputFields[i].text = vector[i].ToString(); - m_InputFields[i].ForceUpdateLabel(); - } - } + for (var i = 0; i < count; i++) + { + m_InputFields[i].text = vector[i].ToString(); + m_InputFields[i].ForceUpdateLabel(); + } + } - protected override void FirstTimeSetup() - { - base.FirstTimeSetup(); + protected override void FirstTimeSetup() + { + base.FirstTimeSetup(); - for (var i = 0; i < m_InputFields.Length; i++) - { - var index = i; - m_InputFields[i].onValueChanged.AddListener(value => - { - if (SetValue(value, index)) - data.serializedObject.ApplyModifiedProperties(); - }); - } - } + for (var i = 0; i < m_InputFields.Length; i++) + { + var index = i; + m_InputFields[i].onValueChanged.AddListener(value => + { + if (SetValue(value, index)) + data.serializedObject.ApplyModifiedProperties(); + }); + } + } - public override void OnObjectModified() - { - base.OnObjectModified(); - UpdateInputFields(); - } + public override void OnObjectModified() + { + base.OnObjectModified(); + UpdateInputFields(); + } - public bool SetValue(string input, int index) - { - float value; - if (!float.TryParse(input, out value)) return false; + public bool SetValue(string input, int index) + { + float value; + if (!float.TryParse(input, out value)) return false; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - var vector2 = m_SerializedProperty.vector2Value; - if (!Mathf.Approximately(vector2[index], value)) - { - vector2[index] = value; - m_SerializedProperty.vector2Value = vector2; - UpdateInputFields(); - return true; - } - break; - case SerializedPropertyType.Vector3: - var vector3 = m_SerializedProperty.vector3Value; - if (!Mathf.Approximately(vector3[index], value)) - { - vector3[index] = value; - m_SerializedProperty.vector3Value = vector3; - UpdateInputFields(); - return true; - } - break; - case SerializedPropertyType.Vector4: - var vector4 = m_SerializedProperty.vector4Value; - if (!Mathf.Approximately(vector4[index], value)) - { - vector4[index] = value; - m_SerializedProperty.vector4Value = vector4; - UpdateInputFields(); - return true; - } - break; - case SerializedPropertyType.Quaternion: - var euler = m_SerializedProperty.quaternionValue.eulerAngles; - if (!Mathf.Approximately(euler[index], value)) - { - euler[index] = value; - m_SerializedProperty.quaternionValue = Quaternion.Euler(euler); - UpdateInputFields(); - return true; - } - break; - } + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + var vector2 = m_SerializedProperty.vector2Value; + if (!Mathf.Approximately(vector2[index], value)) + { + vector2[index] = value; + m_SerializedProperty.vector2Value = vector2; + UpdateInputFields(); + return true; + } + break; + case SerializedPropertyType.Vector3: + var vector3 = m_SerializedProperty.vector3Value; + if (!Mathf.Approximately(vector3[index], value)) + { + vector3[index] = value; + m_SerializedProperty.vector3Value = vector3; + UpdateInputFields(); + return true; + } + break; + case SerializedPropertyType.Vector4: + var vector4 = m_SerializedProperty.vector4Value; + if (!Mathf.Approximately(vector4[index], value)) + { + vector4[index] = value; + m_SerializedProperty.vector4Value = vector4; + UpdateInputFields(); + return true; + } + break; + case SerializedPropertyType.Quaternion: + var euler = m_SerializedProperty.quaternionValue.eulerAngles; + if (!Mathf.Approximately(euler[index], value)) + { + euler[index] = value; + m_SerializedProperty.quaternionValue = Quaternion.Euler(euler); + UpdateInputFields(); + return true; + } + break; + } - return false; - } + return false; + } - protected override object GetDropObjectForFieldBlock(Transform fieldBlock) - { - object dropObject = null; - var inputfields = fieldBlock.GetComponentsInChildren(); - if (inputfields.Length > 1) - { - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - dropObject = m_SerializedProperty.vector2Value; - break; - case SerializedPropertyType.Quaternion: - dropObject = m_SerializedProperty.quaternionValue; - break; - case SerializedPropertyType.Vector3: - dropObject = m_SerializedProperty.vector3Value; - break; - case SerializedPropertyType.Vector4: - dropObject = m_SerializedProperty.vector4Value; - break; - } - } - else if (inputfields.Length > 0) - dropObject = inputfields[0].text; + protected override object GetDropObjectForFieldBlock(Transform fieldBlock) + { + object dropObject = null; + var inputfields = fieldBlock.GetComponentsInChildren(); + if (inputfields.Length > 1) + { + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + dropObject = m_SerializedProperty.vector2Value; + break; + case SerializedPropertyType.Quaternion: + dropObject = m_SerializedProperty.quaternionValue; + break; + case SerializedPropertyType.Vector3: + dropObject = m_SerializedProperty.vector3Value; + break; + case SerializedPropertyType.Vector4: + dropObject = m_SerializedProperty.vector4Value; + break; + } + } + else if (inputfields.Length > 0) + dropObject = inputfields[0].text; - return dropObject; - } + return dropObject; + } - protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) - { - return dropObject is string || dropObject is Vector2 || dropObject is Vector3 - || dropObject is Vector4 || dropObject is Quaternion || dropObject is Color; - } + protected override bool CanDropForFieldBlock(Transform fieldBlock, object dropObject) + { + return dropObject is string || dropObject is Vector2 || dropObject is Vector3 + || dropObject is Vector4 || dropObject is Quaternion || dropObject is Color; + } - protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) - { - var str = dropObject as string; - if (str != null) - { - var inputField = fieldBlock.GetComponentInChildren(); - var index = Array.IndexOf(m_InputFields, inputField); + protected override void ReceiveDropForFieldBlock(Transform fieldBlock, object dropObject) + { + var str = dropObject as string; + if (str != null) + { + var inputField = fieldBlock.GetComponentInChildren(); + var index = Array.IndexOf(m_InputFields, inputField); - if (SetValue(str, index)) - { - inputField.text = str; - inputField.ForceUpdateLabel(); - FinalizeModifications(); - } - } + if (SetValue(str, index)) + { + inputField.text = str; + inputField.ForceUpdateLabel(); + FinalizeModifications(); + } + } - if (dropObject is Vector2) - { - var vector2 = (Vector2)dropObject; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - m_SerializedProperty.vector2Value = vector2; - break; - case SerializedPropertyType.Vector3: - var vector3 = (Vector4)vector2; - vector3.z = m_SerializedProperty.vector3Value.z; - m_SerializedProperty.vector3Value = vector3; - break; - case SerializedPropertyType.Vector4: - var vector4 = m_SerializedProperty.vector4Value; - vector3.x = vector2.x; - vector3.y = vector2.y; - m_SerializedProperty.vector4Value = vector4; - break; - case SerializedPropertyType.Quaternion: - var euler = m_SerializedProperty.quaternionValue.eulerAngles; - euler.x = vector2.x; - euler.y = vector2.y; - m_SerializedProperty.quaternionValue = Quaternion.Euler(euler); - break; - } + if (dropObject is Vector2) + { + var vector2 = (Vector2)dropObject; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + m_SerializedProperty.vector2Value = vector2; + break; + case SerializedPropertyType.Vector3: + var vector3 = (Vector4)vector2; + vector3.z = m_SerializedProperty.vector3Value.z; + m_SerializedProperty.vector3Value = vector3; + break; + case SerializedPropertyType.Vector4: + var vector4 = m_SerializedProperty.vector4Value; + vector3.x = vector2.x; + vector3.y = vector2.y; + m_SerializedProperty.vector4Value = vector4; + break; + case SerializedPropertyType.Quaternion: + var euler = m_SerializedProperty.quaternionValue.eulerAngles; + euler.x = vector2.x; + euler.y = vector2.y; + m_SerializedProperty.quaternionValue = Quaternion.Euler(euler); + break; + } - UpdateInputFields(); - FinalizeModifications(); - } + UpdateInputFields(); + FinalizeModifications(); + } - if (dropObject is Vector3) - { - var vector3 = (Vector3)dropObject; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - m_SerializedProperty.vector2Value = vector3; - break; - case SerializedPropertyType.Vector3: - m_SerializedProperty.vector3Value = vector3; - break; - case SerializedPropertyType.Vector4: - var vector4 = (Vector4)vector3; - vector4.w = m_SerializedProperty.vector4Value.w; - m_SerializedProperty.vector4Value = vector4; - break; - case SerializedPropertyType.Quaternion: - m_SerializedProperty.quaternionValue = Quaternion.Euler(vector3); - break; - } + if (dropObject is Vector3) + { + var vector3 = (Vector3)dropObject; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + m_SerializedProperty.vector2Value = vector3; + break; + case SerializedPropertyType.Vector3: + m_SerializedProperty.vector3Value = vector3; + break; + case SerializedPropertyType.Vector4: + var vector4 = (Vector4)vector3; + vector4.w = m_SerializedProperty.vector4Value.w; + m_SerializedProperty.vector4Value = vector4; + break; + case SerializedPropertyType.Quaternion: + m_SerializedProperty.quaternionValue = Quaternion.Euler(vector3); + break; + } - UpdateInputFields(); - FinalizeModifications(); - } + UpdateInputFields(); + FinalizeModifications(); + } - if (dropObject is Vector4) - { - var vector4 = (Vector4)dropObject; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - m_SerializedProperty.vector2Value = vector4; - break; - case SerializedPropertyType.Vector3: - m_SerializedProperty.vector3Value = vector4; - break; - case SerializedPropertyType.Vector4: - m_SerializedProperty.vector4Value = vector4; - break; - case SerializedPropertyType.Quaternion: - m_SerializedProperty.quaternionValue = new Quaternion(vector4.x, vector4.y, vector4.z, vector4.w); - break; - } + if (dropObject is Vector4) + { + var vector4 = (Vector4)dropObject; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + m_SerializedProperty.vector2Value = vector4; + break; + case SerializedPropertyType.Vector3: + m_SerializedProperty.vector3Value = vector4; + break; + case SerializedPropertyType.Vector4: + m_SerializedProperty.vector4Value = vector4; + break; + case SerializedPropertyType.Quaternion: + m_SerializedProperty.quaternionValue = new Quaternion(vector4.x, vector4.y, vector4.z, vector4.w); + break; + } - UpdateInputFields(); - FinalizeModifications(); - } + UpdateInputFields(); + FinalizeModifications(); + } - if (dropObject is Color) - { - var color = (Color)dropObject; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - Vector2 vector2; - vector2.x = color.r; - vector2.y = color.g; - m_SerializedProperty.vector2Value = vector2; - break; - case SerializedPropertyType.Vector3: - Vector3 vector3; - vector3.x = color.r; - vector3.y = color.g; - vector3.z = color.b; - m_SerializedProperty.vector3Value = vector3; - break; - case SerializedPropertyType.Vector4: - m_SerializedProperty.vector4Value = color; - break; - case SerializedPropertyType.Quaternion: - m_SerializedProperty.quaternionValue = new Quaternion(color.r, color.g, color.b, color.a); - break; - } + if (dropObject is Color) + { + var color = (Color)dropObject; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + Vector2 vector2; + vector2.x = color.r; + vector2.y = color.g; + m_SerializedProperty.vector2Value = vector2; + break; + case SerializedPropertyType.Vector3: + Vector3 vector3; + vector3.x = color.r; + vector3.y = color.g; + vector3.z = color.b; + m_SerializedProperty.vector3Value = vector3; + break; + case SerializedPropertyType.Vector4: + m_SerializedProperty.vector4Value = color; + break; + case SerializedPropertyType.Quaternion: + m_SerializedProperty.quaternionValue = new Quaternion(color.r, color.g, color.b, color.a); + break; + } - UpdateInputFields(); - FinalizeModifications(); - } + UpdateInputFields(); + FinalizeModifications(); + } - if (dropObject is Quaternion) - { - var quaternion = (Quaternion)dropObject; - switch (m_SerializedProperty.propertyType) - { - case SerializedPropertyType.Vector2: - m_SerializedProperty.vector2Value = quaternion.eulerAngles; - break; - case SerializedPropertyType.Vector3: - m_SerializedProperty.vector3Value = quaternion.eulerAngles; - break; - case SerializedPropertyType.Vector4: - m_SerializedProperty.vector4Value = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w); - break; - case SerializedPropertyType.Quaternion: - m_SerializedProperty.quaternionValue = quaternion; - break; - } + if (dropObject is Quaternion) + { + var quaternion = (Quaternion)dropObject; + switch (m_SerializedProperty.propertyType) + { + case SerializedPropertyType.Vector2: + m_SerializedProperty.vector2Value = quaternion.eulerAngles; + break; + case SerializedPropertyType.Vector3: + m_SerializedProperty.vector3Value = quaternion.eulerAngles; + break; + case SerializedPropertyType.Vector4: + m_SerializedProperty.vector4Value = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w); + break; + case SerializedPropertyType.Quaternion: + m_SerializedProperty.quaternionValue = quaternion; + break; + } - UpdateInputFields(); - FinalizeModifications(); - } - } - } + UpdateInputFields(); + FinalizeModifications(); + } + } + } } + #endif diff --git a/Workspaces/InspectorWorkspace/Scripts/LockUI.cs b/Workspaces/InspectorWorkspace/Scripts/LockUI.cs index 1be6e4af2..7e058c04f 100644 --- a/Workspaces/InspectorWorkspace/Scripts/LockUI.cs +++ b/Workspaces/InspectorWorkspace/Scripts/LockUI.cs @@ -5,53 +5,54 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - sealed class LockUI : MonoBehaviour, IUsesStencilRef - { - [SerializeField] - Image m_LockImage; - - [SerializeField] - Sprite m_LockIcon; - - [SerializeField] - Sprite m_UnlockIcon; - - [SerializeField] - WorkspaceButton m_Button; - - public byte stencilRef { get; set; } - - public event Action hovered; - public event Action clicked; - - public void Setup() - { - var mr = GetComponentInChildren(); - foreach (var sm in mr.sharedMaterials) - { - sm.SetInt("_StencilRef", stencilRef); - } - - m_Button.clicked += OnClicked; - m_Button.hovered += OnHovered; - } - - void OnClicked(Transform rayOrigin) - { - if (clicked != null) - clicked(rayOrigin); - } - - void OnHovered(Transform rayOrigin) - { - if (hovered != null) - hovered(rayOrigin); - } - - public void UpdateIcon(bool locked) - { - m_LockImage.sprite = locked ? m_LockIcon : m_UnlockIcon; - } - } + sealed class LockUI : MonoBehaviour, IUsesStencilRef + { + [SerializeField] + Image m_LockImage; + + [SerializeField] + Sprite m_LockIcon; + + [SerializeField] + Sprite m_UnlockIcon; + + [SerializeField] + WorkspaceButton m_Button; + + public byte stencilRef { get; set; } + + public event Action hovered; + public event Action clicked; + + public void Setup() + { + var mr = GetComponentInChildren(); + foreach (var sm in mr.sharedMaterials) + { + sm.SetInt("_StencilRef", stencilRef); + } + + m_Button.clicked += OnClicked; + m_Button.hovered += OnHovered; + } + + void OnClicked(Transform rayOrigin) + { + if (clicked != null) + clicked(rayOrigin); + } + + void OnHovered(Transform rayOrigin) + { + if (hovered != null) + hovered(rayOrigin); + } + + public void UpdateIcon(bool locked) + { + m_LockImage.sprite = locked ? m_LockIcon : m_UnlockIcon; + } + } } + #endif diff --git a/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs b/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs index fa47d3cff..4b87c7f39 100644 --- a/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs +++ b/Workspaces/LockedObjectsWorkspace/LockedObjectsWorkspace.cs @@ -7,78 +7,79 @@ namespace UnityEditor.Experimental.EditorVR.Workspaces { - [MainMenuItem("Locked Objects", "Workspaces", "View all locked objects in your scene(s)")] - class LockedObjectsWorkspace : HierarchyWorkspace, IUsesGameObjectLocking - { - [SerializeField] - GameObject m_UnlockAllPrefab; + [MainMenuItem("Locked Objects", "Workspaces", "View all locked objects in your scene(s)")] + class LockedObjectsWorkspace : HierarchyWorkspace, IUsesGameObjectLocking + { + [SerializeField] + GameObject m_UnlockAllPrefab; - string m_BaseSearchQuery; - string m_CachedSearchQuery; + string m_BaseSearchQuery; + string m_CachedSearchQuery; - public override string searchQuery - { - get - { - var query = base.searchQuery; - if (m_BaseSearchQuery != query) - { - m_BaseSearchQuery = query; - m_CachedSearchQuery = string.Format("{0} {1}", m_BaseSearchQuery, k_LockedQuery); - } + public override string searchQuery + { + get + { + var query = base.searchQuery; + if (m_BaseSearchQuery != query) + { + m_BaseSearchQuery = query; + m_CachedSearchQuery = string.Format("{0} {1}", m_BaseSearchQuery, k_LockedQuery); + } - return m_CachedSearchQuery; - } - } + return m_CachedSearchQuery; + } + } - public override List filterList - { - set - { - m_FilterList = value; - m_FilterList.Sort(); - - if (m_FilterUI) - m_FilterUI.filterList = value; - } - } + public override List filterList + { + set + { + m_FilterList = value; + m_FilterList.Sort(); - public Action setLocked { get; set; } - public Func isLocked { get; set; } + if (m_FilterUI) + m_FilterUI.filterList = value; + } + } - public override void Setup() - { - base.Setup(); + public Action setLocked { get; set; } + public Func isLocked { get; set; } - if (m_UnlockAllPrefab) - { - var unlockAllUI = ObjectUtils.Instantiate(m_UnlockAllPrefab, m_WorkspaceUI.frontPanel, false); - foreach (var mb in unlockAllUI.GetComponentsInChildren()) - { - this.ConnectInterfaces(mb); - } + public override void Setup() + { + base.Setup(); - unlockAllUI.GetComponentInChildren