Quick answer: Initialize on main thread via [RuntimeInitializeOnLoadMethod] before scheduling any job that reads it.
Job reads from a SharedStatic config. Reads zero. Init function ran later than the job. Or didn’t run yet on first frame.
The Fix
public static class GameConfig {
public struct Data { public float Speed; public int MaxEnemies; }
public static readonly SharedStatic<Data> Ref =
SharedStatic<Data>.GetOrCreate<GameConfig>();
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void Init() {
Ref.Data = new Data { Speed = 5f, MaxEnemies = 100 };
}
}
// Job reads via Ref.Data — populated before any Update runs.
SubsystemRegistration runs before scenes load and before any user MonoBehaviour. Safer than Awake which races with parallel job systems started elsewhere.
Verifying
Job reads expected speed. Disable init: reads zero (or whatever default). Confirm SubsystemRegistration runs before any scheduled work.
“Init early. SharedStatic warm. Job sees data.”
Related Issues
For Burst FunctionPointer, see function pointer. For Burst AOT, see AOT.
Init before schedule. Static warm.