Exemple #1
0
        /// <summary>
        /// EventReleased, dispatched by Scaffoldings InputManager
        /// Passes through a InputTracker of the current touch.
        /// </summary>
        /// <param name="tracker">Tracker.</param>
        public override void HandleEventReleased(InputTracker tracker)
        {
            base.HandleEventReleased(tracker);

            if (_hit)
            {
                if (tracker.HitGameObject(_collider.gameObject))
                {
                    float   threshold = 20;
                    Vector3 pos       = tracker.Position;
                    if (Mathf.Abs(pos.x - _clickedPos.x) < threshold && Mathf.Abs(pos.y - _clickedPos.y) < threshold)
                    {
                        RunButtonPressedCallbacks();

                        switch (buttonActionType)
                        {
                        case ButtonActionType.Open:
                            OpenView();
                            break;

                        case ButtonActionType.Close:
                            CloseOverlay();
                            break;
                        }

                        RunButtonMethods();
                    }
                }
            }
            if (_currentState == ButtonState.Down)
            {
                ChangeState(ButtonState.Up);
            }
            _hit = false;
        }
Exemple #2
0
        /************************************************
        * AbstractInput overrides.
        ************************************************/
        /// <summary>
        /// EventPressed, dispatched by Scaffoldings InputManager
        /// Passes through a InputTracker of the current touch.
        /// </summary>
        /// <param name="tracker">Tracker.</param>
        public override void HandleEventPressed(InputTracker tracker)
        {
            base.HandleEventPressed(tracker);

            if (tracker.HitGameObject(_collider.gameObject))
            {
                RunButtonDownCallbacks();
                _hit        = true;
                _clickedPos = tracker.Position;
                ChangeState(ButtonState.Down);
            }
        }