ObjectPath = {}; -- 在前面加上工程名就是这个 /TrainingCamp/Asset/Blueprint/UGCPlayerPawn.UGCPlayerPawn_C ObjectPath.ActorClassPath = { UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/UGCPlayerPawn.UGCPlayerPawn_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneObj/Start/BP_ActorStart.BP_ActorStart_C'), }; if not UE_SERVER then ObjectPath.ClientClassPath = { ------------------------------------------UI类------------------------------------------ --- UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tool/Child/WB_PlayerInfoItem.WB_PlayerInfoItem_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tool/Child/WB_SelectPartItem.WB_SelectPartItem_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tool/Child/WB_SelectPartButton.WB_SelectPartButton_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/Child/WB_AllWeapon_Type.WB_AllWeapon_Type_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/Child/WB_AllWeapon_Item.WB_AllWeapon_Item_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/Child/WB_SelectWeaponItems.WB_SelectWeaponItems_C'), }; end function ObjectPath.Init() ObjectPath.LoadClass(ObjectPath.ActorClassPath) if not UE_SERVER then ObjectPath.LoadClass(ObjectPath.ClientClassPath) end end function ObjectPath.LoadClass(InTable) for i, v in pairs(InTable) do local dot_num = string.find(v, '%.'); local val = string.sub(v, dot_num + 1, string.len(v) - 2); UE.AsyncLoadClass(v, function(TargetClass) ObjectPath[val] = TargetClass; if ObjectPath.WaitFuncs[val] then for c, d in pairs(ObjectPath.WaitFuncs[val]) do d(TargetClass); end ObjectPath.WaitFuncs[val] = nil; end end); end end ObjectPath.WaitFuncs = {}; ---@param Func fun(TargetClass:UClass) function ObjectPath.AddFunc(InClassName, Func) UGCLogSystem.Log("[ObjectPath.AddFunc] 开始添加 %s", InClassName); if ObjectPath[InClassName] then Func(ObjectPath[InClassName]); else if ObjectPath.WaitFuncs[InClassName] == nil then ObjectPath.WaitFuncs[InClassName] = {}; end table.insert(ObjectPath.WaitFuncs[InClassName], Func); UGCLogSystem.LogTree(string.format("[ObjectPath.AddFunc] ObjectPath.WaitFuncs ="), ObjectPath.WaitFuncs) end end return ObjectPath;