示例#1
0
        /// <summary>
        /// Allows the object to change which controller it tracks, based on handedness.
        /// </summary>
        /// <param name="newHandedness">The new handedness to track. Does nothing if the handedness doesn't change.</param>
#if UNITY_WSA && UNITY_2017_2_OR_NEWER
        public void ChangeHandedness(InteractionSourceHandedness newHandedness)
        {
            if (newHandedness != handedness)
            {
                Handedness = newHandedness;
            }
        }
示例#2
0
 private void SetLaserPointer(InteractionSourceUpdatedEventArgs obj, InteractionSourceHandedness handedness,
     Vector3 controllerPosition, Vector3 pointerPosition)
 {
     if (handedness == InteractionSourceHandedness.Left)
         if (LeftGrasped && obj.state.grasped
             || LeftMenuDown && obj.state.menuPressed
             || LeftSelectDown && obj.state.selectPressed
             || LeftThumbstickDown && obj.state.thumbstickPressed
             || LeftTouchpadTouched && obj.state.touchpadTouched)
         {
             _leftLaserPointer.positionCount = 2;
             _leftLaserPointer.SetPosition(0, controllerPosition);
             _leftLaserPointer.SetPosition(1, pointerPosition);
         }
         else
         {
             _leftLaserPointer.positionCount = 0;
         }
     else if (handedness == InteractionSourceHandedness.Right)
         if (RightGrasped && obj.state.grasped
             || RightMenuDown && obj.state.menuPressed
             || RightSelectDown && obj.state.selectPressed
             || RightThumbstickDown && obj.state.thumbstickPressed
             || RightTouchpadTouched && obj.state.touchpadTouched)
         {
             _rightLaserPointer.positionCount = 2;
             _rightLaserPointer.SetPosition(0, controllerPosition);
             _rightLaserPointer.SetPosition(1, pointerPosition);
         }
         else
         {
             _rightLaserPointer.positionCount = 0;
         }
 }
        private void FinishControllerSetup(GameObject controllerModelGameObject, InteractionSourceHandedness handedness, string dictionaryKey)
        {
            var parentGameObject = new GameObject
            {
                name = handedness + "Controller"
            };

            parentGameObject.transform.parent          = transform;
            controllerModelGameObject.transform.parent = parentGameObject.transform;

            var newControllerInfo = new MotionControllerInfo(parentGameObject, handedness);

            newControllerInfo.LoadInfo(controllerModelGameObject.GetComponentsInChildren <Transform>());

            if (handedness == InteractionSourceHandedness.Left)
            {
                leftControllerModel = newControllerInfo;
            }
            else if (handedness == InteractionSourceHandedness.Right)
            {
                rightControllerModel = newControllerInfo;
            }

            if (OnControllerModelLoaded != null)
            {
                OnControllerModelLoaded(newControllerInfo);
            }

            loadingControllers.Remove(dictionaryKey);
            controllerDictionary.Add(dictionaryKey, newControllerInfo);
        }
        private void FinishControllerSetup(GameObject controllerModelGameObject, InteractionSourceHandedness handedness, string dictionaryKey)
        {
            Debug.Log("Make Comtroller");

            var parentGameObject = new GameObject
            {
                name = handedness + "Controller"
            };

            parentGameObject.transform.parent          = transform;
            controllerModelGameObject.transform.parent = parentGameObject.transform;

            var newControllerInfo = new MotionControllerInfo(parentGameObject, handedness);

            newControllerInfo.LoadInfo(controllerModelGameObject.GetComponentsInChildren <Transform>());

            if (handedness == InteractionSourceHandedness.Left)
            {
                leftControllerModel = newControllerInfo;
            }
            else if (handedness == InteractionSourceHandedness.Right)
            {
                rightControllerModel = newControllerInfo;
            }

            if (OnControllerModelLoaded != null)
            {
                OnControllerModelLoaded(newControllerInfo);
            }

            loadingControllers.Remove(dictionaryKey);
            controllerDictionary.Add(dictionaryKey, newControllerInfo);

            //컨트롤러가 생성되면 찾아서 태그를 바꾸어 준다//
            conL = GameObject.Find("LeftController");
            conR = GameObject.Find("RightController");
            if (conL != null)
            {
                //컨트롤러 레이져 봉 추가//
                lineL.SetActive(true);
                lineL.transform.parent        = conL.transform;
                lineL.transform.localPosition = Vector3.zero;
                //레이어 위치 변경//
                //conL.layer = 9;
                ChangeLayer(conL.transform, 9);
                Debug.Log("왼쪽 컨트롤러 생성!::: " + conL.layer);
            }
            if (conR != null)
            {
                //컨트롤러 레이져 봉 추가//
                lineR.SetActive(true);
                lineR.transform.parent        = conR.transform;
                lineR.transform.localPosition = Vector3.zero;

                //레이어 위치 변경//
                //conR.layer = 9;
                ChangeLayer(conR.transform, 9);
                Debug.Log("오른쪽 컨트롤러 생성!::: " + conR.layer);
            }
        }
示例#5
0
        /// <summary>
        /// Allows the object to change which controller it tracks, based on handedness.
        /// </summary>
        /// <param name="newHandedness">The new handedness to track. Does nothing if the handedness doesn't change.</param>
#if UNITY_WSA && UNITY_2017_2_OR_NEWER
        public void ChangeHandedness(InteractionSourceHandedness newHandedness)
        {
            if (newHandedness != handedness)
            {
                RemoveControllerTransform(ControllerInfo);
                handedness = newHandedness;
                CheckModelAlreadyLoaded();
            }
        }
示例#6
0
        public MotionControllerInfo(GameObject controllerParent
#if UNITY_WSA && UNITY_2017_2_OR_NEWER
                                    , InteractionSourceHandedness handedness
#endif
                                    )
        {
            ControllerParent = controllerParent;
#if UNITY_WSA && UNITY_2017_2_OR_NEWER
            Handedness = handedness;
#endif
        }
示例#7
0
    void Start()
    {
        tracker = GetComponent <TrackedPoseDriver>();
        if (tracker.poseSource == TrackedPoseDriver.TrackedPose.LeftPose)
        {
            handedness = InteractionSourceHandedness.Left;
        }
        else
        {
            handedness = InteractionSourceHandedness.Right;
        }

        InteractionManager.InteractionSourcePressed  += InteractionManager_InteractionSourcePressed;
        InteractionManager.InteractionSourceReleased += InteractionManager_InteractionSourceReleased;
        InteractionManager.InteractionSourceUpdated  += InteractionManager_InteractionSourceUpdated;
    }
        bool IsMatchingHand(Side side, InteractionSourceHandedness hand)
        {
            switch (side)
            {
            case Side.Anything:
                return(true);

            case Side.Left:
                return(hand == InteractionSourceHandedness.Left);

            case Side.Right:
                return(hand == InteractionSourceHandedness.Right);

            default:
                return(false);
            }
        }
 public bool TryGetControllerModel(InteractionSourceHandedness handedness, out MotionControllerInfo controller)
 {
     if (handedness == InteractionSourceHandedness.Left && leftControllerModel != null)
     {
         controller = leftControllerModel;
         return(true);
     }
     else if (handedness == InteractionSourceHandedness.Right && rightControllerModel != null)
     {
         controller = rightControllerModel;
         return(true);
     }
     else
     {
         controller = null;
         return(false);
     }
 }
        private void FinishControllerSetup(GameObject controllerModelGameObject, InteractionSourceHandedness handedness, string dictionaryKey)
        {
            string parentGameObjectName = handedness + "ControllerModel";
            // Find child with proper name - Name cannot be changed!
            GameObject parentGameObject = transform.Find("Controller (" + handedness.ToString() + ")/" + parentGameObjectName).gameObject;

            // if no child, simply create new one
            if (parentGameObject == null)
            {
                parentGameObject = new GameObject
                {
                    name = parentGameObjectName
                };
                parentGameObject.transform.parent = transform;
            }

            controllerModelGameObject.transform.parent        = parentGameObject.transform;
            controllerModelGameObject.transform.localPosition = Vector3.zero;
            controllerModelGameObject.transform.localRotation = Quaternion.identity;

            var newControllerInfo = new MotionControllerInfo(parentGameObject, handedness);

            newControllerInfo.LoadInfo(controllerModelGameObject.GetComponentsInChildren <Transform>());

            if (handedness == InteractionSourceHandedness.Left)
            {
                leftControllerModel = newControllerInfo;
            }
            else if (handedness == InteractionSourceHandedness.Right)
            {
                rightControllerModel = newControllerInfo;
            }

            if (OnControllerModelLoaded != null)
            {
                OnControllerModelLoaded(newControllerInfo);
            }

            loadingControllers.Remove(dictionaryKey);
            controllerDictionary.Add(dictionaryKey, newControllerInfo);
        }
        public string GetPathToButton(SDK_BaseController.ControllerElements element, InteractionSourceHandedness handedness)
        {
            switch (handedness)
            {
            case InteractionSourceHandedness.Left:
                if (leftControllerModel != null)
                {
                    return(leftControllerModel.GetPathToVisualizedButton(element));
                }
                return(null);

            case InteractionSourceHandedness.Right:
                if (rightControllerModel != null)
                {
                    return(rightControllerModel.GetPathToVisualizedButton(element));
                }
                return(null);

            default:
                return(null);
            }
        }
示例#12
0
 protected override void OnAttachToController()
 {
     // Subscribe to input now that we're parented under the controller
     UnityEngine.XR.WSA.Input.InteractionManager.InteractionSourceUpdated += InteractionSourceUpdated;
     hand = handedness;
 }
示例#13
0
 public MotionControllerEventArgs(InteractionSourceState sourceState, InteractionSourceHandedness handedness)
 {
     SourceState = sourceState;
     Handedness  = handedness;
 }
 public MotionControllerInfo(GameObject controllerParent, InteractionSourceHandedness handedness)
 {
     ControllerParent = controllerParent;
     Handedness       = handedness;
 }
 public MotionControllerPositionEventArgs(InteractionSourceState sourceState, Vector3 pointerPosition, Quaternion pointerRotation, Vector3 controllerPosition, Quaternion controllerRotation, InteractionSourceHandedness handedness) : base(
         sourceState, handedness)
 {
     PointerPosition    = pointerPosition;
     PointerRotation    = pointerRotation;
     ControllerPosition = controllerPosition;
     ControllerRotation = controllerRotation;
 }
示例#16
0
 public TouchpadManipulateEventArgs(InteractionSourceState sourceState, bool touchpadPressed, bool touchpadTouch, Vector2 touchpadPosition, InteractionSourceHandedness handedness) : base(sourceState, handedness)
 {
     TouchpadPressed  = touchpadPressed;
     TouchpadTouch    = touchpadTouch;
     TouchpadPosition = touchpadPosition;
 }
示例#17
0
 private void FinishControllerSetup(GameObject controllerModelGameObject, InteractionSourceHandedness handedness, string dictionaryKey)
 {
     controllerModelGameObject.transform.parent        = transform;
     controllerModelGameObject.transform.localRotation = Quaternion.identity;
     controllerModelGameObject.transform.localPosition = Vector3.zero;
 }
 public SelectManipulateEventArgs(InteractionSourceState sourceState, bool selectPressed, float selectPressedAmount, InteractionSourceHandedness handedness) : base(sourceState, handedness)
 {
     SelectPressed       = selectPressed;
     SelectPressedAmount = selectPressedAmount;
 }
示例#19
0
 public ThumbstickManipilateEventArgs(InteractionSourceState sourceState, bool thumbstickPressed, Vector2 thumbstickPosition, InteractionSourceHandedness handedness) : base(sourceState, handedness)
 {
     ThumbstickPressed  = thumbstickPressed;
     ThumbstickPosition = thumbstickPosition;
 }