#Creating a modular button system, but wondering about structure.

30 messages ยท Page 1 of 1 (latest)

celest idol
#

The file limit dialog deleted my whole message so I'll upload it soon

#

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?

opal roost
celest idol
#

Thanks Hukasu! I'll have a mosey

opal roost
celest idol
#

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

opal roost
celest idol
#

myeah sure

opal roost
#

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()
}
celest idol
#

that's not really what I'm after, but good to know

opal roost
#

you want a system that runs once when the button is created?

celest idol
#

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

opal roost
#

you are just putting to many constraints on yourself

celest idol
#

haha that might be, my brain is still in OOP

opal roost
#

what you have right now works?

celest idol
#

it does yeah