- Edited
In the 2d mainscreen (layout) the tree-items display if I generate them in _ready
I don't know quite how to puzzle this out. I've added a button to the scene and it presents and operates fine. I even use it to generate tree-items but they do not show.
I would appreciate any tips on debugging stuff like this or some documentation clarifying the rules of the road
// Editor.gd
tool extends VBoxContainer
var tree_ : Tree
var button_ : Button
func _ready():
button_ = get_node("Welcome") as Button
tree_ = get_node("HBoxContainer/Tree") as Tree
func _on_Welcome_button_down():
print("hello tree")
if tree_ == null :
print("no tree_")
else:
var root = tree_.create_item()
var child1 = tree_.create_item(root)
var child2 = tree_.create_item(root)
var subchild1 = tree_.create_item(child1)
child1.set_text(0, "Child1")
child2.set_text(0, "Child2")
subchild1.set_text(0, "Subchild1")
//plugin.gd
tool
extends EditorPlugin
const MainPanel = preload("res://addons/Editor/Editor.tscn")
var main_
func _enter_tree():
main_ = MainPanel.instance()
get_editor_interface().get_editor_viewport().add_child(main_)
make_visible(false)
func _exit_tree():
if main_:
main_.queue_free()
func _ready():
pass
func has_main_screen():
return true
func make_visible(visible):
print("make_visible")
if main_:
main_.visible = visible
func get_plugin_name():
return "MyEditor"
func get_plugin_icon():
return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons")
// editor.tscn
[gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/PsycheEditor/Editor.gd" type="Script" id=1]
[sub_resource type="Theme" id=1]
[sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 0.376471, 0.192157, 0.192157, 1 )
[node name="Editor" type="VBoxContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 92.0
margin_top = 27.0
margin_right = 92.0
margin_bottom = 27.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Welcome" type="Button" parent="."]
margin_right = 1024.0
margin_bottom = 20.0
text = "If you want to know more."
[node name="Tree" type="Tree" parent="HBoxContainer"]
margin_right = 1024.0
margin_bottom = 576.0
size_flags_horizontal = 3
size_flags_vertical = 3
theme = SubResource( 1 )
custom_styles/bg = SubResource( 2 )
allow_reselect = true
[connection signal="button_down" from="Welcome" to="." method="_on_Welcome_button_down"]