コード例 #1
0
        private void Start()
        {
            if (GetComponent <VRTK_ControllerEvents>() == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same"));
                return;
            }

            //Setup controller event listeners
            GetComponent <VRTK_ControllerEvents>().TriggerPressed  += new ControllerInteractionEventHandler(DoTriggerPressed);
            GetComponent <VRTK_ControllerEvents>().TriggerReleased += new ControllerInteractionEventHandler(DoTriggerReleased);

            GetComponent <VRTK_ControllerEvents>().TriggerTouchStart += new ControllerInteractionEventHandler(DoTriggerTouchStart);
            GetComponent <VRTK_ControllerEvents>().TriggerTouchEnd   += new ControllerInteractionEventHandler(DoTriggerTouchEnd);

            GetComponent <VRTK_ControllerEvents>().TriggerHairlineStart += new ControllerInteractionEventHandler(DoTriggerHairlineStart);
            GetComponent <VRTK_ControllerEvents>().TriggerHairlineEnd   += new ControllerInteractionEventHandler(DoTriggerHairlineEnd);

            GetComponent <VRTK_ControllerEvents>().TriggerClicked   += new ControllerInteractionEventHandler(DoTriggerClicked);
            GetComponent <VRTK_ControllerEvents>().TriggerUnclicked += new ControllerInteractionEventHandler(DoTriggerUnclicked);

            GetComponent <VRTK_ControllerEvents>().TriggerAxisChanged += new ControllerInteractionEventHandler(DoTriggerAxisChanged);

            GetComponent <VRTK_ControllerEvents>().GripPressed  += new ControllerInteractionEventHandler(DoGripPressed);
            GetComponent <VRTK_ControllerEvents>().GripReleased += new ControllerInteractionEventHandler(DoGripReleased);

            GetComponent <VRTK_ControllerEvents>().GripTouchStart += new ControllerInteractionEventHandler(DoGripTouchStart);
            GetComponent <VRTK_ControllerEvents>().GripTouchEnd   += new ControllerInteractionEventHandler(DoGripTouchEnd);

            GetComponent <VRTK_ControllerEvents>().GripHairlineStart += new ControllerInteractionEventHandler(DoGripHairlineStart);
            GetComponent <VRTK_ControllerEvents>().GripHairlineEnd   += new ControllerInteractionEventHandler(DoGripHairlineEnd);

            GetComponent <VRTK_ControllerEvents>().GripClicked   += new ControllerInteractionEventHandler(DoGripClicked);
            GetComponent <VRTK_ControllerEvents>().GripUnclicked += new ControllerInteractionEventHandler(DoGripUnclicked);

            GetComponent <VRTK_ControllerEvents>().GripAxisChanged += new ControllerInteractionEventHandler(DoGripAxisChanged);

            GetComponent <VRTK_ControllerEvents>().TouchpadPressed  += new ControllerInteractionEventHandler(DoTouchpadPressed);
            GetComponent <VRTK_ControllerEvents>().TouchpadReleased += new ControllerInteractionEventHandler(DoTouchpadReleased);

            GetComponent <VRTK_ControllerEvents>().TouchpadTouchStart += new ControllerInteractionEventHandler(DoTouchpadTouchStart);
            GetComponent <VRTK_ControllerEvents>().TouchpadTouchEnd   += new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            GetComponent <VRTK_ControllerEvents>().TouchpadAxisChanged += new ControllerInteractionEventHandler(DoTouchpadAxisChanged);

            GetComponent <VRTK_ControllerEvents>().ButtonOnePressed  += new ControllerInteractionEventHandler(DoButtonOnePressed);
            GetComponent <VRTK_ControllerEvents>().ButtonOneReleased += new ControllerInteractionEventHandler(DoButtonOneReleased);

            GetComponent <VRTK_ControllerEvents>().ButtonOneTouchStart += new ControllerInteractionEventHandler(DoButtonOneTouchStart);
            GetComponent <VRTK_ControllerEvents>().ButtonOneTouchEnd   += new ControllerInteractionEventHandler(DoButtonOneTouchEnd);

            GetComponent <VRTK_ControllerEvents>().ButtonTwoPressed  += new ControllerInteractionEventHandler(DoButtonTwoPressed);
            GetComponent <VRTK_ControllerEvents>().ButtonTwoReleased += new ControllerInteractionEventHandler(DoButtonTwoReleased);

            GetComponent <VRTK_ControllerEvents>().ButtonTwoTouchStart += new ControllerInteractionEventHandler(DoButtonTwoTouchStart);
            GetComponent <VRTK_ControllerEvents>().ButtonTwoTouchEnd   += new ControllerInteractionEventHandler(DoButtonTwoTouchEnd);

            GetComponent <VRTK_ControllerEvents>().StartMenuPressed  += new ControllerInteractionEventHandler(DoStartMenuPressed);
            GetComponent <VRTK_ControllerEvents>().StartMenuReleased += new ControllerInteractionEventHandler(DoStartMenuReleased);

            GetComponent <VRTK_ControllerEvents>().ControllerEnabled  += new ControllerInteractionEventHandler(DoControllerEnabled);
            GetComponent <VRTK_ControllerEvents>().ControllerDisabled += new ControllerInteractionEventHandler(DoControllerDisabled);

            GetComponent <VRTK_ControllerEvents>().ControllerIndexChanged += new ControllerInteractionEventHandler(DoControllerIndexChanged);
        }
コード例 #2
0
        // Token: 0x06001D3B RID: 7483 RVA: 0x00095A7C File Offset: 0x00093C7C
        protected virtual GameObject CreateHighlightModel(GameObject givenOutlineModel, string givenOutlineModelPath)
        {
            if (givenOutlineModel != null)
            {
                givenOutlineModel = (givenOutlineModel.GetComponent <Renderer>() ? givenOutlineModel : givenOutlineModel.GetComponentInChildren <Renderer>().gameObject);
            }
            else if (givenOutlineModelPath != "")
            {
                Transform transform = base.transform.Find(givenOutlineModelPath);
                givenOutlineModel = (transform ? transform.gameObject : null);
            }
            GameObject gameObject = givenOutlineModel;

            if (gameObject == null)
            {
                gameObject = (base.GetComponent <Renderer>() ? base.gameObject : base.GetComponentInChildren <Renderer>().gameObject);
            }
            if (gameObject == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, new object[]
                {
                    "VRTK_OutlineObjectCopyHighlighter",
                    "Renderer",
                    "the same or child",
                    " to add the highlighter to"
                }));
                return(null);
            }
            GameObject gameObject2 = new GameObject(base.name + "_HighlightModel");

            gameObject2.transform.SetParent(gameObject.transform.parent, false);
            gameObject2.transform.localPosition = gameObject.transform.localPosition;
            gameObject2.transform.localRotation = gameObject.transform.localRotation;
            gameObject2.transform.localScale    = gameObject.transform.localScale;
            gameObject2.transform.SetParent(base.transform);
            foreach (Component component in gameObject.GetComponents <Component>())
            {
                if (Array.IndexOf <string>(this.copyComponents, component.GetType().ToString()) >= 0)
                {
                    VRTK_SharedMethods.CloneComponent(component, gameObject2, false);
                }
            }
            MeshFilter component2 = gameObject.GetComponent <MeshFilter>();
            MeshFilter component3 = gameObject2.GetComponent <MeshFilter>();

            if (component3)
            {
                if (this.enableSubmeshHighlight)
                {
                    List <CombineInstance> list = new List <CombineInstance>();
                    for (int j = 0; j < component2.mesh.subMeshCount; j++)
                    {
                        list.Add(new CombineInstance
                        {
                            mesh         = component2.mesh,
                            subMeshIndex = j,
                            transform    = component2.transform.localToWorldMatrix
                        });
                    }
                    component3.mesh = new Mesh();
                    component3.mesh.CombineMeshes(list.ToArray(), true, false);
                }
                else
                {
                    component3.mesh = component2.mesh;
                }
                gameObject2.GetComponent <Renderer>().material = this.stencilOutline;
            }
            gameObject2.SetActive(false);
            VRTK_PlayerObject.SetPlayerObject(gameObject2, VRTK_PlayerObject.ObjectTypes.Highlighter);
            return(gameObject2);
        }
