0 votes

Using add_custom_type I tried to create a node with custom behavior. The problem I ran into, was that you are only able to create a custom node based on a script, but I need to create one based on a scene, that also has children nodes.
Is there any way to create a custom node based on a scene?

Godot version v3.3.2.stable.official
in Engine by (160 points)

I'm not sure if you can do that. What about an inherited scene?

1 Answer

0 votes

The only solution i can muster up is to use tool

Unfortunately the following is an estimation and has not been tested
So it may not work as intended

tool 
extends Node
class_name My_Custom_Node

func _enter_tree():
    if Engine.editor_hint:
        var packed_scene = load("custom_node")
        var custom_node = packed_scene.instance()
        self.replace_by(custom_node)
        custom_node.set_owner(get_scene())

Or you can try the plug-in way which should get you the results you expect

by (4,480 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.