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.

6 scripts intermediate Starter kit Any mobile Unity game needing touch controls

Download mobile-controls-kit.zip 6 scripts and a README · 21 KB of C# · MIT

What is inside

What it does

  • 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

Setup, in order

  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. Add a full-screen panel under the Canvas, attach MobileSafeArea to it, and put the controls inside it

If something does not work

The joystick and buttons do not respond to touch
They use Unity UI pointer events, so the scene needs an EventSystem and the Canvas a Graphic Raycaster. Make sure no other full-screen UI image with Raycast Target on sits above the controls.
Controls sit under the notch or home bar
Put MobileSafeArea on a full-screen panel under the Canvas and make the controls its children. It resizes that panel to Screen.safeArea, so anything outside the panel is not protected.
The gyroscope camera does nothing
It checks SystemInfo.supportsGyroscope and stays still on devices without one, including the Editor and most tablets without motion sensors. Test on a phone.
Every input call throws InvalidOperationException in a new Unity 6 project
The scripts read the legacy Input class, which new Unity 6 projects switch off. Set Project Settings > Player > Active Input Handling to Both and let the Editor restart. Details and the Input System alternative.

Preview

An excerpt of the kit's main types, and the Inspector fields they expose.

InspectorExcerpt

Fields from the kit's preview excerpt; the full kit has more.

Handle Range 50
Dynamic Position
Swipe Threshold 50
Excerpt
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
}