1099 Posted December 30, 2022 Share Posted December 30, 2022 I want to implement UI canvas display on off with menu button with simulator. How can I attempt this? I created two functions to turn on off, but I am not sure if this is the right approach. private void menuButtonOff() { ViveInput.RemoveListenerEx(HandRole.RightHand, ControllerButton.Menu, ButtonEventType.Down, menuButtonOff); cube.SetActive(false); } private void menuButton() { ViveInput.AddListenerEx(HandRole.RightHand, ControllerButton.Menu, ButtonEventType.Down, menuButton); cube.SetActive(true); Debug.Log("test menu button"); } Link to comment Share on other sites More sharing options...
chengnay Posted December 30, 2022 Share Posted December 30, 2022 Hi @1099, After revised your script, I got it working with below solution, public GameObject cube; private void OnEnable() { ViveInput.AddListenerEx(HandRole.RightHand, ControllerButton.Menu, ButtonEventType.Down, menuButton); } private void OnDisable() { ViveInput.RemoveListenerEx(HandRole.RightHand, ControllerButton.Menu, ButtonEventType.Down, menuButton); } private void menuButton() { cube.SetActive(!cube.activeSelf); } If you still have issue, please let me know, thanks! Link to comment Share on other sites More sharing options...
laurafinn Posted December 30, 2022 Share Posted December 30, 2022 same, i dont know how to disable it Link to comment Share on other sites More sharing options...
chengnay Posted December 30, 2022 Share Posted December 30, 2022 Hi @laurafinn, 1 hour ago, chengnay said: public GameObject cube; private void OnEnable() { ViveInput.AddListenerEx(HandRole.RightHand, ControllerButton.Menu, ButtonEventType.Down, menuButton); } private void OnDisable() { ViveInput.RemoveListenerEx(HandRole.RightHand, ControllerButton.Menu, ButtonEventType.Down, menuButton); } private void menuButton() { cube.SetActive(!cube.activeSelf); } Please try this script. Link to comment Share on other sites More sharing options...
1099 Posted December 30, 2022 Author Share Posted December 30, 2022 @chengnay It works! Thank you so much! I have another question. Do I need to use this specific method to access Simulator button? ViveInput.AddListenerEx(HandRole.RightHand, ControllerButton.Menu, ButtonEventType.Down, menuButton) Or, can I use different method such as Unity's TryGetFeatureValue? Unity - Manual: Unity XR Input (unity3d.com) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now