Graph Editor Help

I have been following the tutorial on how to make a custom asset type, and am currently working on a dialogue editor plugin for my game. My plan was to have a graph editor with dialogue nodes, however I have ran into an issue and cannot get the graph tab to open.

void DialogueAssetEditorToolkit::InitEditor(const TArray<UObject*>& InObjects)
{
	CurDialogue = Cast<UDialogueAsset>(InObjects[0]);

	const TSharedRef<FTabManager::FLayout> Layout = FTabManager::NewLayout("DialogueAssetEditorLayout")
		->AddArea
		(
			FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
			->Split
			(
				FTabManager::NewSplitter()
				->SetSizeCoefficient(0.6f)
				->SetOrientation(Orient_Horizontal)
				->Split
				(
					FTabManager::NewStack()
					->SetSizeCoefficient(0.8f)
					->AddTab("DialogueGraph", ETabState::OpenedTab)
				)
				->Split
				(
					FTabManager::NewStack()
					->SetSizeCoefficient(0.2f)
					->AddTab("DialogueDetails", ETabState::OpenedTab)
				)
			)
		);
	FAssetEditorToolkit::InitAssetEditor(EToolkitMode::Standalone, {}, "DialogueAssetEditor", Layout, true, true, InObjects);
}
void DialogueAssetEditorToolkit::RegisterTabSpawners(const TSharedRef<class FTabManager>& DialogueTabManager)
{
	FAssetEditorToolkit::RegisterTabSpawners(DialogueTabManager);

	WorkspaceMenuCategory = DialogueTabManager->AddLocalWorkspaceMenuCategory(INVTEXT("Dialogue Asset Editor"));

		DialogueTabManager->RegisterTabSpawner("DialogueGraph", FOnSpawnTab::CreateLambda([=](const FSpawnTabArgs&)
		{
			//DGraph = CastChecked<UEdGraph>(FBlueprintEditorUtils::CreateNewGraph(DGraph, NAME_None, UEdGraph::StaticClass(), UEdGraphSchema::StaticClass()));
			return SNew(SDockTab)
				[
					//SNew(DialogueEditorMainUI).GraphToEdit(DGraph)
					SNew(SBox)
						.HAlign ( HAlign_Left )
						.VAlign ( VAlign_Bottom )
						.Padding ( 40.f )
						.WidthOverride ( 500.0f )
						.HeightOverride ( 400.0f)
						[
							SNew(DialogueEditorMainUI)
							
						]
				];
		}))
		.SetDisplayName(INVTEXT("Dialogue Graph"))
			.SetGroup(WorkspaceMenuCategory.ToSharedRef());

		FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
		FDetailsViewArgs DetailsViewArgs;
		DetailsViewArgs.NameAreaSettings = FDetailsViewArgs::HideNameArea;
		TSharedRef<IDetailsView> DetailsView = PropertyEditorModule.CreateDetailView(DetailsViewArgs);
		DetailsView->SetObjects(TArray<UObject*>{ CurDialogue });
		DialogueTabManager->RegisterTabSpawner("DialogueDetails", FOnSpawnTab::CreateLambda([=](const FSpawnTabArgs&)
			{
				return SNew(SDockTab)
					[
						DetailsView
					];
			}))
			.SetDisplayName(INVTEXT("Details"))
				.SetGroup(WorkspaceMenuCategory.ToSharedRef());
}

DialogueEditorMainUI is a class that derives from SGraphEditor. Made the class following the tutorial some what. If this can be done without making a class derived from it then im all for it. I will need a box that can scroll horizontal and vertical which seems like a graph editor would be what I need. Also if someone wants to tell me how to flag a block of code I will go back and edit

bump

