private void OnEnable()
        {
            if (Target == null)
            {
                Target = transform;
            }

            PanGesture = new PanGestureRecognizer();
            PanGesture.StateUpdated += PanGestureCallback;
            FingersScript.Instance.AddGesture(PanGesture);

            TiltGesture = new PanGestureRecognizer();
            TiltGesture.StateUpdated  += TiltGestureCallback;
            TiltGesture.ThresholdUnits = 0.5f; // higher than normal to not interfere with other gestures
            TiltGesture.MinimumNumberOfTouchesToTrack = TiltGesture.MaximumNumberOfTouchesToTrack = 2;
            FingersScript.Instance.AddGesture(TiltGesture);

            ScaleGesture = new ScaleGestureRecognizer();
            ScaleGesture.StateUpdated += ScaleGestureCallback;
            FingersScript.Instance.AddGesture(ScaleGesture);

            RotateGesture = new RotateGestureRecognizer();
            RotateGesture.StateUpdated += RotateGestureCallback;
            FingersScript.Instance.AddGesture(RotateGesture);

            PanGesture.AllowSimultaneousExecution(ScaleGesture);
            PanGesture.AllowSimultaneousExecution(RotateGesture);
            ScaleGesture.AllowSimultaneousExecution(RotateGesture);
        }
        private void OnEnable()
        {
            RotationGesture = new RotateGestureRecognizer();
            RotationGesture.StateUpdated += RotationGesture_Updated;

            FingersScript.Instance.AddGesture(RotationGesture);
        }
Пример #3
0
        private void Start()
        {
            if (FingersScript.Instance == null)
            {
                Debug.LogError("Fingers script prefab needs to be added to the first scene");
                return;
            }

            this.Camera = (this.Camera == null ? Camera.main : this.Camera);
            panGesture  = new PanGestureRecognizer();
            panGesture.MinimumNumberOfTouchesToTrack = PanMinimumTouchCount;
            panGesture.Updated    += PanGestureUpdated;
            scaleGesture           = new ScaleGestureRecognizer();
            scaleGesture.Updated  += ScaleGestureUpdated;
            rotateGesture          = new RotateGestureRecognizer();
            rotateGesture.Updated += RotateGestureUpdated;
            rigidBody              = GetComponent <Rigidbody2D>();
            spriteRenderer         = GetComponent <SpriteRenderer>();
            if (spriteRenderer != null)
            {
                startSortOrder = spriteRenderer.sortingOrder;
            }
            panGesture.AllowSimultaneousExecution(scaleGesture);
            panGesture.AllowSimultaneousExecution(rotateGesture);
            scaleGesture.AllowSimultaneousExecution(rotateGesture);
            FingersScript.Instance.AddGesture(panGesture);
            FingersScript.Instance.AddGesture(scaleGesture);
            FingersScript.Instance.AddGesture(rotateGesture);
        }
 private void Start()
 {
     this.Camera = (this.Camera == null ? Camera.main : this.Camera);
     PanGesture  = new PanGestureRecognizer();
     PanGesture.MinimumNumberOfTouchesToTrack = PanMinimumTouchCount;
     PanGesture.MaximumNumberOfTouchesToTrack = 2;
     PanGesture.StateUpdated    += PanGestureUpdated;
     ScaleGesture                = new ScaleGestureRecognizer();
     ScaleGesture.StateUpdated  += ScaleGestureUpdated;
     RotateGesture               = new RotateGestureRecognizer();
     RotateGesture.StateUpdated += RotateGestureUpdated;
     SetStartState(gameObject);
     if (AllowExecutionWithAllGestures)
     {
         PanGesture.AllowSimultaneousExecutionWithAllGestures();
         PanGesture.AllowSimultaneousExecutionWithAllGestures();
         ScaleGesture.AllowSimultaneousExecutionWithAllGestures();
     }
     else
     {
         PanGesture.AllowSimultaneousExecution(ScaleGesture);
         PanGesture.AllowSimultaneousExecution(RotateGesture);
         ScaleGesture.AllowSimultaneousExecution(RotateGesture);
     }
     if (Mode == GestureRecognizerComponentScriptBase.GestureObjectMode.RequireIntersectWithGameObject)
     {
         RotateGesture.PlatformSpecificView = gameObject;
         PanGesture.PlatformSpecificView    = gameObject;
         ScaleGesture.PlatformSpecificView  = gameObject;
     }
     FingersScript.Instance.AddGesture(PanGesture);
     FingersScript.Instance.AddGesture(ScaleGesture);
     FingersScript.Instance.AddGesture(RotateGesture);
 }
        private void OnEnable()
        {
            contentRectTransform   = ScrollContent.GetComponent <RectTransform>();
            containerRectTransform = ScrollContentContainer.GetComponent <RectTransform>();

            // create the scale, tap and pan gestures that will manage the scroll view
            ScaleGesture = new ScaleGestureRecognizer();
            ScaleGesture.StateUpdated        += Scale_Updated;
            ScaleGesture.PlatformSpecificView = ScrollContentContainer;
            ScaleGesture.ThresholdUnits       = 0.0f; // start zooming immediately

            RotateGesture = new RotateGestureRecognizer();
            RotateGesture.StateUpdated        += Rotate_Updated;
            RotateGesture.PlatformSpecificView = ScrollContentContainer;
            RotateGesture.AllowSimultaneousExecution(ScaleGesture);

            DoubleTapGesture = new TapGestureRecognizer();
            DoubleTapGesture.NumberOfTapsRequired = 2;
            DoubleTapGesture.StateUpdated        += Tap_Updated;
            DoubleTapGesture.PlatformSpecificView = ScrollContentContainer;

            PanGesture = new PanGestureRecognizer();
            PanGesture.MaximumNumberOfTouchesToTrack = 2;
            PanGesture.StateUpdated += Pan_Updated;
            PanGesture.AllowSimultaneousExecution(ScaleGesture);
            PanGesture.AllowSimultaneousExecution(RotateGesture);
            PanGesture.PlatformSpecificView = ScrollContentContainer;

            FingersScript.Instance.AddGesture(ScaleGesture);
            FingersScript.Instance.AddGesture(RotateGesture);
            FingersScript.Instance.AddGesture(DoubleTapGesture);
            FingersScript.Instance.AddGesture(PanGesture);
        }
