Permanent UUID System in Unity

UUID

Whenever you’re making a save system or you’re making cross-scene references, you might come across a need for a unique ID for all your GameObjects. You might think Unity offers a solution for this, but there’s no clean solution offered yet.

Internally, each GameObject does have a UUID, but this value changes every run. This basically makes this value unusable.

Unity provides a git repository called guid-based-reference (https://github.com/Unity-Technologies/guid-based-reference) that provides this feature, but this comes with multiple disadvantages.

  1. A prefab instance’s Guid shows up as modified compared to the prefab. If you accidentally apply all changes, then this library will die.
  2. Guids are illegible. Wouldn’t it be better to mention an important GameObject as BossCharacter┬árather than 2c138012-f543-4caa-bcd4-e4a64bbeb623?
  3. Small memory inefficiencies. There are extra 8 bytes per instance to store a reference to a byte array. The sad part is that this array is only used during Unity’s serialization/deserialization.

The Solution

Here’s how CloudCanard’s UUID system handles these issues.

Continue reading