Skip to main content

GameService

class · Singleton<GameService> Unity component singleton
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

PropertyTypeDefaultDescription
State
StateGameStatecurrent lifecycle phase (Ready / Started / Stopped / Lobby); get public, set private
Configuration
PlayerNamestring"Player#1"display name for the local player
PlaceablesGamePlaceable[]placeable objects available to this game

Method summary

MethodReturns
EnterLobbyvoidUnity component
SetPlaceableTask<PlacingResult>async
Setupvoid⚠️ no-op stub
CancelSetupvoid⚠️ no-op stub

→ Full descriptions in Method details below.

Events

EventSignatureFires when
GameStateChangedGameStateEventHandler(GameState state)the game's lifecycle State transitions (ReadyStartedStoppedLobby)

State reflects the current lifecycle phase; subscribe to GameStateChanged to be notified on every transition rather than polling State.

Method details

EnterLobby

methodUnity component
public void EnterLobby();

Moves the game into the Lobby state. GameStateChanged fires with the new state.

Exampleinferred
var game = GameService.Instance;
game.GameStateChanged += state => Debug.Log($"Game state → {state}");
game.EnterLobby(); // State becomes Lobby; GameStateChanged fires

SetPlaceable

methodasync
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.

Parameters
placeableIPlaceablethe object to place in the scene
ReturnsTask<PlacingResult>a task that resolves with the placement result — anchor id + completion state
Exampleinferred
PlacingResult result = await GameService.Instance.SetPlaceable(myPlaceable);
// result carries the anchor id and the final placement state

Setup / CancelSetup

methodUnity component
public void Setup();
public void CancelSetup();

Intended to begin / cancel a setup phase.

⚠️ Needs confirmation

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 on
  • UnityService — remote-control façade over Unity scene operations
  • Connection — services and lifecycle overview
  • Class index — all Unity SDK types
Was this page helpful?