KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
UGameSoundManager 클래스 참조

게임 내 모든 사운드 재생을 관리하는 중앙 사운드 관리 서브시스템입니다. 더 자세히 ...

#include <UGameSoundManager.h>

+ UGameSoundManager에 대한 상속 다이어그램 :
+ UGameSoundManager에 대한 협력 다이어그램:

Public 멤버 함수

 UGameSoundManager ()
 
 DEFINE_SUBSYSTEM_GETTER_INLINE (UGameSoundManager)
 
EGameSoundType GetCurrentBGMType () const
 
virtual void Initialize (FSubsystemCollectionBase &Collection) override
 
bool IsConversationVoicePlaying () const
 
void PlayBGM (EGameSoundType Type)
 BGM을 재생합니다.
 
UAudioComponent * PlayConversationVoice (USoundBase *Sound)
 
void PlaySound (EGameSoundType Type, FVector Location)
 
void PlaySound2D (EGameSoundType Type)
 
void StopBGM ()
 현재 재생 중인 BGM을 중지합니다.
 
void StopConversationVoice ()
 
void StopSound2D (const EGameSoundType Type)
 

Private 속성

TMap< EGameSoundType, UAudioComponent * > ActiveSounds
 
TObjectPtr< UAudioComponent > ConversationVoice
 
TObjectPtr< UAudioComponent > CurrentBGM
 
EGameSoundType CurrentBGMType
 
TObjectPtr< class USoundDataSoundAsset
 
TMap< EGameSoundType, TObjectPtr< class USoundBase > > SoundData
 

상세한 설명

게임 내 모든 사운드 재생을 관리하는 중앙 사운드 관리 서브시스템입니다.

2D 및 3D 사운드 재생, 중지 기능을 제공하며, 특히 대화 음성과 같이 단일 인스턴스만 허용되어야 하는 사운드를 별도로 제어합니다.

UGameSoundManager.h 파일의 20 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ UGameSoundManager()

UGameSoundManager::UGameSoundManager ( )

UGameSoundManager.cpp 파일의 16 번째 라인에서 정의되었습니다.

17{
18 // FComponentHelper를 사용해 생성자에서 안전하게 에셋을 로드합니다.
20 {
21 for (const auto& Pair : LoadedAsset->SoundData)
22 {
23 SoundAsset = LoadedAsset;
24 SoundData = SoundAsset->SoundData;
25
26 TSoftObjectPtr<USoundBase> SoundAssetPtr = Pair.Value;
27 if (!SoundAssetPtr.IsNull()) {
28 SoundData.Add(Pair.Key, SoundAssetPtr.LoadSynchronous());
29 }
30 }
31 }
32 else
33 {
34 // 실패 시, 에디터 실행 시 Output Log에 에러를 출력합니다.
35 UE_LOG(LogTemp, Error, TEXT("UGameSoundManager failed to load USoundData at path: %s"), SOUND_DATA_PATH);
36 }
37}
#define SOUND_DATA_PATH
TMap< EGameSoundType, TObjectPtr< class USoundBase > > SoundData
TObjectPtr< class USoundData > SoundAsset
static T * LoadAsset(const TCHAR *Path)

다음을 참조함 : FComponentHelper::LoadAsset(), SOUND_DATA_PATH, SoundAsset, SoundData.

+ 이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 함수 문서화

◆ DEFINE_SUBSYSTEM_GETTER_INLINE()

UGameSoundManager::DEFINE_SUBSYSTEM_GETTER_INLINE ( UGameSoundManager  )

◆ GetCurrentBGMType()

EGameSoundType UGameSoundManager::GetCurrentBGMType ( ) const
inline

UGameSoundManager.h 파일의 65 번째 라인에서 정의되었습니다.

65{ return CurrentBGMType;}
EGameSoundType CurrentBGMType

◆ Initialize()

void UGameSoundManager::Initialize ( FSubsystemCollectionBase &  Collection)
overridevirtual

UGameSoundManager.cpp 파일의 39 번째 라인에서 정의되었습니다.

