Question by 
               pgilmorepf · Jul 19, 2016 at 09:15 PM · 
                scripting problemeditor  
              
 
              HideAndDontSave disables OnDestroy
In a recent test, we discovered that OnDestroy() was not being called for a MonoBehaviour. We're testing in-editor by toggling the play button with Debug.Log() statements.
On a hunch, I commented out one line of my MonoBehaviour:
 gameObject.hideFlags = HideFlags.HideAndDontSave;
 
               And suddenly our OnDestroy is called as expected. From my perspective, this seems like a bug in Unity.
Is there an alternate explanation?
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
The variables modified in the inspector are not kept on build 0 Answers
Custom inspector. Pick one bool from a list. 1 Answer
After Build Scripts no longer functioning in build or editor 1 Answer
Setting GameObject properties in editor when public script fields are changed 2 Answers
Parts of code only execute when there is a Debug.Log() statement in them. Why? 2 Answers