示例#1
0
        public override void SetNodeType(NodeType nodeType)
        {
            base.SetNodeType(nodeType);

            m_LeftCtrl.SetActive(isLeft);

            m_RightCtrl.SetActive(!isLeft);

            m_Animator = Ctrl.GetComponent <Animator>();

            m_Laser = Ctrl.GetComponentInChildren <LaserPointer>();

            m_Laser.inputType = isLeft ? LaserPointer.InputType.LeftHand : LaserPointer.InputType.RightHand;

            m_Laser.SetVisiable(m_LaserShow);
        }
示例#2
0
        private MouseButtonEventData GetLaserPointerEventData(LaserPointer laser)
        {
            MouseButtonEventData mouseButtonData;
            var created = GetLaserPointerData(laser.fingerId, out mouseButtonData, true);

            XRPointEventData pointerData = mouseButtonData.buttonData as XRPointEventData;

            pointerData.Reset();

            pointerData.origin        = laser.origin;
            pointerData.direction     = laser.direction;
            pointerData.hitDistance   = laser.raycastDistance;
            pointerData.button        = PointerEventData.InputButton.Left;
            pointerData.raycastCamera = laser.raycastCamera;
            pointerData.position      = new Vector2(laser.raycastCamera.pixelWidth * 0.5f, laser.raycastCamera.pixelHeight * 0.5f);

            pointerData.useFingerRaycast = false;
            eventSystem.RaycastAll(pointerData, m_RaycastResultCache);
            var raycast = FindFirstRaycast(m_RaycastResultCache);

            pointerData.pointerCurrentRaycast = raycast;
            m_RaycastResultCache.Clear();

            //更新射线状态
            laser.UpdateStateFormRaycast(ref raycast);

            mouseButtonData.buttonState = XRPointEventData.StateForButton(laser.isPressed, laser.isReleased);
            if (laser.isHit)
            {
                if (created)
                {
                    pointerData.hitPoint = laser.hitPoint;
                }
                pointerData.scrollDelta = laser.scrollDelta;
                pointerData.delta       = laser.delta;
                pointerData.hitNormal   = laser.hitNormal;
                pointerData.hitPoint    = laser.hitPoint;
            }
            return(mouseButtonData);
        }
示例#3
0
 internal static void Remove(LaserPointer laser)
 {
     GetLasers()?.Remove(laser);
 }
示例#4
0
 internal static void Regist(LaserPointer laser)
 {
     GetLasers().Add(laser);
 }