I'm working on some side projects and have been toying with ideas for more efficient ways to write games in Unity with C#. One of the major hangups for some of my larger side projects is that once it reaches sufficient complexity, it's hard to tell exactly what state the app is in. Even the simple wallet app I built has this issue. I've come up with the beginnings of a solution so I wanted to write it down before it gets lost.
The key problem is that you want your program to respond to inputs that require waiting for a response from something (a webserver, a user, etc). There are a number of options in Unity with C#.
These first 4 options are variations on a theme of control "elsewhere" in the program letting your code know that something has happened:
- Virtual Callback E.g. if you derive from a class, and override a method which gets called in response to an event
- Reflection Callback E.g. if you declare
OnMouseMove
on a class and that function gets called whenever the mouse moves
- **Callb