게임엔진/Unreal
[Unreal] 인스턴스와 서브시스템 (Instance/SubSystem) 갖고오는 방법
ShovelingLife
2022. 5. 28. 14:57
Instance 가져오는 방법
1) Kismet/GameplayStatics.h 헤더 파일 안에 있는 UGameplayStatics 내 static 함수 사용.
UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<클래스명>();
2) UWorld 클래스 내 static 함수 사용
GetWorld()->GetGameInstance();
SubSystem 가져오는 방법
1) UGameInstance 클래스 내 static 함수 사용.
UGameInstance::GetSubsystem<클래스명>(GetWorld()->GetGameInstance());
2) UWorld 클래스 내 static 함수 사용
if (auto pWorld = GetWorld())
pWorld->GetSubsystem<클래스명>(pWorld->GetGameInstance());