Generated from the SDK’s canonical reference at v0.4.0. Fixes belong in pio-unity-sdk, not here.
Conventions
PIO (static class)
The sole public entry point. Studios interact with the SDK exclusively through
this class.
Properties
All properties are read-only and safe to read at any time.
Events
event Action<PioError> OnError
Raised when the SDK encounters an error: auth, a decision fallback, event
ingestion, an evicted queue, or an unhandled exception inside SDK code. Always
fires on the Unity main thread, so handlers may touch Unity APIs. Standard C#
event: subscribe with +=, unsubscribe with -=. Subscribe before Init
to catch init-time errors. See error handling.
Methods
Init(PioConfig config, PioOptions options = null) → Task
Initialise the SDK. Resolves the stable user ID, authenticates with PIO
(when tracking is enabled), warms the connection, and starts the
session.
Init() → Task
Zero-argument overload that loads a PioSettings
asset from Resources/PioSettings.asset, so no code configuration is required.
Throws InvalidOperationException if no asset is present. For explicit config or
secure runtime key injection, use the two-argument overload (its arguments take
precedence over the asset).
SetTrackingEnabled(bool enabled) → Task
Toggle data collection at runtime (e.g. after a CMP consent change).
See consent integration.
GetDecision(string actionDefKey, CancellationToken ct = default) → Task<DecisionResult>
Request configuration for a registered action definition. Read behaviour through
the generated payload class; keep Action for logging, analytics and
debugging. See the payload contract below.
TrackEvent(string eventType[, double value]) → void
Fire a custom game event, optionally with a non-negative numeric value.
Enqueues synchronously and returns immediately.
The numeric overload writes
value to the top-level event_value field.
SetState(string key, object value) → void
Set a custom game state value included in the next GetDecision snapshot.
Keys should match state definitions registered in the PIO dashboard (e.g.
std_level_index).
PioConfig (sealed class)
Connection configuration passed to PIO.Init. The three string identifiers are
required and validated at init time. Use object initialiser syntax.
ActionDef (sealed class)
A single action space registered in PioConfig.Actions.
PioOptions (sealed class)
Behavioural options, separate from connection config. Optional second argument to
PIO.Init.
PioSettings (ScriptableObject)
Inspector-editable configuration asset at Assets/Resources/PioSettings.asset,
loaded by the zero-argument PIO.Init(). The Setup Wizard generates it.
Carries the PioConfig connection fields and the PioOptions knobs, plus
AutoInitialize (auto-init on game start, off by default). PioConfig.Actions
stays code-only: Unity can’t serialise a dictionary in the Inspector.
Ship exactly one PioSettings asset: Resources.Load returns the first one
found in any Resources/ folder, so a duplicate silently shadows the real one.
DecisionResult (sealed class)
Immutable result from PIO.GetDecision. Studios cannot construct instances; they
read configuration through generated payload classes.
Option payload
Set defaults in the dashboard schema, then runPIO > Generate Code Constants.
Codegen writes a class for each action with parameters to
Assets/PIO.Generated/PioPayloads.cs. Each property has its default compiled in:
HasPayload and run your current flow when it is false.
Action is a label for logs. Don’t use it to choose what to do.
Generated code lands in Assembly-CSharp. If your game uses an assembly
definition, put the generated folder in that assembly or add an assembly
reference asset in the generated folder.
For reading without codegen, use the getters below. Each takes your default,
returned when the payload or key is missing or the value has the wrong type.
Array getters skip elements of the wrong type.
Schema drift
The Editor compares the server’s schema againstPioGeneratedSchema.json on focus
and on entering play mode, and warns when a parameter is added, removed, or
re-typed, the changes that stale your generated code. Editing a parameter’s
default or description is not drift: defaults are re-read from the server on
every decision. Regenerate to clear the warning.
PioError (sealed class)
An error surfaced via PIO.OnError. Studios receive instances; they never
construct them. Compare Code against PioErrorCodes.
PioErrorCodes (static class)
Stable string codes for PioError.Code. The set is fixed for the cloud-only
architecture.
Enums
PioState
Transitions:
Uninitialized → Initializing → Ready, or Initializing → Failed.
DecisionSource
PioErrorSeverity
PioEnvironment
Studios only target
Production. Internal/test rigs use the *UrlOverride
fields on PioConfig.