private void Unhighlight(VRTK_ControllerHighlighter h)
 {
     for (int i = 0; i < elements.Count; ++i)
     {
         h.UnhighlightElement(elements[i]);
     }
 }
        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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        obiTape = GameObject.Find("TapeController");
        obiTape.SetActive(false);

        string leftPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/Model";

        leftHighlighter = GameObject.Find(leftPath).GetComponent <VRTK_ControllerHighlighter>();
    }
    private void OnEnable()
    {
        var evnts = GetComponentInParent <VRTK_ControllerEvents>();

        if (highlighter == null)
        {
            highlighter = evnts.GetComponentInChildren <VRTK_ControllerHighlighter>();
        }
        if (tooltips == null)
        {
            tooltips = evnts.GetComponentInChildren <VRTK_ControllerTooltips>();
        }
    }
    public override void Highlight()
    {
        highlighterR = rightHand ? FetchHighlighter(VRTK_DeviceFinder.GetControllerRightHand()) : null;
        highlighterL = leftHand ? FetchHighlighter(VRTK_DeviceFinder.GetControllerLeftHand()) : null;

        if (highlighterR != null)
        {
            Highlight(highlighterR);
        }
        if (highlighterL != null)
        {
            Highlight(highlighterL);
        }
    }
Exemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        restDarboux = new Quaternion(0.7f, 0.0f, 0.0f, 0.7f);       // constant
        offset      = new Vector3(0.2f, -1.0f, -0.3f);
        offsetNeg   = new Vector3(-0.2f, -1.0f, -0.3f);

        leftController  = VRTK_DeviceFinder.GetControllerLeftHand();
        rightController = VRTK_DeviceFinder.GetControllerRightHand();
        leftHandler     = GameObject.Find("left_hand");
        rightHandler    = GameObject.Find("right_hand");
        tapeSection     = GameObject.Find("clothPart");
        obiCloth        = tapeSection.GetComponent <ObiCloth>();

        leftCollider  = leftHandler.GetComponent <ObiCollider>();
        rightCollider = rightHandler.GetComponent <ObiCollider>();

        hint = GameObject.FindGameObjectsWithTag("Hint");

        audioHint[0] = false;
        audioHint[1] = false;
        audioHint[2] = false;
        audioHint[3] = false;

        stickPos[0] = GameObject.Find("StickPos_1");
        stickPos[1] = GameObject.Find("StickPos_2");
        stickPos[2] = GameObject.Find("StickPos_3");
        stickPos[3] = GameObject.Find("StickPos_4");

        foreach (var item in hint)
        {
            ParticleSystem particleSystem = item.GetComponent <ParticleSystem>();
            if (!particleSystem.isStopped)
            {
                particleSystem.Stop();
            }
        }

        Debug.Log("current part: " + StaticData.getTargetNum());

        string leftPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/Model";

        rightHighlighter = GameObject.Find(leftPath).GetComponent <VRTK_ControllerHighlighter>();
        string rightPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (right)/Model";

        rightHighlighter = GameObject.Find(rightPath).GetComponent <VRTK_ControllerHighlighter>();
    }
Exemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     time        = 0;
     highlighter = gameObject.GetComponent <VRTK_ControllerHighlighter>();
     tooltip.ResetTooltip();//初始化文字提示
 }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        // set up left controller highlight
        if (!StaticData.getShowScissor())
        {
            string leftPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/Model";

            // if(leftHighlighter == null) {
            // leftHighlighter = GameObject.Find(leftPath).GetComponent<VRTK_ControllerHighlighter>();
            // }

            // set up left highlighter
            // leftHighlighter.HighlightElement(SDK_BaseController.ControllerElements.GripLeft, Color.yellow, 0.0f);
            // leftHighlighter.HighlightElement(SDK_BaseController.ControllerElements.GripRight, Color.yellow, 0.0f);
            // leftHighlighter.highlightGrip = Color.yellow;

            // draw grip button to yellow
            StaticData.setActiveBtn(leftPath + "/lgrip", "on");
            StaticData.setActiveBtn(leftPath + "/rgrip", "on");
            // GameObject drawLeftGrip = GameObject.Find(leftPath + "/lgrip");
            // GameObject drawRightGrip = GameObject.Find(leftPath + "/rgrip");

            // if(drawLeftGrip.GetComponent<MeshRenderer>() != null) {
            //     MeshRenderer leftGrip = drawLeftGrip.GetComponent<MeshRenderer>();
            //     Material[] m = leftGrip.materials;
            //     m[0] = Resources.Load("activeBtn") as Material;
            //     leftGrip.materials = m;
            // }

            // if(drawRightGrip.GetComponent<MeshRenderer>() != null) {
            //     MeshRenderer rightGrip = drawRightGrip.GetComponent<MeshRenderer>();
            //     Material[] m = rightGrip.materials;
            //     m[0] = Resources.Load("activeBtn") as Material;
            //     rightGrip.materials = m;
            // }

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(leftPath), 0.8f);
        }
        if (StaticData.getShowScissor() && !StaticData.isTapeAttachLeftHand())
        {
            string leftPath  = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/Model";
            string rightPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (right)/Model";

            if (rightHighlighter == null)
            {
                rightHighlighter = GameObject.Find(rightPath).GetComponent <VRTK_ControllerHighlighter>();
            }

            // clear left controller hint
            // leftHighlighter.UnhighlightController();

            // leftHighlighter.highlightGrip = Color.clear;

            // clear grip button color
            StaticData.setActiveBtn(leftPath + "/lgrip", "off");
            StaticData.setActiveBtn(leftPath + "/rgrip", "off");

            // GameObject drawLeftGrip = GameObject.Find(leftPath + "/lgrip");
            // GameObject drawRightGrip = GameObject.Find(leftPath + "/rgrip");

            // if(drawLeftGrip.GetComponent<MeshRenderer>() != null) {
            //     MeshRenderer leftGrip = drawLeftGrip.GetComponent<MeshRenderer>();
            //     Material[] m = leftGrip.materials;
            //     m[0] = Resources.Load("Standard") as Material;
            //     leftGrip.materials = m;
            // }

            // if(drawRightGrip.GetComponent<MeshRenderer>() != null) {
            //     MeshRenderer rightGrip = drawRightGrip.GetComponent<MeshRenderer>();
            //     Material[] m = rightGrip.materials;
            //     m[0] = Resources.Load("Standard") as Material;
            //     rightGrip.materials = m;
            // }

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(leftPath), 1.0f);

            // set up right controller hint
            // rightHighlighter.HighlightElement(SDK_BaseController.ControllerElements.Trigger, Color.yellow, 0.0f);

            // rightHighlighter.highlightTrigger = Color.yellow;

            // draw right trigger yellow
            StaticData.setActiveBtn(rightPath + "/trigger", "on");

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(rightPath), 0.8f);
        }


        // check if cut tape is not attached to the left hand
        if (StaticData.getIsCut() && StaticData.getShowScissor() && !StaticData.isTapeAttachLeftHand())
        {
            obiTape.SetActive(true);
            Transform cloth = GameObject.Find("/TapeController/clothPart").transform;
            obiTape.transform.position = this.transform.position - new Vector3(0.0f, cloth.lossyScale.y / 2, 0.0f);
            // Debug.Log("scale: " + obiTape.transform.lossyScale.y);

            // set up position
            GameObject leftHandler = GameObject.Find("/TapeController/clothPart/left_hand");

            GameObject leftController = GameObject.Find("[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/LeftController");
            leftHandler.transform.SetParent(leftController.transform);
            leftHandler.transform.localPosition = new Vector3(0.0f, 0.0f, 0.1f);
            leftHandler.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));

            // set up left hand animation
            setHandHolded("[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/LeftController/VRTK_BasicHand/LeftHand");

            StaticData.setTapeAttachLeftHand(true);
        }


        if (StaticData.isTapeAttachLeftHand() && !StaticData.isTapeAttachBothHands())
        {
            // let tape moves followed left hand
            GameObject leftController = VRTK_DeviceFinder.GetControllerLeftHand();
            Transform  cloth          = GameObject.Find("/TapeController/clothPart").transform;
            obiTape.transform.position = this.transform.position - new Vector3(0.0f, cloth.lossyScale.y * 0.3f, 0.0f);

            GameObject rightController = VRTK_DeviceFinder.GetControllerRightHand();
            GameObject rightHandler    = GameObject.Find("/TapeController/clothPart/right_hand");

            // touch and grab the right side of the tape
            if (rightHandler != null && rightHandler.GetComponent <VRTK_InteractableObject>().IsUsing())
            {
                rightHandler.transform.SetParent(GameObject.Find("RightController").transform);
                rightHandler.transform.localPosition = new Vector3(0.0f, 0.0f, 0.1f);
                rightHandler.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));

                // hide the rectangular prism
                rightHandler.GetComponent <MeshRenderer>().enabled = false;

                // set up right hand animation
                setHandHolded("[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (right)/RightController/VRTK_BasicHand/RightHand");


                StaticData.setTapeAttachBothHands(true);
            }
        }
    }
