local UIPrefabObject = require "app/bf/unity/uiprefab_object" local UIPrefabManager = {} local TypeOfGameObject = GConst.TYPEOF_UNITY_CLASS.GAME_OBJECT function UIPrefabManager:loadUIWidgetAsync(path, parent, callback) ResourceManager:loadAsync(path, TypeOfGameObject, function(assetPath, prefab) if parent and parent:isDestroyed() then ResourceManager:destroyPrefab(prefab) ResourceManager:unload(assetPath) return end local prefabObject = UIPrefabObject:create() prefabObject:initWithPrefab(assetPath, prefab) prefabObject:initPrefabHelper() prefabObject:addUnloadCallback(function(obj) ResourceManager:unload(obj:getAssetPath()) end) if parent then prefabObject:setParent(parent, false) end if callback then callback(prefabObject) end end) end return UIPrefabManager