Point phones at on-screen menus
A cursor follows each phone; press A to click the uGUI button under it. Several players at once.
Video: Point phones at on-screen menus (2:33)
Add Component → PadPlay → Gyro Pointer, one per player
Set a UI Image as each pointer's Reticle
Add the PhoneCursor script below next to each Gyro Pointer
using PadPlay;
using UnityEngine;
using UnityEngine.EventSystems;
// Next to a PadPlayGyroPointer: A on the phone clicks the uGUI under the cursor.
public class PhoneCursor : MonoBehaviour
{
[SerializeField] PadPlayHost host;
[SerializeField] PadPlayGyroPointer gyro;
PadPlayScreenPointer pointer;
void Update()
{
pointer ??= new PadPlayScreenPointer(gyro.PlayerSlot);
PadPlayPad pad = host.GetPad(gyro.PlayerSlot);
bool pressing = pad != null && pad.buttonSouth.isPressed;
// pixels of Display 1, origin at the bottom left
pointer.Process(EventSystem.current, gyro.IsPointing,
gyro.GetScreenPosition(), 0, pressing);
}
void OnDisable() => pointer?.Cancel();
}Point the phone's top edge (the camera end) at the screen and the cursor moves. Over a button, press A to click it (its OnClick runs). Give a second phone the same set and two players can press different buttons at once.