When switching scenarios using the unity3d Editor, The ngui gallery is not released, resulting in insufficient memory and game crash.
By default, memory is released after unity3d switching, that is, resources. unloadunusedassets are called internally to release unreferenced resources.
The problem is that the ngui gallery is not released by checking the memory usage from the profiler in the editor.
Solution:
1. unloadunusedassets are valid only when the resource is not referenced, including the reference of static variables in the script. When closing any interface, we set the reference of static variables on the interface to null.
2. do not observe the memory usage in the editor. Some editor-related code references the resource so that the resource cannot be released. For example, if you open a sub-object of profab from the project directory, the profab will be loaded to the memory by the editor (if the editor does not load this object, how can the editor know which sub-objects the object has ). That is to say, we can package the game into a Windows version, and then observe the memory of the game.
3. In earlier versions of ngui, static variables may reference resources. Generally, upgrading ngui will solve these problems.
The game crash is successfully solved.
Solve the problem that ngui Atlas resources are not released when switching scenarios