Let's sum up today's harvest: When initializing a member variable in a script class, when in awake (), when it is in Start () is fastidious.
1) When a member variable is referenced by an external script, especially if the member variable is a self -defined non-scripting class that must be initialized with a constructor . Also, an external script reference refers to "when an internal member function or property referencing the variable is called by an external function ", and the member variable should be initialized in the awake function.
2) If the member variable is referenced only in the script class where it is located, it should be initialized in the start function.
The pit we met today was due to not noticing the above two points. I initialized a poker class with a constructor in the start function, but an instance of this class was called by an external script in its own public method. This is not the most important, because I met once before. It is important to copy the preset in the update () function, whose awake () function is immediately called in the update of the current frame , but the start () function is executed at the next frame .
Today using unity to meet a big pit