UE4
[UE4][Editor] Asset 저장
TigerFish
2022. 7. 25. 11:09
글을 쓰는 목적
Asset을 저장해야하는 경우가 있었다. 에디터 툴 작업하면서 생각보다 많이 쓰는 기능이라 기억하기 위해 글을 쓴다.
작업 환경
UE4.26
Asset 저장
1. UEditorUtilityLibrary::GetSelectedAssets를 통해 선택한 에셋들을 가져온다.
2. 선택된 에셋들을 MakrPackageDirty를 통해 수정한 상태로 변경
3. FEditorFileUtils::PromptForCheckoutAndSave 를 통해 에셋 저장
TArray<UObject*> selectedAssetArray = UEditorUtilityLibrary::GetSelectedAssets();
TArray<UPackage*> packagesToSave;
for(UObject* asset : selectedAssetArray)
{
UParticle* particle = Cast<UParticle>(asset);
if(particle)
{
packagesToSave.Add(Particle);
particle->MarkPackageDirty();
}
}
FEditorFileUtils::PromptForCheckoutAndSave(packagesToSave, true, false);
참고
UEditorUtilityLibrary::GetSelectedAssets
Gets the set of currently selected assets.
docs.unrealengine.com
FEditorFileUtils::PromptForCheckoutAndSave
Optionally prompts the user for which of the provided packages should be saved, and then additionally prompts the user to check-out any of the provided packages which are under source control.
docs.unrealengine.com