Skip to content

Allow resetbutton to be moved - issue #114 #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using HTC.UnityPlugin.ColliderEvent;
//========= Copyright 2016-2018, HTC Corporation. All rights reserved. ===========

using HTC.UnityPlugin.ColliderEvent;
using HTC.UnityPlugin.Utility;
using System.Collections.Generic;
using UnityEngine;
Expand Down Expand Up @@ -39,6 +41,13 @@ public ColliderButtonEventData.InputButton activeButton
}

private void Start()
{
CachePositions();
}

// Cache the positions of the effectTargets and of the buttonObject so they can be restored
// in OnColliderEventPressUp and OnColliderEventPressExit
private void CachePositions()
{
resetPoses = new RigidPose[effectTargets.Length];
for (int i = 0; i < effectTargets.Length; ++i)
Expand All @@ -48,6 +57,7 @@ private void Start()

buttonOriginPosition = buttonObject.position;
}

#if UNITY_EDITOR
protected virtual void OnValidate()
{
Expand Down Expand Up @@ -81,6 +91,7 @@ public void OnColliderEventPressEnter(ColliderButtonEventData eventData)
{
if (eventData.button == m_activeButton && pressingEvents.Add(eventData) && pressingEvents.Count == 1)
{
CachePositions();
buttonObject.position = buttonOriginPosition + buttonDownDisplacement;
}
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Repository: [GitHub](https://github.com/ViveSoftware/ViveInputUtility-Unity)
5. After you finish your work
- Make sure all files start with `//========= Copyright 2016-2018, 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.
6. Submit a pull request from your new branch to our develop branch.