EditorScenePostImport

Inherits: Reference < Object

类别: 核心

简要说明

导入后处理场景。

方法

String

get_source_file ( ) const

String

get_source_folder ( ) const

Object

post_import ( Object scene ) virtual

描述

导入的场景可以在导入后通过设置其 自定义脚本 将属性导入到 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)

方法说明

  • String get_source_file ( ) const

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

  • String get_source_folder ( ) const

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

在导入场景后调用。此方法必须返回场景的修改版本。