示例#1
0
    /// <summary>
    /// When Grip is clicked, notify InteractableObject of OnGripPressed and OnPointerLeave
    /// <returns></returns>
    ///
    private void Controller_GripClicked(object sender, ControllerInteractionEventArgs e)
    {
        // Report that the current object is being grabbed. This can tell the stack it is being removed


        currentObject?.OnGripPressed();
        selectingObject = false;
        currentObject?.OnPointerLeave();
        currentObject = null;
        dataToolTip.ToggleTips(false);
    }
        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.ToggleTips(false);
        }
示例#3
0
        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>();
            highligher        = GetComponent <VRTK_ControllerHighlighter>();
            tooltips          = GetComponentInChildren <VRTK_ControllerTooltips>();
            currentPulseColor = pulseColor;
            highlighted       = false;

            //Setup controller event listeners
            events.TriggerPressed  += new ControllerInteractionEventHandler(DoTriggerPressed);
            events.TriggerReleased += new ControllerInteractionEventHandler(DoTriggerReleased);

            events.ButtonOnePressed  += new ControllerInteractionEventHandler(DoButtonOnePressed);
            events.ButtonOneReleased += new ControllerInteractionEventHandler(DoButtonOneReleased);

            events.ButtonTwoPressed  += new ControllerInteractionEventHandler(DoButtonTwoPressed);
            events.ButtonTwoReleased += new ControllerInteractionEventHandler(DoButtonTwoReleased);

            events.StartMenuPressed  += new ControllerInteractionEventHandler(DoStartMenuPressed);
            events.StartMenuReleased += new ControllerInteractionEventHandler(DoStartMenuReleased);

            events.GripPressed  += new ControllerInteractionEventHandler(DoGripPressed);
            events.GripReleased += new ControllerInteractionEventHandler(DoGripReleased);

            events.TouchpadPressed  += new ControllerInteractionEventHandler(DoTouchpadPressed);
            events.TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadReleased);

            tooltips.ToggleTips(false);
        }
        private void Start()
        {
            if (GetComponent <VRTK_ControllerEvents>() == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerAppearance_Example", "VRTK_ControllerEvents", "the same"));
                return;
            }

            events   = GetComponent <VRTK_ControllerEvents>();
            tooltips = GetComponentInChildren <VRTK_ControllerTooltips>();

            //Setup controller event listeners
            events.TriggerPressed  += new ControllerInteractionEventHandler(DoTriggerPressed);
            events.TriggerReleased += new ControllerInteractionEventHandler(DoTriggerReleased);

            events.ButtonOnePressed  += new ControllerInteractionEventHandler(DoButtonOnePressed);
            events.ButtonOneReleased += new ControllerInteractionEventHandler(DoButtonOneReleased);

            events.ButtonTwoPressed  += new ControllerInteractionEventHandler(DoButtonTwoPressed);
            events.ButtonTwoReleased += new ControllerInteractionEventHandler(DoButtonTwoReleased);

            events.TouchpadTouchStart += new ControllerInteractionEventHandler(DoTouchpadTouchStart);
            events.TouchpadTouchEnd   += new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            events.GripPressed  += new ControllerInteractionEventHandler(DoGripPressed);
            events.GripReleased += new ControllerInteractionEventHandler(DoGripReleased);

            //  events.TouchpadPressed += new ControllerInteractionEventHandler(DoTouchpadPressed);
            //  events.TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadReleased);

            tooltips.ToggleTips(false);
        }
        private void OnEnable()
        {
            if (GetComponent <VRTK_ControllerEvents>() == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerAppearance_Example", "VRTK_ControllerEvents", "the same"));
                return;
            }

            events            = GetComponent <VRTK_ControllerEvents>();
            highligher        = GetComponent <VRTK_ControllerHighlighter>();
            tooltips          = GetComponentInChildren <VRTK_ControllerTooltips>();
            currentPulseColor = pulseColor;
            highlighted       = false;

            //Setup controller event listeners
            events.TriggerPressed    += DoTriggerPressed;
            events.TriggerReleased   += DoTriggerReleased;
            events.ButtonOnePressed  += DoButtonOnePressed;
            events.ButtonOneReleased += DoButtonOneReleased;
            events.ButtonTwoPressed  += DoButtonTwoPressed;
            events.ButtonTwoReleased += DoButtonTwoReleased;
            events.StartMenuPressed  += DoStartMenuPressed;
            events.StartMenuReleased += DoStartMenuReleased;
            events.GripPressed       += DoGripPressed;
            events.GripReleased      += DoGripReleased;
            events.TouchpadPressed   += DoTouchpadPressed;
            events.TouchpadReleased  += DoTouchpadReleased;

            tooltips.ToggleTips(false);
        }
        /*    void CheckAction<T>(AudioRef audio, Func<T> currentState, T state)
         *   {
         *       bool isPlaying = audio.Value.isPlaying;
         *       while (isPlaying)
         *       {
         *           if (currentState().Equals(state))
         *           {
         *               Debug.Log(currentState());
         *               stepFinished = true;
         *               return;
         *           }
         *           isPlaying = audio.Value.isPlaying;
         *       }
         *   }
         *
         *   IEnumerator CheckAction<T> (Func<T> currentState, T state)
         *   {
         *       if (!stepFinished)
         *       {
         *           Debug.Log(currentState());
         *           yield return new WaitUntil(() => currentState().Equals(state));
         *       }
         *       stepFinished = false;
         *   }
         */

        /// <summary>
        /// Plays the audio of the tutorial step, and shows the tooltip of the corresponding button and additional givin tooltip if there is one.
        /// Waits until does the task mentioned in the tutorial step.
        /// </summary>
        /// <param name="audio">The audio to play for the tutorial step</param>
        /// <param name="button">The button that is required for the tutorial step, of which its tooltip should show</param>
        /// <param name="tooltip">Additional tooltip object that should show if needed for the tutorial step, null if only one tooltip is needed.</param>
        /// <param name="controller">If controller is -1 then left only, 0 then both, 1 then right controller only</param>
        /// <returns></returns>
        IEnumerator TutorialStep(AudioSource audio, VRTK_ControllerTooltips.TooltipButtons button, VRTK_ObjectTooltip tooltip, int controller)
        {
            audio.Play();

            //change tooltip colors to the color during tutorial step
            if (controller <= 0)
            {
                ChangeTooltipColorDuringTutorialStep(leftToggling, leftToggling.ChangeButtonToTooltip(button));
                leftTooltips.ToggleTips(true, button);
            }
            if (controller >= 0)
            {
                if (tooltip != null)
                {
                    ChangeTooltipColorDuringTutorialStep(rightToggling, tooltip);
                    rightTooltips.ToggleTips(true, rightToggling.ChangeTooltipToButton(tooltip));
                }
                ChangeTooltipColorDuringTutorialStep(rightToggling, rightToggling.ChangeButtonToTooltip(button));
                rightTooltips.ToggleTips(true, button);
            }
            //CheckAction(audio, currentState, state);
            yield return(new WaitForSecondsRealtime(audio.clip.length));

            //yield return StartCoroutine(CheckAction(currentState, state));

            yield return(new WaitUntil(() => stepFinished)); //wait until step is finished before continuing tutorial

            //change tooltip colors once step is finished
            if (controller <= 0)
            {
                ChangeTooltipColorAfterTutorialStep(leftToggling, leftToggling.ChangeButtonToTooltip(button));
                leftTooltips.ToggleTips(false, button);
            }
            if (controller >= 0)
            {
                if (tooltip != null)
                {
                    ChangeTooltipColorAfterTutorialStep(rightToggling, tooltip);
                    rightTooltips.ToggleTips(false, rightToggling.ChangeTooltipToButton(tooltip));
                }
                ChangeTooltipColorAfterTutorialStep(rightToggling, rightToggling.ChangeButtonToTooltip(button));
                rightTooltips.ToggleTips(false, button);
            }

            //set it back to false for the next step
            stepFinished = false;
        }
