Create a unique ID for each gameobject ... but always it, in any case ...

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 () {


		foreach (string CheckID in _GameManager.DestroyedObjectList) {
			if (CheckID == UniqueID) {



But if at scene reload the ID changes, obviously it is not working.

You might like to do?

One solution would be to add a component to the game object whose sole purpose is to remember an ID.

public class GameID : MonoBehaviour
    public int ID;

Of course, you’d have to set the ID yourself, or create an editor utility script that goes through all GameIDs in a scene and makes sure they have a unique ID each. Obviously the latter would be more convenient but requires you to write an editor extension to deal with it.

I “semi-solved” with a custom button in inspector to generate a random id… but now i have this strange problem: