Struct gdnative::core_types::NodePath
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§
§impl NodePath
impl NodePath
pub fn from_str(path: &str) -> NodePath
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.
pub fn new(path: &GodotString) -> NodePath
pub fn new(path: &GodotString) -> NodePath
Create a NodePath from a GodotString.
pub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Returns true if the node path is absolute.
pub fn name_count(&mut self) -> i32
pub fn name_count(&mut self) -> i32
Get the number of node names which make up the path.
pub fn get_subname(&self, idx: i32) -> GodotString
pub fn get_subname(&self, idx: i32) -> GodotString
Returns the resource name of the specified idx, 0 to subname_count()
pub fn get_subname_count(&self) -> i32
pub fn get_subname_count(&self) -> i32
Returns the number of resource names in the path.
pub fn get_concatenated_subnames(&self) -> GodotString
pub fn to_godot_string(&self) -> GodotString
pub fn to_godot_string(&self) -> GodotString
Returns the NodePath as a GodotString
Trait Implementations§
§impl CoerceFromVariant for NodePath
impl CoerceFromVariant for NodePath
fn coerce_from_variant(v: &Variant) -> NodePath
§impl<'de> Deserialize<'de> for NodePath
impl<'de> Deserialize<'de> for NodePath
§fn deserialize<D>(
deserializer: D,
) -> Result<NodePath, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<NodePath, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Export for NodePath
impl Export for NodePath
§fn export_info(_hint: Option<<NodePath as Export>::Hint>) -> ExportInfo
fn export_info(_hint: Option<<NodePath as Export>::Hint>) -> ExportInfo
ExportInfo given an optional typed hint.§impl From<GodotString> for NodePath
impl From<GodotString> for NodePath
§fn from(s: GodotString) -> NodePath
fn from(s: GodotString) -> NodePath
§impl From<NodePath> for GodotString
impl From<NodePath> for GodotString
§fn from(p: NodePath) -> GodotString
fn from(p: NodePath) -> GodotString
§impl FromVariant for NodePath
impl FromVariant for NodePath
fn from_variant(variant: &Variant) -> Result<NodePath, FromVariantError>
§impl Serialize for NodePath
impl Serialize for NodePath
§fn serialize<S>(
&self,
ser: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
ser: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for NodePath
impl ToVariantEq for NodePath
Auto Trait Implementations§
impl Freeze for NodePath
impl RefUnwindSafe for NodePath
impl Send for NodePath
impl Sync for NodePath
impl Unpin for NodePath
impl UnwindSafe for NodePath
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.