티스토리 뷰
Asset Delete 를 구현했으므로 Folder Delete 또한 구현했다.
Asset Delete에 대해서 따로 포스팅한 적이 없어서 과정을 간단하게 설명하겠다.
한 폴더를 선택하고 내부의 사용하지 않는 에셋을 몽땅 지우는 과정은 다음과 같다.
- 한 폴더만 선택했는지
- 내부에 지울 에셋이 있는지 확인
- Developers 와 Collections 을 포함하고 있는 에셋이 있는지 확인
- 경로에 올바른 에셋이 있는지 확인
- 사용하지 않는 에셋이 1개 이상인지 확인 의 과정을 거친다.
void FSuperManagerModule::OnDeleteUnusedAssetButtonClicked()
{
// 1. 한 폴더만 선택했는지
if (FolderPathsSelected.Num() > 1)
{
DebugHeader::ShowMsgDialog(EAppMsgType::Ok, TEXT("You can only do this to one folder!"));
return;
}
TArray<FString> AssetsPathNames = UEditorAssetLibrary::ListAssets(FolderPathsSelected[0]);
// 2. 내부에 지울 에셋이 있는지 확인
if (AssetsPathNames.Num() == 0)
{
// NO ASSETS!
DebugHeader::ShowMsgDialog(EAppMsgType::Ok, TEXT("No Asset found under selected folder"));
return;
}
EAppReturnType::Type ConfirmResult =
DebugHeader::ShowMsgDialog( EAppMsgType::YesNo, TEXT("A Total of")
+ FString::FromInt(AssetsPathNames.Num())
+ TEXT(" found. \n Would tou like to proceed? "));
if (ConfirmResult == EAppReturnType::No) return;
TArray<FAssetData> UnusedAssetsDataArray;
for (const auto& AssetPathName : AssetsPathNames)
{
// 3. Developers 와 Collections 을 포함하고 있는 에셋이 있는지 확인
if (AssetPathName.Contains(TEXT("Developers")) || AssetPathName.Contains(TEXT("Collections")))
{
continue;
}
// 4. 경로에 에셋이 있는지 확인
if (!UEditorAssetLibrary::DoesAssetExist(AssetPathName)) continue;
TArray<FString> AssetReferencers =
UEditorAssetLibrary::FindPackageReferencersForAsset(AssetPathName);
// 5. 사용하지 않는 에셋이 1개 이상인지 확인
if (AssetReferencers.Num() == 0)
{
const FAssetData UnusedAssetData = UEditorAssetLibrary::FindAssetData(AssetPathName);
UnusedAssetsDataArray.Add(UnusedAssetData);
}
}
if (UnusedAssetsDataArray.Num() > 0)
{
ObjectTools::DeleteAssets(UnusedAssetsDataArray);
}
else
{
DebugHeader::ShowMsgDialog(EAppMsgType::Ok, TEXT("No Unused asset found under selected folder"));
}
}
코드.
2 번에서 내부에 지울 에셋이 있는지 확인하는 방법이 있다. 이를 토대로 내부에 에셋이 없는 빈 파일을 지우는 방법도 금방 구현할 수 있다!
에셋/폴더 지우기는 경로에 파일이 있는지 삭제 전에 확인하는 과정이 필수다. Redirector 이라고 함. 지우기 이전에 이 Redirector 함수를 호출해주어야 한다.
void FSuperManagerModule::FixUpRedirectors()
{
TArray<UObjectRedirector*> RedirectorsToFixArray;
// 콘텐츠 브라우저 내부 경로를 가져오려면 FAssetRegistryModule 에 접근해야함.
// 우선 모듈을 얻어온다.
FAssetRegistryModule& AssetRegistryModule =
FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
// 하단의 GetAssets 을 사용할때 필터를 사용한다.
// 여러 범주별로 필터링 되는 에셋을 만들 수 있음.
FARFilter Filter;
Filter.bRecursivePaths = true;
Filter.PackagePaths.Emplace("/Game");
Filter.ClassNames.Emplace("ObjectRedirector");
// 필터에 해당되는 에셋을 TArray 형태로 저장한다.
TArray<FAssetData> OutRedirectors;
AssetRegistryModule.Get().GetAssets(Filter, OutRedirectors);
// UObjectRedirector 는 개체이름이 다른 패키지나 그룹으로 바뀌면
// 해당 개체에 대한 외부 참조를 찾을 수 있음.
// 개체가 바뀌어서 참조를 찾으면 RedirectorsToFixArray 에 넣어줌.
for (const auto& RedirectorData : OutRedirectors)
{
if (UObjectRedirector* RedirectorToFix = Cast<UObjectRedirector>(RedirectorData.GetAsset()))
{
RedirectorsToFixArray.Add(RedirectorToFix);
}
}
// AssetTools 모듈을 호출함.
FAssetToolsModule& AssetToolsModule =
FModuleManager::LoadModuleChecked<FAssetToolsModule>(TEXT("AssetTools"));
// 호출한 모듈을 가지고 경로를 바꿔줌.
AssetToolsModule.Get().FixupReferencers(RedirectorsToFixArray);
}
주석을 세밀하게 적어둬서 이해가 금방 갈 것이다.
중간에 Developers 와 Collections 경로를 제외한 폴더만 검사하는 부분이 다음처럼 달라졌다.
__ExternalActors__ 과 __ExternalObject__ 폴더가 UE5부터 추가되었다고 한다. 이는 무었인가?
if (AssetPathName.Contains(TEXT("Developers")) ||
AssetPathName.Contains(TEXT("Collections")) ||
AssetPathName.Contains(TEXT("__ExternalActors__")) ||
AssetPathName.Contains(TEXT("__ExternalObject__")) )
{
continue;
}
결론부터 말하면 World Partition 이라는 기능이 추가되어 생긴 것이다!
World Partition 이라는 기능은 UE5에 추가되었다. 메모리 절약을 위해 레벨의 일부만 로드하려는 오픈 월드 게임을 구축하기 위한 도구이다. 이 외에도
- 대규모 환경을 위한 개선된 도구 - 개발자는 필요한 자산만 로드가능. 액터와 세셋의 인스턴싱 관리도 용이.
- 더 빠른 팀 협업 - 전체 맵을 잠글 필요제거. 여려명이 맵의 서로 다른 영역에서 동시 작업가능.
- 더 작은 프로젝트 버전 - 소스제어. 맵 전체파일이 아닌 변경된 자산만 업로드!
등의 이점이 있다.
전체 콘텐츠를 .umap 파일에 저장하는 대신 UE5는 작은 외부 .uasset 파일에 액터 데이터를 저장하는 것이다. 따라서 __ExternalActors__ 폴더안의 .uasset 파일에 저장된다. __ExternalObject__ 또한 마찬가지.
Git 주소 ->
https://github.com/InKyung-U/CustomEditor
GitHub - InKyung-U/CustomEditor
Contribute to InKyung-U/CustomEditor development by creating an account on GitHub.
github.com
아무생각 없이 올렸는데 앞으로 깃 올릴때 브런치를 따서 개발 과정도 보일 수 있게 해야겠다.
월드 파티션 참조 블로그
https://www.anchorpoint.app/blog/ue5-world-partition
UE5 World Partition
Unreal Engine 5 (shortened to UE5) introduced the World Partition feature to enhance workflows when working on large environments. In this article, we will explore why it makes sense to use World Partition. We will also compare the experience of working wi
www.anchorpoint.app
'Unreal > Custom Editor' 카테고리의 다른 글
[UE 5.1] Custom Slate Widget 02 (0) | 2023.09.12 |
---|---|
[UE 5.1] Custom Slate Widget 01 (0) | 2023.09.06 |
[UE 5.1] ContentBrowser 메뉴 추가 (0) | 2023.08.22 |
[UE 5.1]Custom Editor - Asset Remove (0) | 2023.08.18 |
[UE 5.1]Custom Editor - Asset Duplicate (0) | 2023.08.17 |
- Total
- Today
- Yesterday
- DFS
- UE5
- 탐욕법
- 누적합
- 해시
- 개인공부
- Heap
- 너비우선탐색
- 프로그래머스
- 디자인 패턴
- IMGUI
- level3
- 재귀
- Ue
- 데디케이티드
- sort
- BFS
- LV3
- 정렬
- LV2
- Unreal 5.1
- 채팅서버
- 힙
- 고득점kit
- 스택/큐
- 완전탐색
- greedy
- C++
- 고득점 Kit
- FPS
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |