Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

EditorScenePostImport

繼承: RefCounted < Object

匯入後對場景進行後處理。

說明

通過將自訂腳本匯入屬性設定為從此類繼承的 tool 腳本,可以在匯入後立即自動修改匯入的場景。

_post_import() 回呼接收匯入場景的根節點,並回傳場景的修改版本。

@tool # 需要它才能在編輯器中執行。
extends EditorScenePostImport

# 該範例更改所有節點名稱。
# 在匯入場景並取得根節點後立即呼叫。
func _post_import(scene):
    # 將所有節點名稱更改為 “modified_[oldnodename]”
    iterate(scene)
    return scene # 記得回傳匯入的場景

func iterate(node):
    if node != null:
        node.name = "modified_" + node.name
        for child in node.get_children():
            iterate(child)

教學

方法

Object

_post_import(scene: Node) virtual

String

get_source_file() const


方法說明

Object _post_import(scene: Node) virtual 🔗

在場景被匯入後觸發。本方法必須返回場景的修改版本。


String get_source_file() const 🔗

返回匯入的原始檔案路徑(如res://scene.dae)。