using System.Collections; using System.Collections.Generic; using UnityEngine; using Valve.VR.InteractionSystem; public class CheckVisible : MonoBehaviour { Interactable ParentInteractable; bool CurrentState; Canvas GuiCanvas; void Start() { ParentInteractable = GetComponentInParent(); GuiCanvas = GetComponentInChildren(); CurrentState = true; } // Update is called once per frame void Update() { bool newState; if (ParentInteractable.attachedToHand) newState = true; else newState = false; if (CurrentState != newState) UpdateVisibility(newState); } private void UpdateVisibility(bool newState) { GuiCanvas.enabled = newState; CurrentState = newState; } }