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