I have Created a VR video player using Google Cardboard SDK and Easy Movie Texture plugin in Unity. I want to add control buttons like play,pause ,stream like a normal video player. Anybody knows how it can be implemented ?
noob at Unity. Need a great help. Thanks in advance
I would suggest using the magnetic sliding trigger at the cardboard's side to allow the user to toggle a menu, and use the phone's gyroscope or compass to track user rotation and allow the user to select Play/Pause etc... A nod of the head, detectable by the phone's accelerometer, will be used to confirm an action.
Use the Cardboard.SDK.OnTrigger
event provided by the Google Cardboard API to detect the magnetic trigger pull in your script as such:
void OnEnable() {
Cardboard.SDK.OnTrigger += triggerPulledEvent;
}
void triggerPulledEvent() {
menuOpen = !menuOpen;//Toggle the menu
}
Then, poll the mobile device for sensors:
To select option based on head rotation:
Input.compass.enabled = true;
int totalOptions = 3;//Play, pause, exit
int selectionNumber = Input.compass.magneticHeading / 360 * totalOptions;
enum Options {
PLAY = 0, PAUSE = 1, EXIT = 2//Add more as needed
}
Of course, you'll need to display the current option the user is looking at, but I'll leave it to you.
For the accelerometer to detect nod, check for a significant value acceleration in the Y axis:
if(Math.Abs(Input.acceleration.y) > 13) {
ConfirmOption();
}
void ConfirmOption() {
//Code that plays, pauses, stops the video etc
}