godot-proposals
godot-proposals copied to clipboard
Expose signals to GDExtension to be more similar to how they're exposed in GDScript
Describe the project you are working on
I'm working on a 3D game with heavy use of Signals to notify things about states being changed
Describe the problem or limitation you are having in your project
When connecting signals in C++, built-in nodes have to be connected using the StringName of the signal instead of the signal being part of the class itself. (I.E. childNode3D->connect("visiblity_changed",Callable(this,"do_something")) ) this is more so to prevent the ability to accidentally mispell the name of the signal
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Where applicable, use the signal class to store the reference to the class' signal
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
either
class Node3D : public Object{
private:
Signal visibility_changed{this,"visibility_changed"};
public:
Signal& get_visibility_changed_signal() const
{
return visibility_changed;
}
}
or
class Node3D : public Object{
public:
Signal visibility_changed = Signal(this,"visibility_changed");
}
though based on what's already established, the first one may be better
If this enhancement will not be used often, can it be worked around with a few lines of script?
this can be worked around with
class MyClass : public Node3D{
GDCLASS(MyClass,Node3D)
public:
Signal visibility_changed{this,"visibility_changed");
Signal child_visibility_changed;
void _ready() override
{
childNode = get_node<Node3D>(childNodePath);
if(childNode != nullptr){
child_visibility_changed = Signal(childNode,"visibility_changed");
}
}
private:
Node3D* childNode = nullptr;
NodePath childNodePath;
};
Is there a reason why this should be core and not an add-on in the asset library?
according to what was said here
https://github.com/godotengine/godot-cpp/issues/1523
this would have to be part of the engine as it's due to how signals are exposed from the engine.