Пример #6
0
 private void OnEnable()
 {
     this.Camera = (this.Camera == null ? Camera.main : this.Camera);
     PanGesture  = new PanGestureRecognizer {
         MaximumNumberOfTouchesToTrack = 2, ThresholdUnits = 0.01f
     };
     PanGesture.StateUpdated    += PanGestureUpdated;
     ScaleGesture                = new ScaleGestureRecognizer();
     ScaleGesture.StateUpdated  += ScaleGestureUpdated;
     RotateGesture               = new RotateGestureRecognizer();
     RotateGesture.StateUpdated += RotateGestureUpdated;
     if (Mode != GestureRecognizerComponentScriptBase.GestureObjectMode.AllowOnAnyGameObjectViaRaycast)
     {
         SetStartState(null, gameObject, true);
     }
     if (DoubleTapToReset)
     {
         DoubleTapGesture = new TapGestureRecognizer {
             NumberOfTapsRequired = 2
         };
         DoubleTapGesture.StateUpdated += DoubleTapGestureUpdated;
     }
     if (AllowExecutionWithAllGestures)
     {
         PanGesture.AllowSimultaneousExecutionWithAllGestures();
         RotateGesture.AllowSimultaneousExecutionWithAllGestures();
         ScaleGesture.AllowSimultaneousExecutionWithAllGestures();
         if (DoubleTapGesture != null)
         {
             DoubleTapGesture.AllowSimultaneousExecutionWithAllGestures();
         }
     }
     else
     {
         PanGesture.AllowSimultaneousExecution(ScaleGesture);
         PanGesture.AllowSimultaneousExecution(RotateGesture);
         ScaleGesture.AllowSimultaneousExecution(RotateGesture);
         if (DoubleTapGesture != null)
         {
             DoubleTapGesture.AllowSimultaneousExecution(ScaleGesture);
             DoubleTapGesture.AllowSimultaneousExecution(RotateGesture);
             DoubleTapGesture.AllowSimultaneousExecution(PanGesture);
         }
     }
     if (Mode == GestureRecognizerComponentScriptBase.GestureObjectMode.RequireIntersectWithGameObject)
     {
         RotateGesture.PlatformSpecificView = gameObject;
         PanGesture.PlatformSpecificView    = gameObject;
         ScaleGesture.PlatformSpecificView  = gameObject;
         if (DoubleTapGesture != null)
         {
             DoubleTapGesture.PlatformSpecificView = gameObject;
         }
     }
     FingersScript.Instance.AddGesture(PanGesture);
     FingersScript.Instance.AddGesture(ScaleGesture);
     FingersScript.Instance.AddGesture(RotateGesture);
     FingersScript.Instance.AddGesture(DoubleTapGesture);
 }
        private void OnEnable()
        {
            if (Camera == null)
            {
                Camera = Camera.main;
            }

            Target       = (Target == null ? transform : Target);
            origRotation = Target.rotation;
            origScale    = Target.localScale;

            PanGesture = new PanGestureRecognizer();
            PanGesture.StateUpdated        += PanGestureStateUpdated;
            PanGesture.PlatformSpecificView = gameObject;
            FingersScript.Instance.AddGesture(PanGesture);

            RotateGesture = new RotateGestureRecognizer();
            RotateGesture.StateUpdated        += RotateGestureStateUpdated;
            RotateGesture.PlatformSpecificView = gameObject;
            RotateGesture.AllowSimultaneousExecution(PanGesture);
            FingersScript.Instance.AddGesture(RotateGesture);

            ScaleGesture = new ScaleGestureRecognizer();
            ScaleGesture.StateUpdated        += ScaleGestureStateUpdated;
            ScaleGesture.PlatformSpecificView = gameObject;
            ScaleGesture.ZoomSpeed           *= ScaleSpeed;
            ScaleGesture.AllowSimultaneousExecution(RotateGesture);
            ScaleGesture.AllowSimultaneousExecution(PanGesture);
            FingersScript.Instance.AddGesture(ScaleGesture);

            TapGestureReset = new TapGestureRecognizer();
            TapGestureReset.NumberOfTapsRequired = 2;
            TapGestureReset.PlatformSpecificView = gameObject;
            TapGestureReset.StateUpdated        += TapGestureResetStateUpdated;
            FingersScript.Instance.AddGesture(TapGestureReset);

            TapGestureDestroy = new TapGestureRecognizer();
            TapGestureDestroy.NumberOfTapsRequired = 3;
            TapGestureDestroy.PlatformSpecificView = gameObject;
            TapGestureDestroy.StateUpdated        += TapGestureDestroyStateUpdated;
            FingersScript.Instance.AddGesture(TapGestureDestroy);

            TapGestureReset.RequireGestureRecognizerToFail = TapGestureDestroy;

            LongPressGesture = new LongPressGestureRecognizer();
            LongPressGesture.PlatformSpecificView = gameObject;
            LongPressGesture.StateUpdated        += LongPressGestureStateUpdated;
            FingersScript.Instance.AddGesture(LongPressGesture);
        }
        private void OnEnable()
        {
            if (Camera == null)
            {
                Camera = Camera.main;
            }

            Targets = (Targets == null || Targets.Count == 0 ? new List <Transform> {
                transform
            } : Targets);
            UpdateOrigStates();

            PanGesture = new PanGestureRecognizer();
            PanGesture.StateUpdated += PanGestureStateUpdated;
            FingersScript.Instance.AddGesture(PanGesture);

            RotateGesture = new RotateGestureRecognizer();
            RotateGesture.StateUpdated += RotateGestureStateUpdated;
            RotateGesture.AllowSimultaneousExecution(PanGesture);
            FingersScript.Instance.AddGesture(RotateGesture);

            ScaleGesture = new ScaleGestureRecognizer();
            ScaleGesture.StateUpdated += ScaleGestureStateUpdated;
            ScaleGesture.ZoomSpeed    *= ScaleSpeed;
            ScaleGesture.AllowSimultaneousExecution(RotateGesture);
            ScaleGesture.AllowSimultaneousExecution(PanGesture);
            FingersScript.Instance.AddGesture(ScaleGesture);

            TapGestureReset = new TapGestureRecognizer();
            TapGestureReset.NumberOfTapsRequired = 2;
            TapGestureReset.StateUpdated        += TapGestureResetStateUpdated;
            FingersScript.Instance.AddGesture(TapGestureReset);

            TapGestureDestroy = new TapGestureRecognizer();
            TapGestureDestroy.NumberOfTapsRequired = 3;
            TapGestureDestroy.StateUpdated        += TapGestureDestroyStateUpdated;
            FingersScript.Instance.AddGesture(TapGestureDestroy);
            TapGestureReset.RequireGestureRecognizerToFail = TapGestureDestroy;

            LongPressGesture = new LongPressGestureRecognizer();
            LongPressGesture.StateUpdated += LongPressGestureStateUpdated;
            FingersScript.Instance.AddGesture(LongPressGesture);
        }
