Trying to keep classes uncoupled. I am setting up some event actions where I can from one script invoke methods in a different class/script. That works fine, but it only runs it once.
I could put a conditionMet = false at the beginning of the method and then while(!conditionMet) in the method but that seems wrong.
Advise?
Probably is wrong as this will likely end in an infinite loop.
It’s hard to advise without seeing some code examples first, of course.
Here’s how I do it, completely generic, just call and give it two delegates.
It has a destroy-when-actioned once mechanism: you could change or invert it, make it continuous, hook it to other callbacks, etc.
It lives on a blank GameObject so its lifecycle is tied to your scene, so plan accordingly.
Seems like a case for events to me. Have your script with the condition in it fire an event when the condition changes, and have the other script subscribe to that event.