private void DoButtonTwoPressed(object sender, ControllerInteractionEventArgs e) { _showOptions = !_showOptions; if (_showOptions) { SwitchMode.OptionLock = true; _originalPointerState = GameObject.Find("RightController").GetComponent <VRTK_Pointer>().enabled; GameObject.Find("RightController").GetComponent <VRTK_UIPointer>().enabled = true; SwitchMode.Instance.ReleaseCurrentTool(); _originalPointerOrigin = SwitchMode.IsHeadsetPointer(); if (SwitchMode.IsHeadsetPointer()) { SwitchMode.Instance.TogglePointerOrigin(); } SwitchMode.EnablePointer(); _originalColorpickerState = SwitchMode.IsColorPickerActive(); SwitchMode.DisableColorPicker(); } else { GameObject.Find("RightController").GetComponent <VRTK_UIPointer>().enabled = false; if (!_originalPointerState) { SwitchMode.DisablePointer(); } SwitchMode.Instance.RestoreLastTool(); SwitchMode.OptionLock = false; if (_originalPointerOrigin) { SwitchMode.Instance.TogglePointerOrigin(); } if (_originalColorpickerState) { SwitchMode.EnableColorPicker(); } } transform.GetChild(0).gameObject.SetActive(_showOptions); }
void Start() { SwitchMode.EnablePointer(); _headset = GameObject.Find("Headset"); if (GetComponent <VRTK_ControllerEvents>() == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same")); return; } _headset.GetComponent <VRTK_Pointer>().PointerStateValid += DoPointerEnter; _headset.GetComponent <VRTK_Pointer>().PointerStateInvalid += DoPointerExit; GetComponent <VRTK_Pointer>().PointerStateValid += DoPointerEnter; GetComponent <VRTK_Pointer>().PointerStateInvalid += DoPointerExit; }