[−][src]Struct gdnative::prelude::SceneTree
core class SceneTree
inherits MainLoop
(unsafe).
Official documentation
See the documentation of this class in the Godot engine's official documentation.
Memory management
Non reference counted objects such as the ones of this type are usually owned by the engine.
SceneTree
is a reference-only type. Persistent references can
only exist in the unsafe Ref<SceneTree>
form.
In the cases where Rust code owns an object of this type, for example if the object was just
created on the Rust side and not passed to the engine yet, ownership should be either given
to the engine or the object must be manually destroyed using Ref::free
, or Ref::queue_free
if it is a Node
.
Class hierarchy
SceneTree inherits methods from:
Safety
All types in the Godot API have "interior mutability" in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Implementations
impl SceneTree
[src]
Constants
pub const GROUP_CALL_DEFAULT: i64
[src]
pub const GROUP_CALL_REALTIME: i64
[src]
pub const GROUP_CALL_REVERSE: i64
[src]
pub const GROUP_CALL_UNIQUE: i64
[src]
pub const STRETCH_ASPECT_EXPAND: i64
[src]
pub const STRETCH_ASPECT_IGNORE: i64
[src]
pub const STRETCH_ASPECT_KEEP: i64
[src]
pub const STRETCH_ASPECT_KEEP_HEIGHT: i64
[src]
pub const STRETCH_ASPECT_KEEP_WIDTH: i64
[src]
pub const STRETCH_MODE_2D: i64
[src]
pub const STRETCH_MODE_DISABLED: i64
[src]
pub const STRETCH_MODE_VIEWPORT: i64
[src]
impl SceneTree
[src]
pub fn new() -> Ref<SceneTree, Unique>
[src]
Creates a new instance of this object.
Because this type is not reference counted, the lifetime of the returned object is not automatically managed.
Immediately after creation, the object is owned by the caller, and can be
passed to the engine (in which case the engine will be responsible for
destroying the object) or destroyed manually using Ref::free
, or preferably
Ref::queue_free
if it is a Node
.
pub fn call_group(
&self,
group: impl Into<GodotString>,
method: impl Into<GodotString>,
varargs: &[Variant]
) -> Variant
[src]
&self,
group: impl Into<GodotString>,
method: impl Into<GodotString>,
varargs: &[Variant]
) -> Variant
Calls [code]method[/code] on each member of the given group.
pub fn call_group_flags(
&self,
flags: i64,
group: impl Into<GodotString>,
method: impl Into<GodotString>,
varargs: &[Variant]
) -> Variant
[src]
&self,
flags: i64,
group: impl Into<GodotString>,
method: impl Into<GodotString>,
varargs: &[Variant]
) -> Variant
Calls [code]method[/code] on each member of the given group, respecting the given [enum GroupCallFlags].
pub fn change_scene(
&self,
path: impl Into<GodotString>
) -> Result<(), GodotError>
[src]
&self,
path: impl Into<GodotString>
) -> Result<(), GodotError>
Changes the running scene to the one at the given [code]path[/code], after loading it into a [PackedScene] and creating a new instance.
Returns [constant OK] on success, [constant ERR_CANT_OPEN] if the [code]path[/code] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if that scene cannot be instantiated.
pub fn change_scene_to(
&self,
packed_scene: impl AsArg<PackedScene>
) -> Result<(), GodotError>
[src]
&self,
packed_scene: impl AsArg<PackedScene>
) -> Result<(), GodotError>
Changes the running scene to a new instance of the given [PackedScene].
Returns [constant OK] on success or [constant ERR_CANT_CREATE] if the scene cannot be instantiated.
pub fn create_timer(
&self,
time_sec: f64,
pause_mode_process: bool
) -> Option<Ref<SceneTreeTimer, Shared>>
[src]
&self,
time_sec: f64,
pause_mode_process: bool
) -> Option<Ref<SceneTreeTimer, Shared>>
Returns a [SceneTreeTimer] which will [signal SceneTreeTimer.timeout] after the given time in seconds elapsed in this [SceneTree]. If [code]pause_mode_process[/code] is set to [code]false[/code], pausing the [SceneTree] will also pause the timer.
Commonly used to create a one-shot delay timer as in the following example:
[codeblock]
func some_function():
print("start")
yield(get_tree().create_timer(1.0), "timeout")
print("end")
[/codeblock]
Default Arguments
pause_mode_process
-true
pub fn current_scene(&self) -> Option<Ref<Node, Shared>>
[src]
The current scene.
pub fn edited_scene_root(&self) -> Option<Ref<Node, Shared>>
[src]
The root of the edited scene.
pub fn get_frame(&self) -> i64
[src]
Returns the current frame number, i.e. the total frame count since the application started.
pub fn multiplayer(&self) -> Option<Ref<MultiplayerAPI, Shared>>
[src]
The default [MultiplayerAPI] instance for this [SceneTree].
pub fn get_network_connected_peers(&self) -> TypedArray<i32>
[src]
Returns the peer IDs of all connected peers of this [SceneTree]'s [member network_peer].
pub fn network_peer(&self) -> Option<Ref<NetworkedMultiplayerPeer, Shared>>
[src]
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the [SceneTree] will become a network server (check with [method is_network_server]) and will set the root node's network mode to master, or it will become a regular peer with the root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to [SceneTree]'s signals.
pub fn get_network_unique_id(&self) -> i64
[src]
Returns the unique peer ID of this [SceneTree]'s [member network_peer].
pub fn get_node_count(&self) -> i64
[src]
Returns the number of nodes in this [SceneTree].
pub fn get_nodes_in_group(
&self,
group: impl Into<GodotString>
) -> VariantArray<Shared>
[src]
&self,
group: impl Into<GodotString>
) -> VariantArray<Shared>
Returns a list of all nodes assigned to the given group.
pub fn root(&self) -> Option<Ref<Viewport, Shared>>
[src]
The [SceneTree]'s root [Viewport].
pub fn get_rpc_sender_id(&self) -> i64
[src]
Returns the sender's peer ID for the most recently received RPC call.
pub fn has_group(&self, name: impl Into<GodotString>) -> bool
[src]
Returns [code]true[/code] if the given group exists.
pub fn has_network_peer(&self) -> bool
[src]
Returns [code]true[/code] if there is a [member network_peer] set.
pub fn is_debugging_collisions_hint(&self) -> bool
[src]
If [code]true[/code], collision shapes will be visible when running the game from the editor for debugging purposes.
pub fn is_debugging_navigation_hint(&self) -> bool
[src]
If [code]true[/code], navigation polygons will be visible when running the game from the editor for debugging purposes.
pub fn is_input_handled(&self) -> bool
[src]
Returns [code]true[/code] if the most recent [InputEvent] was marked as handled with [method set_input_as_handled].
pub fn is_multiplayer_poll_enabled(&self) -> bool
[src]
If [code]true[/code] (default value), enables automatic polling of the [MultiplayerAPI] for this SceneTree during [signal idle_frame].
If [code]false[/code], you need to manually call [method MultiplayerAPI.poll] to process network packets and deliver RPCs/RSETs. This allows running RPCs/RSETs in a different loop (e.g. physics, thread, specific time step) and for manual [Mutex] protection when accessing the [MultiplayerAPI] from threads.
pub fn is_network_server(&self) -> bool
[src]
Returns [code]true[/code] if this [SceneTree]'s [member network_peer] is in server mode (listening for connections).
pub fn is_paused(&self) -> bool
[src]
If [code]true[/code], the [SceneTree] is paused. Doing so will have the following behavior:
- 2D and 3D physics will be stopped.
- [method Node._process], [method Node._physics_process] and [method Node._input] will not be called anymore in nodes.
pub fn is_refusing_new_network_connections(&self) -> bool
[src]
If [code]true[/code], the [SceneTree]'s [member network_peer] refuses new incoming connections.
pub fn is_using_font_oversampling(&self) -> bool
[src]
If [code]true[/code], font oversampling is used.
pub fn notify_group(&self, group: impl Into<GodotString>, notification: i64)
[src]
Sends the given notification to all members of the [code]group[/code].
pub fn notify_group_flags(
&self,
call_flags: i64,
group: impl Into<GodotString>,
notification: i64
)
[src]
&self,
call_flags: i64,
group: impl Into<GodotString>,
notification: i64
)
Sends the given notification to all members of the [code]group[/code], respecting the given [enum GroupCallFlags].
pub fn queue_delete(&self, obj: impl AsArg<Object>)
[src]
Queues the given object for deletion, delaying the call to [method Object.free] to after the current frame.
pub fn quit(&self, exit_code: i64)
[src]
Quits the application. A process [code]exit_code[/code] can optionally be passed as an argument. If this argument is [code]0[/code] or greater, it will override the [member OS.exit_code] defined before quitting the application.
Default Arguments
exit_code
--1
pub fn reload_current_scene(&self) -> Result<(), GodotError>
[src]
Reloads the currently active scene.
Returns [constant OK] on success, [constant ERR_UNCONFIGURED] if no [member current_scene] was defined yet, [constant ERR_CANT_OPEN] if [member current_scene] cannot be loaded into a [PackedScene], or [constant ERR_CANT_CREATE] if the scene cannot be instantiated.
pub fn set_auto_accept_quit(&self, enabled: bool)
[src]
If [code]true[/code], the application automatically accepts quitting. Enabled by default.
For mobile platforms, see [method set_quit_on_go_back].
pub fn set_current_scene(&self, child_node: impl AsArg<Node>)
[src]
The current scene.
pub fn set_debug_collisions_hint(&self, enable: bool)
[src]
If [code]true[/code], collision shapes will be visible when running the game from the editor for debugging purposes.
pub fn set_debug_navigation_hint(&self, enable: bool)
[src]
If [code]true[/code], navigation polygons will be visible when running the game from the editor for debugging purposes.
pub fn set_edited_scene_root(&self, scene: impl AsArg<Node>)
[src]
The root of the edited scene.
pub fn set_group(
&self,
group: impl Into<GodotString>,
property: impl Into<GodotString>,
value: impl OwnedToVariant
)
[src]
&self,
group: impl Into<GodotString>,
property: impl Into<GodotString>,
value: impl OwnedToVariant
)
Sets the given [code]property[/code] to [code]value[/code] on all members of the given group.
pub fn set_group_flags(
&self,
call_flags: i64,
group: impl Into<GodotString>,
property: impl Into<GodotString>,
value: impl OwnedToVariant
)
[src]
&self,
call_flags: i64,
group: impl Into<GodotString>,
property: impl Into<GodotString>,
value: impl OwnedToVariant
)
Sets the given [code]property[/code] to [code]value[/code] on all members of the given group, respecting the given [enum GroupCallFlags].
pub fn set_input_as_handled(&self)
[src]
Marks the most recent [InputEvent] as handled.
pub fn set_multiplayer(&self, multiplayer: impl AsArg<MultiplayerAPI>)
[src]
The default [MultiplayerAPI] instance for this [SceneTree].
pub fn set_multiplayer_poll_enabled(&self, enabled: bool)
[src]
If [code]true[/code] (default value), enables automatic polling of the [MultiplayerAPI] for this SceneTree during [signal idle_frame].
If [code]false[/code], you need to manually call [method MultiplayerAPI.poll] to process network packets and deliver RPCs/RSETs. This allows running RPCs/RSETs in a different loop (e.g. physics, thread, specific time step) and for manual [Mutex] protection when accessing the [MultiplayerAPI] from threads.
pub fn set_network_peer(&self, peer: impl AsArg<NetworkedMultiplayerPeer>)
[src]
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the [SceneTree] will become a network server (check with [method is_network_server]) and will set the root node's network mode to master, or it will become a regular peer with the root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to [SceneTree]'s signals.
pub fn set_pause(&self, enable: bool)
[src]
If [code]true[/code], the [SceneTree] is paused. Doing so will have the following behavior:
- 2D and 3D physics will be stopped.
- [method Node._process], [method Node._physics_process] and [method Node._input] will not be called anymore in nodes.
pub fn set_quit_on_go_back(&self, enabled: bool)
[src]
If [code]true[/code], the application quits automatically on going back (e.g. on Android). Enabled by default.
To handle 'Go Back' button when this option is disabled, use [constant MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST].
pub fn set_refuse_new_network_connections(&self, refuse: bool)
[src]
If [code]true[/code], the [SceneTree]'s [member network_peer] refuses new incoming connections.
pub fn set_screen_stretch(
&self,
mode: i64,
aspect: i64,
minsize: Vector2D<f32, UnknownUnit>,
shrink: f64
)
[src]
&self,
mode: i64,
aspect: i64,
minsize: Vector2D<f32, UnknownUnit>,
shrink: f64
)
Configures screen stretching to the given [enum StretchMode], [enum StretchAspect], minimum size and [code]shrink[/code] ratio.
Default Arguments
shrink
-1
pub fn set_use_font_oversampling(&self, enable: bool)
[src]
If [code]true[/code], font oversampling is used.
Methods from Deref<Target = MainLoop>
pub const NOTIFICATION_APP_PAUSED: i64
[src]
pub const NOTIFICATION_APP_RESUMED: i64
[src]
pub const NOTIFICATION_CRASH: i64
[src]
pub const NOTIFICATION_OS_IME_UPDATE: i64
[src]
pub const NOTIFICATION_OS_MEMORY_WARNING: i64
[src]
pub const NOTIFICATION_TRANSLATION_CHANGED: i64
[src]
pub const NOTIFICATION_WM_ABOUT: i64
[src]
pub const NOTIFICATION_WM_FOCUS_IN: i64
[src]
pub const NOTIFICATION_WM_FOCUS_OUT: i64
[src]
pub const NOTIFICATION_WM_GO_BACK_REQUEST: i64
[src]
pub const NOTIFICATION_WM_MOUSE_ENTER: i64
[src]
pub const NOTIFICATION_WM_MOUSE_EXIT: i64
[src]
pub const NOTIFICATION_WM_QUIT_REQUEST: i64
[src]
pub const NOTIFICATION_WM_UNFOCUS_REQUEST: i64
[src]
pub fn finish(&self)
[src]
Should not be called manually, override [method _finalize] instead. Will be removed in Godot 4.0.
pub fn idle(&self, delta: f64) -> bool
[src]
Should not be called manually, override [method _idle] instead. Will be removed in Godot 4.0.
pub fn init(&self)
[src]
Should not be called manually, override [method _initialize] instead. Will be removed in Godot 4.0.
pub fn input_event(&self, event: impl AsArg<InputEvent>)
[src]
Should not be called manually, override [method _input_event] instead. Will be removed in Godot 4.0.
pub fn input_text(&self, text: impl Into<GodotString>)
[src]
Should not be called manually, override [method _input_text] instead. Will be removed in Godot 4.0.
pub fn iteration(&self, delta: f64) -> bool
[src]
Should not be called manually, override [method _iteration] instead. Will be removed in Godot 4.0.
Trait Implementations
impl Debug for SceneTree
[src]
impl Deref for SceneTree
[src]
impl DerefMut for SceneTree
[src]
impl GodotObject for SceneTree
[src]
type RefKind = ManuallyManaged
The memory management kind of this type. This modifies the behavior of the
Ref
smart pointer. See its type-level documentation for more
information. Read more
fn class_name() -> &'static str
[src]
fn null() -> Null<Self>
[src]
fn new() -> Ref<Self, Unique> where
Self: Instanciable,
[src]
Self: Instanciable,
fn cast<T>(&self) -> Option<&T> where
T: GodotObject + SubClass<Self>,
[src]
T: GodotObject + SubClass<Self>,
fn upcast<T>(&self) -> &T where
Self: SubClass<T>,
T: GodotObject,
[src]
Self: SubClass<T>,
T: GodotObject,
unsafe fn assume_shared(&self) -> Ref<Self, Shared>
[src]
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
[src]
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_unique(&self) -> Ref<Self, Unique>
[src]
impl Instanciable for SceneTree
[src]
impl SubClass<MainLoop> for SceneTree
[src]
impl SubClass<Object> for SceneTree
[src]
Auto Trait Implementations
impl RefUnwindSafe for SceneTree
impl !Send for SceneTree
impl !Sync for SceneTree
impl Unpin for SceneTree
impl UnwindSafe for SceneTree
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SubClass<T> for T where
T: GodotObject,
[src]
T: GodotObject,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,