With Unity’s 5.4 changing how serialization works I’ve had to think about how to change my code; since you can no longer call serialized variables in constructors. You’re supposed to use Start and Awake instead, but the scripts are never called except for within those constructors.
As an example I’d have a class with a function like this:
public class Example : MonoBehaviour {
private void Test() {
for (int i = 0; i < 5; i++) {
// Calling constructor from otherClass
otherClass newVariable = new otherClass(i);
someVariable.Add(newVariable);
}
}
}
That constructor contains serialized variables that can now only be called in Start or Awake otherwise it will throw an error. Maybe I’m overthinking, but is there another way to call serialized variables from a class if Start and Awake are never initialized(and have the variables reached and working)? Or am I going to have to do a lot of refactoring.
Thank you.