Programmatically "Make Local" in GDScript Broken in 4.3-beta3

Godot Version

4.3-beta3

Question

I’ve had a hack for programmatically “Making Local” scenes that come from imported GLTF files, and it has worked in all versions of Godot 4+ until 4.3-beta3 came along.

I know it was working in 4.3-dev5.

The code (with some pseudo code) goes like this:

@tool
# ...

# attach and run this script on any packed scene that came from an imported GLTF file
func make_local_hack() -> void:

  duplicate_scene = duplicate()
  
  # MAKE LOCAL HACK
  duplicate_scene.scene_file_path = ""
  
  duplicate_scene.name = "MyDuplicatedGLTFNode"
  
  # finally, add the node to the scene
  get_parent().add_child(duplicate_scene)
  
  # set it's owner
  duplicate_scene.owner = get_tree().edited_scene_root

Full import code, with context for the project, is here:

I have been up and down the 4.3-beta3 changelog and I’m not finding anything that indicated this behaviour should have change.

Anyone have any clue what’s going on here?

I found a workaround by implementing a small delay. It’s not ideal, but it’s fixed the behaviour.

The full workflow is now this:

  1. Run GLTF import GDScript
  2. Attach a “Scene Initialization” GDScript to the packed scene
  3. Drag the GLTF file into the scene
  4. Upon initialization, put in a small delay (0.1s)
  5. Duplicate the node of the scene that was dropped in
  6. Remove init script from the duplicated node
  7. Apply the make local hack as described above

And that works.

I’d still like to understand why this change was needed in 4.3-beta3. But I may never know :slight_smile:

1 Like