liveBook · Manning

Unique identifier

As explained in High Performance Unity Game Development

A value assigned to an entity to distinguish it from other entities and preserve its identity across changes.

A unique identifier distinguishes an enemy type from other types and stays fixed even when its array index changes. Keep it unchanged so saved data can still identify the enemy after the balance data is reordered. section 10.6

A practical compatibility workflow:

  • Assign each enemy a unique value, such as “Big Zombie” or a numeric string. One format uses nine digits: three for faction, three for class, and three incremented linearly. section 10.6
  • Save the identifier with the game data. On load, use it to find the enemy’s current index and update the saved data if the index has moved. section 10.6
  • Use a dictionary to map saved indices to objects during loading, keeping dictionary lookups out of the gameplay loop. section 10.8
Figure 10.21 By saving the unique identifier in the game data, we can update indices as needed. When the vampire is added at index 1, and the zombie is moved to index 2, we can update the data accordingly.

Shows how a saved identifier lets the game update an enemy’s index when the balance data changes. section 10.6

How High Performance Unity Game Development covers it

How deep it goes
Defines immutable identifiers and walks through saving them and resolving changed indices during loading.
Examples
Uses enemy names and nine-digit faction-class-sequence strings as identifiers.
What it assumes
Assumes enemy data has indices and saved games can store data identifying each enemy type.
What you can do after
Understand how immutable enemy identifiers let saved data resolve to current entries after balance changes.
How it connects
Connects stable identifiers to array indices, dictionaries, and backward compatibility in saved games.

Also explained in

Compare how 10 books explain unique identifier →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of High Performance Unity Game Development. The section links point to the parts of the book it draws on.