Create custom nodes

Godot Version 4.2.1

How do I make custom nodes in Godot 4?

I want to make custom Node3D with custom properties which need to show up in the editor and when I changes made it must replicated on the editor (not just in the game). I am now using @tool and @export for this but this feels inefficient and wrong. I have to use signals to get job done. This is some what okay because setters play main role. But If I export Array of something (Resource) and add it in inspector there’s no way (atleast I don’t know) to emit signal because there is no way to observe adding or removing item. If you guys can direct me in right path that would be very helpful. Thank you for your support.

I am not sure if there is any way of doing what you are looking for. You can create your custom nodes with GDExtension and some language such as C++ for example but I would not recommend this for your case as this requires a lot more work.

1 Like

I tested this:

extends Node

@export var array:Array[Texture2D]:
		array = value

And it prints “changed” whenever I edit the array (add, remove, or change an element) so using a signal in the setter should work too.

1 Like

usually just use class_name NewNode3d in a script, it should be reflected when you try to create new node
like this

in the script just look like this, nothing special

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.