#Creating a modular button system, but wondering about structure.
30 messages ยท Page 1 of 1 (latest)
I've got a MainMenuPlugin that calls a function from a ButtonPlugin, problem is, to call the updating function of button plugin (the hovering and pressing image change), MainMenu needs to first add ButtonPlugin as a plugin, I was hoping to do this within the create_button function instead, any way of doing this?
here's the MainMenuPlugin
here's the ButtonPlugin
this project of mine is 100% ui nodes, it has a main menu with 25 buttons that trasition to different scenes, and most of the scenes have buttons to change their view, all of them have buttons to return to main menu
https://github.com/hukasu/aoc2024_vis
Visualizations for AoC2024 problems. Contribute to hukasu/aoc2024_vis development by creating an account on GitHub.
Thanks Hukasu! I'll have a mosey
https://github.com/hukasu/aoc2024_vis/blob/30ad41a5d992c84dd34824622f77a586c603c7f6/src/scenes/days.rs#L88-L134 creating the buttons on the scenes to change their view or return to the main menu
system that checks their interaction https://github.com/hukasu/aoc2024_vis/blob/30ad41a5d992c84dd34824622f77a586c603c7f6/src/scenes/mod.rs#L82-L113
is there any way of running this system on update on creation of a button entity?
I was hoping to make the button functionality run when one is spawned, but I guess ECS favours an overseeing button manager system?
my thought about how this would work would be something like this
main -> add main_menu plugin
main_menu -> button pressed checker system running on Update
button -> button spawning + hover/pressed image button change system running on Update
currently it's doing something like this
main -> add main_menu plugin
main_menu -> add button plugin to run button change system on Update
button -> spawning button```
So this is what I currently have
I want this
not necessarely, you could very well just add everything straight into the App without a plugin
myeah sure
you can create a system condition that returns false if there are no buttons spawned
app.add_system(Update, check_buttons.run_if(there_are_buttons));
fn there_are_buttons(buttons: Query<(), With<Button>>) -> bool {
!buttons.is_empty()
}
that's not really what I'm after, but good to know
you want a system that runs once when the button is created?
that updates every tick once the button is created
but I want this functionality to stay within the button folder
essentially, I just want to add the MainMenuPlugin in the app, and have the hovering functionality consolidated within any spawned button
it could be that what I'm asking is very un-bevy like
and if it is, I'll just consolidate that updated system within the main_menu instead
you are just putting to many constraints on yourself
haha that might be, my brain is still in OOP
what you have right now works?
it does yeah