How to open an error warning windows dialog in Godot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By roma

enter image description hereHow to open an error warning in Godot? Something similar to the picture.

:bust_in_silhouette: Reply From: jgodfrey

You can do this with an AcceptDialog node. Just add one to your scene and set the properties (via the inspector or via code) to suit your needs. Here’s an example, setting a few properties in code:

func _ready():
	$AcceptDialog.window_title = "The title"
	$AcceptDialog.dialog_text = "The message you want to show"
	$AcceptDialog.get_ok().text = "Close"

Note that call to .popup_centered() will make the dialog visible. You’d call that when you want the dialog to be shown.

But I also need an icon.

roma | 2023-01-14 19:15

Ah, for that you might want to use the base WindowDialog node, which just gives you a blank, popup dialog. From there, you can add any content you need, including text, icons, buttons, …

Here’s a video that might be helpful.

jgodfrey | 2023-01-14 19:24