Skip to content

Commit

Permalink
Fix ResetButton teleports if moved after Start()
Browse files Browse the repository at this point in the history
Let red parts animated locally
Close #114
Close #115
  • Loading branch information
lawwong committed Apr 18, 2019
1 parent 13f1677 commit cff744a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public class ResetButton : MonoBehaviour

private RigidPose[] resetPoses;

private Vector3 buttonOriginPosition;

private HashSet<ColliderButtonEventData> pressingEvents = new HashSet<ColliderButtonEventData>();

public ColliderButtonEventData.InputButton activeButton
Expand All @@ -45,8 +43,6 @@ private void Start()
{
resetPoses[i] = new RigidPose(effectTargets[i]);
}

buttonOriginPosition = buttonObject.position;
}
#if UNITY_EDITOR
protected virtual void OnValidate()
Expand Down Expand Up @@ -81,15 +77,15 @@ public void OnColliderEventPressEnter(ColliderButtonEventData eventData)
{
if (eventData.button == m_activeButton && pressingEvents.Add(eventData) && pressingEvents.Count == 1)
{
buttonObject.position = buttonOriginPosition + buttonDownDisplacement;
buttonObject.localPosition += buttonDownDisplacement;
}
}

public void OnColliderEventPressExit(ColliderButtonEventData eventData)
{
if (pressingEvents.Remove(eventData) && pressingEvents.Count == 0)
{
buttonObject.position = buttonOriginPosition;
buttonObject.localPosition -= buttonDownDisplacement;
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit cff744a

Please sign in to comment.