Search Unity

Gear VR back button menu

Discussion in 'AR/VR (XR) Discussion' started by Gnimmel, May 20, 2016.

  1. Gnimmel

    Gnimmel

    Joined:
    Apr 21, 2010
    Posts:
    358
    Are there any examples of how to open the Gear VR back button menu?

    The Gear VR examples I've downloaded from the asset store don't seem to work, they just fade the screen to black repeatedly once the back button has been held?
     
  2. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    Use the OvrPlatformMenu.cs available in Oculus Utilities.
     
  3. Gnimmel

    Gnimmel

    Joined:
    Apr 21, 2010
    Posts:
    358
    That did the trick :)

    Thank you very much.
     
  4. malcriado

    malcriado

    Joined:
    Dec 14, 2013
    Posts:
    8
    Hi guys,
    i´m also using OvrPlatformMenu.cs but i´m not having the chance to go, lets say to the main menu for short press of the back button in a level. Any ideas?
    Thanks in advance
     
  5. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    You could simply modify OvrPlatformMenu.cs. I've added a condition in the input check, so that if the user is in game a short press displays a pause menu rather than the gear vr 'Quit to home' menu. Just make sure you can leave the game with back button at root menu and keep access to the long press universal menu.
     
  6. malcriado

    malcriado

    Joined:
    Dec 14, 2013
    Posts:
    8
    Still no luck getting back button to go to home menu. Gruguir, could you elaborate how did you modify the code to get that working? it may help me to understand how to get miy issue solved.
    Thanks!
     
  7. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    Hey @malcriado , was out for some days.
    I added a 'showConfirmQuit' bool condition, that is active only at root menu of my app.

    Code (CSharp):
    1. void Update()
    2.     {
    3. #if UNITY_ANDROID
    4.         eBackButtonAction action = HandleBackButtonState();
    5.         if ( action == eBackButtonAction.DOUBLE_TAP )
    6.         {
    7.             ResetCursor();
    8.         }
    9.         else if ( action == eBackButtonAction.SHORT_PRESS && showConfirmQuit == true )
    10.         {
    11.             ResetCursor();
    12.             ShowConfirmQuitMenu();
    13.         }
    14.         else if ( action == eBackButtonAction.LONG_PRESS )
    15.         {
    16.             ShowGlobalMenu();
    17.         }
    18. #endif
    19.     }
     
  8. Sylafrs

    Sylafrs

    Joined:
    Jun 25, 2013
    Posts:
    65
  9. malcriado

    malcriado

    Joined:
    Dec 14, 2013
    Posts:
    8
    Hi @Gruguir sorry for the late reply, i ve been filming for a couple of days without having chances to continue on this :s
    My lack of knowledge in programming didnt let me get working your idea. When i replace the line:
    else if ( action == eBackButtonAction.SHORT_PRESS && showConfirmQuit == true )
    Unity throws an error fo missing a condition, and i have no idea what are we talking about! ja!
    What i did was to replace:

    elseif(action==eBackButtonAction.SHORT_PRESS)
    {
    ResetCursor();
    Application.LoadLevel("MainMenu");
    }

    And after that i resolved going back to main menu.
    I know its not the solution, but couldnt figure out any other way. It would be great if the script "OVRPLAtformMenu.cs" script could resolve this by default, again since im not a programmer i dont know if its possible.
     
  10. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    @malcriado the idea is you add your own boolean condition (i named it 'showConfirmQuit') - you have to declare the variable at the top of your script or you'll get an error - it's up to you to set it to true or false at given points of your game.
    You must allow your user to access the confirm quit menu at least at the root of your app, or it will be rejected by Oculus.
     
  11. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340