private void OnEnable() { rectTransform = GetComponent <RectTransform>(); rectTransform.pivot = new Vector2(0.5f, 0.5f); PanGesture.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 if JoystickImage is set, the Canvas is 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); SetIdleState(); homePosition = rectTransform.position; }