Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eml] allow to bind to eml-based assets #8

Closed
jkb0o opened this issue Nov 30, 2022 · 1 comment
Closed

[eml] allow to bind to eml-based assets #8

jkb0o opened this issue Nov 30, 2022 · 1 comment

Comments

@jkb0o
Copy link
Owner

jkb0o commented Nov 30, 2022

After #5 (and may be #1 ) will be implemented, it will be possible to select elements as entities using ess selector and provide bindings for them:

// declaring eml scene
#[derive(Component)]
#[scene("path/to/scene.eml")]
pub struct ProfilePage {

 #[source]  
 pub profile: Entity

 #[select(.profile-avatar)]
 pub avatar: Entity
 
 #[select(.profile-name)]
 pub name: Entity

 #[select(.profile-health)]
 pub health: Entity
}

// handle loading
impl SceneBind for ProfilePage {
    fn bind(&mut self, this: Entity, commands: Commands, asset_server: AssetServer) {
        commands.add(from!(this, Self:profile @ User:name) >> to!(self.name, Label:value));
        commands.add(from!(this, Self:profile @ Health:current) >> to!(self.health, Range:value));
        commands.add(from!(this, Self:profile @ Health:max) >> to!(self.health, Range:maximum));
    }
}

Later we can all required information for instancing scene:

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
  let player = commands.spawn_empty().id();
  let scene = asset_server.instance::<ProfilePage>(player);
  commands.add(scene);
}
@jkb0o jkb0o changed the title [eml] allow to bind eml loaded from asset [eml] allow to bind to eml-based assets Dec 16, 2022
@jkb0o
Copy link
Owner Author

jkb0o commented Sep 25, 2023

This will be done right in polako (#77)

@jkb0o jkb0o closed this as completed Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant