예제 #1
0
        //If the object is a controller, then emit the relevant event for it.
        protected virtual void EmitControllerEvents(GameObject model, bool state)
        {
            GameObject controllerObject = null;

            //Check to see if the given model is either the left or right controller model alias object
            if (VRTK_DeviceFinder.GetModelAliasControllerHand(model) == SDK_BaseController.ControllerHand.Left)
            {
                controllerObject = VRTK_DeviceFinder.GetControllerLeftHand(false);
            }
            else if (VRTK_DeviceFinder.GetModelAliasControllerHand(model) == SDK_BaseController.ControllerHand.Right)
            {
                controllerObject = VRTK_DeviceFinder.GetControllerRightHand(false);
            }

            //if it is then attempt to get the controller events script from the script alias
            if (controllerObject != null && controllerObject.activeInHierarchy)
            {
                VRTK_ControllerEvents controllerEvents = controllerObject.GetComponent <VRTK_ControllerEvents>();
                if (controllerEvents != null)
                {
                    if (state)
                    {
                        controllerEvents.OnControllerVisible(controllerEvents.SetControllerEvent());
                    }
                    else
                    {
                        controllerEvents.OnControllerHidden(controllerEvents.SetControllerEvent());
                    }
                }
            }
        }
예제 #2
0
        // Token: 0x060016AC RID: 5804 RVA: 0x0007A6F8 File Offset: 0x000788F8
        protected virtual void EmitControllerEvents(GameObject model, bool state)
        {
            GameObject gameObject = null;

            if (VRTK_DeviceFinder.GetModelAliasControllerHand(model) == SDK_BaseController.ControllerHand.Left)
            {
                gameObject = VRTK_DeviceFinder.GetControllerLeftHand(false);
            }
            else if (VRTK_DeviceFinder.GetModelAliasControllerHand(model) == SDK_BaseController.ControllerHand.Right)
            {
                gameObject = VRTK_DeviceFinder.GetControllerRightHand(false);
            }
            if (gameObject != null && gameObject.activeInHierarchy)
            {
                VRTK_ControllerEvents component = gameObject.GetComponent <VRTK_ControllerEvents>();
                if (component != null)
                {
                    if (state)
                    {
                        component.OnControllerVisible(component.SetControllerEvent());
                        return;
                    }
                    component.OnControllerHidden(component.SetControllerEvent());
                }
            }
        }