Conversation
Removed logging and added custom panic messages instead
ceb555a to
1cc7bd2
Compare
| pub visibility: Visibility, | ||
| } | ||
|
|
||
| /// A UI node that is an image with texture sheet |
There was a problem hiding this comment.
| /// A UI node that is an image with texture sheet | |
| /// A UI node that displays an image stored in a texture sheet |
| pub image_mode: ImageMode, | ||
| /// The calculated size based on the given image | ||
| pub calculated_size: CalculatedSize, | ||
| /// The color of the node |
There was a problem hiding this comment.
This should describe how the blending is done.
|
|
||
| /// A UI node that is a button with a texture sheet | ||
| #[derive(Bundle, Clone, Debug)] | ||
| pub struct ButtonSheetBundle { |
There was a problem hiding this comment.
I don't like the creation of a dedicated bundle here: this should be done compositionally.
| pub visibility: Visibility, | ||
| } | ||
|
|
||
| impl Default for ButtonSheetBundle { |
There was a problem hiding this comment.
Shouldn't the derive work fine here?
| .add_system_to_stage(RenderStage::Extract, extract_ui_camera_phases) | ||
| .add_system_to_stage( | ||
| RenderStage::Extract, | ||
| // This system is the first of `RenderStage::Extract` it is responsible for both: |
There was a problem hiding this comment.
This should be on doc strings for extract_uinodes and RenderUiSystem instead.
| } | ||
| } | ||
|
|
||
| pub fn extract_atlas_uinodes( |
There was a problem hiding this comment.
This is public, and thus needs doc strings.
| /// The texture atlas of the node | ||
| #[derive(Component, Clone, Debug, Default, Reflect)] | ||
| #[reflect(Component)] | ||
| pub struct UiTextureAtlas { |
There was a problem hiding this comment.
This doesn't feel UI specific at all. Why can't we just use TextureAtlasSprite + Handle<TextureAtlas>?
Whenever possible, we should try to avoid duplicated structures between UI and 2D to avoid divergence and confusion.
| @@ -0,0 +1,80 @@ | |||
| use bevy::prelude::*; | |||
|
|
|||
| /// This example illustrates how to create a button that changes color and text based on its | |||
| Example | File | Description | ||
| --- | --- | --- | ||
| `button` | [`ui/button.rs`](./ui/button.rs) | Illustrates creating and updating a button | ||
| `button_with_atlas` | [`ui/button_with_atlas.rs`](./ui/button_with_atlas.rs) | Illustrates creating and updating a button with a texture atlas |
There was a problem hiding this comment.
I'd prefer if we could roll this into the button.rs example, and just create two different buttons there.
alice-i-cecile
left a comment
There was a problem hiding this comment.
Some nits, and one major objection: I think that whenever possible we should try to reuse and unify code between UI and 2D.
I agree with the direction here and think it's quite useful. Can you add more context to the Objective section of your PR explaining what end users might use this feature for in practice?
My instinct was that you could use this for animated buttons (including changes on e.g. hover), and @inodentry pointed out that you could use this to enable reuse of texture atlases across the game content and UI, like in menus.
|
Thanks for the review, I completely forgot about this PR. I think I'll redo it completely from the About the use cases I see both:
|
|
@alice-i-cecile I'm closing this in favor of #5070 |
Objective
Adds support for texture atlas in
bevy_uiNodesSolution
UiTextureAtlascomponent with a simple textureindexand aHandle<bevy_sprite::TextureAtlas>UiTextureAtlasImageModesupport