40{
41 Super::Initialize(Collection);
42
43 // FSoftObjectPath AssetPath(SOUND_DATA_PATH);
44 // USoundData* LoadedAsset = Cast<USoundData>(StaticLoadObject(USoundData::StaticClass(), nullptr, *AssetPath.ToString()));
45 //
46 // if (LoadedAsset)
47 // {
48 // for (const auto& Pair : LoadedAsset->SoundData)
49 // {
50 // SoundAsset = LoadedAsset;
51 // SoundData = SoundAsset->SoundData;
52 //
53 // TSoftObjectPtr<USoundBase> SoundAssetPtr = Pair.Value;
54 // if (!SoundAssetPtr.IsNull())
55 // {
56 // SoundData.Add(Pair.Key, SoundAssetPtr.LoadSynchronous());
57 // }
58 // }
59 // }
60 // else
61 if (!SoundAsset)
62 {
63 UE_LOG(LogTemp, Error, TEXT("Failed to load SoundDataAsset from path"));
64 }
65}

다음을 참조함 : SoundAsset.

◆ IsConversationVoicePlaying()

bool UGameSoundManager::IsConversationVoicePlaying ( ) const

UGameSoundManager.cpp 파일의 132 번째 라인에서 정의되었습니다.

133{
134 return ConversationVoice && ConversationVoice->IsPlaying();
135}
TObjectPtr< UAudioComponent > ConversationVoice

다음을 참조함 : ConversationVoice.

◆ PlayBGM()

void UGameSoundManager::PlayBGM ( EGameSoundType  Type)

BGM을 재생합니다.

이미 같은 BGM이 재생 중이면 유지하고, 다른 BGM이면 전환합니다.

매개변수
Type재생할 BGM 타입

UGameSoundManager.cpp 파일의 137 번째 라인에서 정의되었습니다.

138{
139 // 이미 같은 BGM 타입이고, AudioComponent가 유효하며 재생 중인지 확인
140 // (레벨 전환 시 AudioComponent가 파괴되므로 IsValid 체크 필수)
141 if ( CurrentBGMType == Type &&
142 IsValid(CurrentBGM)
143 && CurrentBGM->IsPlaying())
144 {
145 return;
146 }
147
148 // 기존 BGM 중지
149 StopBGM();
150
151 // 새 BGM 재생
152 if (TObjectPtr<USoundBase>* FoundSound = SoundData.Find(Type))
153 {
154 if (*FoundSound)
155 {
156 // bPersistAcrossLevelTransition = true로 설정하여 레벨 전환에도 유지되도록 함
157 CurrentBGM = UGameplayStatics::CreateSound2D(
158 GetWorld(),
159 *FoundSound,
160 1.0f, // VolumeMultiplier
161 1.0f, // PitchMultiplier
162 0.0f, // StartTime
163 nullptr, // ConcurrencySettings
164 true, // bPersistAcrossLevelTransition - 레벨 전환에도 유지
165 false // bAutoDestroy
166 );
167
168 if (CurrentBGM)
169 {
170 CurrentBGM->Play();
171 CurrentBGMType = Type;
172 }
173 }
174 }
175}
void StopBGM()
현재 재생 중인 BGM을 중지합니다.
TObjectPtr< UAudioComponent > CurrentBGM

다음을 참조함 : CurrentBGM, CurrentBGMType, SoundData, StopBGM().

+ 이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ PlayConversationVoice()

UAudioComponent * UGameSoundManager::PlayConversationVoice ( USoundBase *  Sound)

UGameSoundManager.cpp 파일의 110 번째 라인에서 정의되었습니다.

111{
112 if (!Sound)
113 return nullptr;
114
115 // 기존 대화 음성이 재생 중이면 중지
117
118 // 새로운 대화 음성 재생
119 ConversationVoice = UGameplayStatics::SpawnSound2D(GetWorld(), Sound);
120 return ConversationVoice;
121}

다음을 참조함 : ConversationVoice, StopConversationVoice().

+ 이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ PlaySound()

void UGameSoundManager::PlaySound ( EGameSoundType  Type,
FVector  Location 
)

UGameSoundManager.cpp 파일의 67 번째 라인에서 정의되었습니다.

