Hello everyone,
I have this problem. I want to draw text characters and symbols with debug lines. Therefore I store Vector jagged arrays that represent the shape of the text characters and shapes in a class. In my class it looks like this:
public Vector3[][] char_a = { new Vector3[] { new Vector2(0.723f, 0.165f), new Vector2(0.539f, 0.035f), new Vector2(0.263f, 0.037f), new Vector2(0.173f, 0.1421f), new Vector2(0.1761f, 0.2576f), new Vector2(0.3387f, 0.3954f), new Vector2(0.5582f, 0.4002f), new Vector2(0.7232f, 0.3654f) }, new Vector3[] { new Vector2(0.25f, 0.641f), new Vector2(0.397f, 0.698f), new Vector2(0.586f, 0.697f), new Vector2(0.724f, 0.579f), new Vector2(0.724f, 0.044f), new Vector2(0.84f, 0.044f) } };
public Vector3[][] char_b = { new Vector3[] { new Vector2(0.225f, 0.256f), new Vector2(0.458f, 0.035f), new Vector2(0.644f, 0.037f), new Vector2(0.795f, 0.1421f), new Vector2(0.873f, 0.289f), new Vector2(0.875f, 0.438f), new Vector2(0.791f, 0.583f), new Vector2(0.651f, 0.692f), new Vector2(0.465f, 0.692f), new Vector2(0.226f, 0.481f) }, new Vector3[] { new Vector2(0.1f, 0.972f), new Vector2(0.23f, 0.966f), new Vector2(0.227f, 0.042f), new Vector2(0.122f, 0.043f) } };
public Vector3[][] char_c = { new Vector3[] { new Vector2(0.877f, 0.158f), new Vector2(0.653f, 0.035f), new Vector2(0.425f, 0.037f), new Vector2(0.265f, 0.147f), new Vector2(0.1991f, 0.289f), new Vector2(0.2052f, 0.438f), new Vector2(0.279f, 0.595f), new Vector2(0.4362f, 0.692f), new Vector2(0.6296f, 0.692f), new Vector2(0.7598f, 0.6229f), new Vector2(0.8288f, 0.511f), new Vector2(0.826f, 0.6743f) } };
This is only a small fraction of all Vector3 jagged arrays, I have more than 100 symbols, and each of them has a Vector3[ ][ ] line that defines it.
Now there is sometimes the problem that I cannot enter playmode because the class that holds the vector arrays has a stack overflow in its constructor. I think the vector array initialization is automatically moved to the constructor and all the jagged arrays with the vectors fill up the stack ultimately leading to the stack overflow.
How can I get around this? Is there a way to have so much data accessible in a script without reaching the stack overflow limit?
(by the way: The error only happens on Mac machines, not on PC)