Class PlayerPrefsSaveStore

Namespace
TDMaker.Unity.Campaign
Assembly
TDMaker.Unity.dll

Store in UnityEngine.PlayerPrefs (browser storage in WebGL builds): one string per slot under prefix + slot number. Unreadable content is copied to key.bak before the slot is cleared. Flushes with UnityEngine.PlayerPrefs.Save() on every write.

public sealed class PlayerPrefsSaveStore : TextSaveStore, ISaveStore
Inheritance
PlayerPrefsSaveStore
Implements
Inherited Members

Constructors

PlayerPrefsSaveStore(string, int)

Creates a store using keys keyPrefix1, 2, ...

public PlayerPrefsSaveStore(string keyPrefix = "TDMaker.Save.Slot", int slots = 3)

Parameters

keyPrefix string
slots int

Properties

KeyPrefix

Key prefix.

public string KeyPrefix { get; }

Property Value

string

Methods

Backup(int, string)

Moves unreadable slot content out of the way, keeping it. Returns where it went (for the warning).

protected override string Backup(int slot, string text)

Parameters

slot int
text string

Returns

string

DeleteText(int)

Removes a slot.

protected override void DeleteText(int slot)

Parameters

slot int

HasText(int)

Whether a slot holds text.

protected override bool HasText(int slot)

Parameters

slot int

Returns

bool

KeyOf(int)

PlayerPrefs key of slot.

public string KeyOf(int slot)

Parameters

slot int

Returns

string

ReadText(int)

Reads the raw text of a slot, or null when it is empty.

protected override string ReadText(int slot)

Parameters

slot int

Returns

string

WriteText(int, string)

Writes the raw text of a slot.

protected override void WriteText(int slot, string text)

Parameters

slot int
text string