EditorScenePostImport

Inherits: Reference < Object

Post-processes scenes after import.

Description

Imported scenes can be automatically modified right after import by setting their Custom Script Import property to a tool script that inherits from this class.

The post_import callback receives the imported scene’s root node and returns the modified version of the scene. Usage example:

  1. tool # Needed so it runs in editor
  2. extends EditorScenePostImport
  3. # This sample changes all node names
  4. # Called right after the scene is imported and gets the root node
  5. func post_import(scene):
  6. # Change all node names to "modified_[oldnodename]"
  7. iterate(scene)
  8. return scene # Remember to return the imported scene
  9. func iterate(node):
  10. if node != null:
  11. node.name = "modified_" + node.name
  12. for child in node.get_children():
  13. iterate(child)

Tutorials

Methods

Stringget_source_file ( ) const
Stringget_source_folder ( ) const
Objectpost_import ( Object scene ) virtual

Method Descriptions

  • String get_source_file ( ) const

Returns the source file path which got imported (e.g. res://scene.dae).


  • String get_source_folder ( ) const

Returns the resource folder the imported scene file is located in.


Called after the scene was imported. This method must return the modified version of the scene.