I got some problem with access to static typed objects in U3, while I hadn’t any with UnityiPhone 1.7 :
Let’s admit this sample :
_component1 will be output as “null”.
This is not logical as Awake() is called at script instanciation, so component1 should be available inside myClass from any script as soon as it is added ? It’s like the Awake() call momentum was changed with U3… weird.
This is really problematic, as it prevents from direct accesses.
Plus I had whole my framework revolved around this direct access (as said, it didn’t make any problem with iPhone1.7), because Singleton had in some cases better performance than class instancing.
this is very well logically explainable because within awake you should never expect the rest of the world to be fully there. try it within start and the gameobject find should work preventing you from failing.
that or store a reference to the object you want to use
By pure luck ;-). It is written somewhere in docs that order in which Awake/Start is called for objects is undefined - the only thing you can be sure of - when you are in Start method, Awake was called for everything else in the world.
it worked before because the object init order potentially was different. Generally its not defined in which order the awake calls on the objects are done its only defined that all objects in the scene will do awake before the first will do start and all will do start before the first will get update called.
I normally split the code like
Awake: Local init on me and potentially same game object
Start: relation ship init with other components, especially on other GOs