Dialogue Plugin

Is it possible to add texture support for the node editor by editing the C++ code? How easy is it?

There’s already textures used in the editor, i.e. each node is a texture. So without any more context, I guess the answer is yes.

Submitted an update for a ChatGPT integration today. It should pop up on the marketplace soon.

2 Likes

I meant attaching textures to nodes in the right menu. If I edit the “dialog node” structure, will it be possible to select a texture in the editor?

Yes, you can add a texture to a node, but to display it in the Details panel there’s an additional step involved, it’s described in the documentation (7.8 Adding More Variables to Nodes).
As for drawing it, you can look at the code that draws other icons and add the same code to draw your desired texture. It’s just a couple of lines of code using Slate.

1 Like

Thanks for the reply, I’ve been doing some more testing. It looks like it’s not memory related.

Exactly my thoughts, if there are hard references (which there are), it should be in memory. I also added some ‘Begin Play’ Nodes that reference the sound que to ensure it is loaded.

It is pretty inconsistent unfortunately and I can’t really find the culprit; it only seems to happen on the ‘first interaction’ and is inconsistent in reproduction. After the first interaction, it reliably plays every time. It exists in cooked builds and in-editor, with no errors or remarks in the output log.

Has anyone else had a similar issue? Any ideas how to debug? I use the source build of the engine if there is some clever way to see what exactly is happening

Did you try with other sounds?

Yeah I have quite a few sound ques and waves, they all behave in this way

@Subressor I just tried to reproduce the issue, but wasn’t able to. I relaunched the Editor 10 times, started a dialogue, in which the first node has a sound, and it didn’t happen.

If you want to get to the bottom of this, you could make a minimal repro project and I could check if it still doesn’t happen on my hardware. I could ask a couple of people to try on their hardware too. If it happens for some, we could send in an engine bug report. It it doesn’t happen for anyone, you can dismiss the issue, because it won’t occur for your players.

Or you could try to change some things around. Keep a weak pointer to the sound, async load it, then play it, for example. Just to see if it changes anything. Then, if you find some working solution, you just keep it.

1 Like

Thanks for trying it on your side, I’m going to keep debugging and see if I can get to the bottom of it. If I do I’ll try to make a minimal repo project for you.

It happens on the packaged build for all testers as well. It’s not game breaking, but a little annoyance

maybe you have bunch of other sounds playing and reaching max channel count? Also one shot metasounds that don’t have ‘OnFinished’ node connected ‘leak’ and can fill the limit.

Hello. I have made code changes to add UTexture2D to the nodes. It works, but only with already created dialogs (The already created dialogs allow me to select a texture for the node.). When I try to create and save a new dialog asset, I get an editor crash.


Dialogue.h

USTRUCT(BlueprintType)
struct FDialogueNode
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue Node")
	int32 id = -1;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue Node")
	bool isPlayer = false;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue Node")
	FText Text;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue Node")
	UTexture2D* TextureCard;
DialoguePluginEditorDetails.cpp

...
		const TSharedPtr<IPropertyHandle> ConditionsField = Child->GetChildHandle("Conditions");
		const TSharedPtr<IPropertyHandle> SoundField = Child->GetChildHandle("Sound");
		const TSharedPtr<IPropertyHandle> DialogueWaveField = Child->GetChildHandle("DialogueWave");

		const TSharedPtr<IPropertyHandle> TextureCardField = Child->GetChildHandle("TextureCard");		// my edit
		
		CurrentNodeCategory.AddProperty(IsPlayerField);
		CurrentNodeCategory.AddProperty(DrawCommentBubble);
		CurrentNodeCategory.AddProperty(Comment);
		CurrentNodeCategory.AddProperty(EventsField);
		CurrentNodeCategory.AddProperty(ConditionsField);		
		CurrentNodeCategory.AddProperty(SoundField);
		CurrentNodeCategory.AddProperty(DialogueWaveField);	

		CurrentNodeCategory.AddProperty(TextureCardField);		// my edit

.

Summary

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff

