Prefab 异步加载

function  ui_game_hlnn:text_hlnn_waitLoadPrefabFinish(time,ppk,func,cunt)
    local ltDescr1 = LeanTween.moveLocalZ(self.transform:Find('Image').gameObject, math.random(-1,1), time)
    if ltDescr1 then
        ltDescr1:setOnComplete(System.Action(function()
            local count=cunt
            if self.hlnngame_roles[ppk] then
                func()
            else
                if count>=20 then
                    return
                end
                count=count+1
                self:text_hlnn_waitLoadPrefabFinish(0.1,ppk,func,count)
            end
        end))
    end
end
--
self.hlnngame_roles = {1}
local m_parent=self.transform:Find('roleHead')
for i=1,roomPeoplenum do
    local role=game_role_infro:new()
    GameResFactory.Instance():GetUIPrefab(ui_session_id.UI_ROLES, m_parent.transform, role,function (go)
        go.name = RInfro[9*(i-1)+1]..'copy'

        role:init(go.transform,RInfro,self.RoomProperty.state,pos_index[i],My_pos)
        role:load_role_content(i)
        go.transform.localPosition=Vector3.zero
        for key,var in pairs(self.hlnngame_roles) do
            key=go.name
            self.hlnngame_roles[go.name]=role
        end
        print('创建角色成功')
    end,nil )
end
print(self.hlnngame_roles[URole.ppk..'copy'])
if self.hlnngame_roles[URole.ppk..'copy'] then
    print('存在执行隐藏动作',URole.ppk)
    self.hlnngame_roles[URole.ppk..'copy']:count_down_times(10,1,0,0.001)
else
    self:text_hlnn_waitLoadPrefabFinish(0.1,URole.ppk..'copy',function()
        self.hlnngame_roles[URole.ppk..'copy']:count_down_times(10,1,0,0.001)
    end,1)
end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值