示例#7
0
    /// <summary>
    /// When TriggerPressed, two options for behaviour. If user is currently pointing at object, notify object on event. Otherwise, show tooltip.
    /// <returns></returns>
    ///
    private void Controller_TriggerPressed(object sender, ControllerInteractionEventArgs e)
    {
        //If still on an object
        triggerPressed = true;

        TubeRenderer closestTube = pickingTube(this.transform.position, this.transform.position + this.transform.forward * sizeRay);

        if (closestTube != null)
        {
            //closestTube.GetComponent<Renderer>().material.color = lineRenderer.material.color;
            var p1 = closestTube.p1;
            var p2 = closestTube.p2;

            m1 = p1.draw_map(pointer.transform.parent.transform);
            m2 = p2.draw_map(pointer.transform.parent.transform);

            //m1.transform.position = p1.transform            //m1.transform.position = p1.transform


            m1.link_two_maps(m2);

            cp1 = m1.transform.parent;
            cp2 = m2.transform.parent;

            m1.transform.parent = pointer.transform;
            m2.transform.parent = pointer.transform;

            reset_parents = true;
        }


        else if (currentObject != null)
        {
            //Do something on click
            GameObject go = currentObject.OnTriggerPressed(pointer.transform.parent.transform);
            if (go != null)
            {
                GetComponent <VRTK_InteractGrab>().AttemptGrabObject(go);
            }
        }
        else
        {
            helpTooltipState = !helpTooltipState;
            helpTooltip.ToggleTips(helpTooltipState);
        }
    }
 private void Start()
 {
     InitVRInputListeners();
     tooltips = GetComponentInChildren <VRTK_ControllerTooltips>();
     if (tooltips != null)
     {
         tooltips.ToggleTips(false);
     }
 }
示例#9
0
        void SetMode(IHandMode mode)
        {
            var newActiveFuncs = mode.FuncTypes;

            TooltipButtons newTooltips = 0;

            foreach (var func in activeFuncs)
            {
                if (!newActiveFuncs.Contains(func))
                {
                    var fnObj = funcs[func];

                    fnObj.Disable(this);

                    foreach (var pair in fnObj.Tooltips)
                    {
                        tooltips.UpdateText(pair.Key, "");

                        newTooltips |= pair.Key;
                    }
                }
            }

            foreach (var func in newActiveFuncs)
            {
                if (!activeFuncs.Contains(func))
                {
                    var fnObj = funcs[func];

                    fnObj.Enable(this);

                    foreach (var pair in fnObj.Tooltips)
                    {
                        tooltips.UpdateText(pair.Key, pair.Value);

                        newTooltips |= pair.Key;
                    }
                }
            }

            // ...because apparently passing a mask to ToggleTips breaks it.
            foreach (TooltipButtons value in Enum.GetValues(typeof(TooltipButtons)))
            {
                if ((newTooltips & value) != 0)
                {
                    tooltips.ToggleTips(true, value);
                }
            }

            activeFuncs = newActiveFuncs;
        }
示例#10
0
        public static TutorialState currentTutorialState; //keeps track of the current tutorial state

        /// <summary>
        /// Initializes all necessary variables and starts the tutorial
        /// </summary>
        void Start()
        {
            stepFinished = false;

            rightTooltips = rightController.GetComponentInChildren <VRTK_ControllerTooltips>();
            leftTooltips  = leftController.GetComponentInChildren <VRTK_ControllerTooltips>();
            rightToggling = rightController.GetComponent <Tooltips>();
            leftToggling  = leftController.GetComponent <Tooltips>();

            leftTooltips.ToggleTips(false);
            rightTooltips.ToggleTips(false);

            currentTutorialState = TutorialState.NONE;

            StartCoroutine(TutorialCoroutine());
        }
        /// <summary>
        /// Initializes all necessary variables and starts the tutorial
        /// </summary>
        void Start()
        {
            stepFinished = false;

            rightTooltips = rightController.GetComponentInChildren <VRTK_ControllerTooltips>();
            leftTooltips  = leftController.GetComponentInChildren <VRTK_ControllerTooltips>();
            rightToggling = rightController.GetComponent <Tooltips>();
            leftToggling  = leftController.GetComponent <Tooltips>();

            leftTooltips.ToggleTips(false);
            rightTooltips.ToggleTips(false);

            currentTutorialState = TutorialState.NONE;

            instruction = GameObject.Find("InstructionCanvas/InstructionText").GetComponent <Text>();

            StartCoroutine(TutorialCoroutine());
        }
