godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.09k stars 21.18k forks source link

Panel plugin does not show button child nodes. #33821

Closed wyattbiker closed 4 years ago

wyattbiker commented 4 years ago

Godot version: 3.2Beta1 OS/device including version: Mac OS X, Mojave

Issue description: Panel plugin does not show button child nodes. Screen shots below

Steps to reproduce: Create a new project ButtonDialog and add empty Control scene. Create addons folder called ButtonDialog.. Create ButtonDialog.tscn with a Panel control (name it ButtonDialog) and add 4 buttons (e.g. Add,Edit,Delete Cancel).

Add the following gd files in the addons folder.

ButtonDialog.gd

tool
extends EditorPlugin

func _enter_tree():
    # Initialization of the plugin goes here
    add_custom_type("ButtonDialog", "Panel", preload("ButtonDialogNode.gd"), preload("icon.png"))
    pass

func _exit_tree():
    # Clean-up of the plugin goes here
    remove_custom_type("ButtonDialog")
    pass

ButtonDialogNode.gd

tool
extends Panel

func _ready():
    pass

plugin.cfg

[plugin]

name="Button Dialog"
description="Button Dialog""
author="author"
version="1.0"
script="ButtonDialog.gd"

Enable the plugin in the Project. Add scene ButtonDialog using + to Control scene. Notice buttons do not show up when added as child plugin. (+) However buttons do show up when added as instance scene.

ButtonDialog.tscn image

Control.tscn image

Zylann commented 4 years ago

add_custom_type("ButtonDialog", "Panel", preload("ButtonDialogNode.gd"), preload("icon.png"))

This line means when you ask to add a ButtonDialog from the Add Node dialog, Godot will instanciate a Panel and put the ButtonDialogNode.gd on it with the specified custom icon. At no point the scene file is specified, and the script does nothing so the result is an empty panel.

I think it's not possible to specify a scene as a custom type, even if you have put a script on it, because the "add node" dialog is for adding standalone node types. You may have to either construct buttons from that script (or add a subscene), or simply use the chainlink button next to the "add node" button to quickly access scenes to instance.

wyattbiker commented 4 years ago

ok thanks will look at alternate ways.