A class in Root.Township, the global namespace.
Keeps an object alive across scene loads, allowing only one per identifier; later duplicates destroy themselves.
Constructors
| Member | What it is |
|---|
DontDestroyOnLoad() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|
protected string identifier | Key that decides which objects count as duplicates. |
1 private and internal field
| Member | What it is |
|---|
private static Dictionary<string, DontDestroyOnLoad> identifiers | Static map from identifier to the surviving instance. |
Properties
| Member | What it is |
|---|
bool IsOfficial { get; private set; } | True on the instance that registered and survived, false on a duplicate. |
Methods
| Member | What it is |
|---|
protected virtual void Awake() | Destroys this object if another live one has the same identifier, otherwise registers it and marks it don't-destroy-on-load. |