Skip to content

[Question] Access properties of a property through the Godot EditorΒ #932

@RaineGit

Description

@RaineGit

Context

I have a struct "BasicPlayer" which has a property "speed" that is accessible through the Godot Editor:

#[derive(NativeClass)]
#[inherit(Spatial)]
pub struct BasicPlayer {
	#[property(path = "BasicPlayer/speed", default = 0.15)]
	pub speed: f32,
	pub keys: HashMap<u64, ()>,
	pub cam: Option<TRef<'static, Camera>>,
}

Screenshot_2022-08-24_17-55-27

And I have another struct "FPSPlayer" which has a property "player", which I would want to be able to access through the Godot Editor:

#[derive(NativeClass)]
#[inherit(Spatial)]
pub struct FPSPlayer {
	pub player: BasicPlayer,
}

Problem

In a node that has the "FPSPlayer" class assigned as a script, I need to access the properties under the "player" property through the Godot Editor, preferably without having to manually make a setter for it.

Example of what I would want to do (which obviously doesn't actually work)

#[derive(NativeClass)]
#[inherit(Spatial)]
pub struct FPSPlayer {
	#[property] // This line was added
	pub player: BasicPlayer,
}

And I should be able to access its properties through the Godot Editor:
Screenshot_2022-08-24_17-55-27

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions