Common Unity Bugs and How to Fix Them

This post contains affiliate links, meaning at no cost to you I earn a commission if you purchase through one of the links on this page. Read the full disclosure here.


Fix the most common issue that crop up in Unity!

InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method: {script}. Notice that DontDestroyOnLoad can only be used in play mode and, as such, cannot be part of an editor script.

This error is slightly misleading. It can occur on non-editor scripts and it doesn’t mean there’s not a solution.

Use Application.isPlaying to check if the application is running before calling DontDestroyOnLoad.

Before you go check out our top tips and favorite assets!

Leave a Comment

Your email address will not be published. Required fields are marked *