I'm creating a simulation, but just starting with a simple ui that lets users input a chemical equation. Every time they type something different, I quickly parse and balance that equation displaying the result. I'm using bevy_egui and an UiState struct to contain the current user input. I was trying to create a simple system will try to balance the user input whenever it changes using ResMut<T>::is_changed, however since by ui system passes a mutable reference to my input data to egui::Ui::text_edit_single_line, the mutable deref triggers a change every frame even when there isn't one. I'm new to bevy so I'm assuming I'm missing something... Is there anyway to prevent triggering a change when there isn't one despite mutable derefing?
#Detect State Changes with User Input
1 messages · Page 1 of 1 (latest)
You could try making another resource to store input from previous tick and compare it and then fire events if it changed. Instead of making another resource you could try reusing your current one
Right now I just added another resource that's a wrapper on the string, and then compare that with the saved value. I'm not sure what your other suggestion means though
Sorry for not being clear. I meant adding another field to UiState which would represent last tick value
Yep, it worked...
You can use a combination of bypass_change_detection and set_changed to only mark the value as changed when egui says that you actually changed it