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 的占位符。
描述¶
在编辑器中为实例化的场景打开加载为占位符选项会导致在运行游戏时将其替换为 InstancePlaceholder。这样就可以将场景的实际加载推迟到调用 create_instance 时。这对于通过选择性加载部分场景来避免一次性加载大场景很有用。
InstancePlaceholder 不具备变换属性。因此任何子节点都会相对于 Viewport 从 (0, 0) 点开始定位,而不是在编辑器中显示的父节点。用一个具有变换属性的场景来替换占位符,将使子节点再次相对于它们的父节点进行变换。
方法¶
create_instance ( bool replace=false, PackedScene custom_scene=null ) |
|
get_instance_path ( ) const |
|
get_stored_values ( bool with_order=false ) |
方法说明¶
Node create_instance ( bool replace=false, PackedScene custom_scene=null )
调用这个方法会实际载入节点。创建的节点会被放置在场景树中该 InstancePlaceholder 的上方。出于方便的考虑,还会返回该 Node 的引用。
注意:create_instance 不是线程安全的。从线程中调用时请使用 Object.call_deferred。
String get_instance_path ( ) const
获取调用 create_instance 时默认加载的 PackedScene 资源文件的路径。不是线程安全的。如果从线程调用,请使用 Object.call_deferred。
Dictionary get_stored_values ( bool with_order=false )
返回在调用 create_instance 时会应用到节点上的属性列表。
如果 with_order
为 true
,会在字典中加入 .order
字段(注意有个前缀的点)。这个 .order
字段是属性名称 String 的 Array,指定属性的应用顺序(索引为 0 的是第一个)。