FSM Start() behavior array-serialization bug
Posted: 2017/07/06 22:48
Hi
When starting game, FSMInternal invokes state.EnableState( true,true );
It in turn, calls behaviour.OnStateAwake()
and behaviour.OnStateBegin();
Problem:
I have script on first state. It always gets OnStateAwake() + OnStateBegin() during FSMInternal.Start()
My script has [SerializeField] GameObject[] prefabArray;
On first frame, I get exception from the script - it has empty array, because it was enabled during OnStateBegin()
Unity didn't have time yet to load array with data
Next frame, unity serialized the array with prefabs, and everything is ok
When starting game, FSMInternal invokes state.EnableState( true,true );
It in turn, calls behaviour.OnStateAwake()
and behaviour.OnStateBegin();
Problem:
I have script on first state. It always gets OnStateAwake() + OnStateBegin() during FSMInternal.Start()
My script has [SerializeField] GameObject[] prefabArray;
On first frame, I get exception from the script - it has empty array, because it was enabled during OnStateBegin()
Unity didn't have time yet to load array with data
Next frame, unity serialized the array with prefabs, and everything is ok