// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "EdGraph/EdGraph.h" #include "MetasoundAssetBase.h" #include "MetasoundDocumentInterface.h" #include "MetasoundFrontend.h" #include "MetasoundFrontendDocument.h" #include "MetasoundFrontendTransform.h" #include "MetasoundOperatorSettings.h" #include "MetasoundRouter.h" #include "MetasoundUObjectRegistry.h" #include "Serialization/Archive.h" #include "UObject/ObjectSaveContext.h" #include "UObject/SoftObjectPath.h" #include "Metasound.generated.h" UCLASS(Abstract) class METASOUNDENGINE_API UMetasoundEditorGraphBase : public UEdGraph { GENERATED_BODY() public: virtual bool IsEditorOnly() const override { return true; } virtual bool NeedsLoadForEditorGame() const override { return false; } virtual void RegisterGraphWithFrontend() PURE_VIRTUAL(UMetasoundEditorGraphBase::RegisterGraphWithFrontend(), ) #if WITH_EDITORONLY_DATA virtual FMetasoundFrontendDocumentModifyContext& GetModifyContext() PURE_VIRTUAL(UMetasoundEditorGraphBase::GetModifyContext, static FMetasoundFrontendDocumentModifyContext InvalidModifyData; return InvalidModifyData; ) virtual const FMetasoundFrontendDocumentModifyContext& GetModifyContext() const PURE_VIRTUAL(UMetasoundEditorGraphBase::GetModifyContext, static const FMetasoundFrontendDocumentModifyContext InvalidModifyData; return InvalidModifyData; ) virtual void ClearVersionedOnLoad() PURE_VIRTUAL(UMetasoundEditorGraphBase::ClearVersionedOnLoad, ) virtual bool GetVersionedOnLoad() const PURE_VIRTUAL(UMetasoundEditorGraphBase::GetVersionedOnLoad, return false; ) virtual void SetVersionedOnLoad() PURE_VIRTUAL(UMetasoundEditorGraphBase::SetVersionedOnLoad, ) #endif // WITH_EDITORONLY_DATA int32 GetHighestMessageSeverity() const; }; namespace Metasound { // Forward declare struct FMetaSoundEngineAssetHelper; } /** * This asset type is used for Metasound assets that can only be used as nodes in other Metasound graphs. * Because of this, they contain no required inputs or outputs. */ UCLASS(hidecategories = object, BlueprintType) class METASOUNDENGINE_API UMetaSoundPatch : public UObject, public FMetasoundAssetBase, public IMetaSoundDocumentInterface { GENERATED_BODY() friend struct Metasound::FMetaSoundEngineAssetHelper; protected: UPROPERTY(EditAnywhere, Category = CustomView) FMetasoundFrontendDocument RootMetaSoundDocument; UPROPERTY() TSet ReferencedAssetClassKeys; UPROPERTY() TSet> ReferencedAssetClassObjects; UPROPERTY() TSet ReferenceAssetClassCache; #if WITH_EDITORONLY_DATA UPROPERTY() TObjectPtr Graph; #endif // WITH_EDITORONLY_DATA public: UMetaSoundPatch(const FObjectInitializer& ObjectInitializer); UPROPERTY(AssetRegistrySearchable) FGuid AssetClassID; #if WITH_EDITORONLY_DATA UPROPERTY(AssetRegistrySearchable) FString RegistryInputTypes; UPROPERTY(AssetRegistrySearchable) FString RegistryOutputTypes; UPROPERTY(AssetRegistrySearchable) int32 RegistryVersionMajor = 0; UPROPERTY(AssetRegistrySearchable) int32 RegistryVersionMinor = 0; UPROPERTY(AssetRegistrySearchable) bool bIsPreset = false; // Sets Asset Registry Metadata associated with this MetaSound virtual void SetRegistryAssetClassInfo(const Metasound::Frontend::FNodeClassInfo& InClassInfo) override; // Returns document name (for editor purposes, and avoids making document public for edit // while allowing editor to reference directly) static FName GetDocumentPropertyName() { return GET_MEMBER_NAME_CHECKED(UMetaSoundPatch, RootMetaSoundDocument); } // Name to display in editors virtual FText GetDisplayName() const override; // Returns the graph associated with this Metasound. Graph is required to be referenced on // Metasound UObject for editor serialization purposes. // @return Editor graph associated with UMetaSoundSource. virtual UEdGraph* GetGraph() override; virtual const UEdGraph* GetGraph() const override; virtual UEdGraph& GetGraphChecked() override; virtual const UEdGraph& GetGraphChecked() const override; // Sets the graph associated with this Metasound. Graph is required to be referenced on // Metasound UObject for editor serialization purposes. // @param Editor graph associated with UMetaSoundSource. virtual void SetGraph(UEdGraph* InGraph) override { Graph = CastChecked(InGraph); } #endif // #if WITH_EDITORONLY_DATA virtual const UClass& GetBaseMetaSoundUClass() const final override; virtual const FMetasoundFrontendDocument& GetDocument() const override; #if WITH_EDITOR virtual void PostDuplicate(EDuplicateMode::Type DuplicateMode) override; virtual void PostEditUndo() override; #endif // WITH_EDITOR virtual void BeginDestroy() override; virtual void PreSave(FObjectPreSaveContext InSaveContext) override; virtual void Serialize(FArchive& InArchive) override; virtual void PostLoad() override; // Returns Asset Metadata associated with this MetaSound virtual Metasound::Frontend::FNodeClassInfo GetAssetClassInfo() const override; virtual bool ConformObjectDataToInterfaces() override { return false; } virtual const TSet& GetReferencedAssetClassKeys() const override { return ReferencedAssetClassKeys; } virtual TArray GetReferencedAssets() override; virtual const TSet& GetAsyncReferencedAssetClassPaths() const override; virtual void OnAsyncReferencedAssetsLoaded(const TArray& InAsyncReferences) override; UObject* GetOwningAsset() override { return this; } const UObject* GetOwningAsset() const override { return this; } protected: #if WITH_EDITOR virtual void SetReferencedAssetClasses(TSet&& InAssetClasses) override; #endif // #if WITH_EDITOR Metasound::Frontend::FDocumentAccessPtr GetDocumentAccessPtr() override { using namespace Metasound::Frontend; // Return document using FAccessPoint to inform the TAccessPtr when the // object is no longer valid. return MakeAccessPtr(RootMetaSoundDocument.AccessPoint, RootMetaSoundDocument); } Metasound::Frontend::FConstDocumentAccessPtr GetDocumentConstAccessPtr() const override { using namespace Metasound::Frontend; // Return document using FAccessPoint to inform the TAccessPtr when the // object is no longer valid. return MakeAccessPtr(RootMetaSoundDocument.AccessPoint, RootMetaSoundDocument); } private: virtual FMetasoundFrontendDocument& GetDocument() override { return RootMetaSoundDocument; } };