diff --git a/Assets/HTC.UnityPlugin/ViveInputUtility/Examples/5.ColliderEvent/Scripts/ResetButton.cs b/Assets/HTC.UnityPlugin/ViveInputUtility/Examples/5.ColliderEvent/Scripts/ResetButton.cs index f393f33d..07257573 100644 --- a/Assets/HTC.UnityPlugin/ViveInputUtility/Examples/5.ColliderEvent/Scripts/ResetButton.cs +++ b/Assets/HTC.UnityPlugin/ViveInputUtility/Examples/5.ColliderEvent/Scripts/ResetButton.cs @@ -37,6 +37,12 @@ public ColliderButtonEventData.InputButton activeButton } private void Start() + { + CacheResetPoses(); + } + + // Updates the resetPoses with the current effectTarget poses + private void CacheResetPoses() { resetPoses = new RigidPose[effectTargets.Length]; for (int i = 0; i < effectTargets.Length; ++i) @@ -44,6 +50,7 @@ private void Start() resetPoses[i] = new RigidPose(effectTargets[i]); } } + #if UNITY_EDITOR protected virtual void OnValidate() { @@ -77,6 +84,7 @@ public void OnColliderEventPressEnter(ColliderButtonEventData eventData) { if (eventData.button == m_activeButton && pressingEvents.Add(eventData) && pressingEvents.Count == 1) { + CacheResetPoses(); buttonObject.localPosition += buttonDownDisplacement; } }