c1_lua/lua/app/ui/loading/loading_cloud_ui.lua
2023-04-03 10:59:13 +08:00

42 lines
1.1 KiB
Lua

local LoadingCloudUI = class("LoadingCloudUI", BaseUI)
function LoadingCloudUI:init(parent, callback)
UIPrefabManager:loadUIWidgetAsync("assets/prefabs/ui/loading/loading_cloud_ui.prefab", parent, function(root)
self.root = root
self:showLoading(callback)
end)
end
function LoadingCloudUI:showLoading(callback)
self.root:setActive(true)
local animator = self.root:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
animator:Play("loading_cloud_close")
if self.scheduleShowId then
self:unscheduleGlobal(self.scheduleShowId)
end
if self.scheduleHideId then
self:unscheduleGlobal(self.scheduleHideId)
self.scheduleHideId = nil
end
self.scheduleShowId = self:performWithDelayGlobal(function()
self.scheduleShowId = nil
callback()
end, 0.3)
end
function LoadingCloudUI:hideLoading(callback)
local animator = self.root:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
animator:Play("loading_cloud_open")
if self.scheduleHideId then
self:unscheduleGlobal(self.scheduleHideId)
end
self.scheduleHideId = self:performWithDelayGlobal(function()
self.scheduleHideId = nil
self.root:setActive(false)
callback()
end, 0.3)
end
return LoadingCloudUI