Пример #9
0
 private void Start()
 {
     this.Camera = (this.Camera == null ? Camera.main : this.Camera);
     PanGesture  = new PanGestureRecognizer();
     PanGesture.MinimumNumberOfTouchesToTrack = PanMinimumTouchCount;
     PanGesture.StateUpdated    += PanGestureUpdated;
     ScaleGesture                = new ScaleGestureRecognizer();
     ScaleGesture.StateUpdated  += ScaleGestureUpdated;
     RotateGesture               = new RotateGestureRecognizer();
     RotateGesture.StateUpdated += RotateGestureUpdated;
     rigidBody2D    = GetComponent <Rigidbody2D>();
     rigidBody      = GetComponent <Rigidbody>();
     spriteRenderer = GetComponent <SpriteRenderer>();
     canvasRenderer = GetComponent <CanvasRenderer>();
     if (spriteRenderer != null)
     {
         startSortOrder = spriteRenderer.sortingOrder;
     }
     if (AllowExecutionWithAllGestures)
     {
         PanGesture.AllowSimultaneousExecutionWithAllGestures();
         PanGesture.AllowSimultaneousExecutionWithAllGestures();
         ScaleGesture.AllowSimultaneousExecutionWithAllGestures();
     }
     else
     {
         PanGesture.AllowSimultaneousExecution(ScaleGesture);
         PanGesture.AllowSimultaneousExecution(RotateGesture);
         ScaleGesture.AllowSimultaneousExecution(RotateGesture);
     }
     if (SetPlatformSpecificView)
     {
         RotateGesture.PlatformSpecificView = gameObject;
         PanGesture.PlatformSpecificView    = gameObject;
         ScaleGesture.PlatformSpecificView  = gameObject;
     }
     FingersScript.Instance.AddGesture(PanGesture);
     FingersScript.Instance.AddGesture(ScaleGesture);
     FingersScript.Instance.AddGesture(RotateGesture);
 }
        private void OnEnable()
        {
            _camera = GetComponent <Camera>();
            if (GetComponent <UnityEngine.EventSystems.PhysicsRaycaster>() == null)
            {
                gameObject.AddComponent <UnityEngine.EventSystems.PhysicsRaycaster>();
            }
            if (GetComponent <UnityEngine.EventSystems.Physics2DRaycaster>() == null)
            {
                gameObject.AddComponent <UnityEngine.EventSystems.Physics2DRaycaster>();
            }

            ScaleGesture = new ScaleGestureRecognizer
            {
                ThresholdUnits = ScaleThreshold,
                ZoomSpeed      = 6.0f // for a touch screen you'd probably not do this, but if you are using ctrl + mouse wheel then this helps zoom faster
            };
            ScaleGesture.StateUpdated += Gesture_Updated;

            PanGesture = new PanGestureRecognizer();
            PanGesture.StateUpdated += PanGesture_Updated;

            // the scale and pan can happen together
            ScaleGesture.AllowSimultaneousExecution(PanGesture);

            TapGesture = new TapGestureRecognizer();
            TapGesture.StateUpdated += TapGesture_Updated;

            RotateGesture = new RotateGestureRecognizer();
            RotateGesture.StateUpdated += RotateGesture_Updated;
            RotateGesture.AllowSimultaneousExecution(PanGesture);
            RotateGesture.AllowSimultaneousExecution(ScaleGesture);

            FingersScript.Instance.AddGesture(ScaleGesture);
            FingersScript.Instance.AddGesture(PanGesture);
            FingersScript.Instance.AddGesture(TapGesture);
            FingersScript.Instance.AddGesture(RotateGesture);
        }
Пример #11
0
 private void CreateRotateGesture()
 {
     rotateGesture = new RotateGestureRecognizer();
     rotateGesture.StateUpdated += RotateGestureCallback;
     FingersScript.Instance.AddGesture(rotateGesture);
 }
		private void CreateRotateGesture()
		{
			rotateGesture = new RotateGestureRecognizer();
			rotateGesture.Updated += RotateGestureCallback;
			FingerScript.AddGesture(rotateGesture);
		}
Пример #13
0
 private void Start()
 {
     rotationGesture = new RotateGestureRecognizer();
     rotationGesture.StateUpdated += RotationGesture_Updated;
     FingersScript.Instance.AddGesture(rotationGesture);
 }