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

May need more example or doc for the bevy UI layout #2249

Open
ChenhuiZhang opened this issue May 25, 2021 · 5 comments
Open

May need more example or doc for the bevy UI layout #2249

ChenhuiZhang opened this issue May 25, 2021 · 5 comments
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Docs An addition or correction to our documentation

Comments

@ChenhuiZhang
Copy link

Hi,

I just want to implement a score board, which will have all player's name and score, the player will use a SpritBundle and score use TextBundle, but I'm quite confuse with how to combine them in the UI layout.

The below is what I'm look into:
https://docs.rs/bevy/0.5.0/bevy/prelude/struct.Style.html

I also think about if all the SpritBundle and TextBundle should be the children of another Bundle (NodeBundle?) Does there some examples for such case?

@ChenhuiZhang ChenhuiZhang added C-Docs An addition or correction to our documentation S-Needs-Triage This issue needs to be labelled labels May 25, 2021
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets and removed S-Needs-Triage This issue needs to be labelled labels May 25, 2021
@NathanSWard
Copy link
Contributor

NathanSWard commented May 25, 2021

There's a pretty big UI over-hull in the works:
see the following RFCs
bevyengine/rfcs#1
bevyengine/rfcs#11
bevyengine/rfcs#22

So there's not much effort put into maintaining the current UI system.
I'll probably defer this to @alice-i-cecile, since she would ultimately knows more.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible and removed C-Feature A new feature, making something new possible labels May 25, 2021
@alice-i-cecile
Copy link
Member

alice-i-cecile commented May 25, 2021

The existing bevy_ui solution badly needs documentation unfortunately. For what you're trying to do, you may be able to get it to work by modifying a ButtonBundle. You'd then change the Handle<Material> field to your loaded asset.

My guess is that you'll need all of the components in that bundle listed other than Interaction and FocusPolicy, but I haven't tested it out.

I presume you need something like a sprite (rather than just text) to display the user's name as you'd like to use some non-standard representation of it, like a logogram (e.g. Hanzi)?

For posterity, this is a great example of why a compositional approach to UI (see rfcs#22) is valuable. It allows users to mix-and-match concepts in a flexible way.

@ChenhuiZhang
Copy link
Author

Hi alice,

Thanks for quick reply.

No, I just want to display the players role from an icon, and then flow the score of this player. So it should be standard resource as a normal SpirtBundle.

I do a quick look at the ButtonBundle, but it seems no new things. Actually the example of text, that's similar as what I want, the score value will be changed (only for text, like the FPS value in text), but the leading icon is static.

@alice-i-cecile alice-i-cecile self-assigned this May 25, 2021
@alice-i-cecile
Copy link
Member

Alright, I'm going to try to see if I can get an example of asset loading for a Node working, and then make a PR for that example (and probably add some extremely basic docs to the library).

@tigregalis
Copy link
Contributor

tigregalis commented May 26, 2021

Are you after an ImageBundle perhaps? see https://github.com/bevyengine/bevy/blob/main/examples/ui/ui.rs#L206-L215

This is just an analogy, but SpriteBundle is in the "game world space" while ImageBundle and TextBundle are in the "UI space". You can only compose UI things in the UI space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Docs An addition or correction to our documentation
Projects
None yet
Development

No branches or pull requests

4 participants