EditorScenePostImport.xml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="EditorScenePostImport" inherits="Reference" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Post-processes scenes after import.
  5. </brief_description>
  6. <description>
  7. Imported scenes can be automatically modified right after import by setting their [b]Custom Script[/b] 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>$DOCS_URL/tutorials/assets_pipeline/importing_scenes.html#custom-script</link>
  27. </tutorials>
  28. <methods>
  29. <method name="get_source_file" qualifiers="const">
  30. <return type="String" />
  31. <description>
  32. Returns the source file path which got imported (e.g. [code]res://scene.dae[/code]).
  33. </description>
  34. </method>
  35. <method name="get_source_folder" qualifiers="const">
  36. <return type="String" />
  37. <description>
  38. Returns the resource folder the imported scene file is located in.
  39. </description>
  40. </method>
  41. <method name="post_import" qualifiers="virtual">
  42. <return type="Object" />
  43. <argument index="0" name="scene" type="Object" />
  44. <description>
  45. Called after the scene was imported. This method must return the modified version of the scene.
  46. </description>
  47. </method>
  48. </methods>
  49. <constants>
  50. </constants>
  51. </class>