class_editorscenepostimport.rst 3.3 KB

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