Object.Destroy vs. Object.DestroyImmediate

Hello everybody,
I want to delete a game object within the script. First I wanted to use Object.Delete(). But I was able to use the game object by using GameObject.Find(). I thought the game object is completely deleted with this.

I don’t have this problem if I use Object.DestroyImmediate(). And I think, I don’t really understand the difference.

DestroyImmediate() should only be used in editor scripts.

Are you sure you’re destroying the gameObject instead of the instance of the script?

If you want to destroy the game object you should use:

private MyClass instance;

public void DestroyInstance()
{
     Destroy(instance.gameObject);
     //Instead of this:
     //Destroy(instance);
}

Destroy() has an optional float parameter that waits for the passed amount before destroying your object.
Make sure you’re not passing any values if you want instant destruction.