c1_lua/lua/app/common/texture_manager.lua
2023-04-03 10:59:13 +08:00

36 lines
897 B
Lua

local TextureManager = { }
function TextureManager:loadAtlas(prefabObject, atlasPath, callback)
ResourceManager:loadOriginAssetAsync(atlasPath, GConst.TYPEOF_UNITY_CLASS.BF_ATLAS, function(assetPath, asset)
if prefabObject:isDestroyed() then
ResourceManager:unload(assetPath)
return
end
callback(assetPath, asset)
end)
end
function TextureManager:unloadAtlas(atlasPath)
ResourceManager:unload(atlasPath)
end
function TextureManager:loadTextureAsync(prefabObject, texturePath, callback)
ResourceManager:loadOriginAssetAsync(texturePath, GConst.TYPEOF_UNITY_CLASS.TEXTURE_2D, function(assetPath, texture)
if prefabObject:isDestroyed() then
ResourceManager:unload(assetPath)
return
end
if callback then
callback(assetPath, texture)
end
end)
end
function TextureManager:unLoadTexture(texturePath)
ResourceManager:unload(texturePath)
end
return TextureManager