// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "Toolkits/IToolkitHost.h" #include "Toolkits/AssetEditorToolkit.h" #include "Editor/PropertyEditor/Public/PropertyEditorDelegates.h" class IDetailsView; class SDockableTab; class UNREALED_API FSimpleAssetEditor: public FAssetEditorToolkit { public: /** Delegate that, given an array of assets, returns an array of objects to use in the details view of an FSimpleAssetEditor */ DECLARE_DELEGATE_RetVal_OneParam(TArray, FGetDetailsViewObjects, const TArray&); virtual void RegisterTabSpawners(const TSharedRef& TabManager) override; virtual void UnregisterTabSpawners(const TSharedRef& TabManager) override; /** * Edits the specified asset object * * @param Mode Asset editing mode for this editor (standalone or world-centric) * @param InitToolkitHost When Mode is WorldCentric, this is the level editor instance to spawn this editor within * @param ObjectsToEdit The object to edit * @param GetDetailsViewObjects If bound, a delegate to get the array of objects to use in the details view; uses ObjectsToEdit if not bound */ void InitEditor(const EToolkitMode::Type Mode, const TSharedPtr& InitToolkitHost, const TArray& ObjectsToEdit, FGetDetailsViewObjects GetDetailsViewObjects); /** Destructor */ virtual ~FSimpleAssetEditor(); /** IToolkit interface */ virtual FName GetToolkitFName() const override; virtual FText GetBaseToolkitName() const override; virtual FText GetToolkitName() const override; virtual FText GetToolkitToolTipText() const override; virtual FString GetWorldCentricTabPrefix() const override; virtual FLinearColor GetWorldCentricTabColorScale() const override; virtual bool IsPrimaryEditor() const override { return true; } virtual bool IsSimpleAssetEditor() const override { return true; } /** FAssetEditorToolkit interface */ virtual void PostRegenerateMenusAndToolbars() override; /** Used to show or hide certain properties */ void SetPropertyVisibilityDelegate(FIsPropertyVisible InVisibilityDelegate); /** Can be used to disable the details view making it read-only */ void SetPropertyEditingEnabledDelegate(FIsPropertyEditingEnabled InPropertyEditingDelegate); private: /** Create the properties tab and its content */ TSharedRef SpawnPropertiesTab(const FSpawnTabArgs& Args); /** Handles when an asset is imported */ void HandleAssetPostImport(class UFactory* InFactory, UObject* InObject); /** Called when objects need to be swapped out for new versions, like after a blueprint recompile. */ void OnObjectsReplaced(const TMap& ReplacementMap); /** Dockable tab for properties */ TSharedPtr PropertiesTab; /** Details view */ TSharedPtr DetailsView; /** App Identifier. Technically, all simple editors are the same app, despite editing a variety of assets. */ static const FName SimpleEditorAppIdentifier; /** The tab ids for all the tabs used */ static const FName PropertiesTabId; /** The objects open within this editor */ TArray EditingObjects; public: /** The name given to all instances of this type of editor */ static const FName ToolkitFName; static TSharedRef CreateEditor(const EToolkitMode::Type Mode, const TSharedPtr& InitToolkitHost, UObject* ObjectToEdit, FGetDetailsViewObjects GetDetailsViewObjects = FGetDetailsViewObjects()); static TSharedRef CreateEditor(const EToolkitMode::Type Mode, const TSharedPtr& InitToolkitHost, const TArray& ObjectsToEdit, FGetDetailsViewObjects GetDetailsViewObjects = FGetDetailsViewObjects()); };