private void InputTracking_trackingAcquired(XRNodeState nodeState)
        {
            XRUserController controller = _userControllers.Find(x => x.UniqueID == nodeState.uniqueID);

            if (controller != null)
            {
                Debug.Log("InputTracking_trackingAcquired " + controller + " " + nodeState.uniqueID + " " + nodeState.nodeType);
                _registrationEvents.TrackingAcquired.Invoke(controller);
            }
        }
        private void InputTracking_nodeRemoved(XRNodeState nodeState)
        {
            Debug.Log("InputTracking_nodeRemoved for UniqueID :" + nodeState.uniqueID);

            XRUserController controller = _userControllers.Find(x => x.UniqueID == nodeState.uniqueID);

            if (controller != null)
            {
                _registrationEvents.Removed.Invoke(controller);
                _userControllers.Remove(controller);
                Destroy(controller.gameObject);
            }
        }
Exemple #3
0
        public XRButtonDatum(XRUserController parentUserController, XRPhysicsInteractor parentInteractor, XRInputName inputName)
        {
            ParentUserController = parentUserController;
            ParentInteractor     = parentInteractor;
            InputName            = inputName;

            _pressLocalTransform = new GameObject("PressLocalTransform").transform;
            _pressLocalTransform.gameObject.hideFlags = HideFlags.HideAndDontSave;
            _pressLocalTransform.SetParent(parentInteractor.transform);

            _pressLocalHitTransform = new GameObject("PressLocalHitTransform").transform;
            _pressLocalHitTransform.gameObject.hideFlags = HideFlags.HideAndDontSave;
            _pressLocalHitTransform.SetParent(parentInteractor.transform);
        }
        private void InputTracking_nodeAdded(XRNodeState nodeState)
        {
            Debug.Log("InputTracking_nodeAdded for nodeType :" + nodeState.nodeType + "\nWith UniqueID : " +
                      nodeState.uniqueID);

            if (_acquiredXRNodes.Contains(nodeState.nodeType))
            {
                return;
            }

            Chirality chirality = (Chirality)0; //0 is none

            if (nodeState.nodeType == XRNode.LeftHand)
            {
                chirality = (Chirality)1;
            }
            else if (nodeState.nodeType == XRNode.RightHand)
            {
                chirality = (Chirality)2;
            }
            else
            {
                return;
            }

            _acquiredXRNodes.Add(nodeState.nodeType);

            XRUserController addedController = Instantiate(
                configuration.UserControllerPrefab(chirality),
                Vector3.zero,
                Quaternion.identity);

            addedController.Initialize(
                chirality,
                this,
                configuration,
                nodeState.uniqueID);
            addedController.gameObject.RemoveCloneSuffix();
            addedController.transform.SetParent(transform);

            if (nodeState.nodeType == XRNode.LeftHand || nodeState.nodeType == XRNode.RightHand)
            {
                string joystickToFind = "left";
                if (nodeState.nodeType == XRNode.RightHand)
                {
                    joystickToFind = "right";
                }
                string[] joysticks     = Input.GetJoystickNames();
                bool     foundJoystick = false;
                foreach (string name in joysticks)
                {
                    if (name.ToLower().Contains(joystickToFind))
                    {
                        foundJoystick = true;
                        break;
                    }
                }

                XRUserController controller = _userControllers.Find(x => x.UniqueID == nodeState.uniqueID);
                if (controller != null)
                {
                    controller.gameObject.SetActive(foundJoystick);
                }
            }

            _userControllers.Add(addedController);
            _registrationEvents.Added.Invoke(addedController);
        }
Exemple #5
0
 public virtual void Initialize(XRUserController userController)
 {
     UserController = userController;
 }