Last active
August 18, 2018 16:00
-
-
Save jackbrookes/5a0f8e86c10161955a76fa47e1733856 to your computer and use it in GitHub Desktop.
Unity script that enables/disables a gameobject (like a warning text) when the user presses the System Button in SteamVR
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class SteamVROverlayCheck : MonoBehaviour | |
{ | |
public GameObject warningDisplay; | |
void OnEnable() | |
{ | |
SteamVR_Events.InputFocus.AddListener(OnFocus); | |
} | |
void OnDisable() | |
{ | |
SteamVR_Events.InputFocus.RemoveListener(OnFocus); | |
} | |
void OnFocus(bool focusState) | |
{ | |
warningDisplay.SetActive(!focusState); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment