Beispiel #1
0
        void StopCountDown(SCPointEventData scData)
        {
            if (scData == null)
            {
                return;
            }

            if (coroutineAddKey != null)
            {
                StopCoroutine(coroutineAddKey);
            }

            scData.inputDevicePartBase.detectorBase.pointerBase.cursorBase.StopGazeAnimation();
            if (isAddKeyFinish)
            {
                isAddKeyFinish = false;
                StartCoroutine(AddKey(InputKeyCode.Enter, InputKeyState.UP, scData, 0.5f));
            }
        }
Beispiel #2
0
        public virtual void ProcessCS(SCPointEventData scPointEventData, Transform posture, int layerMask = 1 << 8, float maxDetectDistance = 30, bool isSimlate = false, RaycastResult simlateResult = new RaycastResult())
        {
            //if(!eventSystem.isFocused)
            //    return;

            bool usedEvent = SendUpdateEventToSelectedObject();

            ProcessSCEventInit(scPointEventData, posture, layerMask, maxDetectDistance);
            ProcessSCEvent(scPointEventData, isSimlate, simlateResult);

            if (eventSystem.sendNavigationEvents)
            {
                if (!usedEvent)
                {
                    usedEvent |= SendMoveEventToSelectedObject();
                }

                if (!usedEvent)
                {
                    SendSubmitEventToSelectedObject();
                }
            }
        }
Beispiel #3
0
 public virtual void OnPokeUp(TouchPointer touchPointer, SCPointEventData eventData)
 {
     AudioSystem.getInstance.PlayAudioOneShot(gameObject, PokeUpAudio);
     PokeUp.Invoke(touchPointer, eventData);
 }
Beispiel #4
0
 public virtual void OnPokeUpdated(TouchPointer touchPointer, SCPointEventData eventData)
 {
     PokeUpdated.Invoke(touchPointer, eventData);
 }
Beispiel #5
0
        /// <summary>
        /// Process all mouse events.
        /// </summary>
        protected void ProcessSCEvent(SCPointEventData scPointEventData, bool isSimlate = false, RaycastResult simlateResult = new RaycastResult())
        {
            scPointEventData.MouseButtonEventData.buttonData  = scPointEventData;
            scPointEventData.MouseButtonEventData.buttonState = StateForMouseButton(scPointEventData.inputDevicePartBase);

            if (isSimlate)
            {
                scPointEventData.pointerCurrentRaycast = simlateResult;
            }
            else
            {
                eventSystem.RaycastAll(scPointEventData, m_RaycastResultCache);
                scPointEventData.pointerCurrentRaycast = FindFirstRaycast(m_RaycastResultCache);
                m_RaycastResultCache.Clear();
            }



            scPointEventData.Forward = RayCasterCamera.transform.forward;

            if (scPointEventData.MouseButtonEventData.PressedThisFrame() && scPointEventData.pointerCurrentRaycast.gameObject)
            {
                scPointEventData.HitPointerRelativeRayCasterCamera = RayCasterCamera.transform.InverseTransformPoint(scPointEventData.pointerCurrentRaycast.worldPosition);
                scPointEventData.Position3D          = scPointEventData.PressPosition3D = RayCasterCamera.transform.TransformPoint(scPointEventData.HitPointerRelativeRayCasterCamera);
                scPointEventData.pressForward        = RayCasterCamera.transform.forward;
                scPointEventData.DownPressGameObject = scPointEventData.pointerCurrentRaycast.gameObject;
            }
            else if (scPointEventData.MouseButtonEventData.ReleasedThisFrame())
            {
                scPointEventData.HitPointerDeltaDragObjCenter = scPointEventData.HitPointerRelativeRayCasterCamera = scPointEventData.dragObjPosition = Vector3.zero;
                scPointEventData.Position3D          = Vector3.zero;
                scPointEventData.PressPosition3D     = Vector3.zero;
                scPointEventData.DownPressGameObject = null;
                scPointEventData.pressForward        = Vector3.zero;
            }


            if (scPointEventData.DownPressGameObject)
            {
                scPointEventData.Position3D = RayCasterCamera.transform.TransformPoint(scPointEventData.HitPointerRelativeRayCasterCamera);
            }

            // Process the first mouse button fully
            ProcessMousePress(scPointEventData.MouseButtonEventData);
            ProcessMove(scPointEventData);


            if (scPointEventData.MouseButtonEventData.PressedThisFrame() && scPointEventData.pointerCurrentRaycast.gameObject && scPointEventData.pointerDrag)
            {
                ///碰撞点指向碰撞物体中心的向量
                scPointEventData.HitPointerDeltaDragObjCenter = scPointEventData.pointerDrag.transform.position - scPointEventData.pointerCurrentRaycast.worldPosition;
                ///第一次赋值 ,must
                scPointEventData.dragObjPosition = scPointEventData.HitPointerDeltaDragObjCenter + scPointEventData.Position3D;
            }

            ///必须在ProcessDrag前,否则,延迟一帧导致停顿感
            if (scPointEventData.dragging)
            {
                scPointEventData.dragObjPosition = scPointEventData.HitPointerDeltaDragObjCenter + scPointEventData.Position3D;
            }

            ///拖拽不启动阈值,否则不能触发IDragHandler
            //scPointEventData.useDragThreshold = false;

            ProcessDrag(scPointEventData);

            ///更新dragHitPinterPosition,必须在ProcessDrag后,ProcessDrag调用的DragHandler可能会更改PointerDrag对象的Transform
            if (scPointEventData.dragging)
            {
                scPointEventData.dragAnchorPosition3D = scPointEventData.pointerDrag.transform.position - scPointEventData.HitPointerDeltaDragObjCenter;
            }
            else
            {
                scPointEventData.dragAnchorPosition3D = Vector3.zero;
            }


            if (!Mathf.Approximately(scPointEventData.scrollDelta.sqrMagnitude, 0.0f))
            {
                var scrollHandler = ExecuteEvents.GetEventHandler <IScrollHandler>(scPointEventData.pointerCurrentRaycast.gameObject);
                ExecuteEvents.ExecuteHierarchy(scrollHandler, scPointEventData, ExecuteEvents.scrollHandler);
            }

            scPointEventDataxx = scPointEventData;
        }
