Created
June 29, 2026 12:07
-
-
Save sinbad/b6bb477554ccf8562d2ee0049ef84d3a to your computer and use it in GitHub Desktop.
A sound asset validator for Unreal Engine 5. Place this in an Editor-only C++ module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "SoundAssetValidator.h" | |
| #include "MetasoundSource.h" | |
| #include "Sound/SoundCue.h" | |
| #include "Sound/SoundWave.h" | |
| bool USoundAssetValidator::CanValidateAsset_Implementation(const FAssetData& InAssetData, | |
| UObject* InObject, | |
| FDataValidationContext& InContext) const | |
| { | |
| UClass* AssetClass = InAssetData.GetClass(); | |
| return AssetClass == USoundWave::StaticClass() || | |
| AssetClass == USoundCue::StaticClass() || | |
| AssetClass == UMetaSoundSource::StaticClass(); | |
| } | |
| EDataValidationResult USoundAssetValidator::ValidateLoadedAsset_Implementation( | |
| const FAssetData& InAssetData, | |
| UObject* InAsset, | |
| FDataValidationContext& Context) | |
| { | |
| if (auto S = Cast<USoundBase>(InAsset)) | |
| { | |
| bool bAssetFails = false; | |
| if (!S->AttenuationSettings) | |
| { | |
| AssetFails(InAsset, INVTEXT("Missing Attenuation")); | |
| bAssetFails = true; | |
| } | |
| if (!S->SoundClassObject) | |
| { | |
| AssetFails(InAsset, INVTEXT("Missing Sound Class")); | |
| bAssetFails = true; | |
| } | |
| if (bAssetFails) | |
| { | |
| return EDataValidationResult::Invalid; | |
| } | |
| } | |
| AssetPasses(InAsset); | |
| return EDataValidationResult::Valid; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| #pragma once | |
| #include "CoreMinimal.h" | |
| #include "EditorValidatorBase.h" | |
| #include "MinerSoundAssetValidator.generated.h" | |
| /** | |
| * Can't do this in a Blueprint since attenuation settings aren't available! | |
| */ | |
| UCLASS() | |
| class YOURGAMEED_API USoundAssetValidator : public UEditorValidatorBase | |
| { | |
| GENERATED_BODY() | |
| public: | |
| virtual bool CanValidateAsset_Implementation(const FAssetData& InAssetData, | |
| UObject* InObject, | |
| FDataValidationContext& InContext) const override; | |
| virtual EDataValidationResult ValidateLoadedAsset_Implementation(const FAssetData& InAssetData, | |
| UObject* InAsset, | |
| FDataValidationContext& Context) override; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment