Skip to content

Commit cff744a

Browse files
committed
Fix ResetButton teleports if moved after Start()
Let red parts animated locally Close #114 Close #115
1 parent 13f1677 commit cff744a

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Assets/HTC.UnityPlugin/ViveInputUtility/Examples/5.ColliderEvent/Scripts/ResetButton.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public class ResetButton : MonoBehaviour
1717

1818
private RigidPose[] resetPoses;
1919

20-
private Vector3 buttonOriginPosition;
21-
2220
private HashSet<ColliderButtonEventData> pressingEvents = new HashSet<ColliderButtonEventData>();
2321

2422
public ColliderButtonEventData.InputButton activeButton
@@ -45,8 +43,6 @@ private void Start()
4543
{
4644
resetPoses[i] = new RigidPose(effectTargets[i]);
4745
}
48-
49-
buttonOriginPosition = buttonObject.position;
5046
}
5147
#if UNITY_EDITOR
5248
protected virtual void OnValidate()
@@ -81,15 +77,15 @@ public void OnColliderEventPressEnter(ColliderButtonEventData eventData)
8177
{
8278
if (eventData.button == m_activeButton && pressingEvents.Add(eventData) && pressingEvents.Count == 1)
8379
{
84-
buttonObject.position = buttonOriginPosition + buttonDownDisplacement;
80+
buttonObject.localPosition += buttonDownDisplacement;
8581
}
8682
}
8783

8884
public void OnColliderEventPressExit(ColliderButtonEventData eventData)
8985
{
9086
if (pressingEvents.Remove(eventData) && pressingEvents.Count == 0)
9187
{
92-
buttonObject.position = buttonOriginPosition;
88+
buttonObject.localPosition -= buttonDownDisplacement;
9389
}
9490
}
9591
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ Repository: [GitHub](https://github.com/ViveSoftware/ViveInputUtility-Unity)
4444
3. [Fork this project](https://github.com/ViveSoftware/ViveInputUtility-Unity/fork) on GitHub.
4545
4. Create a new branch (based on master branch) for your work on your fork.
4646
5. After you finish your work
47-
- Make sure all files start with `//========= Copyright 2016-2018, HTC Corporation. All rights reserved. ===========`
47+
- Make sure all files start with `//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========`
4848
- 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).
4949
6. Submit a pull request from your new branch to our develop branch.

0 commit comments

Comments
 (0)