float USdkboxFyberListener::_setMasterVolume(float Volume) { FAudioDevice* AudioDevice = GEngine->GetMainAudioDevice(); if (!AudioDevice) return -1; float previousVolume = -1; for (auto i = AudioDevice->SoundClasses.CreateIterator(); i; ++i) { USoundClass* SoundClass = i.Key(); FString SoundClassName; // Test if the Split function works then, if the name was the right one if (SoundClass->GetFullName().Split(L".", nullptr, &SoundClassName, ESearchCase::CaseSensitive) && SoundClassName.Equals("Master")) { previousVolume = SoundClass->Properties.Volume; SoundClass->Properties.Volume = Volume; break; } } //UE_LOG(SDKBOX, Warning, TEXT("previousVolume: %.02f"), previousVolume); return previousVolume; }
void SoundManager::SetEffects(bool enable){ FAudioDevice* Device = GEngine->GetMainAudioDevice(); if (!Device) return; for (TMap<USoundClass*, FSoundClassProperties>::TIterator It(Device->SoundClasses); It; ++It){ USoundClass* SoundClass = It.Key(); if (SoundClass && SoundClass->GetFullName().Find("SFX") != INDEX_NONE){ SoundClass->Properties.Volume = enable ? 1.f : 0.f; } } }
void FSoundClassEditor::CreateSoundClass(UEdGraphPin* FromPin, const FVector2D& Location, FString Name) { // If we have a valid name if (!Name.IsEmpty()) { FName NewClassName = *Name; UPackage* Package = SoundClass->GetOutermost(); USoundClass* NewSoundClass = NewObject<USoundClass>(Package, NewClassName, RF_Public); SoundClass->SoundClassGraph->AddNewSoundClass(FromPin, NewSoundClass, Location.X, Location.Y); Package->MarkPackageDirty(); NewSoundClass->PostEditChange(); } }
void USoundClassGraph::LinkSoundClasses() { for (int32 NodeIndex = 0; NodeIndex < Nodes.Num(); NodeIndex++) { USoundClassGraphNode* Node = CastChecked<USoundClassGraphNode>(Nodes[NodeIndex]); if (!Node->CheckRepresentsSoundClass()) { Node->SoundClass->Modify(); // remove parents of existing children for (int32 ChildIndex = 0; ChildIndex < Node->SoundClass->ChildClasses.Num(); ChildIndex++) { USoundClass* ChildClass = Node->SoundClass->ChildClasses[ChildIndex]; if (ChildClass) { ChildClass->Modify(); ChildClass->ParentClass = NULL; } } Node->SoundClass->ChildClasses.Empty(); UEdGraphPin* ChildPin = Node->GetChildPin(); for (int32 ChildIndex = 0; ChildIndex < ChildPin->LinkedTo.Num(); ChildIndex++) { USoundClassGraphNode* ChildNode = CastChecked<USoundClassGraphNode>(ChildPin->LinkedTo[ChildIndex]->GetOwningNode()); Node->SoundClass->ChildClasses.Add(ChildNode->SoundClass); ChildNode->SoundClass->SetParentClass(Node->SoundClass); } Node->SoundClass->PostEditChange(); Node->SoundClass->MarkPackageDirty(); } } RootSoundClass->RefreshAllGraphs(true); }