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.
Checking the stable version of the documentation...
InstancePlaceholder
PackedScene 根 Node 的預留位置。
說明
Turning on the option Load As Placeholder for an instantiated scene in the editor causes it to be replaced by an InstancePlaceholder when running the game, this will not replace the node in the editor. This makes it possible to delay actually loading the scene until calling create_instance(). This is useful to avoid loading large scenes all at once by loading parts of it selectively.
Note: Like Node, InstancePlaceholder does not have a transform. This causes any child nodes to be positioned relatively to the Viewport origin, rather than their parent as displayed in the editor. Replacing the placeholder with a scene with a transform will transform children relatively to their parent again.
方法
create_instance(replace: bool = false, custom_scene: PackedScene = null) |
|
get_instance_path() const |
|
get_stored_values(with_order: bool = false) |
方法說明
Node create_instance(replace: bool = false, custom_scene: PackedScene = null) 🔗
呼叫這個方法會實際載入節點。建立的節點會被放置在場景樹中該 InstancePlaceholder 的上方。出於方便的考慮,還會返回該 Node 的引用。
注意:create_instance() 不是執行緒安全的。從執行緒中呼叫時請使用 Object.call_deferred()。
String get_instance_path() const 🔗
獲取呼叫 create_instance() 時預設載入的 PackedScene 資源檔的路徑。不是執行緒安全的。如果從執行緒呼叫,請使用 Object.call_deferred()。
Dictionary get_stored_values(with_order: bool = false) 🔗
返回在呼叫 create_instance() 時會套用到節點上的屬性列表。
如果 with_order 為 true,會在字典中加入 .order 欄位(注意有個前綴的點)。這個 .order 欄位是屬性名稱 String 的 Array,指定屬性的套用順序(索引為 0 的是第一個)。