I would like to write a plugin for Godot, which adds a new type.
I already wrote this type in a scene called
LivePlot.tscn. It is a simple scene with multiple subnodes and a script
LivePlot.gd attached to the root node. I then looked into how to write plugins. I followed the official tutorial for a plugin which adds a custom node (this seemed to be very similar to what I want).
My settup in
res://addons/LivePlot/ is now as follows:
plugin.cfg with the line
script="add_LivePlot_as_a_new_type.gd" in it.
add_LivePlot_as_a_new_type.gd script which effectifly is these 6 lines:
add_custom_type("LivePlot", "Node2D", preload("LivePlot.gd"), preload("icon.svg"))
LivePlot.gd. The later has a function
_enter_tree(): pass which does nothing, but without it nothing seems to work at all.
After enabling the plugin I can now add a new node, but it is just a node which doesn't have the scene
LivePlot.tscn attached to it, only the script. This is not suprising, I never told the plugin about the scene file. But how can I do that?
The official tutorial doesn't mention how to add a scene. I also don't want the user to have access to the internal script
LivePlot.gd (the user shouldn't have to bother with that, if they want they can check the source).
How can I add a custom scene as a new type in a plugin?