Exemplo n.º 10
0
    public void setControllerHighlight(CurState state)
    {
        string leftPath  = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/Model";
        string rightPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (right)/Model";

        if (leftHighlighter == null)
        {
            leftHighlighter = GameObject.Find(leftPath).GetComponent <VRTK_ControllerHighlighter>();
        }

        if (rightHighlighter == null)
        {
            rightHighlighter = GameObject.Find(rightPath).GetComponent <VRTK_ControllerHighlighter>();
        }

        switch (state)
        {
        case (CurState.singleAttach):
            // rightHighlighter.UnhighlightController();
            // rightHighlighter.highlightTrigger = Color.clear;

            // rightHighlighter.HighlightElement(SDK_BaseController.ControllerElements.GripLeft, Color.yellow, 0.0f);
            // rightHighlighter.HighlightElement(SDK_BaseController.ControllerElements.GripRight, Color.yellow, 0.0f);
            // rightHighlighter.highlightGrip = Color.yellow;

            StaticData.setActiveBtn(rightPath + "/trigger", "off");

            StaticData.setActiveBtn(rightPath + "/lgrip", "on");
            StaticData.setActiveBtn(rightPath + "/rgrip", "on");

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(rightPath), 0.8f);
            break;

        case (CurState.leftStep):

            // clear right highlighter
            // rightHighlighter.UnhighlightController();
            // rightHighlighter.highlightGrip = Color.clear;

            StaticData.setActiveBtn(rightPath + "/lgrip", "off");
            StaticData.setActiveBtn(rightPath + "/rgrip", "off");

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(rightPath), 1.0f);

            // set up left highlighter
            // leftHighlighter.HighlightElement(SDK_BaseController.ControllerElements.Trigger, Color.yellow, 0.0f);
            // leftHighlighter.highlightTrigger = Color.yellow;

            StaticData.setActiveBtn(leftPath + "/trigger", "on");

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(leftPath), 0.8f);
            break;

        case (CurState.rightStep):

            // clear left highlighter
            // leftHighlighter.UnhighlightController();
            // leftHighlighter.highlightTrigger = Color.clear;

            StaticData.setActiveBtn(leftPath + "/trigger", "off");

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(leftPath), 1.0f);

            // set up right highlighter
            // rightHighlighter.HighlightElement(SDK_BaseController.ControllerElements.Trigger, Color.yellow, 0.0f);
            // rightHighlighter.highlightTrigger = Color.yellow;

            StaticData.setActiveBtn(rightPath + "/trigger", "on");

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(rightPath), 0.8f);
            break;

        case (CurState.finished):       // finish taping

            // rightHighlighter.UnhighlightController();
            // rightHighlighter.highlightTrigger = Color.clear;

            StaticData.setActiveBtn(rightPath + "/trigger", "off");

            VRTK_ObjectAppearance.SetOpacity(GameObject.Find(rightPath), 1.0f);
            break;
        }
    }