GameService
public sealed class GameService : Singleton<GameService>, IGameService
Namespace: AR51.Unity.SDK · Implements: IGameService
Tracks the high-level game lifecycle state and drives placement of placeable objects in the scene. Reach it via the singleton (GameService.Instance); subscribe to GameStateChanged to react to lifecycle transitions, and call SetPlaceable to run an async placement flow.
All positions are in meters (Unity world space).
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| State | |||
State | GameState | — | current lifecycle phase (Ready / Started / Stopped / Lobby); get public, set private |
| Configuration | |||
PlayerName | string | "Player#1" | display name for the local player |
Placeables | GamePlaceable[] | — | placeable objects available to this game |
Method summary
| Method | Returns | |
|---|---|---|
EnterLobby | void | Unity component |
SetPlaceable | Task<PlacingResult> | async |
Setup | void | ⚠️ no-op stub |
CancelSetup | void | ⚠️ no-op stub |
→ Full descriptions in Method details below.
Events
| Event | Signature | Fires when |
|---|---|---|
GameStateChanged | GameStateEventHandler(GameState state) | the game's lifecycle State transitions (Ready ⇄ Started ⇄ Stopped ⇄ Lobby) |
State reflects the current lifecycle phase; subscribe to GameStateChanged to be notified on every transition rather than polling State.
Method details
EnterLobby
public void EnterLobby();
Moves the game into the Lobby state. GameStateChanged fires with the new state.
var game = GameService.Instance;
game.GameStateChanged += state => Debug.Log($"Game state → {state}");
game.EnterLobby(); // State becomes Lobby; GameStateChanged fires
SetPlaceable
public Task<PlacingResult> SetPlaceable(IPlaceable placeable);
Starts an async placement for placeable and resolves once placement completes. The resulting PlacingResult carries the anchor id and the completion state.
PlacingResult result = await GameService.Instance.SetPlaceable(myPlaceable);
// result carries the anchor id and the final placement state
Setup / CancelSetup
public void Setup();
public void CancelSetup();
Intended to begin / cancel a setup phase.
In this SDK version, Setup() and CancelSetup() appear to be no-op stubs — they have no observable effect. Treat them as not-yet-implemented until confirmed against the source.
See also
ServiceManager— entry point that brings up the service layer GameService runs onUnityService— remote-control façade over Unity scene operations- Connection — services and lifecycle overview
- Class index — all Unity SDK types