use three backticks (``` )

I usually add the name of language after starting fence. Like this:

```cpp

codes

```

Thanks. Looking to see if there are any tutorials again.

  • It seemd you forget tell to your DialogueEditorMainUI what graph to use. “.GraphToEdit(DGraph)” part in below.
			return SNew(SDockTab)
				[
					//SNew(DialogueEditorMainUI).GraphToEdit(DGraph)
					SNew(SBox)
						.HAlign ( HAlign_Left )
						.VAlign ( VAlign_Bottom )
						.Padding ( 40.f )
						.WidthOverride ( 500.0f )
						.HeightOverride ( 400.0f)
						[
							SNew(DialogueEditorMainUI)
								.GraphToEdit(DGraph)//<-This is what you forgot.
						]
				];
  • Also I suggest to you that see and learn about how FArguments of the Slate(SWidget) work. You can see the SLATE_BEGIN_ARGS(SomeSlateWidgetClassName) ~ SLATE_END_ARGS(), from almost every SWidget derived classes. (Not all. Something does not have that). Here define the things can add like below, “.GraphToEdit(DGraph)”. These works in void Construct( const FArguments& InArgs );
    I’m in developing the editor tool plugin, as like you. Until I know that, I had to get similar hard times.
SNew(SomeWidgetClassName)
	.GraphToEdit(DGraph)
	.AlsoSomethingYouWantToSet(Something)

I’ll write down some more example code. There are still things I don’t know about this well, so just use as reference.


class SomeWidgetClassName : public SomeWidgetClassParent
{
	SLATE_BEGIN_ARGS(SomeWidgetClassName)
		: _SomeInitializedVar(SomeInitialValue)
		{}				
		SLATE_ARGUMENT( bool, AlsoSomethingYouWantToSet )
	SLATE_END_ARGS()

	void Construct(const FArguments& InArgs);

void SomeWidgetClassName::Construct(const FArguments& InArgs)
{
	SomeWidgetClassParent::FArguments Arg = SomeWidgetClassParent::FArguments();
	Arg.SomethingToPass(InArgs._SomethingToPass);
	SomeWidgetClassParent::Construct(Arg);	
}
  • You should use the derived class from SGraphEditor, like above that you did. You can make the your own graph editor, from scratch or from SGraphPanel or from SNodePanel. But it will very hard way, and It would not be what you want.

  • If you ask someone about problem, it would be better that tell about “What is happening now”, more clearly. For example, screenshot, error message, etc. Still I can not understand your situation well. Only that I can understand was “You can not see the something”.

  • I suggest to you that remove " Also if someone wants to tell me how to flag a block of code I will go back and edit" part from your first post. That made confusing me. I felt that is still problem of yours now :wink:

  • Good luck. I hope that I can see your successful screenshot at next time.

thanks I will take a look at it. finally found another forum post as well. I just wish they would add examples in the docs instead of dumping the methods and other things. Wont complain to much since their network subsys is so well done compared to other engines.

1 Like

Oh please. I did give those above, but you eat some delicious by alone? :wink: I want to know the link of that post, because I’m in the middle of learning this and that, too.

It would be better to lower expectations. Of course the overall quality of the documents of Epic is very good, than the other software projects. But it’s not perfect, and very slow. And, for the Slate ? - I can not continue to tell about this because it is too miserable. (Crying) I hope there is some way to contribute to enhance or add documents, but there is no way, And there is official wiki, https://unrealcommunity.wiki/ But, browsing, searching, navigating experience of this wiki is too bad.

Also I removed the code block statement prior to your comment not sure if it is still showing up or if it is gone, Either way thanks for your help.

1 Like

It’s almost nothing but I meaned this :smiley:


Ok I am still having issues, see above image. No errors to point to anything I am doing wrong. The large gray area should be a graph.

AssetEditorToolkit h

#include "CoreMinimal.h"
#include "DialogueAsset.h"
#include "Toolkits/AssetEditorToolkit.h"

/**
 * 
 */
class MHP_DIALOGUESYSTEMEDITOR_API DialogueAssetEditorToolkit : public FAssetEditorToolkit
{
public:
	void InitEditor(const TArray<UObject*>& InObjects);

	void RegisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) override;
	void UnregisterTabSpawners(const TSharedRef<class FTabManager>& TabManager) override;

	FName GetToolkitFName() const override { return "DialogueEditor"; }
	FText GetBaseToolkitName() const override { return INVTEXT("Dialogue Editor"); }
	FString GetWorldCentricTabPrefix() const override { return "Dialogue "; }
	FLinearColor GetWorldCentricTabColorScale() const override { return {}; }

protected:

private:
	//Current Dialogue asset being edited
	UDialogueAsset* CurDialogue; //This is my custom asset type that will be assigned to npc's needing a dialogue

};

Asset Editor Toolkit ++

#include "DialogueAssetEditorToolkit.h"
#include "Widgets/Docking/SDockTab.h"
#include "Kismet2/BlueprintEditorUtils.h"
#include "EdGraph/EdGraphSchema.h"
#include "DialogueEditorMainUI.h"
#include "Modules/ModuleManager.h"
#include "EdGraph/EdGraph.h"
#include "Widgets/Layout/SScrollBox.h"


void DialogueAssetEditorToolkit::InitEditor(const TArray<UObject*>& InObjects)
{
	CurDialogue = Cast<UDialogueAsset>(InObjects[0]);

	const TSharedRef<FTabManager::FLayout> Layout = FTabManager::NewLayout("DialogueAssetEditorLayout")
		->AddArea
		(
			FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
			->Split
			(
				FTabManager::NewSplitter()
				->SetSizeCoefficient(0.6f)
				->SetOrientation(Orient_Horizontal)
				->Split
				(
					FTabManager::NewStack()
					->SetSizeCoefficient(0.8f)
					->AddTab("DialogueGraph", ETabState::OpenedTab)
				)
				->Split
				(
					FTabManager::NewStack()
					->SetSizeCoefficient(0.2f)
					->AddTab("DialogueDetails", ETabState::OpenedTab)
				)
			)
		);
	FAssetEditorToolkit::InitAssetEditor(EToolkitMode::Standalone, {}, "DialogueAssetEditor", Layout, true, true, InObjects);
}

void DialogueAssetEditorToolkit::RegisterTabSpawners(const TSharedRef<class FTabManager>& DialogueTabManager)
{
	FAssetEditorToolkit::RegisterTabSpawners(DialogueTabManager);

	WorkspaceMenuCategory = DialogueTabManager->AddLocalWorkspaceMenuCategory(INVTEXT("Dialogue Asset Editor"));

		DialogueTabManager->RegisterTabSpawner("DialogueGraph", FOnSpawnTab::CreateLambda([=](const FSpawnTabArgs&)
		{
			//DGraph = CastChecked<UEdGraph>(FBlueprintEditorUtils::CreateNewGraph(DGraph, NAME_None, UEdGraph::StaticClass(), UEdGraphSchema::StaticClass()));
			return SNew(SDockTab)
				[
				//GED = SNew(SGraphEditor).GraphToEdit(DGraph)

					//SNew(SDesignerView)
					SNew(SBox)
						.HAlign ( HAlign_Left )
						.VAlign ( VAlign_Bottom )
						.Padding ( 40.f )
						.WidthOverride ( 500.0f )
						.HeightOverride ( 400.0f)
						[
							//SNew(SScrollBox)
							SNew(DialogueEditorMainUI)
						]
				];
		}))
		.SetDisplayName(INVTEXT("Dialogue Graph"))
			.SetGroup(WorkspaceMenuCategory.ToSharedRef());

		FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked<FPropertyEditorModule>("PropertyEditor");
		FDetailsViewArgs DetailsViewArgs;
		DetailsViewArgs.NameAreaSettings = FDetailsViewArgs::HideNameArea;
		TSharedRef<IDetailsView> DetailsView = PropertyEditorModule.CreateDetailView(DetailsViewArgs);
		DetailsView->SetObjects(TArray<UObject*>{ CurDialogue });
		DialogueTabManager->RegisterTabSpawner("DialogueDetails", FOnSpawnTab::CreateLambda([=](const FSpawnTabArgs&)
			{
				return SNew(SDockTab)
					[
						DetailsView
					];
			}))
			.SetDisplayName(INVTEXT("Details"))
				.SetGroup(WorkspaceMenuCategory.ToSharedRef());
}

void DialogueAssetEditorToolkit::UnregisterTabSpawners(const TSharedRef<class FTabManager>& DialogueTabManager)
{
	FAssetEditorToolkit::UnregisterTabSpawners(DialogueTabManager);
	DialogueTabManager->UnregisterTabSpawner("DialogueGraph");
	DialogueTabManager->UnregisterTabSpawner("DialogueDetails");
}

Widget.h

#include "CoreMinimal.h"
#include "GraphEditor.h"
#include "Dialogue_Graph.h"
#include "Editor.h"


/**
 * 
 */
class  MHP_DIALOGUESYSTEMEDITOR_API DialogueEditorMainUI : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS(DialogueEditorMainUI) {}
	SLATE_END_ARGS()
	void Construct(const FArguments& InArgsW);
	//void Construct();
	void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime) override;
	int32 OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const override;
	FVector2D ComputeDesiredSize(float) const override;

protected:

private:
	TSharedPtr<SGraphEditor> GEditor;
	UDialogue_Graph* DGraph;
};

Widget ++

#include "DialogueEditorMainUI.h"

void DialogueEditorMainUI::Construct(const FArguments& InArgs)
{
	DGraph = NewObject<UDialogue_Graph>(UDialogue_Graph::StaticClass());
	DGraph->Schema = UEdGraphSchema::StaticClass();
	DGraph->AddToRoot();

	GEditor = SNew(SGraphEditor).GraphToEdit(DGraph);

	ChildSlot
		[
			SNew(SVerticalBox)
				+ SVerticalBox::Slot().FillHeight(1.f)
				[
					SNew(SOverlay)
						+ SOverlay::Slot()
						[
							GEditor.ToSharedRef()
						]
				]
		];
}

void DialogueEditorMainUI::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
{
	SCompoundWidget::Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
}

int32 DialogueEditorMainUI::OnPaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{

	return LayerId;
}

FVector2D DialogueEditorMainUI::ComputeDesiredSize(float) const
{
	return FVector2D(200.0, 200.0);
}

GraphClass .h

#include "CoreMinimal.h"
#include "EdGraph/EdGraph.h"
#include "Dialogue_Graph.generated.h"

/**
 * 
 */
UCLASS()
class MHP_DIALOGUESYSTEMEDITOR_API UDialogue_Graph : public UEdGraph
{
	GENERATED_BODY()
public:
	UDialogue_Graph(const FObjectInitializer& ObjectInitializer);
	void RefreshGraph();

protected:

private:
};

Graphclass ++

#include "Dialogue_Graph.h"

UDialogue_Graph::UDialogue_Graph(const FObjectInitializer& ObjectInitializer)
{
	
}

void UDialogue_Graph::RefreshGraph()
{

}

Should I just use the list view and scrap the whole editor graph since all of the data for the dialogue will be in my custom asset type “Dialogue Asset”?