여기서는 CheatManager에 로직을 추가
MyCheatManager.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/CheatManager.h"
#include "MyCheatManager.generated.h"
/**
*
*/
UCLASS()
class TEST_API UMyCheatManager : public UCheatManager
{
GENERATED_BODY()
public:
// 사운드웨이브 파일을 wav로 export
// inExportPath : 추출된 wav파일이 위치할 경로 프로젝트 경로 기반
// inAssetPath : 대상 사운드 웨이브 파일. /Game 경로 기반
UFUNCTION(exec)
void ExportWav(const FString& inExportPath, const FString& inAssetPath);
};
MyCheatManager.cpp
#include "MyCheatManager.h"
// exporter
#include "Exporters/Exporter.h"
#include "AssetExportTask.h"
void UMyCheatManager::ExportWav(const FString& inExportPath, const FString& inAssetPath)
{
USoundWave* soundWav = Cast<USoundWave>(StaticLoadObject(USoundWave::StaticClass(), nullptr, *inAssetPath));
if (nullptr == soundWav) {
return;
}
UExporter* exporter = UExporter::FindExporter(soundWav, TEXT("wav"));
if (nullptr == exporter) {
return;
}
// 경로는 프로젝트 내부로 설정해야함
FString tempPath = FPaths::ProjectDir() + inExportPath;
int32 result = UExporter::ExportToFile(soundWav, exporter, *tempPath, false);
if (0 == result)
{
// 실패
}
else
{
// 성공
}
}
실행
[프로젝트 경로]/sound1.wav 생성
[프로젝트 경로]/temp/sound1.wav 생성
'Unreal > 기본' 카테고리의 다른 글
[Unreal] 특정 디렉터리 파일 리스트 얻기 (0) | 2025.01.05 |
---|---|
[Unreal] SoundCue에 설정된 SoundWave 리스트 얻기 (0) | 2024.11.30 |
[Unreal] SoundCue 출력 (0) | 2024.11.30 |
[Unreal] 파이썬 사용 (0) | 2024.11.23 |
[Unreal] Json 사용법 (0) | 2024.08.23 |