-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nodes added as children in tool scripts are not visible in the editor #40385
Comments
That is normal. You haven't set the owner variable, so they do not show up in the scene tree. You should try to set the scene root as owner, using set_owner() and get_tree().get_root(). |
@Zireael07 |
|
@volzhs ok oh that resolves this issue. |
There is very little information on how to solve this problem. I know this issue is very old but I still have the same problem today while trying to spawn new nodes from a tool script. @tool
extends Node2D
@export var points : Array[Node2D]
func _process(delta):
for index in range(points.size()):
# If the user wants to add a new point, we automatically create it for convenience
if points[index] == null:
print("Spawning node")
var node = Node2D.new()
points[index] = node
# The following never worked.
# node.set_owner(get_tree().get_root())
# node.owner = get_tree().get_root()
# node.owner = get_owner()
# node.owner = self
# node.owner = get_tree().get_edited_scene_root()
add_child(node) Sometimes I get the error
And sometimes I don't get any error but the node doesn't show in the scene inspector. |
You can't set owner before adding the node to the parent, owner must be an ancestor, see documentation The error could be improved to say this though Edit: PR for error open #79000 |
skeleton = Skeleton3D.new()
add_child(skeleton)
# skeleton.owner = self # doesn't work
skeleton.owner = self.get_parent() # works
# NOTE: set owner AFTER add_child |
Godot version:
3.2.2
OS/device including version:
Windows 10 Pro Education Nvidia geforce gtx 650 gles2
Issue description:
I have this script..
attached to this object..
but as you can see the ColorRect are not appearing in the hboxcontainer even though they are there and the script is a tool script
Steps to reproduce:
Minimal reproduction project:
Not Needed
The text was updated successfully, but these errors were encountered: