intermediate
Mobile Controls Kit
Complete touch input system for any mobile Unity game — virtual joystick, on-screen buttons, swipe gestures, pinch-to-zoom, gyroscope, and safe area handling.
Features
Virtual joystick with dynamic positioning
Configurable on-screen action buttons
4-directional swipe gesture detection
Pinch-to-zoom for orthographic and perspective cameras
Gyroscope-based camera look
Automatic safe area handling for notched devices
Included Scripts
/mobile-controls-kit/
Setup Guide
1
Import all scripts into your Unity project
2
Create a UI Canvas and add TouchJoystick to a child Image element
3
Add TouchButton components for action buttons (jump, attack, etc.)
4
Attach SwipeInputController to a manager for gesture detection
5
Add PinchToZoomCamera to your main camera for zoom support
6
Attach MobileSafeArea to your root Canvas to handle notched devices
Code Preview
C#
// TouchJoystick.cs - Virtual joystick for mobile
public class TouchJoystick : MonoBehaviour
{
[SerializeField] private float handleRange = 50f;
[SerializeField] private bool dynamicPosition = true;
public Vector2 InputDirection { get; private set; }
// Drag handle within range, returns normalized direction
// Supports dynamic repositioning on touch start
}
// SwipeInputController.cs - Swipe gesture detection
public class SwipeInputController : MonoBehaviour
{
[SerializeField] private float swipeThreshold = 50f;
public event Action<SwipeDirection> OnSwipe;
// Detects Up, Down, Left, Right swipes
// Filters taps vs swipes by distance threshold
}Available Individually
These scripts are also available as standalone downloads: