![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Kaligule |
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:
- a
plugin.cfg
with the linescript="add_LivePlot_as_a_new_type.gd"
in it. - the
add_LivePlot_as_a_new_type.gd
script which effectifly is these 6 lines:
tool
extends EditorPlugin
func _enter_tree():
add_custom_type("LivePlot", "Node2D", preload("LivePlot.gd"), preload("icon.svg"))
func _exit_tree():
remove_custom_type("LivePlot")
- the
icon.svg
- the
LivePlot.tscn
andLivePlot.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?
I am trying to create the same things like you
Did you find a solution?
skeleton60 | 2021-05-15 18:41
I am also trying to do the same thing. Do either of you find out how to do it?
edbeeching | 2021-09-02 02:14
This has been a request for a while now, but apparently never implemented. Ability to create plugin that is based on a scene · Issue #3895 · godotengine/godot · GitHub
sirdorius | 2022-12-03 17:51