ObjectPath = {}; -- 在前面加上工程名就是这个 /TrainingCamp/Asset/Blueprint/UGCPlayerPawn.UGCPlayerPawn_C ObjectPath.ActorClassPath = { UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/UGCPlayerPawn.UGCPlayerPawn_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneObj/Machine/BP_Machine_Jump.BP_Machine_Jump_C'), ------------------------------------------UI类------------------------------------------ UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tool/WB_SelectPartItem.WB_SelectPartItem_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tool/WB_SelectPartButton.WB_SelectPartButton_C'), UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/SelectWeapons/Child/WB_SelectWeaponItems.WB_SelectWeaponItems_C'), }; --- 需要加载 Object 的类 ObjectPath.ActorObjectPath = { '/Game/Arts_Effect/ParticleSystems/Share/P_AH6_baozha_01.P_AH6_baozha_01', -- 爆炸特效 }; function ObjectPath.Init() for i, v in pairs(ObjectPath.ActorClassPath) 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 for i, v in pairs(ObjectPath.ActorObjectPath) do local dot_num = string.find(v, '%.'); local val = string.sub(v, dot_num + 1, string.len(v)); UE.AsyncLoadObject(v, function(TargetObject) ObjectPath[val] = TargetObject; 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;