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);
        }
        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);
        }
        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);
        }