Skip to content

Instantly share code, notes, and snippets.

@jackbrookes
Last active August 18, 2018 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackbrookes/5a0f8e86c10161955a76fa47e1733856 to your computer and use it in GitHub Desktop.
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
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