示例#12
0
    /// <summary>
    /// Set up event listeners from Controller and Pointer
    /// <returns></returns>
    ///
    void Awake()
    {
        //VRTK_ControllerEvents controller;

        //Set up event listeners
        pointer = GetComponent <VRTK_Pointer>();
        pointer.DestinationMarkerEnter += Pointer_DestinationMarkerEnter;
        pointer.DestinationMarkerExit  += Pointer_DestinationMarkerExit;

        controller = GetComponent <VRTK_ControllerEvents>();
        controller.TriggerPressed      += Controller_TriggerPressed;
        controller.TriggerReleased     += Controller_TriggerReleased;
        controller.TouchpadAxisChanged += Controller_TouchpadAxisChanged;
        controller.TouchpadReleased    += Controller_TouchpadReleased;
        controller.TouchpadPressed     += Controller_TouchpadPressed;
        controller.GripClicked         += Controller_GripClicked;

        lineRenderer                 = gameObject.AddComponent <LineRenderer>();
        lineRenderer.material        = new Material(Shader.Find("Sprites/Default"));
        lineRenderer.widthMultiplier = 0.02f;
        lineRenderer.positionCount   = 2;
        bundle  = true;
        sizeRay = 1;
        lineRenderer.material.color = Color.green;


        helpTooltip = gameObject.transform.GetChild(0).GetComponent <VRTK_ControllerTooltips>();
        helpTooltip.ToggleTips(false);


        dataToolTip = gameObject.transform.GetChild(1).GetComponent <VRTK_ControllerTooltips>();
        dataToolTip.ToggleTips(false);


        //Anonymous function to Update the dataToolTip text.
        changeText = delegate(string x) {
            dataToolTip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, x);
        };
    }
 private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e)
 {
     tooltips.ToggleTips(true, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip);
     actions.ToggleHighlightTrigger(true, Color.yellow, 0.5f);
     actions.SetControllerOpacity(0.8f);
 }
 private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e)
 {
     tooltips.ToggleTips(true, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip);
     highligher.HighlightElement(SDK_BaseController.ControllerElements.Trigger, highlightColor, (pulseTriggerHighlightColor ? pulseTimer : highlightTimer));
     if (pulseTriggerHighlightColor)
     {
         InvokeRepeating("PulseTrigger", pulseTimer, pulseTimer);
     }
     VRTK_ObjectAppearance.SetOpacity(VRTK_DeviceFinder.GetModelAliasController(events.gameObject), dimOpacity);
 }
 private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e)
 {
     tooltips.ToggleTips(true, VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip);
 }
示例#16
0
 /// <summary>
 /// This function determines the behavior of the tooltip when the corresponding button is pressed
 /// </summary>
 /// <param name="tooltip">The tooltip which should have its behavior changed</param>
 /// <param name="tooltipButton">The button that corresponds to the tooltip</param>
 private void DoTooltipPressed(VRTK_ObjectTooltip tooltip, VRTK_ControllerTooltips.TooltipButtons tooltipButton)
 {
     tooltips.ToggleTips(true, tooltipButton);
 }
        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.ToggleTips(false);
        }