본문 바로가기
Unreal/기본

[Unreal] 상대/절대 경로를 /Game/ 기반의 경로로 변경

by 카피마스터 2025. 1. 5.

 

FString ConvertGameBasePath(const FString& inPath)
{
	FString absPath = FPaths::ConvertRelativePathToFull(inPath);

	// 컨텐츠 디렉터리 절대 경로
	FString contentsDir = FPaths::ProjectContentDir();
	FString absContentsDir = FPaths::ConvertRelativePathToFull(contentsDir);


	// 경로에 포함되는지 체크
	FString gameBasePath;
	if (true == absPath.StartsWith(absContentsDir))
	{
		// 컨텐츠 경로를 제거한 경로
		FString tempPath = absPath.Mid(absContentsDir.Len());
		gameBasePath = FString::Printf(TEXT("/Game/%s"), *tempPath);
	}
	
	return gameBasePath;
}