public override void Grabbed(VRTK.VRTK_InteractGrab currentGrabbingObject)
 {
     base.Grabbed(currentGrabbingObject);
     Debug.Log("Grabbed");
     controllerEvents = currentGrabbingObject.GetComponent <VRTK.VRTK_ControllerEvents>();
     shootAudio       = GetComponent <AudioSource> ();
 }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
//		lastTime = Time.realtimeSinceStartup;
        cameraPlayer = VRTK.VRTK_SDKManager.instance.actualBoundaries.gameObject;
        canvas       = cameraPlayer.transform.FindChild("Camera (eye)").FindChild("Canvas").gameObject;
        canvasParent = canvas.transform.parent.gameObject;
        //canvas = cameraPlayer.transform.FindChild("Canvas").gameObject;
        itemMenuPanel = canvas.transform.FindChild("ItemMenuPanel").gameObject;
        itemMenuPanel.SetActive(false);

        canvasWhenGamePaused = Instantiate <GameObject>(canvas);
        canvasWhenGamePaused.transform.SetParent(canvasParent.transform);
        canvasWhenGamePaused.SetActive(false);
        canvasWhenGamePaused.transform.position = canvas.transform.position;
        canvasWhenGamePaused.transform.rotation = canvas.transform.rotation;

        int i = 0;

        foreach (Transform itemSlot in itemMenuPanel.transform)
        {
            itemSlots [i] = itemSlot.gameObject;
            itemSlots [i].SetActive(false);
            i++;
        }

        usedItemSlots = 0;

        //VRTK.VRTK_SDKManager.instance.scriptAliasRightController.GetComponent<VRTK.VRTK_Pointer> ().enabled = false;
        VRTK.VRTK_SDKManager.instance.scriptAliasRightController.GetComponent <VRTK.VRTK_StraightPointerRenderer> ().enabled = false;
        controllerEvents = VRTK.VRTK_SDKManager.instance.scriptAliasRightController.GetComponent <VRTK.VRTK_ControllerEvents>();
        //Button Two ist oberer Menu Button
        controllerEvents.ButtonTwoPressed += ControllerEvents_StartMenuPressed;
    }
 protected virtual void Initialize()
 {
     if (events == null)
     {
         events = GetComponentInParent<VRTK_ControllerEvents>();
     }
 }
Ejemplo n.º 4
0
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            theScript = go.GetComponent <VRTK.VRTK_ControllerEvents>();

            if (!everyFrame.Value)
            {
                MakeItSo();
                Finish();
            }
        }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        GameObject wso = GameObject.FindWithTag("WebsocketTag");

        wsc = wso.GetComponent <WebsocketClient> ();
        //while (!wsc.IsConnected ()) {

        //}
        wsc.Advertise("ein/" + arm + "/forth_commands", "std_msgs/String");
        InvokeRepeating("sendControls", .1f, .1f);
        controller = this.GetComponent <VRTK.VRTK_ControllerEvents>();

        TFListener = GameObject.Find("TFListener").GetComponent <TFListener> ();
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>();
        VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>();

        bool l_buttonOne = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress);
        bool r_buttonOne = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress);

        if (l_buttonOne || r_buttonOne)
        {
            Debug.Log("pressed");
            SceneManager.LoadScene("Rail Scene", LoadSceneMode.Additive);
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        if (movingUp > 3)
        {
            movingUp = 1;
        }

        VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>();
        VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>();

        bool l_buttonOne = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress);
        bool r_buttonOne = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress);

        if ((Input.GetKey("a") || l_buttonOne || r_buttonOne) && (enable < 0.1))
        {
            if (movingUp < 0)
            {
                movingUp = 2.1f;
            }
            else
            {
                movingUp += 2.1f;
                enable    = 1;
            }
        }

        enable   -= Time.deltaTime;
        movingUp -= Time.deltaTime;
        if (movingUp > 0.0)
        {
            if (transform.position.y < 6)
            {
                transform.position += Vector3.up * upSpeed * Time.deltaTime;
            }
            else
            {
                movingUp = 0;
                enable   = 3;
            }
        }
        else
        {
            if (transform.position.y > -5.5f)
            {
                movingUp            = 0;
                transform.position -= Vector3.up * Time.deltaTime;
            }
        }
    }
Ejemplo n.º 8
0
    private void SetControllers()
    {
        m_controllerLeft  = left;
        m_controllerRight = right;

        if (m_controllerLeft != null)
        {
            m_leftEvents = GetLeftController().GetComponent <VRTK.VRTK_ControllerEvents>();
        }

        if (m_controllerRight != null)
        {
            m_rightEvents = GetRightController().GetComponent <VRTK.VRTK_ControllerEvents>();
        }
    }
Ejemplo n.º 9
0
    void Start()
    {
        // Get the live websocket client
        wsc = GameObject.Find("WebsocketClient").GetComponent <WebsocketClient>();

        // Get the live TFListener
        TFListener = GameObject.Find("TFListener").GetComponent <TFListener>();

        // Get the controller componenet of this gameobject
        controller = GetComponent <VRTK.VRTK_ControllerEvents>();

        // Create publisher to the Baxter's arm topic (uses Ein)
        wsc.Advertise("ein/" + arm + "/forth_commands", "std_msgs/String");
        // Asychrononously call sendControls every .1 seconds
        InvokeRepeating("SendControls", .1f, .1f);
    }
Ejemplo n.º 10
0
    private void OnTriggerEnter(Collider other)
    {
        if (bladeIsActive)
        {
            return;
        }

        VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>();


        Debug.Log("reactivated");
        source.PlayOneShot(unsheathe_sound, 0.5f);
        mySword.SetActive(true);
        bladeIsActive = true;
        // if button
    }
Ejemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Start");

        // Get the input controller
        _InputController = gameObject.GetComponent <InputController>();

        _LeftPaddle  = SteamController.left;
        _RightPaddle = SteamController.right;

        Debug.Log("Left: " + _LeftPaddle);
        Debug.Log("Right: " + _RightPaddle);

        _LeftDeviceEvents  = _LeftPaddle.GetComponent <VRTK.VRTK_ControllerEvents>();
        _RightDeviceEvents = _RightPaddle.GetComponent <VRTK.VRTK_ControllerEvents>();
    }
Ejemplo n.º 12
0
    // Update is called once per frame
    void Update()

    {
        VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>();
        VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>();
        bool triggerA = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress);
        bool triggerB = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress);

        if (triggerA && triggerB)
        {
            velocity += (-2 * Time.deltaTime);
        }
        if (player.GetComponent <gameStat>().inPlay)
        {
            transform.Translate(Vector3.forward * velocity * Time.deltaTime);
        }
    }
    // Use this for initialization
    void Start()
    {
        GameObject wso = GameObject.FindWithTag("WebsocketTag");

        wsc = wso.GetComponent <WebsocketClient>();

        wsc.Advertise("ein/" + arm + "/forth_commands", "std_msgs/String");
        controller = GetComponent <VRTK.VRTK_ControllerEvents>();
        TFListener = GameObject.Find("TFListener").GetComponent <TFListener>();
        tf         = GetComponent <Transform>();

        //last positions/rotation of the controller (calculate relative displacement of controller at each update)
        lastControllerPosition = tf.position;
        lastControllerRotation = tf.rotation;
        Invoke("FindArm", 1f);                     //update position of lastArm position and rotation
        InvokeRepeating("sendMessage", 1.2f, .1f); //send message to move arm by displacement of current controller position/rotation with previous position/rotation
        targetTransform = targetModel.GetComponent <Transform>();
    }
Ejemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        m_handEvent = GetComponent <VRTK.VRTK_ControllerEvents>();

        if (m_handEvent == null)
        {
            print("No Hand Events found");
            VRTK.VRTK_Logger.Error(VRTK.VRTK_Logger.GetCommonMessage(VRTK.VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same"));

            return;
        }
        //m_handEvent.TriggerPressed += new VRTK.ControllerInteractionEventHandler(DoTriggerPressed);
        // m_handEvent.TriggerReleased += new VRTK.ControllerInteractionEventHandler(DoTriggerReleased);
        m_handEvent.TriggerClicked   += new VRTK.ControllerInteractionEventHandler(DoTriggerClicked);
        m_handEvent.TriggerUnclicked += new VRTK.ControllerInteractionEventHandler(DoTriggerUnclicked);

        m_Trigger = false;
    }
Ejemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>();
     if (!inPlay)
     {
         bool l_buttonOne = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonOnePress);
         if (l_buttonOne)
         {
             stage.transform.position  = new Vector3(0.44f, 0, -28.743f);
             player.transform.position = new Vector3(0.44f, 0, -22.5f);
             for (int i = 0; i < titans.Count; i++)
             {
                 titans[i].SetActive(true);
             }
             stage.GetComponent <rail>().velocity = -10;
             inPlay = true;
         }
     }
 }
Ejemplo n.º 16
0
    private void DoObjectGrab(object sender, InteractableObjectEventArgs e)
    {
        if (e.interactingObject == controllers.left)
        {
            holdControl = controllers.left.GetComponent<VRTK_ControllerEvents>();
            stringControl = controllers.right.GetComponent<VRTK_ControllerEvents>();

            holdActions = controllers.left.GetComponent<VRTK_ControllerActions>();
            stringActions = controllers.right.GetComponent<VRTK_ControllerActions>();
        }
        else
        {
            stringControl = controllers.left.GetComponent<VRTK_ControllerEvents>();
            holdControl = controllers.right.GetComponent<VRTK_ControllerEvents>();

            stringActions = controllers.left.GetComponent<VRTK_ControllerActions>();
            holdActions = controllers.right.GetComponent<VRTK_ControllerActions>();
        }
        StartCoroutine("GetBaseRotation");
    }
Ejemplo n.º 17
0
        protected virtual void OnEnable()
        {
            pointerOriginTransform = (pointerOriginTransform == null ? VRTK_SDK_Bridge.GenerateControllerPointerOrigin(gameObject) : pointerOriginTransform);

            controller = (controller != null ? controller : GetComponent <VRTK_ControllerEvents>());
            ConfigureEventSystem();
            pointerClicked        = false;
            lastPointerPressState = false;
            lastPointerClickState = false;
            beamEnabledState      = false;

            if (controller != null)
            {
                controllerRenderModel = VRTK_SDK_Bridge.GetControllerRenderModel(controller.gameObject);
                controller.SubscribeToButtonAliasEvent(activationButton, true, DoActivationButtonPressed);
                controller.SubscribeToButtonAliasEvent(activationButton, false, DoActivationButtonReleased);
                controller.SubscribeToButtonAliasEvent(selectionButton, true, DoSelectionButtonPressed);
                controller.SubscribeToButtonAliasEvent(selectionButton, false, DoSelectionButtonReleased);
            }
        }
 void Start()
 {
     menu = GetComponent<RadialMenu>();
     if (events == null)
     {
         events = GetComponentInParent<VRTK_ControllerEvents>();
     }
     if (events == null)
     {
         Debug.LogError("The radial menu must be a child of the controller or be set in the inspector!");
     }
     else
     {   //Start listening for controller events
         events.TouchpadPressed += new ControllerInteractionEventHandler(DoTouchpadClicked);
         events.TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadUnclicked);
         events.TouchpadTouchStart += new ControllerInteractionEventHandler(DoTouchpadTouched);
         events.TouchpadTouchEnd += new ControllerInteractionEventHandler(DoTouchpadUntouched);
         events.TouchpadAxisChanged += new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
     }
 }
        void Start()
        {
            if (controllerActions == null)
            {
                controllerActions = GetComponent <VRTK_ControllerActions>();
                if (controllerActions == null && transform.parent != null)
                {
                    controllerActions = transform.parent.GetComponent <VRTK_ControllerActions>();
                }
            }
            if (controllerEvents == null)
            {
                controllerEvents = GetComponent <VRTK_ControllerEvents>();
                if (controllerEvents == null && transform.parent != null)
                {
                    controllerEvents = transform.parent.GetComponent <VRTK_ControllerEvents>();
                }
            }

            frictionObjects = new List <VRTK_FrictionObject>();
        }
Ejemplo n.º 20
0
        protected virtual void Awake()
        {
            if (controller == null)
            {
                controller = GetComponent <VRTK_ControllerEvents>();
            }

            if (controller == null)
            {
                Debug.LogError("VRTK_WorldPointer requires a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
                return;
            }

            // 给当前脚本绑定的gameobject绑定VRTK_PlayerObject脚本并且设置类型为Controller(手柄)
            Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Controller);

            // 找到头显的位置
            headset  = VRTK_DeviceFinder.HeadsetTransform();
            playArea = FindObjectOfType <SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];
        }
Ejemplo n.º 21
0
        protected virtual void OnEnable()
        {
#pragma warning disable 0618
            controllerEvents = (controller != null && controllerEvents == null ? controller : controllerEvents);
            customOrigin     = (pointerOriginTransform != null && customOrigin == null ? pointerOriginTransform : customOrigin);
#pragma warning restore 0618
            attachedTo       = (attachedTo == null ? gameObject : attachedTo);
            controllerEvents = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            ConfigureEventSystem();
            pointerClicked        = false;
            lastPointerPressState = false;
            lastPointerClickState = false;
            beamEnabledState      = false;

            if (controllerEvents != null)
            {
                controllerEvents.SubscribeToButtonAliasEvent(activationButton, true, DoActivationButtonPressed);
                controllerEvents.SubscribeToButtonAliasEvent(activationButton, false, DoActivationButtonReleased);
                controllerEvents.SubscribeToButtonAliasEvent(selectionButton, true, DoSelectionButtonPressed);
                controllerEvents.SubscribeToButtonAliasEvent(selectionButton, false, DoSelectionButtonReleased);
            }
        }
Ejemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>();
        VRTK.VRTK_ControllerEvents r_hand = rHand.GetComponent <VRTK.VRTK_ControllerEvents>();

        bool l_buttonTwo = l_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress);
        bool r_buttonTwo = r_hand.IsButtonPressed(VRTK.VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress);

        if (l_buttonTwo)
        {
            if (transform.position.x >= -2.5)
            {
                transform.position -= new Vector3(dodge_factor, 0, 0);
            }
        }
        if (r_buttonTwo)
        {
            if (transform.position.x <= 2.5)
            {
                transform.position += new Vector3(dodge_factor, 0, 0);
            }
        }
    }
        protected virtual void Start()
        {
            if (controller == null)
            {
                controller = GetComponent <VRTK_ControllerEvents>();
            }

            if (controller == null)
            {
                Debug.LogError("VRTK_WorldPointer requires a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
                return;
            }

            Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Controller);

            //Setup controller event listeners
            controller.AliasPointerOn  += new ControllerInteractionEventHandler(EnablePointerBeam);
            controller.AliasPointerOff += new ControllerInteractionEventHandler(DisablePointerBeam);
            controller.AliasPointerSet += new ControllerInteractionEventHandler(SetPointerDestination);

            eventsRegistered = true;

            headset = DeviceFinder.HeadsetTransform();

            playArea = FindObjectOfType <SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];

            var tmpMaterial = Resources.Load("WorldPointer") as Material;

            if (pointerMaterial != null)
            {
                tmpMaterial = pointerMaterial;
            }

            pointerMaterial       = new Material(tmpMaterial);
            pointerMaterial.color = pointerMissColor;
        }
