Jump to content
Happy Holidays! Limited Staff Responses: 1/20 - 1/31 ×

How to enable and disable menu button with the simulator?


1099
 Share

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...