add a custom scene as a new type in a plugin

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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 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 line script="" in it.
  • the script which effectifly is these 6 lines:
    extends EditorPlugin

    func _enter_tree():
	    add_custom_type("LivePlot", "Node2D", preload(""), preload("icon.svg"))

    func _exit_tree():
  • the icon.svg
  • the LivePlot.tscn and 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 (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 :slight_smile:

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

1 Like