コード例 #3
0
        private void OnEnable()
        {
            controllerEvents = (controllerEvents == null ? GetComponent <VRTK_ControllerEvents>() : controllerEvents);
            if (controllerEvents == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same"));
                return;
            }

            //Setup controller event listeners
            controllerEvents.TriggerPressed          += DoTriggerPressed;
            controllerEvents.TriggerReleased         += DoTriggerReleased;
            controllerEvents.TriggerTouchStart       += DoTriggerTouchStart;
            controllerEvents.TriggerTouchEnd         += DoTriggerTouchEnd;
            controllerEvents.TriggerHairlineStart    += DoTriggerHairlineStart;
            controllerEvents.TriggerHairlineEnd      += DoTriggerHairlineEnd;
            controllerEvents.TriggerClicked          += DoTriggerClicked;
            controllerEvents.TriggerUnclicked        += DoTriggerUnclicked;
            controllerEvents.TriggerAxisChanged      += DoTriggerAxisChanged;
            controllerEvents.TriggerSenseAxisChanged += DoTriggerSenseAxisChanged;

            controllerEvents.GripPressed       += DoGripPressed;
            controllerEvents.GripReleased      += DoGripReleased;
            controllerEvents.GripTouchStart    += DoGripTouchStart;
            controllerEvents.GripTouchEnd      += DoGripTouchEnd;
            controllerEvents.GripHairlineStart += DoGripHairlineStart;
            controllerEvents.GripHairlineEnd   += DoGripHairlineEnd;
            controllerEvents.GripClicked       += DoGripClicked;
            controllerEvents.GripUnclicked     += DoGripUnclicked;
            controllerEvents.GripAxisChanged   += DoGripAxisChanged;

            controllerEvents.TouchpadPressed          += DoTouchpadPressed;
            controllerEvents.TouchpadReleased         += DoTouchpadReleased;
            controllerEvents.TouchpadTouchStart       += DoTouchpadTouchStart;
            controllerEvents.TouchpadTouchEnd         += DoTouchpadTouchEnd;
            controllerEvents.TouchpadAxisChanged      += DoTouchpadAxisChanged;
            controllerEvents.TouchpadTwoPressed       += DoTouchpadTwoPressed;
            controllerEvents.TouchpadTwoReleased      += DoTouchpadTwoReleased;
            controllerEvents.TouchpadTwoTouchStart    += DoTouchpadTwoTouchStart;
            controllerEvents.TouchpadTwoTouchEnd      += DoTouchpadTwoTouchEnd;
            controllerEvents.TouchpadTwoAxisChanged   += DoTouchpadTwoAxisChanged;
            controllerEvents.TouchpadSenseAxisChanged += DoTouchpadSenseAxisChanged;

            controllerEvents.ButtonOnePressed    += DoButtonOnePressed;
            controllerEvents.ButtonOneReleased   += DoButtonOneReleased;
            controllerEvents.ButtonOneTouchStart += DoButtonOneTouchStart;
            controllerEvents.ButtonOneTouchEnd   += DoButtonOneTouchEnd;

            controllerEvents.ButtonTwoPressed    += DoButtonTwoPressed;
            controllerEvents.ButtonTwoReleased   += DoButtonTwoReleased;
            controllerEvents.ButtonTwoTouchStart += DoButtonTwoTouchStart;
            controllerEvents.ButtonTwoTouchEnd   += DoButtonTwoTouchEnd;

            controllerEvents.StartMenuPressed  += DoStartMenuPressed;
            controllerEvents.StartMenuReleased += DoStartMenuReleased;

            controllerEvents.ControllerEnabled      += DoControllerEnabled;
            controllerEvents.ControllerDisabled     += DoControllerDisabled;
            controllerEvents.ControllerIndexChanged += DoControllerIndexChanged;

            controllerEvents.MiddleFingerSenseAxisChanged += DoMiddleFingerSenseAxisChanged;
            controllerEvents.RingFingerSenseAxisChanged   += DoRingFingerSenseAxisChanged;
            controllerEvents.PinkyFingerSenseAxisChanged  += DoPinkyFingerSenseAxisChanged;
        }
コード例 #4
0
        protected virtual GameObject CreateHighlightModel(GameObject givenOutlineModel, string givenOutlineModelPath)
        {
            if (givenOutlineModel != null)
            {
                givenOutlineModel = (givenOutlineModel.GetComponent <Renderer>() ? givenOutlineModel : givenOutlineModel.GetComponentInChildren <Renderer>().gameObject);
            }
            else if (givenOutlineModelPath != "")
            {
                var getChildModel = transform.FindChild(givenOutlineModelPath);
                givenOutlineModel = (getChildModel ? getChildModel.gameObject : null);
            }

            GameObject copyModel = givenOutlineModel;

            if (copyModel == null)
            {
                copyModel = (GetComponent <Renderer>() ? gameObject : GetComponentInChildren <Renderer>().gameObject);
            }

            if (copyModel == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_OutlineObjectCopyHighlighter", "Renderer", "the same or child", " to add the highlighter to"));
                return(null);
            }

            GameObject highlightModel = new GameObject(name + "_HighlightModel");

            highlightModel.transform.SetParent(copyModel.transform.parent, false);
            highlightModel.transform.localPosition = copyModel.transform.localPosition;
            highlightModel.transform.localRotation = copyModel.transform.localRotation;
            highlightModel.transform.localScale    = copyModel.transform.localScale;
            highlightModel.transform.SetParent(transform);

            foreach (var component in copyModel.GetComponents <Component>())
            {
                if (Array.IndexOf(copyComponents, component.GetType().ToString()) >= 0)
                {
                    VRTK_SharedMethods.CloneComponent(component, highlightModel);
                }
            }

            var copyMesh      = copyModel.GetComponent <MeshFilter>();
            var highlightMesh = highlightModel.GetComponent <MeshFilter>();

            if (highlightMesh)
            {
                if (enableSubmeshHighlight)
                {
                    List <CombineInstance> combine = new List <CombineInstance>();

                    for (int i = 0; i < copyMesh.mesh.subMeshCount; i++)
                    {
                        CombineInstance ci = new CombineInstance();
                        ci.mesh         = copyMesh.mesh;
                        ci.subMeshIndex = i;
                        ci.transform    = copyMesh.transform.localToWorldMatrix;
                        combine.Add(ci);
                    }

                    highlightMesh.mesh = new Mesh();
                    highlightMesh.mesh.CombineMeshes(combine.ToArray(), true, false);
                }
                else
                {
                    highlightMesh.mesh = copyMesh.mesh;
                }

                highlightModel.GetComponent <Renderer>().material = stencilOutline;
            }
            highlightModel.SetActive(false);

            VRTK_PlayerObject.SetPlayerObject(highlightModel, VRTK_PlayerObject.ObjectTypes.Highlighter);

            return(highlightModel);
        }