Hi, i’m getting some NullReferences erros because my array only initiated when i serialize my class and i did this test on blanks scripts with basic code like
EXAMPLE CODE
[System.Serializable]
public class SomeClass
{
}
[SerializeField] private SomeClass[ ] testArray;
private void Awake()
{
testArray = new SomeClass[10];
}
if i do that works perfectly as expected but when i remove the System.Serializable or the SerializeField or even when i hide my SomeClass from inspector my array don’t initiate BUT if i put the debug to show the testArray
suddenly my array got initiated, this is a Unity bug since i can do this code on compilers and i don’t get any NullReference, so what should i do? just let some class on the inspector since unity have this problem? and again, i already tried this exactly same code on compilers and they instantiate my classes perfectly and this problem don’t happens if i do simple arrays like int[ ] intArray = new int[10] and i was not used to get thoose problems in later versions of Unity, so something changed or my unity is bugged?,
Currently using unity LTS 2019.
Cheers.
EDIT: The fixs codes on the internet made my perfomance drop from 1.200fps to 15fps so i’ll let serialized even without necessity since there’s no other way(Until now).
EDIT02: Fixed restarting Unity and compiling the code again(don’t know how)