Skip to content

Using the button function to spawn a bundle with aditional structs #20179

Answered by Galedon
Galedon asked this question in Q&A
Discussion options

You must be logged in to vote

Ok so just for anybody with a similral problem, after some hours of suffering (I am a beginner) I managed to reduce the one button to 3 lines :)
Here is the code:

fn menu_setup(
    mut commands: Commands,
){
    commands.spawn((
        MenuButtons,
        Camera2d::default()
    ));

    let button_node = Node {
        width: Val::Px(300.0),
        height: Val::Px(65.0),
        margin: UiRect::all(Val::Px(20.0)),
        justify_content: JustifyContent::Center,
        align_items: AlignItems::Center,
        ..default()
    };
    let button_full = (Button,
    button_node.clone(),
    BorderRadius::MAX,
    BackgroundColor(NORMAL_BUTTON),
    );
    fn button_text(text: &str) -> i…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@Galedon
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Galedon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants