Unity Development Tips for the three Ugui-lua component recycling

Source: Internet
Author: User

Ugui Tolua

Local test = {}

test.b = Gameobject
test.c = Gameobject:getcomponent (typeof (UnityEngine.UI.Button))

First Call UnityEngine.GameObject.Destroy (TEST.B)
If test this table is also toluaunref recycled, it is found
TEST.c This reference to the button object in C # is not released from the Objecttranslator.objectsbackmap

The object in Objecttranslator is not released, it should be the object that you refer to in Lua. The normal practice is to ensure that the references in Lua are released in a timely manner, but there are many xxx=nil of code that will be annoying if the project starts to pay attention to them. Our approach is to traverse through the basepanel.

function Basepanel:cleanvar () for    k,v in pairs (self) do        if (type (v) = = "UserData" or type (v) = = "Table") and K ~= "Gameobject" then            self[k] = nil        end    EndEnd

Closing the UI interface is called Cleanvar () in OnDestroy ()

Unity Development Tips for the three Ugui-lua component recycling

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.