Created
July 20, 2022 06:29
-
-
Save Venkat-Swaraj/ec03e0bbc7dc6af73f8dd2cd0c6a0f93 to your computer and use it in GitHub Desktop.
Cardboard setup (For cross button and settings button to work you need to use this script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add an empty gameobject to the scene and simple add this script to the gameobject by clicking add component and locate this script | |
// Or create a new script and paste the below code into it. | |
using System.Collections; | |
using Google.XR.Cardboard; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.XR; | |
using UnityEngine.XR.Management; | |
public class CardboardSetup : MonoBehaviour | |
{ | |
// Start is called before the first frame update | |
void Start() | |
{ | |
Screen.sleepTimeout = SleepTimeout.NeverSleep; | |
if (!Api.HasDeviceParams()) | |
Api.ScanDeviceParams(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
if (Api.IsGearButtonPressed) | |
Api.ScanDeviceParams(); | |
if (Api.IsCloseButtonPressed) | |
Application.Quit(); | |
if (Api.HasNewDeviceParams()) | |
Api.ReloadDeviceParams(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment