class_editorscenepostimport.rst 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the EditorScenePostImport.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_EditorScenePostImport:
  6. EditorScenePostImport
  7. =====================
  8. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. Post-processes scenes after import.
  10. Description
  11. -----------
  12. 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.
  13. The :ref:`post_import<class_EditorScenePostImport_method_post_import>` callback receives the imported scene's root node and returns the modified version of the scene. Usage example:
  14. ::
  15. tool # Needed so it runs in editor
  16. extends EditorScenePostImport
  17. # This sample changes all node names
  18. # Called right after the scene is imported and gets the root node
  19. func post_import(scene):
  20. # Change all node names to "modified_[oldnodename]"
  21. iterate(scene)
  22. return scene # Remember to return the imported scene
  23. func iterate(node):
  24. if node != null:
  25. node.name = "modified_" + node.name
  26. for child in node.get_children():
  27. iterate(child)
  28. Tutorials
  29. ---------
  30. - `#custom-script <../tutorials/assets_pipeline/importing_scenes.html#custom-script>`_ in :doc:`../tutorials/assets_pipeline/importing_scenes`
  31. Methods
  32. -------
  33. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`String<class_String>` | :ref:`get_source_file<class_EditorScenePostImport_method_get_source_file>` **(** **)** |const| |
  35. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`String<class_String>` | :ref:`get_source_folder<class_EditorScenePostImport_method_get_source_folder>` **(** **)** |const| |
  37. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Object<class_Object>` | :ref:`post_import<class_EditorScenePostImport_method_post_import>` **(** :ref:`Object<class_Object>` scene **)** |virtual| |
  39. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  40. Method Descriptions
  41. -------------------
  42. .. _class_EditorScenePostImport_method_get_source_file:
  43. - :ref:`String<class_String>` **get_source_file** **(** **)** |const|
  44. Returns the source file path which got imported (e.g. ``res://scene.dae``).
  45. ----
  46. .. _class_EditorScenePostImport_method_get_source_folder:
  47. - :ref:`String<class_String>` **get_source_folder** **(** **)** |const|
  48. Returns the resource folder the imported scene file is located in.
  49. ----
  50. .. _class_EditorScenePostImport_method_post_import:
  51. - :ref:`Object<class_Object>` **post_import** **(** :ref:`Object<class_Object>` scene **)** |virtual|
  52. Called after the scene was imported. This method must return the modified version of the scene.
  53. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  54. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  55. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`