If I put something like field = UnityEngine.GameObject.Find("ObjectName").transform;
in the OnCreate it will throw exception. I’m guessing because this system is being run before the game objects have been set up. I don’t want to have to go find dependencies every time in OnUpdate, so how do I get the dependencies just once? Hoping the answer isn’t a null check in OnUpdate…
You can override OnStartRunning
in your ComponentSystem. It may get called multiple times, but only when system stops/starts, so should be seldom enough for this purpose.
protected override void OnStartRunning() {
field = UnityEngine.GameObject.Find("ObjectName").transform;
}