Solve the problem that ngui Atlas resources are not released when switching scenarios

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.