Unity Conflict Handling

Treat conflict handling as a normal part of the Unity save flow.

A stale baseVersion is not a transport failure. The Unity SDK returns the canonical server save plus typed conflict details so the game can reconcile intentionally.

Conflict Example

Use this pattern for explicit conflict recovery.

var result = await client.SyncSaveAsync(saveId, new PersistlySyncSaveRequest(
    stateJson: nextStateJson,
    baseVersion: local.Version,
    metadataJson: local.MetadataJson
));

if (result.Status == PersistlySyncStatus.Accepted)
{
    local = result.Save;
}

if (result.Status == PersistlySyncStatus.Conflict)
{
    local = result.Save;

    if (result.Details?.Reason == PersistlySyncConflictReason.BaseVersionMismatch)
    {
        // Decide whether to reapply unsynced local edits or prompt the player.
    }
}

Rules

These are the conflict semantics the Unity integration depends on.

A 409 from the runtime becomes PersistlySyncStatus.Conflict in the Unity SDK, not a generic transport failure.

result.Save is always the canonical server save. Replace your local canonical snapshot before any merge logic.

result.Details?.Reason tells you why the conflict happened and is currently BaseVersionMismatch for stale sync attempts.

The right recovery order is: accept canonical save, decide what to do with unsynced local edits, then issue a new sync if needed.