EditorScenePostImport

Inherits: Reference < Object

导入后对场景进行后处理。

描述

导入的场景可以在导入后立即自动修改,方法是将其 自定义脚本 导入属性设置为继承自该类的 tool 脚本。

post_import回调接收导入场景的根节点,并返回场景的修改版本。使用示例。

  1. tool # Needed so it runs in editor
  2. extends EditorScenePostImport
  3. # This sample changes all node names
  4. # Called right after the scene is imported and gets the root node
  5. func post_import(scene):
  6. # Change all node names to "modified_[oldnodename]"
  7. iterate(scene)
  8. return scene # Remember to return the imported scene
  9. func iterate(node):
  10. if node != null:
  11. node.name = "modified_" + node.name
  12. for child in node.get_children():
  13. iterate(child)

教程

方法

String

get_source_file ( ) const

String

get_source_folder ( ) const

Object

post_import ( Object scene ) virtual

方法说明

  • String get_source_file ( ) const

返回导入的源文件路径(如res://scene.dae)。


  • String get_source_folder ( ) const

返回导入的场景文件所在的资源文件夹。


在场景被导入后触发。本方法必须返回场景的修改版本。