Ejemplo n.º 24
0
 // Token: 0x060011B3 RID: 4531 RVA: 0x00066B27 File Offset: 0x00064D27
 public virtual void Initialize(VRTK_ControllerEvents events)
 {
     this.controllerEvents = events;
     this.playArea         = VRTK_DeviceFinder.PlayAreaTransform();
     this.headset          = VRTK_DeviceFinder.HeadsetTransform();
 }
Ejemplo n.º 25
0
 // Use this for initialization
 void Start()
 {
     controller = this.GetComponent <VRTK.VRTK_ControllerEvents>();
     menu.SetActive(menuActive);         //make visible
     lastPressed = Time.time;
 }
Ejemplo n.º 26
0
 private void Awake()
 {
     interactTouch     = GetComponent <VRTK_InteractTouch>();
     controllerActions = GetComponent <VRTK_ControllerActions>();
     controllerEvents  = GetComponent <VRTK_ControllerEvents>();
 }
Ejemplo n.º 27
0
 protected virtual void Awake()
 {
     if (controller == null)
     {
         controller = GetComponent<VRTK_ControllerEvents>();
     }
     if (controller == null)
     {
         Debug.LogError("VRTK_WorldPointer requires a Controller that has the VRTK_ControllerEvents script attached to it");
         return;
     }
     Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Pointer);
 }
 private void DoInteractableObjectIsGrabbed(object sender, InteractableObjectEventArgs e)
 {
     controllerEvents = e.interactingObject.GetComponentInParent<VRTK_ControllerEvents>();
     if (controllerEvents != null)
     {
         BindControllerEvents();
     }
     isGrabbed = true;
 }
 private void Start()
 {
     ConfigureEventSystem();
     ConfigureWorldCanvases();
     if (controller == null)
     {
         controller = this.GetComponent<VRTK_ControllerEvents>();
     }
 }
Ejemplo n.º 30
0
 // Update is called once per frame
 void Update()
 {
     VRTK.VRTK_ControllerEvents l_hand = lHand.GetComponent <VRTK.VRTK_ControllerEvents>();
 }
Ejemplo n.º 31
0
 protected virtual void OnEnable()
 {
     animator         = GetComponent <Animator>();
     controllerEvents = controllerEvents ?? GetComponentInParent <VRTK_ControllerEvents>();
 }
Ejemplo n.º 32
0
 // Use this for initialization
 void Start()
 {
     controllerEvents = GetComponent <VRTK.VRTK_ControllerEvents>();
     controllerEvents.TriggerPressed += OnTriggerPressed;
 }
Ejemplo n.º 33
0
 public override void Grabbed(GameObject grabbingObject)
 {
     base.Grabbed(grabbingObject);
     controllerActions = grabbingObject.GetComponent<VRTK_ControllerActions>();
     controllerEvents = grabbingObject.GetComponent<VRTK_ControllerEvents>();
 }
Ejemplo n.º 34
0
 private void OnValidate()
 {
     pointer          = GetComponent <VRTK.VRTK_Pointer>();
     controllerEvents = GetComponent <VRTK.VRTK_ControllerEvents>();
 }
Ejemplo n.º 35
0
 private void DoTouchpadTouchEnd(object sender, ControllerInteractionEventArgs e)
 {
     touchAxis        = Vector2.zero;
     controllerEvents = null;
 }
        protected virtual void Initialize()
        {
            if (Application.isPlaying)
            {
                if (!isShown)
                {
                    transform.localScale = Vector3.zero;
                }
            }

            if (controllerEvents == null)
            {
                transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z);
                controllerEvents = GetComponentInParent<VRTK_ControllerEvents>();
            }
        }
