Mina Fawzy
Mina Fawzy

Reputation: 21452

Samsung Gear Vr - handle back button clicks

how can I handle back button single click , long click to pause game , if pressed again destroy game

Upvotes: 2

Views: 2852

Answers (1)

Robert
Robert

Reputation: 5302

I think the back button maps to mouse button 1 so you should be able to pick it up with:

Input.GetMouseButtonDown (1);

To detect double clicks or long clicks you would measure the time between each click or how long the button has been pressed, respectively. I have never tried this but it could be something along the lines of setting up a variable to hold the time interval and checking if the second click happens within that time.

-EDIT- I just found another discussion about this here with some examples which should help, e.g.

if(Input.GetMouseButtonDown(0))
{
 _buttonDownPhaseStart = Time.time;    
}

if (_doubleClickPhaseStart > -1 && (Time.time - _doubleClickPhaseStart) > 0.2f)
{
     Debug.Log ("single click");
     _doubleClickPhaseStart = -1;
}

if( Input.GetMouseButtonUp(0) )        
{
      if(Time.time - _buttonDownPhaseStart > 1.0f)
 {
     Debug.Log ("long click");
     _doubleClickPhaseStart = -1;
 }
 else
 {
     if (Time.time - _doubleClickPhaseStart < 0.2f)
      {
           Debug.Log ("double click");
           _doubleClickPhaseStart = -1;
      }
      else
      {
         _doubleClickPhaseStart = Time.time;
      }    
 }
}

Upvotes: 2

Related Questions