- Home /
Unique ID Assignment
I have generated a save system that allows for saving lots of things to playerprefs. To handle automating this I append a uniqueID to the saved variable name (think Apple_UniqueID_Color). The problem I am running into is that I have to set this uniqueID manually (from the inspector) on hundreds of objects, and its a pain to keep track of. It has to stay the same forever in a given script, as it also loads from that uniqueID. Is there any way to generate a uniqueID when I attach a script to a gameObject? I know that you can call on an objects uniqueID, but that is not permanent (and changes), so it will not work.
Did you tried to write editor script called from menu which would march all your items in all scenes and assign their IDs (generating random number for example) if not assigned?
Read more:
http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$enuItem.html http://docs.unity3d.com/Documentation/ScriptReference/EditorApplication.OpenScene.html http://docs.unity3d.com/Documentation/ScriptReference/EditorApplication.SaveScene.html