Class SteamIconPngEncoder
Encodes a Unity-authored achievement icon into the PNG bytes Steam's achievement editor requires: exactly Serenity.Achievements.Infrastructure.Sync.Steam.SteamIconRules.RequiredWidthxSerenity.Achievements.Infrastructure.Sync.Steam.SteamIconRules.RequiredHeight, with the locked variant auto-generated by Serenity.Achievements.Infrastructure.Sync.Steam.SteamIconRules.Grayscale(System.Byte,System.Byte,System.Byte) unless an explicit locked sprite was supplied at construction.
Implements
Inherited Members
Namespace: Serenity.Achievements.Infrastructure.Editor.Sync.Steam
Assembly: Serenity.UnityAchievements.Infrastructure.Editor.Sync.Steam.dll
Syntax
public sealed class SteamIconPngEncoder : IAchievementSyncIconEncoder
Remarks
Blits the sprite's own sub-rect of its texture through a temporary UnityEngine.RenderTexture, the
approach UnityDocsIconExporter already uses to export branding icons — it reads back through
UnityEngine.Texture2D.ReadPixels(UnityEngine.Rect,System.Int32,System.Int32,System.Boolean) instead of the source texture directly, so a non-readable source
texture (Read/Write disabled on import, the common case for a game's sprites) still encodes.
Constructors
SteamIconPngEncoder()
Creates an encoder that auto-generates every locked icon from the achievement's own icon.
Declaration
public SteamIconPngEncoder()
SteamIconPngEncoder(Sprite)
Creates an encoder that uses one fixed locked icon for every achievement instead of auto-generating one from each achievement's unlocked icon.
Declaration
public SteamIconPngEncoder(Sprite explicitLockedIcon)
Parameters
| Type | Name | Description |
|---|---|---|
| Sprite | explicitLockedIcon | The locked icon override, or null to auto-generate as usual. |
Methods
EncodeLocked(UnityAchievementDefinition)
Encodes the icon shown while the achievement is still locked.
Declaration
public AchievementIconPayload EncodeLocked(UnityAchievementDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityAchievementDefinition | definition | The authored achievement to read an icon from. |
Returns
| Type | Description |
|---|---|
| AchievementIconPayload | The encoded icon, or None when it carries none. |
EncodeUnlocked(UnityAchievementDefinition)
Encodes the icon shown once the achievement is unlocked.
Declaration
public AchievementIconPayload EncodeUnlocked(UnityAchievementDefinition definition)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityAchievementDefinition | definition | The authored achievement to read an icon from. |
Returns
| Type | Description |
|---|---|
| AchievementIconPayload | The encoded icon, or None when it carries none. |