I created a new unity project and made new simple script below.
Once I hit play button in editor, in console window it shows “aaa” .
Means unity still found the gameobject that I told it to destroy.
I am using 2018.1.4f1.
any idea know whats happening?
and even change code to below, debug still showing “aaa”.
Destroy does not actually destroy the object but places it in a collection of object to be removed at the end of the frame (after Update).
Since your Awake and Start are in the same frame, the object is still alive.
From the doc:
Actual object destruction is always delayed until after the current Update loop, but will always be done before rendering.
if you need to destroy something then use DestroyImmediately.
I don’t need .gameObject at the end of either of those. You can also look in the hierarchy while it’s running an see if “aaa” is really there. I would think you’d get an error trying to log the name of a non-existent object