I have the following in a script attached to a game object in a unity scene. When I run this scene and press 'E', I get the following logs. (The game object is destroyed too)
In destroy
After destroy
void Update () {
if(Input.GetKey(KeyCode.E)){
Debug.Log ("In destroy");
Destroy (gameObject);
Debug.Log ("After destroy");
}
}
My question is that if the game object is destroyed, then why does the execution continue to the code which logs "After destroy"?