Beispiel #6
0
        public override void OnPointerDown(PointerEventData eventData)
        {
            base.OnPointerDown(eventData);

            if (eventDataDic == null)
            {
                eventDataDic = new Dictionary <InputDevicePartType, SCPointEventData>();
            }

            if (scaleLogic == null)
            {
                scaleLogic = new ScaleLogic();
            }

            if (rotateLogic == null)
            {
                rotateLogic = new RotateLogic();
            }

            if (moveLogic == null)
            {
                moveLogic = new MoveLogic();
            }

            if (eventData is SCPointEventData)
            {
                SCPointEventData scPointEventData = eventData as SCPointEventData;
                eventDataDic[scPointEventData.inputDevicePartBase.PartType] = scPointEventData;
                if (scPointEventData.inputDevicePartBase is InputDeviceHandPart)
                {
                    devicePartManipulation = new HandDevicePartManipulation();
                }
                else if (scPointEventData.inputDevicePartBase is InputDeviceGCPart)
                {
                    devicePartManipulation = new GameControllerDevicePartManipulation();
                }
                else if (scPointEventData.inputDevicePartBase is InputDeviceHeadPart)
                {
                    devicePartManipulation = new HeadDevicePartManipulation();
                }
            }

            //Two DevicePart
            if (eventDataDic.Count > 1)
            {
                devicePartCountManipulation = new TwoDevicePartCountManipulation();
                devicePartCountManipulation.Init(devicePartManipulation, eventDataDic, Target == null ? this.transform : Target.transform, moveLogic, canTwoHandRotate ? rotateLogic : null, canTwoHandScale ? scaleLogic : null);
            }
            //One DevicePart
            else if (eventDataDic.Count == 1)
            {
                devicePartCountManipulation = new OneDevicePartCountManipulation();
                devicePartCountManipulation.Init(devicePartManipulation, eventDataDic, Target == null ? this.transform : Target.transform, moveLogic, canOneHandRotate ? rotateLogic : null, null);
            }

            rigidBody = Target == null?this.GetComponent <Rigidbody>() : Target.GetComponent <Rigidbody>();

            if (rigidBody != null)
            {
                wasKinematic          = rigidBody.isKinematic;
                rigidBody.isKinematic = true;
            }

            AudioSystem.getInstance.PlayAudioOneShot(gameObject, StartAudio);
        }