EditorScenePostImport.xml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="EditorScenePostImport" inherits="Reference" category="Core" version="3.1">
  3. <brief_description>
  4. Post process scenes after import
  5. </brief_description>
  6. <description>
  7. Imported scenes can be automatically modified right after import by setting their [i]Custom Script[/i] Import property to a [code]tool[/code] script that inherits from this class.
  8. The [method post_import] callback receives the imported scene's root node and returns the modified version of the scene. Usage example:
  9. [codeblock]
  10. tool # needed so it runs in editor
  11. extends EditorScenePostImport
  12. # This sample changes all node names
  13. # Called right after the scene is imported and gets the root node
  14. func post_import(scene):
  15. # change all node names to "modified_[oldnodename]"
  16. iterate(scene)
  17. return scene # remember to return the imported scene
  18. func iterate(node):
  19. if node != null:
  20. node.name = "modified_" + node.name
  21. for child in node.get_children():
  22. iterate(child)
  23. [/codeblock]
  24. </description>
  25. <tutorials>
  26. <link>https://docs.godotengine.org/en/latest/getting_started/workflow/assets/importing_scenes.html#custom-script</link>
  27. </tutorials>
  28. <demos>
  29. </demos>
  30. <methods>
  31. <method name="get_source_file" qualifiers="const">
  32. <return type="String">
  33. </return>
  34. <description>
  35. Returns the source file path which got imported (e.g. [code]res://scene.dae[/code]).
  36. </description>
  37. </method>
  38. <method name="get_source_folder" qualifiers="const">
  39. <return type="String">
  40. </return>
  41. <description>
  42. Returns the resource folder the imported scene file is located in.
  43. </description>
  44. </method>
  45. <method name="post_import" qualifiers="virtual">
  46. <return type="Object">
  47. </return>
  48. <argument index="0" name="scene" type="Object">
  49. </argument>
  50. <description>
  51. Gets called after the scene got imported and has to return the modified version of the scene.
  52. </description>
  53. </method>
  54. </methods>
  55. <constants>
  56. </constants>
  57. </class>