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.
- A prefab instance’s Guid shows up as modified compared to the prefab. If you accidentally apply all changes, then this library will die.
- Guids are illegible. Wouldn’t it be better to mention an important GameObject as
BossCharacter
rather than2c138012-f543-4caa-bcd4-e4a64bbeb623
? - 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.