How to modify an instanced scene in GDScript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By indreamer
:warning: Old Version Published before Godot 3 was released.

Hi everyone,

In gds, whenever I instance a scene and change the texture of its child node, then save the new scene, the change doesn’t stick when I open it in the editor.
I know you can select “Editable children” in the editor, but I want to do it in the script.

In short :

onready var t_chara = preload("res://Templates/chara.xml")

func add_char():
    var new_char = t_chara.instance()
    new_char.get_node("chara/Sprite").set_texture(some_texture)
    add_child(new_char)
    new_char.set_owner(self)

func save():
    var packed = PackedScene.new()
    packed.pack(get_tree().get_current_scene())
    ResourceSaver.save("res://test.xml", packed)

When I open “test.xml” in the editor, I still have the old texture, not the some_texture I just tried to set.

Any chance you can help me ?

Thanks and cheers.

maybe its better if you show the code you are using to do that

Nuno Donato | 2017-04-11 17:45

edited, hope it’s a bit clearer

indreamer | 2017-04-11 18:15

AFAIK, there is no way to make an instanced scene as editable children enabled via script.
what are you trying to do?

volzhs | 2017-04-12 16:54

Ok, thanks.
I’m making a level editor, with several choices for characters so I just wanted to change the texture accordingly.
I’ll just work around it and change it in “ready” based on the node name or something.
Thanks anyway :slight_smile:

indreamer | 2017-04-12 20:54