One thing I have managed to achieve is the ability to produce code that will most likely blow up in myface. At least in Unity.
I’ve always been a code-first type of guy and I find the timing methods (do they have an official type name?) to be troublesome. I mean ‘Awake’, ‘Start’, ‘Update’, etc. They’re fine and all, but the simple fact that they are (not)simultaneous makes me nervous. Each time you run the code you get an arbitraty order in which all Awakes are run. This is not bad in and of itself, but you have to build around it.
I know that there are elegant ways to take this into account and you can make code that (in this respect, just as in others) is beautifyl, as well as robust, but… If I can not find anyone that explains how to approach those fickle beasts Awake and Update, then I’ll have to write the book myself.
Specificity? Sure, why not:
The Awake method of my Mono class GreatManager wants to know the int PlayerStartingLife and asks the Mono class PlayerManager. However, the method public int ProvidePlayerLife() can not oblige, because the class has not had it’s awakening yet. If it was awakened first, it would be fine. But that is only the two-body problem. If you are not carefull you might end up with a nasty web of classes, each screaming – ‘Him first! Wake him first!’.
Right now I’ve employed heavy patchwork in some places – it the class is not awake, please ask him to do his awake routine, then as him to do what I need him to do. However, if I am going to init the classes on demand, what do I need the Awake for?
Do I say that the ‘Awake’ class is useless? No, of course. I’m saying that big part of using Unity is learning how to code specifically for Unity and that includes developing within some very odd contraints…
Not that I don’t like it, though. This I will crack. Soon.