internal void Process( Transform transform, Camera renderCamera, IDFTouchInputSource input, bool retainFocusSetting )
        {
            controlUnderMouse = null;

            var touches = input.Touches;
            for( int i = 0; i < touches.Count; i++ )
            {

                // Dereference Touch information
                var touch = touches[ i ];

                // Keep track of the last control under the "mouse"
                var touchedControl = dfGUIManager.HitTestAll( touch.position );
                if( touchedControl != null && touchedControl.transform.IsChildOf( manager.transform ) )
                {
                    controlUnderMouse = touchedControl;
                }

                #region Don't track touches on empty space

                if( controlUnderMouse == null )
                {
                    if( touch.phase == TouchPhase.Began )
                    {

                        if( !retainFocusSetting && untracked.Count == 0 )
                        {
                            var focusControl = dfGUIManager.ActiveControl;
                            if( focusControl != null && focusControl.transform.IsChildOf( manager.transform ) )
                            {
                                focusControl.Unfocus();
                            }
                        }

                        untracked.Add( touch.fingerId );

                        continue;

                    }
                }

                if( untracked.Contains( touch.fingerId ) )
                {

                    if( touch.phase == TouchPhase.Ended )
                        untracked.Remove( touch.fingerId );

                    continue;

                }

                #endregion

                var ray = renderCamera.ScreenPointToRay( touch.position );
                var info = new TouchRaycast( controlUnderMouse, touch, ray );

                var captured = tracked.FirstOrDefault( x => x.IsTrackingFinger( info.FingerID ) );
                if( captured != null )
                {
                    captured.Process( info );
                    continue;
                }

                var processed = false;
                for( int x = 0; x < tracked.Count; x++ )
                {
                    if( tracked[ x ].Process( info ) )
                    {
                        processed = true;
                        break;
                    }
                }

                if( !processed && controlUnderMouse != null )
                {

                    if( !tracked.Any( x => x.control == controlUnderMouse ) )
                    {

                        var newTracker = new ControlTouchTracker( manager, controlUnderMouse );

                        tracked.Add( newTracker );
                        newTracker.Process( info );

                    }

                }

            }

            }
Пример #2
0
        internal void Process( Transform transform, Camera renderCamera, dfList<Touch> touches, bool retainFocus )
        {
            for( int i = 0; i < touches.Count; i++ )
            {

                // Dereference Touch information
                var touch = touches[ i ];

                // Raycast from touch position to find the top-most control under the touch
                var ray = renderCamera.ScreenPointToRay( touch.position );
                var maxDistance = renderCamera.farClipPlane - renderCamera.nearClipPlane;
                var hits = Physics.RaycastAll( ray, maxDistance, renderCamera.cullingMask );

                // Keep track of the last control under the "mouse"
                controlUnderMouse = clipCast( transform, hits );

                #region Don't track touches on empty space

                if( controlUnderMouse == null )
                {
                    if( touch.phase == TouchPhase.Began )
                    {
                        untracked.Add( touch.fingerId );
                        continue;
                    }
                }

                if( untracked.Contains( touch.fingerId ) )
                {

                    if( touch.phase == TouchPhase.Ended )
                        untracked.Remove( touch.fingerId );

                    continue;

                }

                #endregion

                var info = new TouchRaycast( controlUnderMouse, touch, ray );

                var captured = tracked.FirstOrDefault( x => x.IsTrackingFinger( info.FingerID ) );
                if( captured != null )
                {
                    captured.Process( info );
                    continue;
                }

                var processed = false;
                for( int x = 0; x < tracked.Count; x++ )
                {
                    if( tracked[ x ].Process( info ) )
                    {
                        processed = true;
                        break;
                    }
                }

                if( !processed && controlUnderMouse != null )
                {

                    if( !tracked.Any( x => x.control == controlUnderMouse ) )
                    {

                        if( controlUnderMouse == null )
                            Debug.Log( "Tracking touch with no control: " + touch.fingerId );

                        var newTracker = new ControlTouchTracker( manager, controlUnderMouse );

                        tracked.Add( newTracker );
                        newTracker.Process( info );

                    }

                }

            }

            }