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

猜你喜欢

转载自blog.csdn.net/qq_40708273/article/details/81013174