class_editorscenepostimport.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.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. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Post process scenes after import
  13. Methods
  14. -------
  15. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`String<class_String>` | :ref:`get_source_file<class_EditorScenePostImport_method_get_source_file>` **(** **)** const |
  17. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`String<class_String>` | :ref:`get_source_folder<class_EditorScenePostImport_method_get_source_folder>` **(** **)** const |
  19. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Object<class_Object>` | :ref:`post_import<class_EditorScenePostImport_method_post_import>` **(** :ref:`Object<class_Object>` scene **)** virtual |
  21. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------+
  22. Description
  23. -----------
  24. 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.
  25. 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:
  26. ::
  27. tool # needed so it runs in editor
  28. extends EditorScenePostImport
  29. # This sample changes all node names
  30. # Called right after the scene is imported and gets the root node
  31. func post_import(scene):
  32. # change all node names to "modified_[oldnodename]"
  33. iterate(scene)
  34. return scene # remember to return the imported scene
  35. func iterate(node):
  36. if node != null:
  37. node.name = "modified_" + node.name
  38. for child in node.get_children():
  39. iterate(child)
  40. Tutorials
  41. ---------
  42. - `#custom-script <../getting_started/workflow/assets/importing_scenes.html#custom-script>`_ in :doc:`../getting_started/workflow/assets/importing_scenes`
  43. Method Descriptions
  44. -------------------
  45. .. _class_EditorScenePostImport_method_get_source_file:
  46. - :ref:`String<class_String>` **get_source_file** **(** **)** const
  47. Returns the source file path which got imported (e.g. ``res://scene.dae``).
  48. ----
  49. .. _class_EditorScenePostImport_method_get_source_folder:
  50. - :ref:`String<class_String>` **get_source_folder** **(** **)** const
  51. Returns the resource folder the imported scene file is located in.
  52. ----
  53. .. _class_EditorScenePostImport_method_post_import:
  54. - :ref:`Object<class_Object>` **post_import** **(** :ref:`Object<class_Object>` scene **)** virtual
  55. Gets called after the scene got imported and has to return the modified version of the scene.