Skip to main content

NodePath

Struct NodePath 

Source
pub struct NodePath(/* private fields */);
Expand description

A reference-counted relative or absolute path in a scene tree, for use with Node.get_node() and similar functions. It can reference a node, a resource within a node, or a property of a node or resource.

"Path2D/PathFollow2D/Sprite:texture:size" would refer to the size property of the texture resource on the node named “Sprite” which is a child of the other named nodes in the path. Note that if you want to get a resource, you must end the path with a colon, otherwise the last element will be used as a property name.

If a string is passed to Node.get_node(), it will be automatically converted to a NodePath, but NodePath can be parsed ahead of time with NodePath::from_str or NodePath::new.

A NodePath consists of node names, “sub-node” (resource) names, and the name of a property in the final node or resource.

More info at Godot’s official documentation

Implementations§

Source§

impl NodePath

Source

pub fn from_str(path: &str) -> NodePath

Create a NodePath from a string, e.g. "Path2D/PathFollow2D/Sprite:texture:size". A path is absolute if it starts with a slash. Absolute paths are only valid in the global scene tree, not within individual scenes. In a relative path, "." and ".." indicate the current node and its parent.

Source

pub fn new(path: &GodotString) -> NodePath

Create a NodePath from a GodotString.

Source

pub fn is_empty(&self) -> bool

Returns true if the node path is empty.

Source

pub fn is_absolute(&self) -> bool

Returns true if the node path is absolute.

Source

pub fn name_count(&mut self) -> i32

Get the number of node names which make up the path.

Source

pub fn get_subname(&self, idx: i32) -> GodotString

Returns the resource name of the specified idx, 0 to subname_count()

Source

pub fn get_subname_count(&self) -> i32

Returns the number of resource names in the path.

Source

pub fn get_concatenated_subnames(&self) -> GodotString

Source

pub fn to_godot_string(&self) -> GodotString

Returns the NodePath as a GodotString

Source

pub fn to_string(&self) -> String

Returns the NodePath as a String

Source

pub fn new_ref(&self) -> NodePath

Trait Implementations§

Source§

impl Debug for NodePath

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Drop for NodePath

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for NodePath

Source§

impl<'l> From<&'l NodePath> for Variant

Source§

fn from(val: &'l NodePath) -> Variant

Converts to this type from the input type.
Source§

impl From<GodotString> for NodePath

Source§

fn from(s: GodotString) -> NodePath

Converts to this type from the input type.
Source§

impl<S> From<S> for NodePath
where S: AsRef<str>,

Source§

fn from(s: S) -> NodePath

Converts to this type from the input type.
Source§

impl Into<GodotString> for NodePath

Source§

fn into(self) -> GodotString

Converts this type into the (usually inferred) input type.
Source§

impl Into<String> for NodePath

Source§

fn into(self) -> String

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for NodePath

Source§

fn eq(&self, other: &NodePath) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToVariant for NodePath

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.