# IGP Unity SDK Core

`cn.indiegp.sdk.unity` is the Unity platform base package. It contains:

- `IGPConfig` and `IGPRuntimeManager`
- Desktop or Mobile Host Session platform selection
- shared Host Session protobuf client with Desktop Named Pipe and Mobile Flutter transports
- authorization, achievements, account, user profile, and existing command APIs
- an allowlisted Direct Curio path for phone SMS sign-in, session refresh, and profiles
- runtime extension contracts for optional packages

It intentionally contains no Hosted, Room, Realtime, KCP, UDP, network
diagnostics, or Mirror types. Install `cn.indiegp.sdk.unity.multiplayer` only
when the game needs RoomNode Game data synchronization, Realtime, or Mirror.

See [Documentation~/UPM-INSTALL.md](Documentation~/UPM-INSTALL.md) when installing a distributed UPM tarball.

For the binary UPM usage contract and field-level Core models, start with [Documentation~/UPM-INSTALL.md](Documentation~/UPM-INSTALL.md) and [Documentation~/ACCOUNT-AND-PROFILES.md](Documentation~/ACCOUNT-AND-PROFILES.md). The runtime implementation is in the package DLL; these guides are the intended reference for configuring and calling it.

## Minimal Setup

1. Create one `IGPConfig` asset, set `appId`, and select `hostSessionPlatform`.
2. Add `IGPRuntimeManager` to a persistent GameObject.
3. Assign the config and call `await runtime.InitializeAsync()`.

Optional runtime extensions on the same GameObject are discovered, initialized in order, and shut down by the core runtime.

Selecting `Mobile` does not add a game-facing transport API. Game code keeps
calling the same profile, capability, and Multiplayer APIs; Core selects the
Mobile Host Session execution pipeline internally.

## Account And Profiles

Explicit phone sign-in is independent from Desktop attach and does not require `InitializeAsync()`:

```csharp
var sendResult = await runtime.SendPhoneSignInCodeAsync("13800138000");
var session = await runtime.SignInWithPhoneCodeAsync("13800138000", verificationCode);
var profile = await runtime.GetCurrentUserProfileAsync();
var players = await runtime.GetPlayerProfilesAsync(new[] { otherUserId });
```

The sign-in call also creates the user when Curio has no account for that phone. `IGPUserSession` exposes only `Profile`; Core retains access and refresh tokens in memory. `runtime.SignOut()` clears only this explicit account session and does not change Desktop login.

Profile calls use an already attached, signed-in Host Session `userContext` when available. Otherwise they use the explicit Core account session. The source choice is internal, and a failed Host command is never replayed against Curio. See [Documentation~/ACCOUNT-AND-PROFILES.md](Documentation~/ACCOUNT-AND-PROFILES.md).

After initialization, host-provided values are available through named, parameter-free runtime info properties:

```csharp
var saveRootPath = runtime.RuntimeInfo.SaveRootPath;
```

`SaveRootPath` is always non-null. It is an empty string when the runtime host did not provide a save location; reading it does not create or modify the directory.

All public runtime notifications are code-only C# events; they are not Inspector-bindable `UnityEvent` fields. See [Documentation~/EVENT-REFERENCE.md](Documentation~/EVENT-REFERENCE.md) for the maintained event list.

See [Documentation~/QUICKSTART.md](Documentation~/QUICKSTART.md) for the core-only flow and [../IGP.UnitySDK.Multiplayer/README.md](../IGP.UnitySDK.Multiplayer/README.md) for multiplayer.

Core does not provide Gateway sessions, room projection, or room commands. It
owns Host Session platform selection and can broker descriptor acquisition for
Multiplayer through the selected Desktop or Mobile Host provider. A
Gateway-facing integration still owns room control, and caller-owned
orchestration can pass a RoomNode descriptor to Multiplayer explicitly.
