From cff744a96188b0a86b2a26763c96ca17a55b06d6 Mon Sep 17 00:00:00 2001 From: lawwong Date: Thu, 18 Apr 2019 17:17:53 +0800 Subject: [PATCH] Fix ResetButton teleports if moved after Start() Let red parts animated locally Close #114 Close #115 --- .../Examples/5.ColliderEvent/Scripts/ResetButton.cs | 8 ++------ README.md | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) 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 1aa1e10e..f393f33d 100644 --- a/Assets/HTC.UnityPlugin/ViveInputUtility/Examples/5.ColliderEvent/Scripts/ResetButton.cs +++ b/Assets/HTC.UnityPlugin/ViveInputUtility/Examples/5.ColliderEvent/Scripts/ResetButton.cs @@ -17,8 +17,6 @@ public class ResetButton : MonoBehaviour private RigidPose[] resetPoses; - private Vector3 buttonOriginPosition; - private HashSet pressingEvents = new HashSet(); public ColliderButtonEventData.InputButton activeButton @@ -45,8 +43,6 @@ private void Start() { resetPoses[i] = new RigidPose(effectTargets[i]); } - - buttonOriginPosition = buttonObject.position; } #if UNITY_EDITOR protected virtual void OnValidate() @@ -81,7 +77,7 @@ public void OnColliderEventPressEnter(ColliderButtonEventData eventData) { if (eventData.button == m_activeButton && pressingEvents.Add(eventData) && pressingEvents.Count == 1) { - buttonObject.position = buttonOriginPosition + buttonDownDisplacement; + buttonObject.localPosition += buttonDownDisplacement; } } @@ -89,7 +85,7 @@ public void OnColliderEventPressExit(ColliderButtonEventData eventData) { if (pressingEvents.Remove(eventData) && pressingEvents.Count == 0) { - buttonObject.position = buttonOriginPosition; + buttonObject.localPosition -= buttonDownDisplacement; } } } diff --git a/README.md b/README.md index 650d9c0e..2d617917 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,6 @@ Repository: [GitHub](https://github.com/ViveSoftware/ViveInputUtility-Unity) 3. [Fork this project](https://github.com/ViveSoftware/ViveInputUtility-Unity/fork) on GitHub. 4. Create a new branch (based on master branch) for your work on your fork. 5. After you finish your work - - Make sure all files start with `//========= Copyright 2016-2018, HTC Corporation. All rights reserved. ===========` + - Make sure all files start with `//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========` - Try leaving [good commit message](https://chris.beams.io/posts/git-commit/) and [keeping commit histories clean](https://www.notion.so/Keeping-Commit-Histories-Clean-0f717c4e802c4a0ebd852cf9337ce5d2). 6. Submit a pull request from your new branch to our develop branch.