Controller+BETADownload

Start a Unity game

Beta. The package declares Unity 2021.3 and Input System 1.7.0. These are package requirements, not tested versions. No Unity Editor version, native build, scripting backend or WebGL build has been validated. The scene below is a source example; budget time to compile and test it on your target.

The Node host runs beside Unity. Phones join its QR with player authority. Unity connects separately with a private host token and receives Input System gamepads. You do not need the desktop companion or a Controller+ account.

Contents

Start the phone host

Use the unpacked SDK archive, or a source checkout after npm ci. From its root, replace the example IP with the computer's reachable Wi-Fi address:

PORT=49514 PUBLIC_ORIGIN=http://192.168.1.20:49514 node examples/developer-host/server.mjs

Open the host QR lobby on that computer. The host writes temporary credentials to .local/developer-session.json in the SDK root. Keep that file private. It is a local development handoff, not a credential to include in your game.

Leave this Node process running. A restart creates another room. Scan the current QR after a restart.

Install the package and scene

  1. Create a Unity project with the Input System enabled under Project Settings → Player → Active Input Handling. Restart the Editor if requested.
  2. Open Window → Package Manager → + → Add package from disk. Select integrations/unity/package.json in the unpacked SDK archive. Let Unity install its declared Input System dependency.
  3. Create an empty scene and one GameObject named PhoneDots. Save the script below as Assets/PhoneDots.cs, then attach it. RequireComponent adds ControllerPlusInput automatically.
  4. Enter the absolute local credential-file path in the component's Session File field. Keep this as a local test scene; do not ship this field or file. The script also accepts the CONTROLLER_PLUS_SESSION_FILE environment variable, which a release launcher can set before starting the game.
  5. Enter Play mode. The Game view draws a box for each phone. Keep the Game view focused so focus loss does not release your test input.
using System;
using System.Collections.Generic;
using System.IO;
using ControllerPlus;
using UnityEngine;
using UnityEngine.InputSystem;

[RequireComponent(typeof(ControllerPlusInput))]
public sealed class PhoneDots : MonoBehaviour
{
    [Serializable] private sealed class Credentials
    {
        public string endpoint, room, hostToken;
    }
    private sealed class Dot
    {
        public Gamepad pad;
        public Vector2 position;
        public int presses;
    }
    [SerializeField] private string sessionFile = "";
    private ControllerPlusInput hub;
    private readonly Dictionary<string, Dot> dots = new Dictionary<string, Dot>();
    private string status = "Starting host connection…";

    private void Start()
    {
        hub = GetComponent<ControllerPlusInput>();
        hub.ControllerJoined += Joined;
        hub.ControllerLeft += Left;
        hub.ControllerRemoved += Removed;
        hub.ConnectionChanged += ConnectionChanged;
        hub.ConnectionError += ConnectionError;
        try
        {
            string file = Environment.GetEnvironmentVariable("CONTROLLER_PLUS_SESSION_FILE");
            if (string.IsNullOrEmpty(file)) file = sessionFile;
            var credentials = JsonUtility.FromJson<Credentials>(File.ReadAllText(file));
            if (credentials == null || string.IsNullOrEmpty(credentials.endpoint) ||
                string.IsNullOrEmpty(credentials.room) || string.IsNullOrEmpty(credentials.hostToken))
                throw new InvalidDataException("Missing host credentials");
            hub.Connect(credentials.endpoint, credentials.room, credentials.hostToken);
        }
        catch (Exception)
        {
            status = "Could not read the host session file. Check its path and restart Play mode.";
        }
    }
    private void Joined(string id, Gamepad pad)
    {
        if (!dots.TryGetValue(id, out var dot))
        {
            dot = new Dot { position = new Vector2(60 + dots.Count * 100, 180) };
            dots.Add(id, dot);
        }
        dot.pad = pad; // resume binds the replacement device and keeps position/counter
    }
    private void Left(string id) { if (dots.TryGetValue(id, out var dot)) dot.pad = null; }
    private void Removed(string id) { dots.Remove(id); }
    private void ConnectionChanged(bool connected)
    {
        status = connected ? "Scan the Node host QR. Move a stick and tap the bottom face button."
            : "Host connection lost. Reconnecting…";
        if (!connected) foreach (var dot in dots.Values) dot.pad = null;
    }
    private void ConnectionError(string message) { status = message; }
    private void Update()
    {
        foreach (var dot in dots.Values)
        {
            if (dot.pad == null || !dot.pad.added) continue;
            Vector2 move = Vector2.ClampMagnitude(dot.pad.leftStick.ReadValue() + dot.pad.dpad.ReadValue(), 1);
            dot.position += new Vector2(move.x, -move.y) * (180 * Time.deltaTime);
            dot.position.x = Mathf.Clamp(dot.position.x, 0, Mathf.Max(0, Screen.width - 90));
            dot.position.y = Mathf.Clamp(dot.position.y, 80, Mathf.Max(80, Screen.height - 50));
            if (dot.pad.buttonSouth.wasPressedThisFrame) dot.presses++;
        }
    }
    private void OnGUI()
    {
        GUI.Label(new Rect(20, 20, Screen.width - 40, 60), status);
        foreach (var entry in dots)
        {
            var dot = entry.Value;
            GUI.Box(new Rect(dot.position.x, dot.position.y, 90, 50),
                entry.Key + "\n" + dot.presses + (dot.presses == 1 ? " press" : " presses") + (dot.pad == null ? " · away" : ""));
        }
    }
    private void OnDestroy()
    {
        if (hub == null) return;
        hub.ControllerJoined -= Joined;
        hub.ControllerLeft -= Left;
        hub.ControllerRemoved -= Removed;
        hub.ConnectionChanged -= ConnectionChanged;
        hub.ConnectionError -= ConnectionError;
        hub.Close();
    }
}

ControllerJoined fires again on resume. Keep the dot and bind the new Gamepad there. Do not create another dot from ControllerResumed. ControllerLeft releases active input; ControllerRemoved deletes the seat. A physical gamepad stays a normal Unity Gamepad; this script displays only the phones reported by the integration.

See phone input

Scan the Node lobby QR with two phones. Enter names and tap Play. Move each phone's left stick or D-pad: only its own Unity box should move. Tap the bottom face button: only that box's counter should increase. This is the first success to check after compilation.

Disconnect one phone and return within five minutes. Its box should stop while away and keep its position and counter when it resumes. Stopping Play mode closes Unity's host connection; stop Node with Ctrl+C when finished.

These are steps to validate the Beta integration. They are not a claim that the scene was compiled or played. Use the Node start page to verify phone input separately if Unity setup fails.

Build a release

The example reads a local file and targets an Editor or native desktop process. WebGL cannot read it this way. A WebGL build needs its own authorized runtime credential handoff and HTTPS-compatible socket; do not embed a host token in a public download.

For a desktop release, start a matching Node host from your launcher or operate your own reachable host. Supply credentials only to the authorized game process, show the current player QR, and close both processes on exit. Test your actual Editor version, target OS, scripting backend, two phones, physical pads, background/focus behavior and reconnects before shipping. See Ship a game and the Unity API.

All start pages · Search developer docs · Ship a game