UnrealEditor_Engine!UE::Transaction::FPersistentObjectRef::FPersistentObjectRef() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TransactionCommon.cpp:37]
UnrealEditor_Engine!UE::Transaction::FSerializedObjectDataWriter::operator<<() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\TransactionCommon.cpp:302]
UnrealEditor_Core!FStructuredArchiveSlot::operator<<() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Private\Serialization\StructuredArchiveSlots.cpp:260]
UnrealEditor_CoreUObject!FObjectProperty::SerializeItem() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\PropertyObject.cpp:119]

UPD: I changed the code to

UTexture2D* TextureCard = nullptr;

and now the editor doesn’t crash. Strange that without nullptr it worked in already created in assets.

@CodeSpartan semi-related to the plugin, what part of it was the editor bubble and tree made on?

I would like to modify them to add another layer to the trees.

Sorry, could you rephrase that? I didn’t understand the question.

The graph is custom written in Slate.
DialogueViewportWidget.cpp is the graph. This is where all of the elements are drawn: nodes, their selection shadows, lines, splines, selection marquee, comment bubble, etc.
DialogueNodeWidget.cpp represents a single node, with icons and text inside.

Yup that was my question :slight_smile:
I want to make graphs of graphs since my dialogue trees are a bit more complex based on a lot of conditions.

It sounds complicated. I would recommend simply adding support for going into other dialogue files from nodes (implementing a kind of a stack, and once you’re out of a dialogue, you pop and come out in the original dialogue file at the exact place you entered a sub-dialogue).
All it’ll take is just a few modifications to the dialogue widget which drives the conversation, and then you can create dialogue files that are sub-dialogues of other dialogues. With any number of sub-levels. And to know exactly what is a sub-dialogue of what, keeping the same file structure in the project will let you know exactly what’s a subdialogue of what.

1 Like

Hey, thanks again for your reply. Just wanted to come full circle, finally got some time to debug the issue and actually it was a bug on my end. In my ‘play audio’ function I was referencing a replicated actor variable, but on the first spawn, the replication isn’t quick enough to reliably update so it wasn’t finding a sound to play!!

Remember your replication basics kids!

Hi there @CodeSpartan , I am migrating my project from 5.2 to 5.3, and the editor keeps on crashing. Here is an error related to what I assume is the plugin - any ideas -
[2023.11.10-20.05.07:024][ 0]LogClass: Error: FloatProperty FGptRequest::temperature is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h
[2023.11.10-20.05.07:024][ 0]LogClass: Error: IntProperty FDialogueLine::Id is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h
[2023.11.10-20.05.07:024][ 0]LogClass: Error: BoolProperty FDialogueLine::SpokenByPlayer is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h
[2023.11.10-20.05.07:024][ 0]LogClass: Error: IntProperty FDialogueLine::ParentId is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h
[2023.11.10-20.05.07:037][ 0]LogClass: Display: 4 Uninitialized script struct members found including 0 object properties
[2023.11.10-20.05.07:069][ 0]LogAutomationTest: Error: UObject.Class AttemptToFindUninitializedScriptStructMembers will be marked as failing due to errors being logged
[2023.11.10-20.05.07:069][ 0]LogAutomationTest: Error: LogClass: FloatProperty FGptRequest::temperature is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h
[2023.11.10-20.05.07:069][ 0]LogAutomationTest: Error: LogClass: IntProperty FDialogueLine::Id is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h
[2023.11.10-20.05.07:069][ 0]LogAutomationTest: Error: LogClass: BoolProperty FDialogueLine::SpokenByPlayer is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h
[2023.11.10-20.05.07:069][ 0]LogAutomationTest: Error: LogClass: IntProperty FDialogueLine::ParentId is not initialized properly. Module:DialoguePluginEditor File:Public/ChatGptApiClient.h

The final message in the crash window is this - [2023.11.10-20.05.34:111][ 0]LogWindows: Error: appError called: Assertion failed: OwningNode [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Classes\EdGraph\EdGraphPin.h] [Line: 427]
Hope it helps

Thanks. Looks like I forgot to initialize default values again. You can fix it by assigning them like so:

How exactly are you building? Just curious why you get the compiler to treat warnings as errors. They’re really just innocuous warnings.

Hi there and thank you for the reply. I am not building the project, I am just migrating from 5.2 to 5.3. It’s no rush on my end, I can wait if you plan to push this update to the plugin store page, since I am not very proficient with Unreal C++