/// Credit Tima Zhum using UnityEngine.EventSystems; namespace UnityEngine.UI.Extensions { [RequireComponent(typeof(Image))] [AddComponentMenu("Scripts/UnityEngine.UI.Extensions/FloatingJoystickArea")] public class FloatingJoystickArea: MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IDragHandler { /// /// The floating joystick controller /// [Tooltip("The floating joystick that should appear in the area on tap")] [SerializeField] private FloatingJoystick _floatingJoystick = null; #if CROSS_PLATFORM_INPUT /// /// Raises the pointer down event /// /// Ped public void OnPointerDown(PointerEventData _ped) { if (_floatingJoystick) _floatingJoystick.OnPointerDownHelper(_ped); } /// /// Raises the pointer up event /// /// Ped public void OnPointerUp(PointerEventData _ped) { if (_floatingJoystick) _floatingJoystick.OnPointerUpHelper(_ped); } /// /// Raises the drag event /// /// Ped public void OnDrag(PointerEventData _ped) { if (_floatingJoystick) _floatingJoystick.OnDragHelper(_ped); } #else public void OnDrag(PointerEventData data) {} public void OnPointerUp(PointerEventData data) {} public void OnPointerDown(PointerEventData data) {} #endif } }