Пример #1
0
        private void Update()
        {
            if (!ValidateDimension())
            {
                return;
            }

            Vector3 mouseWorldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            UpdateTouchLogic(mouseWorldPoint);
            TouchEventInfo touchInfo = CreateTouchInfo(mouseWorldPoint);

            DispatchEvents(touchInfo);
            OnProcess(touchInfo);
        }
Пример #2
0
        private TouchEventInfo CreateTouchInfo(Vector3 mouseWorldPoint)
        {
            TouchEventInfo info;

            if (_dimension == Dimension.Two)
            {
                RaycastHit2D[] hits = Physics2D.RaycastAll(mouseWorldPoint, Vector2.zero, 1000f);
                info = new TouchEventInfo(this, TouchLogic, hits, mouseWorldPoint);
            }
            else
            {
                RaycastHit[] hits = Physics.RaycastAll(mouseWorldPoint, Vector3.forward, 1000f);
                info = new TouchEventInfo(this, TouchLogic, hits, mouseWorldPoint);
            }

            return(info);
        }
Пример #3
0
        private void DispatchEvents(TouchEventInfo touchInfo)
        {
            if (TouchLogic.IsFirstDown)
            {
                OnDown(touchInfo);
            }

            if (TouchLogic.IsFirstDownOff)
            {
                OnDownOff(touchInfo);
            }

            if (TouchLogic.IsDrag)
            {
                OnDrag(touchInfo);
            }

            if (TouchLogic.IsRelease)
            {
                OnRelease(touchInfo);
            }
        }