Unity3d mobile-side memory optimization (Ngui aspect)

Source: Internet
Author: User

??Unity3d Engine Technology Exchange QQ Group: "21568554"

Doing 3d mobile memory has been a headache for people, the load of resources released, there are other needs to release, such as Ngui release. In fact, mainly Ngui texture and sprite release. Assuming that your script does not use the Ngui build reference, the first time after switching the scene calls

Resources.unloadunusedassets ();

Will be released.

But suppose your script is used to build the Ngui. For example, drag directly onto the object on the script. or a Find object. And so on, just to reference Ngui's build, it will be added to the memory, switching scenes will not be released . Resources.unloadunusedassets (); It will not be released, and when you end it, delete the references and you will release them.

I'm citing the idea of iOS to release it. Wrote a Dealloc method.

Write in the interaction class between your scripts

void Dealloc () {

Call the dealloc of other scripts first

Then release the script in the

For example, I add these references to an array.

for (int i = 0; i < Uispritsinscene.count; i++) {destroyimmediate (uispritsinscene[i]); Uispritsinscene[i]=null; } resources.unloadunusedassets (); System.GC.Collect (); }

Can be released. There are great advantages to the mobile side of my memory from the previous 130MB. Optimized to today's 50MB or so, is very stable.

??

Unity3d mobile-side memory optimization (Ngui aspect)

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.