EditorScenePostImport
导入后对场景进行后处理。
描述
导入的场景可以在导入后立即自动修改,方法是将其 自定义脚本 导入属性设置为继承自该类的 tool
脚本。
post_import回调接收导入场景的根节点,并返回场景的修改版本。使用示例。
tool # Needed so it runs in editor
extends EditorScenePostImport
# This sample changes all node names
# Called right after the scene is imported and gets the root node
func post_import(scene):
# Change all node names to "modified_[oldnodename]"
iterate(scene)
return scene # Remember to return the imported scene
func iterate(node):
if node != null:
node.name = "modified_" + node.name
for child in node.get_children():
iterate(child)
教程
方法
get_source_file ( ) const | |
get_source_folder ( ) const | |
post_import ( Object scene ) virtual |
方法说明
- String get_source_file ( ) const
返回导入的源文件路径(如res://scene.dae
)。
- String get_source_folder ( ) const
返回导入的场景文件所在的资源文件夹。
在场景被导入后触发。本方法必须返回场景的修改版本。