From d4267b8dd11c084ccadda3cffa22c4dabe61df14 Mon Sep 17 00:00:00 2001 From: Amarcolina Date: Fri, 9 Jun 2017 13:50:49 -0700 Subject: [PATCH 1/7] Adding gravity warning to the interaction manager --- .../Editor/InteractionManagerEditor.cs | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs index 3eb8a77033..4f64aa782c 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs @@ -18,10 +18,13 @@ namespace Leap.Unity.Interaction { [CustomEditor(typeof(InteractionManager))] public class InteractionManagerEditor : CustomEditorBase { + public const float MAX_GRAVITY_MAGNITUDE = 4.905f; protected override void OnEnable() { base.OnEnable(); + specifyCustomDecorator("_interactionControllers", drawGravityWarning); + // Interaction Controllers specifyCustomDrawer("_interactionControllers", drawControllersStatusEditor); @@ -42,6 +45,20 @@ public override bool RequiresConstantRepaint() { return Application.isPlaying; } + public void drawGravityWarning(SerializedProperty prop) { + if (Mathf.Abs(Physics.gravity.y) - MAX_GRAVITY_MAGNITUDE > Mathf.Epsilon) { + using (new GUILayout.HorizontalScope()) { + EditorGUILayout.HelpBox("Gravity is stronger than the recommended amount! Weaker gravity is recommended for a more pleasent experience.", MessageType.Warning); + if (GUILayout.Button("Auto-Fix")) { + + Vector3 gravity = Physics.gravity; + gravity.y = MAX_GRAVITY_MAGNITUDE * Mathf.Sign(gravity.y); + Physics.gravity = gravity; + } + } + } + } + private RuntimeGizmoManager _runtimeGizmoManager; private void drawControllerRuntimeGizmoDecorator(SerializedProperty property) { @@ -134,13 +151,13 @@ private void drawControllersStatusEditor(SerializedProperty property) { } public static class Colors { - public static Color DarkGray { get { return new Color(0.4F, 0.4F, 0.4F); } } + public static Color DarkGray { get { return new Color(0.4F, 0.4F, 0.4F); } } public static Color LightGray { get { return new Color(0.7F, 0.7F, 0.7F); } } - public static Color Good { get { return Color.Lerp(Color.green, LightGray, 0.2F); } } - public static Color Caution { get { return Color.Lerp(Good, Color.yellow, 0.8F); } } - public static Color Warning { get { return Color.Lerp(Color.yellow, Problem, 0.5F); } } - public static Color Problem { get { return Color.Lerp(Color.red, Color.yellow, 0.3F); } } + public static Color Good { get { return Color.Lerp(Color.green, LightGray, 0.2F); } } + public static Color Caution { get { return Color.Lerp(Good, Color.yellow, 0.8F); } } + public static Color Warning { get { return Color.Lerp(Color.yellow, Problem, 0.5F); } } + public static Color Problem { get { return Color.Lerp(Color.red, Color.yellow, 0.3F); } } } private struct ControllerStatusMessage { @@ -165,8 +182,7 @@ private void drawControllerStatusEditor(InteractionController controller) { if (controller.intHand != null) { checkInteractionHandStatus(controller.intHand, messages); - } - else if (controller is InteractionVRController) { + } else if (controller is InteractionVRController) { checkInteractionVRControllerStatus(controller as InteractionVRController, messages); } @@ -245,8 +261,7 @@ private void checkInteractionHandStatus(InteractionHand intHand, + "be raised by the hand itself if it is misconfigured.", color = Colors.Caution }); - } - else { + } else { // Check for a LeapProvider in the scene somewhere. if (_provider == null) { _provider = FindObjectOfType(); @@ -276,8 +291,7 @@ private void checkInteractionHandStatus(InteractionHand intHand, } if (_leftHand == null && intHand.handDataMode == HandDataMode.PlayerLeft) { _leftHand = intHand; - } - else if (_rightHand == null && intHand.handDataMode == HandDataMode.PlayerRight) { + } else if (_rightHand == null && intHand.handDataMode == HandDataMode.PlayerRight) { _rightHand = intHand; } } @@ -298,7 +312,7 @@ private void checkInteractionVRControllerStatus(InteractionVRController controll } // Check if the player has duplicate VRNode left controllers or right controllers. - bool isLeftVRNodeController = controller.trackingProvider is DefaultVRNodeTrackingProvider + bool isLeftVRNodeController = controller.trackingProvider is DefaultVRNodeTrackingProvider && controller.chirality == Chirality.Left; bool isRightVRNodeController = controller.trackingProvider is DefaultVRNodeTrackingProvider && controller.chirality == Chirality.Right; From 58cf60610470efca8b4e5894000714bb89c96ecb Mon Sep 17 00:00:00 2001 From: Amarcolina Date: Fri, 9 Jun 2017 14:02:00 -0700 Subject: [PATCH 2/7] Added a preferences menu for interaction engine --- .../Scripts/Editor/InteractionPreferences.cs | 49 +++++++++++++++++++ .../Editor/InteractionPreferences.cs.meta | 12 +++++ 2 files changed, 61 insertions(+) create mode 100644 Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs create mode 100644 Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs.meta diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs new file mode 100644 index 0000000000..129a58e7df --- /dev/null +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs @@ -0,0 +1,49 @@ +using UnityEngine; +using UnityEditor; + +namespace Leap.Unity.Interaction { + + public static class InteractionPreferences { + public const string PROMPT_FOR_GRAVITY_KEY = "InteractionEngine_ShouldPrompForGravity"; + public const string PROMPT_FOR_PHYSICS_TIMESTEP = "InteractionEngine_ShouldPrompForTimestep"; + + private static GUIContent _gravityPrompContent; + private static GUIContent _timestepPrompContent; + + static InteractionPreferences() { + _gravityPrompContent = new GUIContent("Validate Gravity Magnitude", "Should prompt the user if the magnitude of the gravity vector is higher than the recommended amount?"); + _timestepPrompContent = new GUIContent("Validate Physics Timestep", "Should prompt the user if the physics timestep is larger then the recommended value?"); + } + + public static bool shouldPrompForGravity { + get { + return EditorPrefs.GetBool(PROMPT_FOR_GRAVITY_KEY, defaultValue: true); + } + set { + EditorPrefs.SetBool(PROMPT_FOR_GRAVITY_KEY, value); + } + } + + public static bool shouldPrompForPhysicsTimestep { + get { + return EditorPrefs.GetBool(PROMPT_FOR_PHYSICS_TIMESTEP, defaultValue: true); + } + set { + EditorPrefs.SetBool(PROMPT_FOR_PHYSICS_TIMESTEP, value); + } + } + + [PreferenceItem("Leap Interaction")] + private static void preferencesGUI() { + bool newGravityValue = EditorGUILayout.Toggle(_gravityPrompContent, shouldPrompForGravity); + if (newGravityValue != shouldPrompForGravity) { + shouldPrompForGravity = newGravityValue; + } + + bool newTimestepValue = EditorGUILayout.Toggle(_timestepPrompContent, shouldPrompForPhysicsTimestep); + if (newTimestepValue != shouldPrompForPhysicsTimestep) { + shouldPrompForPhysicsTimestep = newTimestepValue; + } + } + } +} diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs.meta b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs.meta new file mode 100644 index 0000000000..1d4c6c7f0f --- /dev/null +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a8a6b8597c834114e96352ee7223ce1a +timeCreated: 1497041654 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From bbfb25f731a86e732d07f14db5d6e6ba7137fff2 Mon Sep 17 00:00:00 2001 From: Amarcolina Date: Fri, 9 Jun 2017 14:02:43 -0700 Subject: [PATCH 3/7] Reset manager editor --- .../Editor/InteractionManagerEditor.cs | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs index 4f64aa782c..3eb8a77033 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionManagerEditor.cs @@ -18,13 +18,10 @@ namespace Leap.Unity.Interaction { [CustomEditor(typeof(InteractionManager))] public class InteractionManagerEditor : CustomEditorBase { - public const float MAX_GRAVITY_MAGNITUDE = 4.905f; protected override void OnEnable() { base.OnEnable(); - specifyCustomDecorator("_interactionControllers", drawGravityWarning); - // Interaction Controllers specifyCustomDrawer("_interactionControllers", drawControllersStatusEditor); @@ -45,20 +42,6 @@ public override bool RequiresConstantRepaint() { return Application.isPlaying; } - public void drawGravityWarning(SerializedProperty prop) { - if (Mathf.Abs(Physics.gravity.y) - MAX_GRAVITY_MAGNITUDE > Mathf.Epsilon) { - using (new GUILayout.HorizontalScope()) { - EditorGUILayout.HelpBox("Gravity is stronger than the recommended amount! Weaker gravity is recommended for a more pleasent experience.", MessageType.Warning); - if (GUILayout.Button("Auto-Fix")) { - - Vector3 gravity = Physics.gravity; - gravity.y = MAX_GRAVITY_MAGNITUDE * Mathf.Sign(gravity.y); - Physics.gravity = gravity; - } - } - } - } - private RuntimeGizmoManager _runtimeGizmoManager; private void drawControllerRuntimeGizmoDecorator(SerializedProperty property) { @@ -151,13 +134,13 @@ private void drawControllersStatusEditor(SerializedProperty property) { } public static class Colors { - public static Color DarkGray { get { return new Color(0.4F, 0.4F, 0.4F); } } + public static Color DarkGray { get { return new Color(0.4F, 0.4F, 0.4F); } } public static Color LightGray { get { return new Color(0.7F, 0.7F, 0.7F); } } - public static Color Good { get { return Color.Lerp(Color.green, LightGray, 0.2F); } } - public static Color Caution { get { return Color.Lerp(Good, Color.yellow, 0.8F); } } - public static Color Warning { get { return Color.Lerp(Color.yellow, Problem, 0.5F); } } - public static Color Problem { get { return Color.Lerp(Color.red, Color.yellow, 0.3F); } } + public static Color Good { get { return Color.Lerp(Color.green, LightGray, 0.2F); } } + public static Color Caution { get { return Color.Lerp(Good, Color.yellow, 0.8F); } } + public static Color Warning { get { return Color.Lerp(Color.yellow, Problem, 0.5F); } } + public static Color Problem { get { return Color.Lerp(Color.red, Color.yellow, 0.3F); } } } private struct ControllerStatusMessage { @@ -182,7 +165,8 @@ private void drawControllerStatusEditor(InteractionController controller) { if (controller.intHand != null) { checkInteractionHandStatus(controller.intHand, messages); - } else if (controller is InteractionVRController) { + } + else if (controller is InteractionVRController) { checkInteractionVRControllerStatus(controller as InteractionVRController, messages); } @@ -261,7 +245,8 @@ private void checkInteractionHandStatus(InteractionHand intHand, + "be raised by the hand itself if it is misconfigured.", color = Colors.Caution }); - } else { + } + else { // Check for a LeapProvider in the scene somewhere. if (_provider == null) { _provider = FindObjectOfType(); @@ -291,7 +276,8 @@ private void checkInteractionHandStatus(InteractionHand intHand, } if (_leftHand == null && intHand.handDataMode == HandDataMode.PlayerLeft) { _leftHand = intHand; - } else if (_rightHand == null && intHand.handDataMode == HandDataMode.PlayerRight) { + } + else if (_rightHand == null && intHand.handDataMode == HandDataMode.PlayerRight) { _rightHand = intHand; } } @@ -312,7 +298,7 @@ private void checkInteractionVRControllerStatus(InteractionVRController controll } // Check if the player has duplicate VRNode left controllers or right controllers. - bool isLeftVRNodeController = controller.trackingProvider is DefaultVRNodeTrackingProvider + bool isLeftVRNodeController = controller.trackingProvider is DefaultVRNodeTrackingProvider && controller.chirality == Chirality.Left; bool isRightVRNodeController = controller.trackingProvider is DefaultVRNodeTrackingProvider && controller.chirality == Chirality.Right; From 0fe78fd367b8da89cee5cb310ca2426911e3786e Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Fri, 9 Jun 2017 14:25:41 -0700 Subject: [PATCH 4/7] Add controller input devx warnings --- .../Scripts/InteractionVRController.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionVRController.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionVRController.cs index 585beb58ec..01bfe72fa2 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionVRController.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionVRController.cs @@ -550,7 +550,12 @@ private void fixedUpdateGraspButtonState() { if (!_graspButtonLastFrame) { if (graspAxisOverride == null) { - graspButton = Input.GetAxis(graspButtonAxis) > graspDepressedValue; + try { + graspButton = Input.GetAxis(graspButtonAxis) > graspDepressedValue; + } catch { + Debug.LogError("INPUT AXIS NOT SET UP. Go to your Input Manager and add a definition for " + graspButtonAxis + " on the " + (isLeft ? "9" : "10") + "th Joystick Axis."); + graspButton = Input.GetKey(isLeft ? KeyCode.JoystickButton14: KeyCode.JoystickButton15); + } } else { graspButton = graspAxisOverride() > graspDepressedValue; @@ -570,7 +575,12 @@ private void fixedUpdateGraspButtonState() { } if (graspAxisOverride == null) { - graspButton = Input.GetAxis(graspButtonAxis) > graspReleasedValue; + try { + graspButton = Input.GetAxis(graspButtonAxis) > graspDepressedValue; + } catch { + Debug.LogError("INPUT AXIS NOT SET UP. Go to your Input Manager and add a definition for " + graspButtonAxis + " on the " + (isLeft ? "9" : "10") + "th Joystick Axis."); + graspButton = Input.GetKey(isLeft ? KeyCode.JoystickButton14 : KeyCode.JoystickButton15); + } } else { graspButton = graspAxisOverride() > graspReleasedValue; From 12d5fb9e70649f0c1a842134dcea5b33d53cfa33 Mon Sep 17 00:00:00 2001 From: Amarcolina Date: Fri, 9 Jun 2017 14:27:10 -0700 Subject: [PATCH 5/7] Added popups to the editor --- .../Scripts/InteractionManager.cs | 63 ++++++++++++------- .../InteractionPreferences.cs | 7 ++- .../InteractionPreferences.cs.meta | 0 3 files changed, 48 insertions(+), 22 deletions(-) rename Assets/LeapMotion/Modules/InteractionEngine/Scripts/{Editor => Internal}/InteractionPreferences.cs (91%) rename Assets/LeapMotion/Modules/InteractionEngine/Scripts/{Editor => Internal}/InteractionPreferences.cs.meta (100%) diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs index faafa81803..d003551671 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs @@ -24,7 +24,7 @@ namespace Leap.Unity.Interaction { [Serializable] public class InteractionControllerSet : SerializableHashSet { } - + [DisallowMultipleComponent] [ExecuteInEditMode] public class InteractionManager : MonoBehaviour, IRuntimeGizmoComponent { @@ -38,7 +38,7 @@ public class InteractionManager : MonoBehaviour, IRuntimeGizmoComponent { public ReadonlyHashSet interactionControllers { get { return _interactionControllers; } } - + [Header("Interaction Settings")] [SerializeField] @@ -202,11 +202,34 @@ void OnValidate() { if (!Application.isPlaying && _autoGenerateLayers) { generateAutomaticLayers(); } - + refreshInteractionControllers(); } void Awake() { +#if UNITY_EDITOR + if (InteractionPreferences.shouldPrompForGravity && Application.isPlaying) { + float magnitude = Physics.gravity.y; + if (Mathf.Abs(magnitude) > InteractionPreferences.MAX_GRAVITY_MAGNITUDE) { + if (!EditorUtility.DisplayDialog("Gravity magnitude too strong!", "Your gravity magnitude is " + magnitude + " which is stronger than the recommended value of -4.905!\n\nGo to Edit->Project Settings->Physics to change the magnitude.", "Ok", "Don't Show Again")) { + InteractionPreferences.shouldPrompForGravity = false; + } + EditorApplication.isPlaying = false; + return; + } + } + + if (InteractionPreferences.shouldPrompForPhysicsTimestep && Application.isPlaying) { + if (Time.fixedDeltaTime > InteractionPreferences.MAX_TIMESTEP + Mathf.Epsilon) { + if (!EditorUtility.DisplayDialog("Timestep too slow!", "Your fixed timestep is " + Time.fixedDeltaTime + ", which is slower than the recommended value of 0.01111.\n\nGo to Edit->ProjectSettings->Time to change the timestep.", "Ok", "Don't Show Again")) { + InteractionPreferences.shouldPrompForPhysicsTimestep = false; + } + EditorApplication.isPlaying = false; + return; + } + } +#endif + refreshInteractionControllers(); if (!Application.isPlaying) return; @@ -221,7 +244,7 @@ void Awake() { _prevPosition = this.transform.position; _prevRotation = this.transform.rotation; - #if UNITY_EDITOR +#if UNITY_EDITOR if (_drawControllerRuntimeGizmos == true) { if (FindObjectOfType() == null) { Debug.LogWarning("'_drawControllerRuntimeGizmos' is enabled, but there is no " @@ -229,13 +252,13 @@ void Awake() { + "like to render gizmos in the editor and in your headset."); } } - #endif +#endif } void OnDisable() { - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) return; - #endif +#endif foreach (var intController in _interactionControllers) { // Disables the colliders in the interaction controller; @@ -249,9 +272,9 @@ void OnDisable() { } void Update() { - #if UNITY_EDITOR +#if UNITY_EDITOR refreshInteractionControllers(); - #endif +#endif } void FixedUpdate() { @@ -259,14 +282,14 @@ void FixedUpdate() { refreshInteractionControllers(); - #if UNITY_EDITOR +#if UNITY_EDITOR if (!Application.isPlaying) return; - #endif +#endif using (new ProfilerSample("Interaction Manager FixedUpdate", this.gameObject)) { // Ensure scale information is up-to-date. _scale = this.transform.lossyScale.x; - + // Update each interaction controller (Leap hands or supported VR controllers). fixedUpdateInteractionControllers(); @@ -521,7 +544,7 @@ private void checkSustainingGrasps(ReadonlyHashSet intera contactedObject.StayGrasped(contactingIntControllers); }); } - + private delegate bool StateChangeCheckFunc(InteractionController controller, out IInteractionBehaviour obj); private delegate bool MultiStateChangeCheckFunc(InteractionController controller, out HashSet objs); @@ -536,7 +559,7 @@ private void remapInteractionObjectStateChecks(ReadonlyHashSet> actionPerInteractionObject) { // Ensure the object->controllers buffer is non-null (ThreadStatic quirk) and clean. - if (s_objControllersMap == null) s_objControllersMap = new Dictionary>(); + if (s_objControllersMap == null) s_objControllersMap = new Dictionary>(); s_objControllersMap.Clear(); // In a nutshell, this remaps methods per-controller that output an interaction object if the controller changed that object's state @@ -714,7 +737,7 @@ public bool hasMovingFrameOfReference { } // Support for a moving frame of reference. - private Vector3 _prevPosition = Vector3.zero; + private Vector3 _prevPosition = Vector3.zero; private Quaternion _prevRotation = Quaternion.identity; private void updateMovingFrameOfReferenceSupport() { @@ -728,8 +751,8 @@ private void updateMovingFrameOfReferenceSupport() { /// frame of reference is moving. /// public void TransformAheadByFixedUpdate(Vector3 position, Quaternion rotation, out Vector3 newPosition, out Quaternion newRotation) { - Vector3 worldDisplacement = this.transform.position - _prevPosition; - Quaternion worldRotation = this.transform.rotation * Quaternion.Inverse(_prevRotation); + Vector3 worldDisplacement = this.transform.position - _prevPosition; + Quaternion worldRotation = this.transform.rotation * Quaternion.Inverse(_prevRotation); newPosition = ((worldRotation * (position - this.transform.position + worldDisplacement))) + this.transform.position; newRotation = worldRotation * rotation; } @@ -780,11 +803,9 @@ protected void generateAutomaticLayers() { if (string.IsNullOrEmpty(layerName)) { if (_interactionLayer == -1) { _interactionLayer = i; - } - else if (_interactionNoContactLayer == -1) { + } else if (_interactionNoContactLayer == -1) { _interactionNoContactLayer = i; - } - else if (_contactBoneLayer == -1) { + } else if (_contactBoneLayer == -1) { _contactBoneLayer = i; break; } diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs similarity index 91% rename from Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs rename to Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs index 129a58e7df..c49d5c31dd 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs @@ -1,9 +1,13 @@ using UnityEngine; using UnityEditor; -namespace Leap.Unity.Interaction { +namespace Leap.Unity.Interaction.Internal { +#if UNITY_EDITOR public static class InteractionPreferences { + public const float MAX_GRAVITY_MAGNITUDE = 4.905f; + public const float MAX_TIMESTEP = 1.0f / 90.0f; + public const string PROMPT_FOR_GRAVITY_KEY = "InteractionEngine_ShouldPrompForGravity"; public const string PROMPT_FOR_PHYSICS_TIMESTEP = "InteractionEngine_ShouldPrompForTimestep"; @@ -46,4 +50,5 @@ private static void preferencesGUI() { } } } +#endif } diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs.meta b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs.meta similarity index 100% rename from Assets/LeapMotion/Modules/InteractionEngine/Scripts/Editor/InteractionPreferences.cs.meta rename to Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs.meta From 5f7915cb5967aaf986856cdb2218548dfeb25901 Mon Sep 17 00:00:00 2001 From: Amarcolina Date: Fri, 9 Jun 2017 14:31:48 -0700 Subject: [PATCH 6/7] Made a little bit better --- .../Modules/InteractionEngine/Scripts/InteractionManager.cs | 3 ++- .../Scripts/Internal/InteractionPreferences.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs index d003551671..dafa68cdb3 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/InteractionManager.cs @@ -221,7 +221,8 @@ void Awake() { if (InteractionPreferences.shouldPrompForPhysicsTimestep && Application.isPlaying) { if (Time.fixedDeltaTime > InteractionPreferences.MAX_TIMESTEP + Mathf.Epsilon) { - if (!EditorUtility.DisplayDialog("Timestep too slow!", "Your fixed timestep is " + Time.fixedDeltaTime + ", which is slower than the recommended value of 0.01111.\n\nGo to Edit->ProjectSettings->Time to change the timestep.", "Ok", "Don't Show Again")) { + float roundedTimestep = (float)Math.Round(InteractionPreferences.MAX_TIMESTEP, 4); + if (!EditorUtility.DisplayDialog("Timestep too slow!", "Your fixed timestep is " + Time.fixedDeltaTime + ", which is slower than the recommended value of " + roundedTimestep + ".\n\nGo to Edit->ProjectSettings->Time to change the fixed timestep.", "Ok", "Don't Show Again")) { InteractionPreferences.shouldPrompForPhysicsTimestep = false; } EditorApplication.isPlaying = false; diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs index c49d5c31dd..15656395d0 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs @@ -6,7 +6,12 @@ namespace Leap.Unity.Interaction.Internal { #if UNITY_EDITOR public static class InteractionPreferences { public const float MAX_GRAVITY_MAGNITUDE = 4.905f; + +#if UNITY_ANDROID + public const float MAX_TIMESTEP = 1.0f / 60.0f; +#else public const float MAX_TIMESTEP = 1.0f / 90.0f; +#endif public const string PROMPT_FOR_GRAVITY_KEY = "InteractionEngine_ShouldPrompForGravity"; public const string PROMPT_FOR_PHYSICS_TIMESTEP = "InteractionEngine_ShouldPrompForTimestep"; From 55b1619100f8d737dce5dfdef2ec732f378a978a Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Fri, 9 Jun 2017 15:25:57 -0700 Subject: [PATCH 7/7] Fix Builds --- .../Scripts/Internal/InteractionPreferences.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs index 15656395d0..6e9706658a 100644 --- a/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs +++ b/Assets/LeapMotion/Modules/InteractionEngine/Scripts/Internal/InteractionPreferences.cs @@ -1,5 +1,7 @@ using UnityEngine; +#if UNITY_EDITOR using UnityEditor; +#endif namespace Leap.Unity.Interaction.Internal {