Files
UnrealEngineUWP/Engine/Plugins/Runtime/Metasound/Source/MetasoundEngine/Public/MetasoundAssetSubsystem.h
rob gay 6d4096c2af - Reduce MetaSounds loaded on Editor startup by moving additional MetaSound loads/registration to occur when MetaSoundEditor is loaded
- Add UX to communicate on first asset editor load that MetaSounds are still loading and class picker results may be incomplete
#rb phil.popp
#jira UE-134364
#rnx
#preflight 6202b588bf28c072cbf2faeb

#ROBOMERGE-AUTHOR: rob.gay
#ROBOMERGE-SOURCE: CL 18911432 in //UE5/Release-5.0/... via CL 18919339 via CL 18920527
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v916-18915374)

[CL 18920775 by rob gay in ue5-main branch]
2022-02-09 12:52:44 -05:00

71 lines
3.0 KiB
C++

// 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;
struct FDirectoryPath;
USTRUCT(BlueprintType)
struct METASOUNDENGINE_API FMetaSoundAssetDirectory
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Directories, meta = (RelativePath, LongPackageName))
FDirectoryPath Directory;
};
/** 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;
Metasound::Frontend::FNodeRegistryKey AddOrUpdateAsset(const FAssetData& InAssetData);
void RemoveAsset(const UObject& InObject);
void RemoveAsset(const FAssetData& InAssetData);
void RenameAsset(const FAssetData& InAssetData, bool bInReregisterWithFrontend = true);
virtual void AddAssetReferences(FMetasoundAssetBase& InAssetBase) override;
virtual Metasound::Frontend::FNodeRegistryKey AddOrUpdateAsset(const UObject& InObject) override;
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;
UFUNCTION(BlueprintCallable, Category = "MetaSounds|Registration")
void RegisterAssetClassesInDirectories(const TArray<FMetaSoundAssetDirectory>& Directories);
UFUNCTION(BlueprintCallable, Category = "MetaSounds|Registration")
void UnregisterAssetClassesInDirectories(const TArray<FMetaSoundAssetDirectory>& Directories);
protected:
void PostEngineInit();
void PostInitAssetScan();
void RebuildDenyListCache(const UAssetManager& InAssetManager);
void ResetAssetClassDisplayName(const FAssetData& InAssetData);
void SearchAndIterateDirectoryAssets(const TArray<FDirectoryPath>& InDirectories, TFunctionRef<void(const FAssetData&)> InFunction);
private:
int32 AutoUpdateDenyListChangeID = INDEX_NONE;
TSet<FName> AutoUpdateDenyListCache;
TMap<Metasound::Frontend::FNodeRegistryKey, FSoftObjectPath> PathMap;
};