2021-11-07 23:43:01 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Engine/Engine.h"
|
|
|
|
|
#include "MetasoundAssetBase.h"
|
|
|
|
|
#include "MetasoundAssetManager.h"
|
|
|
|
|
#include "Subsystems/EngineSubsystem.h"
|
|
|
|
|
#include "UObject/Object.h"
|
|
|
|
|
|
|
|
|
|
#include "MetasoundAssetSubsystem.generated.h"
|
|
|
|
|
|
|
|
|
|
// Forward Declarations
|
|
|
|
|
class UAssetManager;
|
|
|
|
|
class FMetasoundAssetBase;
|
|
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
struct FDirectoryPath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
USTRUCT(BlueprintType)
|
|
|
|
|
struct METASOUNDENGINE_API FMetaSoundAssetDirectory
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Directories, meta = (RelativePath, LongPackageName))
|
|
|
|
|
FDirectoryPath Directory;
|
|
|
|
|
};
|
2021-11-07 23:43:01 -05:00
|
|
|
|
|
|
|
|
/** The subsystem in charge of the MetaSound asset registry */
|
|
|
|
|
UCLASS()
|
|
|
|
|
class METASOUNDENGINE_API UMetaSoundAssetSubsystem : public UEngineSubsystem, public Metasound::Frontend::IMetaSoundAssetManager
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual void Initialize(FSubsystemCollectionBase& InCollection) override;
|
|
|
|
|
|
2021-12-01 15:59:03 -05:00
|
|
|
void AddOrUpdateAsset(const FAssetData& InAssetData);
|
|
|
|
|
void RemoveAsset(UObject& InObject);
|
|
|
|
|
void RemoveAsset(const FAssetData& InAssetData);
|
2021-11-07 23:43:01 -05:00
|
|
|
void RenameAsset(const FAssetData& InAssetData, bool bInReregisterWithFrontend = true);
|
|
|
|
|
|
2021-11-24 16:44:58 -05:00
|
|
|
virtual void AddAssetReferences(FMetasoundAssetBase& InAssetBase) override;
|
2021-12-01 15:59:03 -05:00
|
|
|
virtual void AddOrUpdateAsset(UObject& InObject) override;
|
2021-11-07 23:43:01 -05:00
|
|
|
virtual bool CanAutoUpdate(const FMetasoundFrontendClassName& InClassName) const override;
|
|
|
|
|
virtual bool ContainsKey(const Metasound::Frontend::FNodeRegistryKey& InRegistryKey) const override;
|
|
|
|
|
virtual const FSoftObjectPath* FindObjectPathFromKey(const Metasound::Frontend::FNodeRegistryKey& RegistryKey) const override;
|
|
|
|
|
virtual TSet<Metasound::Frontend::FNodeRegistryKey> GetReferencedKeys(const FMetasoundAssetBase& InAssetBase) const override;
|
|
|
|
|
virtual void RescanAutoUpdateDenyList() override;
|
|
|
|
|
virtual FMetasoundAssetBase* TryLoadAsset(const FSoftObjectPath& InObjectPath) const override;
|
|
|
|
|
virtual FMetasoundAssetBase* TryLoadAssetFromKey(const Metasound::Frontend::FNodeRegistryKey& RegistryKey) const override;
|
|
|
|
|
virtual bool TryLoadReferencedAssets(const FMetasoundAssetBase& InAssetBase, TArray<FMetasoundAssetBase*>& OutReferencedAssets) const override;
|
|
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
UFUNCTION(BlueprintCallable, Category = "MetaSounds|Registration")
|
|
|
|
|
void RegisterAssetClassesInDirectories(const TArray<FMetaSoundAssetDirectory>& Directories);
|
|
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "MetaSounds|Registration")
|
|
|
|
|
void UnregisterAssetClassesInDirectories(const TArray<FMetaSoundAssetDirectory>& Directories);
|
|
|
|
|
|
2021-11-07 23:43:01 -05:00
|
|
|
protected:
|
|
|
|
|
void PostEngineInit();
|
|
|
|
|
void PostInitAssetScan();
|
|
|
|
|
void RebuildDenyListCache(const UAssetManager& InAssetManager);
|
2021-11-18 14:37:34 -05:00
|
|
|
void SearchAndIterateDirectoryAssets(const TArray<FDirectoryPath>& InDirectories, TFunctionRef<void(const FAssetData&)> InFunction);
|
2021-11-07 23:43:01 -05:00
|
|
|
void SynchronizeAssetClassDisplayName(const FAssetData& InAssetData);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int32 AutoUpdateDenyListChangeID = INDEX_NONE;
|
|
|
|
|
TSet<FName> AutoUpdateDenyListCache;
|
|
|
|
|
TMap<Metasound::Frontend::FNodeRegistryKey, FSoftObjectPath> PathMap;
|
|
|
|
|
};
|