godotengine / godotengine/godot-docs
Misleading documentation or Tree nodes
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 25
Description
**Your Godot version:**
3.2.3 mono
**Issue description:**
Documentation of the Tree node is misleading. The sample code tells to create a new Tree by doing `Tree.new()`, but that is not necessary in a Tree node, actually if you do it, it won't work. This works in a Tree node:
```gdscript
func _ready():
var root = create_item()
set_hide_root(true)
var child1 = create_item(root)
var child2 = create_item(root)
var subchild1 = create_item(child1)
subchild1.set_text(0, "Subchild1")
```
Then I didn't understand why you should create a Tree node with `Tree.new()` and not with the usual way of instantiating nodes. If you use `Tree.new()` from a parent container it won't work either, you still need an instantiated Tree node, and then you would add items as above, using the Tree node reference. The documentation seems all wrong to me.
Edit: I confused instantiating _nodes_ with instantiating _scenes_ in the comment above. Anyway, the sample code is still wrong to me because it assumes the Tree node is instantiated somewhere else without mentioning where, while I was assuming that the code would go in the script of the Tree node itself, since it's the Tree node documentation and not some container's.
**URL to the documentation page (if already existing):**
https://docs.godotengine.org/en/3.2/classes/class_tree.html
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.