Skip to content

Instantly share code, notes, and snippets.

@Venkat-Swaraj
Created July 20, 2022 06:29
Show Gist options
  • Save Venkat-Swaraj/ec03e0bbc7dc6af73f8dd2cd0c6a0f93 to your computer and use it in GitHub Desktop.
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)
// 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