Example #1
0
        private void Start()
        {
            // we have set a prefab instance on this script - if we don't have a singleton of FingersScript yet,
            // create an instance of the prefab and set it as the singleton. This allows the fingers script
            // to live forever and eliminates the need to add the fingers script to every scene in your game.
            // you should only have this logic in the first scene of your game, and it must be in the Start method.
            FingersScript.CreateSingletonFromPrefabIfNeeded(FingersScriptPrefab);

            asteroids = Resources.LoadAll <Sprite>("Asteroids");

            // don't reorder the creation of these :)
            CreatePlatformSpecificViewTripleTapGesture();
            CreateDoubleTapGesture();
            CreateTapGesture();
            CreateSwipeGesture();
            CreatePanGesture();
            CreateScaleGesture();
            CreateRotateGesture();
            CreateLongPressGesture();

            // pan, scale and rotate can all happen simultaneously
            panGesture.AllowSimultaneousExecution(scaleGesture);
            panGesture.AllowSimultaneousExecution(rotateGesture);
            scaleGesture.AllowSimultaneousExecution(rotateGesture);

            // prevent the one special no-pass button from passing through,
            //  even though the parent scroll view allows pass through (see FingerScript.PassThroughObjects)
            FingersScript.Instance.CaptureGestureHandler = CaptureGestureHandler;

            // show touches, only do this for debugging as it can interfere with other canvases
            FingersScript.Instance.ShowTouches = true;
        }
Example #2
0
        private void Start()
        {
            // only put this in Start and only in the first scene of your game
            FingersScript.CreateSingletonFromPrefabIfNeeded(FingersScriptPrefab);

            // create a tap gesture that only executes on the left panel
            TapGestureRecognizer tap = new TapGestureRecognizer();

            tap.Updated += Tap_Updated_Panel;
            tap.PlatformSpecificView = LeftPanel;
            FingersScript.Instance.AddGesture(tap);

            TapGestureRecognizer tap2 = new TapGestureRecognizer();

            tap2.Updated += Tap_Updated_Cube;
            tap2.PlatformSpecificView = Cube;
            FingersScript.Instance.AddGesture(tap2);
        }