- Home /
Get GameObject dependencies only once for JobComponentSystem
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...
Answer by mentics · Jan 16, 2020 at 07:19 PM
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;
}
Your answer
Follow this Question
Related Questions
Unsafe.dll from Unity version conflicts with Unsafe.dll from standard collections package. 1 Answer
I'm not seeing a performance increase with the Job System. Help 1 Answer
Jobs perfomance slower than single thread. 2 Answers
How to get a single Entity (or data for it) that a JobComponentSystem depends on for data? 1 Answer
My VS2019 Intellisense does not see the fields in Entities 0.9.1 1 Answer