68{
69 if (TObjectPtr<USoundBase>* FoundSound = SoundData.Find(Type))
70 {
71 if (*FoundSound)
72 {
73 UGameplayStatics::PlaySoundAtLocation(GetWorld(), *FoundSound, Location);
74 }
75 }
76}

다음을 참조함 : SoundData.

◆ PlaySound2D()

void UGameSoundManager::PlaySound2D ( EGameSoundType  Type)

UGameSoundManager.cpp 파일의 79 번째 라인에서 정의되었습니다.

80{
81 if (TObjectPtr<USoundBase>* FoundSound = SoundData.Find(Type))
82 {
83 if (*FoundSound)
84 {
85 // 이미 재생 중인 사운드가 있다면 멈추고 제거
86 if (UAudioComponent* ExistingComp = ActiveSounds.FindRef(Type))
87 {
88 ExistingComp->Stop();
89 ActiveSounds.Remove(Type);
90 }
91
92 // 새로운 사운드 재생 및 저장
93 if (UAudioComponent* NewComp = UGameplayStatics::SpawnSound2D(GetWorld(), *FoundSound))
94 {
95 ActiveSounds.Add(Type, NewComp);
96 }
97 }
98 }
99}
TMap< EGameSoundType, UAudioComponent * > ActiveSounds

다음을 참조함 : ActiveSounds, SoundData.

◆ StopBGM()

void UGameSoundManager::StopBGM ( )

현재 재생 중인 BGM을 중지합니다.

UGameSoundManager.cpp 파일의 177 번째 라인에서 정의되었습니다.

178{
179 if (IsValid(CurrentBGM) && CurrentBGM->IsPlaying())
180 {
181 CurrentBGM->Stop();
182 }
183 CurrentBGM = nullptr;
184}

다음을 참조함 : CurrentBGM.

다음에 의해서 참조됨 : PlayBGM().

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ StopConversationVoice()

void UGameSoundManager::StopConversationVoice ( )

UGameSoundManager.cpp 파일의 123 번째 라인에서 정의되었습니다.

124{
125 if (ConversationVoice && ConversationVoice->IsPlaying())
126 {
127 ConversationVoice->Stop();
128 }
129 ConversationVoice = nullptr;
130}

다음을 참조함 : ConversationVoice.

다음에 의해서 참조됨 : PlayConversationVoice().

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ StopSound2D()

void UGameSoundManager::StopSound2D ( const EGameSoundType  Type)

UGameSoundManager.cpp 파일의 101 번째 라인에서 정의되었습니다.

102{
103 if (UAudioComponent* Comp = ActiveSounds.FindRef(Type))
104 {
105 Comp->Stop();
106 ActiveSounds.Remove(Type);
107 }
108}

다음을 참조함 : ActiveSounds.

멤버 데이터 문서화

◆ ActiveSounds

TMap<EGameSoundType, UAudioComponent*> UGameSoundManager::ActiveSounds
private

UGameSoundManager.h 파일의 75 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : PlaySound2D(), StopSound2D().

◆ ConversationVoice

TObjectPtr<UAudioComponent> UGameSoundManager::ConversationVoice
private

UGameSoundManager.h 파일의 79 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : IsConversationVoicePlaying(), PlayConversationVoice(), StopConversationVoice().

◆ CurrentBGM

TObjectPtr<UAudioComponent> UGameSoundManager::CurrentBGM
private

UGameSoundManager.h 파일의 83 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : PlayBGM(), StopBGM().

◆ CurrentBGMType

EGameSoundType UGameSoundManager::CurrentBGMType
private

UGameSoundManager.h 파일의 86 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : PlayBGM().

◆ SoundAsset

TObjectPtr<class USoundData> UGameSoundManager::SoundAsset
private

UGameSoundManager.h 파일의 69 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : UGameSoundManager(), Initialize().

◆ SoundData

TMap<EGameSoundType, TObjectPtr<class USoundBase> > UGameSoundManager::SoundData
private

UGameSoundManager.h 파일의 72 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : UGameSoundManager(), PlayBGM(), PlaySound(), PlaySound2D().


이 클래스에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.: