Struct gdnative_bindings_lily::scene_tree::SceneTree[][src]

pub struct SceneTree { /* fields omitted */ }
Expand description

core class SceneTree inherits MainLoop (unsafe).

Official documentation

See the documentation of this class in the Godot engine’s official documentation. The method descriptions are generated from it and typically contain code samples in GDScript, not Rust.

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

Constants

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.

Calls method on each member of the given group.

Calls method on each member of the given group, respecting the given [enum GroupCallFlags].

Changes the running scene to the one at the given path, after loading it into a PackedScene and creating a new instance. Returns [constant OK] on success, [constant ERR_CANT_OPEN] if the path cannot be loaded into a PackedScene, or [constant ERR_CANT_CREATE] if that scene cannot be instantiated.

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.

Sample code is GDScript unless otherwise noted.

Returns a SceneTreeTimer which will [signal SceneTreeTimer.timeout] after the given time in seconds elapsed in this SceneTree. If pause_mode_process is set to false, pausing the SceneTree will also pause the timer. Commonly used to create a one-shot delay timer as in the following example:

func some_function():
    print("start")
    yield(get_tree().create_timer(1.0), "timeout")
    print("end")

Default Arguments

  • pause_mode_process - true

The current scene.

The root of the edited scene.

Returns the current frame number, i.e. the total frame count since the application started.

The default MultiplayerAPI instance for this SceneTree.

Returns the peer IDs of all connected peers of this SceneTree’s [member network_peer].

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.

Returns the unique peer ID of this SceneTree’s [member network_peer].

Returns the number of nodes in this SceneTree.

Returns a list of all nodes assigned to the given group.

The SceneTree’s root Viewport.

Returns the sender’s peer ID for the most recently received RPC call.

Returns true if the given group exists.

Returns true if there is a [member network_peer] set.

If true, collision shapes will be visible when running the game from the editor for debugging purposes.

If true, navigation polygons will be visible when running the game from the editor for debugging purposes.

Returns true if the most recent InputEvent was marked as handled with [method set_input_as_handled].

If true (default value), enables automatic polling of the MultiplayerAPI for this SceneTree during [signal idle_frame]. If false, 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.

Returns true if this SceneTree’s [member network_peer] is in server mode (listening for connections).

If true, 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.

If true, the SceneTree’s [member network_peer] refuses new incoming connections.

If true, font oversampling is used.

Sends the given notification to all members of the group.

Sends the given notification to all members of the group, respecting the given [enum GroupCallFlags].

Queues the given object for deletion, delaying the call to [method Object.free] to after the current frame.

Quits the application. A process exit_code can optionally be passed as an argument. If this argument is 0 or greater, it will override the [member OS.exit_code] defined before quitting the application.

Default Arguments

  • exit_code - -1

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.

If true, the application automatically accepts quitting. Enabled by default. For mobile platforms, see [method set_quit_on_go_back].

The current scene.

If true, collision shapes will be visible when running the game from the editor for debugging purposes.

If true, navigation polygons will be visible when running the game from the editor for debugging purposes.

The root of the edited scene.

Sets the given property to value on all members of the given group.

Sets the given property to value on all members of the given group, respecting the given [enum GroupCallFlags].

Marks the most recent InputEvent as handled.

The default MultiplayerAPI instance for this SceneTree.

If true (default value), enables automatic polling of the MultiplayerAPI for this SceneTree during [signal idle_frame]. If false, 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.

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.

If true, 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.

If true, 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].

If true, the SceneTree’s [member network_peer] refuses new incoming connections.

Configures screen stretching to the given [enum StretchMode], [enum StretchAspect], minimum size and shrink ratio.

Default Arguments

  • shrink - 1

If true, font oversampling is used.

Methods from Deref<Target = MainLoop>

Should not be called manually, override [method _finalize] instead. Will be removed in Godot 4.0.

Should not be called manually, override [method _idle] instead. Will be removed in Godot 4.0.

Should not be called manually, override [method _initialize] instead. Will be removed in Godot 4.0.

Should not be called manually, override [method _input_event] instead. Will be removed in Godot 4.0.

Should not be called manually, override [method _input_text] instead. Will be removed in Godot 4.0.

Should not be called manually, override [method _iteration] instead. Will be removed in Godot 4.0.

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

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

Creates an explicitly null reference of Self as a method argument. This makes type inference easier for the compiler compared to Option. Read more

Creates a new instance of Self using a zero-argument constructor, as a Unique reference. Read more

Performs a dynamic reference downcast to target type. Read more

Performs a static reference upcast to a supertype that is guaranteed to be valid. Read more

Creates a persistent reference to the same Godot object with shared thread access. Read more

Creates a persistent reference to the same Godot object with thread-local thread access. Read more

Creates a persistent reference to the same Godot object with unique access. Read more

Recovers a instance ID previously returned by Object::get_instance_id if the object is still alive. See also TRef::try_from_instance_id. Read more

Recovers a instance ID previously returned by Object::get_instance_id if the object is still alive, and panics otherwise. This does NOT guarantee that the resulting reference is safe to use. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.