Ejemplo n.º 37
0
 private void Start()
 {
     if (controller == null)
     {
         controller = GetComponent<VRTK_ControllerEvents>();
     }
     ConfigureEventSystem();
     ConfigureWorldCanvases();
     pointerClicked = false;
     lastPointerPressState = false;
     beamEnabledState = false;
     controllerRenderModel = VRTK_SDK_Bridge.GetControllerRenderModel(controller.gameObject);
 }
 protected virtual VRTK_ControllerReference GetReferenceFromEvents(VRTK_ControllerEvents controllerEvents)
 {
     return(VRTK_ControllerReference.GetControllerReference((controllerEvents != null ? controllerEvents.gameObject : null)));
 }
Ejemplo n.º 39
0
        private void Awake()
        {
            if (GetComponent<VRTK_InteractTouch>() == null)
            {
                Debug.LogError("VRTK_InteractGrab is required to be attached to a Controller that has the VRTK_InteractTouch script attached to it");
                return;
            }

            interactTouch = GetComponent<VRTK_InteractTouch>();
            controllerActions = GetComponent<VRTK_ControllerActions>();
            controllerEvents = GetComponent<VRTK_ControllerEvents>();
        }
        protected virtual void Start()
        {
            if (controller == null)
            {
                controller = this.GetComponent<VRTK_ControllerEvents>();
            }

            if (controller == null)
            {
                Debug.LogError("VRTK_WorldPointer requires a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
                return;
            }

            Utilities.SetPlayerObject(this.gameObject, VRTK_PlayerObject.ObjectTypes.Controller);

            //Setup controller event listeners
            controller.AliasPointerOn += new ControllerInteractionEventHandler(EnablePointerBeam);
            controller.AliasPointerOff += new ControllerInteractionEventHandler(DisablePointerBeam);
            controller.AliasPointerSet += new ControllerInteractionEventHandler(SetPointerDestination);

            eventsRegistered = true;

            headset = DeviceFinder.HeadsetTransform();

            playArea = GameObject.FindObjectOfType<SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];

            var tmpMaterial = Resources.Load("WorldPointer") as Material;
            if (pointerMaterial != null)
            {
                tmpMaterial = pointerMaterial;
            }

            pointerMaterial = new Material(tmpMaterial);
            pointerMaterial.color = pointerMissColor;
        }
        protected virtual void Start()
        {
            if (controller == null)
            {
                controller = this.GetComponent<VRTK_ControllerEvents>();
            }

            if (controller == null)
            {
                Debug.LogError("VRTK_WorldPointer requires a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
                return;
            }

            this.name = "PlayerObject_" + this.name;

            //Setup controller event listeners
            controller.AliasPointerOn += new ControllerInteractionEventHandler(EnablePointerBeam);
            controller.AliasPointerOff += new ControllerInteractionEventHandler(DisablePointerBeam);

            headset = DeviceFinder.HeadsetTransform();

            playArea = GameObject.FindObjectOfType<SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];

            pointerMaterial = new Material(Shader.Find("Unlit/TransparentColor"));
            pointerMaterial.color = pointerMissColor;
        }
 private void Awake()
 {
     controllerEvents = GetComponent<VRTK_ControllerEvents>();
     controllerActions = GetComponent<VRTK_ControllerActions>();
     Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Controller);
     destroyColliderOnDisable = false;
     defaultColliderPrefab = Resources.Load("ControllerColliders/HTCVive");
 }
Ejemplo n.º 43
0
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            theScript = go.GetComponent <VRTK.VRTK_ControllerEvents>();
        }
    private void Start()
    {
        if (GetComponent<VRTK_ControllerEvents>() == null)
        {
            Debug.LogError("VRTK_ControllerEvents_ListenerExample is required to be attached to a SteamVR 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);
    }
        private void DoInteractableObjectIsUngrabbed(object sender, InteractableObjectEventArgs e)
        {
            isGrabbed = false;
            if (isShown)
            {
                HideMenuImmediate();
            }

            if (controllerEvents != null)
            {
                UnbindControllerEvents();
                controllerEvents = null;
            }
        }