Yes, GetInstanceID is a good solution… but not for me.
GetInstanceID is regenerated at load (and reload) scene.
I nedd an always unique ID. That never changes.
I try to explain, sorry for my bad english:
If the player destroys an object (kill) in the scene, when reload that scene, that object must not exist.
To do this I created a static List to where add the IDs of objects when destroyed.
static public List<string> DestroyedObjectList = new List<string>();
When the scene is reloaded, all objects with the ID in this List, are disabled at Awake.
void Awake () {
UniqueID=GetInstanceID().ToString();
foreach (string CheckID in _GameManager.DestroyedObjectList) {
if (CheckID == UniqueID) {
gameObject.SetActive(false);
}
}
}
}
But if at scene reload the ID changes, obviously it is not working.
You might like to do?