Class UnityAchievementPlatformDefinition
Base asset for one storefront the project mirrors its achievements to. A concrete subtype carries whatever that storefront needs to identify the title and builds the gateway that talks to it.
Inheritance
Implements
Namespace: Serenity.Achievements.Infrastructure.Platforms
Assembly: Serenity.UnityAchievements.Infrastructure.dll
Syntax
public abstract class UnityAchievementPlatformDefinition : ScriptableObject, IFoundationSettings
Remarks
The abstraction is an asset rather than a settings enum because the four storefronts need nothing in common: Steam wants an app id, Epic a product and a sandbox, PlayStation a trophy pack. One asset per platform lets each carry exactly its own fields, and lets a licensee add a fifth in their own assembly by subclassing this and marking it ICustomAchievementPlatformDefinition — nothing in Serenity has to change.
A definition that cannot produce a usable gateway answers null; it never throws. The
factory then leaves it out, so a storefront SDK that is not installed costs the project
nothing but a warning. The four shipped subtypes never answer null: their gateways
degrade to an inert template that reports itself unavailable and says why, which is a better
answer than absence because the composite can still name the platform in a log line.
Plugging in a real SDK. Two seams exist, and they are not alternatives — the registry wins where both are present, and the definitions still contribute:
- A gateway for a storefront Serenity already names. Implement
IAchievementPlatformGateway in your own assembly — the one that may reference
the licensed SDK — and register it from a
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]throughAchievementPlatformGatewayRegistry.SetFactory. Take the overload that receives an AchievementPlatformGatewayContext if the gateway has to read the account back; the parameterless one is for a gateway that only pushes. It is consulted before these assets, survives package updates, and needs no Serenity source edited. - A storefront Serenity does not name at all. Subclass this type in your own
assembly, mark it ICustomAchievementPlatformDefinition so tooling reports it
as yours rather than as an unknown asset type, give it a
[CreateAssetMenu], and assign it toUnityAchievementSettings.Platformslike any shipped one. Nothing dispatches on concrete type, so it needs no registration anywhere.
Constructors
UnityAchievementPlatformDefinition()
Declaration
protected UnityAchievementPlatformDefinition()
Fields
Guid
Declaration
public string Guid
Field Value
| Type | Description |
|---|---|
| string | GUID for this platform definition asset. |
Id
Declaration
public string Id
Field Value
| Type | Description |
|---|---|
| string | Unique identifier for this platform definition asset. |
Properties
Kind
Which of the storefronts an achievement can declare an identifier for this asset is.
Declaration
public abstract AchievementPlatformKind Kind { get; }
Property Value
| Type | Description |
|---|---|
| AchievementPlatformKind |
Remarks
Answered by the definition rather than by the gateway because the question is asked at
authoring time, when no gateway exists: it is what lets a project say "we ship on Steam and
PlayStation" from the assets it assigned, so
AchievementAuthoringRules can report an achievement that names no identifier for a
platform the project actually ships on. A custom definition answers with the shipped kind
whose identifier field it borrows.
Methods
CreateGateway(AchievementPlatformGatewayContext)
Builds the gateway that mirrors unlocks to this storefront.
Declaration
public abstract IAchievementPlatformGateway CreateGateway(AchievementPlatformGatewayContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| AchievementPlatformGatewayContext | context | What the gateway is built from. Never |
Returns
| Type | Description |
|---|---|
| IAchievementPlatformGateway | The gateway, or |
Remarks
The context carries the achievements this project declares as well as the log service, because a storefront names achievements by its own identifier: without the declared set a gateway can push an unlock outward but can never read the account back. A subtype that needs neither may ignore it.