class_editorscenepostimport.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/EditorScenePostImport.xml.
  6. .. _class_EditorScenePostImport:
  7. EditorScenePostImport
  8. =====================
  9. **Inherits:** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. Post-processes scenes after import.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 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.
  15. 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:
  16. ::
  17. tool # Needed so it runs in editor
  18. extends EditorScenePostImport
  19. # This sample changes all node names
  20. # Called right after the scene is imported and gets the root node
  21. func post_import(scene):
  22. # Change all node names to "modified_[oldnodename]"
  23. iterate(scene)
  24. return scene # Remember to return the imported scene
  25. func iterate(node):
  26. if node != null:
  27. node.name = "modified_" + node.name
  28. for child in node.get_children():
  29. iterate(child)
  30. .. rst-class:: classref-introduction-group
  31. Tutorials
  32. ---------
  33. - `#custom-script <../tutorials/assets_pipeline/importing_scenes.html#custom-script>`__ in :doc:`../tutorials/assets_pipeline/importing_scenes`
  34. .. rst-class:: classref-reftable-group
  35. Methods
  36. -------
  37. .. table::
  38. :widths: auto
  39. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`String<class_String>` | :ref:`get_source_file<class_EditorScenePostImport_method_get_source_file>` **(** **)** |const| |
  41. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`String<class_String>` | :ref:`get_source_folder<class_EditorScenePostImport_method_get_source_folder>` **(** **)** |const| |
  43. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`Object<class_Object>` | :ref:`post_import<class_EditorScenePostImport_method_post_import>` **(** :ref:`Object<class_Object>` scene **)** |virtual| |
  45. +-----------------------------+----------------------------------------------------------------------------------------------------------------------------+
  46. .. rst-class:: classref-section-separator
  47. ----
  48. .. rst-class:: classref-descriptions-group
  49. Method Descriptions
  50. -------------------
  51. .. _class_EditorScenePostImport_method_get_source_file:
  52. .. rst-class:: classref-method
  53. :ref:`String<class_String>` **get_source_file** **(** **)** |const|
  54. Returns the source file path which got imported (e.g. ``res://scene.dae``).
  55. .. rst-class:: classref-item-separator
  56. ----
  57. .. _class_EditorScenePostImport_method_get_source_folder:
  58. .. rst-class:: classref-method
  59. :ref:`String<class_String>` **get_source_folder** **(** **)** |const|
  60. Returns the resource folder the imported scene file is located in.
  61. .. rst-class:: classref-item-separator
  62. ----
  63. .. _class_EditorScenePostImport_method_post_import:
  64. .. rst-class:: classref-method
  65. :ref:`Object<class_Object>` **post_import** **(** :ref:`Object<class_Object>` scene **)** |virtual|
  66. Called after the scene was imported. This method must return the modified version of the scene.
  67. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  68. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  69. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  70. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`