public bool IsValidInteractableController(GameObject actualController, AllowedController controllerCheck)
        {
            if (controllerCheck == AllowedController.Both)
            {
                return(true);
            }

            var controllerHand = VRTK_DeviceFinder.GetControllerHandType(controllerCheck.ToString().Replace("_Only", ""));

            return(VRTK_DeviceFinder.IsControllerOfHand(actualController, controllerHand));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// IsValidInteractableController方法由于检测一个手柄游戏对象是否被允许与当前物体交互,因为有的情况下(根据使用需求)手柄是禁止与物体交互的
        /// </summary>
        /// <param name="actualController">接受检测的手柄游戏对象</param>
        /// <param name="controllerCheck">哪个手柄被允许与当前物体交互</param>
        /// <returns></returns>
        public bool IsValidInteractableController(GameObject actualController, AllowedController controllerCheck)
        {
            if (controllerCheck == AllowedController.Both)
            {
                // 如果物体被允许与任何手柄交互,那么始终返回真
                return(true);
            }
            // controllerCheck.ToString().Replace("_Only", "")这句代码是把Left_Only和Right_Only里面的_Only去掉,留下Left或者Right
            // 然后用VRTK_DeviceFinder去找到对应的手柄
            var controllerHand = VRTK_DeviceFinder.GetControllerHandType(controllerCheck.ToString().Replace("_Only", ""));

            // 对比,里面要依赖SteamVR_ControllerManager
            return(VRTK_DeviceFinder.IsControllerOfHand(actualController, controllerHand));
        }
        public bool IsValidInteractableController(GameObject actualController, AllowedController controllerCheck)
        {
            if (controllerCheck == AllowedController.Both)
            {
                return true;
            }

            var controllerHand = DeviceFinder.GetControllerHandType(controllerCheck.ToString().Replace("_Only", ""));
            return (DeviceFinder.IsControllerOfHand(actualController, controllerHand));
        }