Download

How can I modify FAssetData of a package?

Hello everyone!
I want to set a FAssetData flag of a package and save it in .uasset file, so I create the codes as below to do this:


UPackage* package = LoadPackage(NULL, *(AssetIt->PackageName.ToString()), LOAD_Verify | LOAD_NoWarn);
		TArray<FAssetData> AssetData;
		FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
		AssetRegistryModule.Get().GetAssetsByPackageName(AssetIt->PackageName, AssetData);
		for (FAssetData& assetdata : AssetData)
		{
			assetdata.PackageFlags |= EPackageFlags::PKG_PlayInEditor;			
		}
		package->MarkPackageDirty();

I modify the FAssetData and click “save all” button in “content browser” for serialize data to uasset, but it doesn’t work? Is there anyone can solve the problem? thanks in advanced!