123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- /*******************************************************************************
- The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
- Technology released in source code form as part of the game integration package.
- The content of this file may not be used without valid licenses to the
- AUDIOKINETIC Wwise Technology.
- Note that the use of the game engine is subject to the Unreal(R) Engine End User
- License Agreement at https://www.unrealengine.com/en-US/eula/unreal
-
- License Usage
-
- Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
- this file in accordance with the end user license agreement provided with the
- software or, alternatively, in accordance with the terms contained
- in a written agreement between you and Audiokinetic Inc.
- Copyright (c) 2023 Audiokinetic Inc.
- *******************************************************************************/
- #include "AkUnrealAssetDataHelper.h"
- #include "AssetRegistry/AssetData.h"
- #include "AkAudioEvent.h"
- #include "AkAuxBus.h"
- #include "AkEffectShareSet.h"
- #include "AkGroupValue.h"
- #include "AkSettings.h"
- #include "AkStateValue.h"
- #include "AkSwitchValue.h"
- #include "AkTrigger.h"
- #include "IAudiokineticTools.h"
- #include "PackageTools.h"
- #include "Wwise/Metadata/WwiseMetadataStateGroup.h"
- #include "Wwise/Metadata/WwiseMetadataSwitchGroup.h"
- #include "Wwise/Ref/WwiseAnyRef.h"
- #include "Wwise/Ref/WwiseRefType.h"
- namespace AkUnrealAssetDataHelper
- {
- bool IsSameType(const FAssetData& AssetData, EWwiseItemType::Type ItemType)
- {
- return GetUClassName(ItemType) == GetAssetClassName(AssetData);
- }
- FName GetUClassName(EWwiseItemType::Type ItemType)
- {
- UClass* Class = nullptr;
- switch (ItemType)
- {
- case EWwiseItemType::Event:
- Class = UAkAudioEvent::StaticClass();
- break;
- case EWwiseItemType::AuxBus:
- Class = UAkAuxBus::StaticClass();
- break;
- case EWwiseItemType::AcousticTexture:
- Class = UAkAcousticTexture::StaticClass();
- break;
- case EWwiseItemType::State:
- Class = UAkStateValue::StaticClass();
- break;
- case EWwiseItemType::Switch:
- Class = UAkSwitchValue::StaticClass();
- break;
- case EWwiseItemType::GameParameter:
- Class = UAkRtpc::StaticClass();
- break;
- case EWwiseItemType::Trigger:
- Class = UAkTrigger::StaticClass();
- break;
- case EWwiseItemType::EffectShareSet:
- Class = UAkEffectShareSet::StaticClass();
- break;
- }
- if (Class)
- {
- #if UE_5_1_OR_LATER
- return Class->GetClassPathName().GetAssetName();
- #else
- return Class->GetFName();
- #endif
- }
- return FName();
- }
- FName GetAssetClassName(const FAssetData& AssetData)
- {
- #if UE_5_1_OR_LATER
- return AssetData.AssetClassPath.GetAssetName();
- #else
- return AssetData.AssetClass;
- #endif
- }
- bool IsAssetAkAudioType(const FAssetData& AssetData)
- {
- auto Value = AssetData.TagsAndValues.FindTag(FName("WwiseGuid"));
- return Value.IsSet();
- }
- bool IsAssetTransient(const FAssetData& AssetData)
- {
- return AssetData.PackagePath.ToString() == UPackageTools::SanitizePackageName(GetTransientPackage()->GetPathName());
- }
- void SetAssetClassName(FAssetData& AssetData, UClass* Class)
- {
- #if UE_5_1_OR_LATER
- AssetData.AssetClassPath = Class->GetClassPathName();
- #else
- AssetData.AssetClass = Class->GetFName();
- #endif
- }
- FString GetAssetDefaultPackagePath(const FAssetData& AssetData)
- {
- if (auto AkAudioAsset = Cast<UAkAudioType>(AssetData.GetAsset()))
- {
- return AkAudioAsset->GetAssetDefaultPackagePath().ToString();
- }
- return {};
- }
- FString GetAssetDefaultPackagePath(const FWwiseAnyRef* WwiseRef)
- {
- auto AkSettings = GetMutableDefault<UAkSettings>();
- if (!AkSettings)
- {
- UE_LOG(LogAudiokineticTools, Error, TEXT("Could not fetch AkSettings"));
- return {};
- }
- auto WwiseRefType = WwiseRef->GetType();
- const FString DefaultPath = AkSettings->DefaultAssetCreationPath;
- switch (WwiseRefType)
- {
- case EWwiseRefType::AcousticTexture:
- return DefaultPath / "VirtualAcoustics";
- case EWwiseRefType::AuxBus:
- return DefaultPath / "AuxBusses/";
- case EWwiseRefType::Event:
- return DefaultPath / "Events/";
- case EWwiseRefType::GameParameter:
- return DefaultPath / "GameParameters/";
- case EWwiseRefType::PluginShareSet:
- return DefaultPath / "Sharesets/";
- case EWwiseRefType::Switch:
- {
- FString GroupName = WwiseRef->GetSwitchGroup()->Name.ToString();
- return DefaultPath / "Switches/" / GroupName;
- }
- case EWwiseRefType::State:
- {
- FString GroupName = WwiseRef->GetStateGroup()->Name.ToString();
- return DefaultPath / "States/" / GroupName;
- }
- case EWwiseRefType::Trigger:
- return DefaultPath / "Triggers/";
- default:
- return {};
- }
- }
- FName GetAssetDefaultName(const FAssetData& AssetData)
- {
- if (auto AkAudioAsset = Cast<UAkAudioType>(AssetData.GetAsset()))
- {
- return AkAudioAsset->GetAssetDefaultName();
- }
- return {};
- }
- FName GetAssetDefaultName(const FWwiseAnyRef* WwiseRef)
- {
- EWwiseRefType WwiseRefType = WwiseRef->GetType();
- FName WwiseName = WwiseRef->GetName();
- FNameBuilder DefaultName;
- switch (WwiseRefType)
- {
- case EWwiseRefType::AcousticTexture:
- case EWwiseRefType::AuxBus:
- case EWwiseRefType::Event:
- case EWwiseRefType::GameParameter:
- case EWwiseRefType::PluginShareSet:
- case EWwiseRefType::Trigger:
- return WwiseName;
- case EWwiseRefType::Switch:
- {
- FString GroupName = WwiseRef->GetSwitchGroup()->Name.ToString();
- DefaultName << GroupName << TEXT("-") << WwiseName;
- #if UE_5_0_OR_LATER
- return FName(DefaultName.ToView());
- #else
- return FName(DefaultName.ToString());
- #endif
- }
- case EWwiseRefType::State:
- {
- FString GroupName = WwiseRef->GetStateGroup()->Name.ToString();
- DefaultName << GroupName << TEXT("-") << WwiseName;
- #if UE_5_0_OR_LATER
- return FName(DefaultName.ToView());
- #else
- return FName(DefaultName.ToString());
- #endif
- }
- default:
- return {};
- }
- }
- }
|