+1 vote

I attached the script below to a Spatial node. When I run it (checking the 'runScript' box), it adds the node to 'myGroup' and prints 'yes'. But nothing appears in the editor. How can I make it visible in the editor? Thanks for your help.

extends Spatial

export(bool) var runScript = false setget onChecked

func _ready():

func onChecked(checked):
    if checked:
        runScript = false
        if self.is_in_group('myGroup'):
in Engine by (18 points)
recategorized by

script reformatted for better reading

OK, what did you actually want to happen? The program worked fine didn't it. It became part of the group and that's what you wanted right? Correct me if I am wrong.

Thank you for your answer. The node has been attached to the group but I cannot see it in the editor. What I would like to do is to save my scene with the node attached to the group. My final goal is to use this kind of tool in a large scene to automaticaly attach nodes to groups without doing this manualy and save the result. How would you do that?

I see. But actually you cannot save the scene after attaching nodes to the groups in the script. What happens in the script happens within the game and will NOT result in any change in the editor. Hope that clarifies your misunderstanding.
As far as I know, you have to do this stuff manually. Correct me if I am wrong.

I already create nodes, add or remove child and rename nodes using a script tool. I only need to apply setowner(gettree().geteditedscene_root()) to each created/modified node and everythings appears correctly in the editor and I can save the modified scene. But it does not work for groups and I don't understand why. Do you have any idea or suggestion ?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.