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);
 }
Пример #2
0
        private void Start()
        {
#if UNITY_EDITOR
            ValidateImages(DPadBackgroundImage, DPadUpImageSelected, DPadRightImageSelected, DPadDownImageSelected, DPadLeftImageSelected, DPadCenterImageSelected);
#endif

            PanGesture = new PanGestureRecognizer
            {
                PlatformSpecificView = (MoveDPadToGestureStartLocation ? null : DPadBackgroundImage.canvas.gameObject),
                ThresholdUnits       = 0.0f
            };
            PanGesture.AllowSimultaneousExecutionWithAllGestures();
            PanGesture.StateUpdated += PanGestureUpdated;
            FingersScript.Instance.AddGesture(PanGesture);

            TapGesture = new TapGestureRecognizer
            {
                PlatformSpecificView = DPadBackgroundImage.gameObject
            };
            TapGesture.AllowSimultaneousExecutionWithAllGestures();
            TapGesture.StateUpdated += TapGestureUpdated;
            FingersScript.Instance.AddGesture(TapGesture);

            if (!string.IsNullOrEmpty(CrossPlatformInputHorizontalAxisName) && !string.IsNullOrEmpty(CrossPlatformInputVerticalAxisName))
            {
                crossPlatformInputHorizontalAxisObject = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputHorizontalAxisName, out crossPlatformInputNewlyRegistered);
                crossPlatformInputVerticalAxisObject   = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputVerticalAxisName, out crossPlatformInputNewlyRegistered);
            }
        }
Пример #3
0
        private void OnEnable()
        {
            rectTransform = GetComponent <RectTransform>();
            PanGesture    = new PanGestureRecognizer
            {
                PlatformSpecificView = JoystickBackground.gameObject,
                ThresholdUnits       = 0.0f
            };
            PanGesture.AllowSimultaneousExecutionWithAllGestures();
            PanGesture.StateUpdated += PanGestureUpdated;

#if UNITY_EDITOR
            if (JoystickImage == null || JoystickImage.canvas.renderMode != RenderMode.ScreenSpaceOverlay)
            {
                Debug.LogError("Fingers joystick script requires that JoystickImage be set and that the Canvas be in ScreenSpaceOverlay mode.");
            }
#endif

            if (!string.IsNullOrEmpty(CrossPlatformInputHorizontalAxisName) && !string.IsNullOrEmpty(CrossPlatformInputVerticalAxisName))
            {
                crossPlatformInputHorizontalAxisObject = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputHorizontalAxisName, out crossPlatformInputNewlyRegistered);
                crossPlatformInputVerticalAxisObject   = FingersCrossPlatformInputReflectionScript.RegisterVirtualAxis(CrossPlatformInputVerticalAxisName, out crossPlatformInputNewlyRegistered);
            }

            FingersScript.Instance.AddGesture(PanGesture);
        }
Пример #4
0
        private void Start()
        {
            // create each pan gesture
            for (int i = 0; i < MaxDragCount; i++)
            {
                PanGestureRecognizer pan = new PanGestureRecognizer();
                pan.StateUpdated += Pan_StateUpdated;
                pan.AllowSimultaneousExecutionWithAllGestures();

                // allow the pan to start immediately with no minimum distance movement required
                pan.ThresholdUnits = 0.0f;

                FingersScript.Instance.AddGesture(pan);
            }

            // randomly position and scale the asteroids in the field of view
            Bounds bounds = new Bounds
            {
                min = Camera.main.ViewportToWorldPoint(Vector3.zero),
                max = Camera.main.ViewportToWorldPoint(Vector3.one)
            };

            foreach (GameObject obj in GameObject.FindObjectsOfType <GameObject>())
            {
                if (obj.name.StartsWith("Asteroid"))
                {
                    float scale = Random.Range(0.2f, 0.5f);
                    obj.transform.localScale = new Vector3(scale, scale, 1.0f);
                    obj.transform.position   = new Vector3(Random.Range(bounds.min.x, bounds.max.x), Random.Range(bounds.min.y, bounds.max.y), 0.0f);
                }
            }
        }
Пример #5
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);
 }
Пример #6
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);
 }
Пример #7
0
        private void Start()
        {
            PanGesture = new PanGestureRecognizer
            {
                PlatformSpecificView = (MoveJoystickToGestureStartLocation ? null : JoystickImage.gameObject),
                ThresholdUnits       = 0.0f
            };
            PanGesture.AllowSimultaneousExecutionWithAllGestures();
            PanGesture.StateUpdated += PanGestureUpdated;
            FingersScript.Instance.AddGesture(PanGesture);

#if UNITY_EDITOR
            if (JoystickImage == null || JoystickImage.canvas.renderMode != RenderMode.ScreenSpaceOverlay)
            {
                Debug.LogError("Fingers joystick script requires that JoystickImage be set and that the Canvas be in ScreenSpaceOverlay mode.");
            }
#endif
        }
Пример #8
0
        private void Start()
        {
#if UNITY_EDITOR
            ValidateImages(DPadBackgroundImage, DPadUpImageSelected, DPadRightImageSelected, DPadDownImageSelected, DPadLeftImageSelected, DPadCenterImageSelected);
#endif

            PanGesture = new PanGestureRecognizer
            {
                PlatformSpecificView = (MoveDPadToGestureStartLocation ? null : DPadBackgroundImage.canvas.gameObject),
                ThresholdUnits       = 0.0f
            };
            PanGesture.AllowSimultaneousExecutionWithAllGestures();
            PanGesture.StateUpdated += PanGestureUpdated;
            FingersScript.Instance.AddGesture(PanGesture);

            TapGesture = new TapGestureRecognizer
            {
                PlatformSpecificView = DPadBackgroundImage.gameObject
            };
            TapGesture.AllowSimultaneousExecutionWithAllGestures();
            TapGesture.StateUpdated += TapGestureUpdated;
            FingersScript.Instance.AddGesture(TapGesture);
        }