예제 #1
0
        private void HandleTouchDown(TouchContext context, Touch touch)
        {
            if (Stage.isTouchOnUI)
            {
                return;
            }

            context.touchDown = true;
            context.position  = context.downPosition = touch.position;

            if (_OnTouchDown != null)
            {
                _OnTouchDown.Invoke(context);
            }
        }
예제 #2
0
        private void HandleMouseUp(TouchContext context)
        {
            context.touchDown = false;

            if (_OnTouchUp != null)
            {
                _OnTouchUp.Invoke(context);
            }

            if (_OnTouchClick != null)
            {
                _OnTouchClick.Invoke(context);
            }

            context.Reset();
        }
예제 #3
0
        protected override void Init()
        {
            base.Init();

            if (Application.platform == RuntimePlatform.WindowsPlayer ||
                Application.platform == RuntimePlatform.WindowsEditor ||
                Application.platform == RuntimePlatform.OSXPlayer ||
                Application.platform == RuntimePlatform.OSXEditor)
            {
                _touchMode = false;
            }
            else
            {
                _touchMode = Input.touchSupported && SystemInfo.deviceType != DeviceType.Desktop;
            }

            _contexts = new TouchContext[5];
            for (int i = 0; i < _contexts.Length; i++)
            {
                _contexts[i]         = new TouchContext();
                _contexts[i].touchID = i;
            }
        }
예제 #4
0
        private void HandleMouseEvents()
        {
            CheckTouchIdleState(Input.GetMouseButton(0) ? 1 : 0);
            TouchContext context = _contexts[0];

            if (Input.GetMouseButtonDown(0))
            {
                HandleMouseDown(context);
            }
            else if (Input.GetMouseButtonUp(0))
            {
                if (context.touchDown)
                {
                    HandleMouseUp(context);
                }
            }
            else
            {
                if (context.touchDown)
                {
                    HandleMouseMove(context);
                }
            }
        }