37 lines
1.0 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "FishInfoConfigAsset.h"
#include "AssetRegistry/AssetRegistryModule.h"
void UFishInfoConfigAsset::PostDuplicate(bool bDuplicateForPIE)
{
Super::PostDuplicate(bDuplicateForPIE);
if (!bDuplicateForPIE)
{
int32 MaxFishID = 0;
// 获取资产注册表模块
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
// 查找所有 QuestAsset 资产
TArray<FAssetData> AssetDataList;
AssetRegistry.GetAssetsByClass(UFishInfoConfigAsset::StaticClass()->GetClassPathName(), AssetDataList, true);
// 遍历所有已存在的任务资产,找到最大的 QuestID
for (const FAssetData& AssetData : AssetDataList)
{
if (UFishInfoConfigAsset* FishAsset = Cast<UFishInfoConfigAsset>(AssetData.GetAsset()))
{
if (FishAsset->FishID > MaxFishID)
{
MaxFishID = FishAsset->FishID;
}
}
}
FishID = MaxFishID + 1;
}
}