Due to script interoperability problems, the entire project is being converted over to C#. But we ran into a problem with one of the scripts. We’re using builtin arrays so that they are accessible in the editor.
Really simple code to reset to the end of a builtin array. chassisType is the pointer for the array chasses. (During update, if the value changed, it grabs the game object at chasses[chassisType] )
if(chassisType < 0)
chassisType = chasses.length-1;
But, this throws an error when compiling in C#. The .length property no longer works.
The alternative is:
private const int CHASSES_LENGTH = 5;
public GameObject[] chasses = new GameObject[CHASSES_LENGTH];
. . .
if(chassisType < 0)
chassisType = CHASSES_LENGTH -1;
However, if the array length is changed in the editor, the entire thing falls apart.
Is .length really not implemented in C#? Is there a reason?