private void Start() { if (GetComponent <VRTK_ControllerEvents>() == null) { Debug.LogError("VRTK_ControllerEvents_ListenerExample is required to be attached to a Controller that has the VRTK_ControllerEvents script attached to it"); return; } events = GetComponent <VRTK_ControllerEvents>(); actions = GetComponent <VRTK_ControllerActions>(); tooltips = GetComponentInChildren <VRTK_ControllerTooltips>(); //Setup controller event listeners events.TriggerPressed += new ControllerInteractionEventHandler(DoTriggerPressed); events.TriggerReleased += new ControllerInteractionEventHandler(DoTriggerReleased); events.ApplicationMenuPressed += new ControllerInteractionEventHandler(DoApplicationMenuPressed); events.ApplicationMenuReleased += new ControllerInteractionEventHandler(DoApplicationMenuReleased); events.GripPressed += new ControllerInteractionEventHandler(DoGripPressed); events.GripReleased += new ControllerInteractionEventHandler(DoGripReleased); events.TouchpadPressed += new ControllerInteractionEventHandler(DoTouchpadPressed); events.TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadReleased); tooltips.ShowTips(false); }
//總是顯示 public void AlwaysShowHint(bool always) { _alwaysShow = always; try { //有時候會因為時間順序不同無法取得腳本 _tooltips = GetComponentInChildren <VRTK_ControllerTooltips>();//取得 _tooltips.ShowTips(_alwaysShow); } catch { } }
//如果板機壓下去 private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e) { _tooltips.ShowTips(true, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip); actions.ToggleHighlightTrigger(true, Color.yellow, 0.5f); actions.SetControllerOpacity(0.8f); }