Пример #1
0
        private void Awake()
        {
            cachedElements   = new Dictionary <string, Transform>();
            gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");

            var controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject);

            if (modelElementPaths.bodyModelPath.Trim() == "")
            {
                modelElementPaths.bodyModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.Body, controllerHand);
            }
            if (modelElementPaths.triggerModelPath.Trim() == "")
            {
                modelElementPaths.triggerModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.Trigger, controllerHand);
            }
            if (modelElementPaths.leftGripModelPath.Trim() == "")
            {
                modelElementPaths.leftGripModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.GripLeft, controllerHand);
            }
            if (modelElementPaths.rightGripModelPath.Trim() == "")
            {
                modelElementPaths.rightGripModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.GripRight, controllerHand);
            }
            if (modelElementPaths.touchpadModelPath.Trim() == "")
            {
                modelElementPaths.touchpadModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.Touchpad, controllerHand);
            }
            if (modelElementPaths.appMenuModelPath.Trim() == "")
            {
                modelElementPaths.appMenuModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.ApplicationMenu, controllerHand);
            }
            if (modelElementPaths.systemMenuModelPath.Trim() == "")
            {
                modelElementPaths.systemMenuModelPath = VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.SystemMenu, controllerHand);
            }
        }
Пример #2
0
        /// <summary>
        /// The InitaliseHighlighters method sets up the highlighters on the controller model.
        /// </summary>
        public virtual void InitaliseHighlighters()
        {
            highlighterOptions = new Dictionary <string, object>();
            highlighterOptions.Add("resetMainTexture", true);
            VRTK_BaseHighlighter objectHighlighter = VRTK_BaseHighlighter.GetActiveHighlighter(gameObject);

            if (objectHighlighter == null)
            {
                objectHighlighter = gameObject.AddComponent <VRTK_MaterialColorSwapHighlighter>();
            }

            var controllerHand = VRTK_DeviceFinder.GetControllerHand(gameObject);

            objectHighlighter.Initialise(null, highlighterOptions);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonOne, controllerHand)), objectHighlighter, elementHighlighterOverrides.buttonOne);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.ButtonTwo, controllerHand)), objectHighlighter, elementHighlighterOverrides.buttonTwo);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Body, controllerHand)), objectHighlighter, elementHighlighterOverrides.body);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripLeft, controllerHand)), objectHighlighter, elementHighlighterOverrides.gripLeft);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.GripRight, controllerHand)), objectHighlighter, elementHighlighterOverrides.gripRight);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.StartMenu, controllerHand)), objectHighlighter, elementHighlighterOverrides.startMenu);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.SystemMenu, controllerHand)), objectHighlighter, elementHighlighterOverrides.systemMenu);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Touchpad, controllerHand)), objectHighlighter, elementHighlighterOverrides.touchpad);
            AddHighlighterToElement(GetElementTransform(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.Trigger, controllerHand)), objectHighlighter, elementHighlighterOverrides.trigger);
        }
        protected virtual void SetControllerAttachPoint()
        {
            //If no attach point has been specified then just use the tip of the controller
            if (controllerReference.model != null && originalControllerAttachPoint == null)
            {
                //attempt to find the attach point on the controller
                Transform defaultAttachPoint = controllerReference.model.transform.Find(VRTK_SDK_Bridge.GetControllerElementPath(SDK_BaseController.ControllerElements.AttachPoint, VRTK_DeviceFinder.GetControllerHand(interactTouch.gameObject)));
                if (defaultAttachPoint != null)
                {
                    controllerAttachPoint = defaultAttachPoint.GetComponent <Rigidbody>();

                    if (controllerAttachPoint == null)
                    {
                        var autoGenRB = defaultAttachPoint.gameObject.AddComponent <Rigidbody>();
                        autoGenRB.isKinematic = true;
                        controllerAttachPoint = autoGenRB;
                    }
                }
            }
        }