Hi all.
I'm somewhat new to Unity. Something very strange is happening in my code.
For my game, I need a bunch of pie charts that show the opinions of my simulated population. Each pie chart is made up of a bunch of slices, and one empty object is the parent of them in the hierarchy. I need exactly 8 of these pie charts, and I need access to them in the code, so in one of the classes, I've put:
public GameObject[] pieCharts;
And I initialize it in the editor, by drag and dropping, and not by finding the right tag every time. Now when these charts are being viewed, I need to make them update live. So I've put the code that calls my redraw function in the update, and rigged it, so that while the user is viewing those, every 2 seconds they get redrawn. Here's the strange thing. It works, but it keeps churning out an error:
IndexOutOfRangeException: Array index is out of range.
It's actually talking about this pieCharts array, and when I step through it with the debugger, it looks like the array magically becomes of 0 length every now and then! Again, it does work, but it floods the console with the same error message. I'm really stumped! I have like 100 little circles standing in for the simulated population. Is there a chance too much object is making the array despawn?
↧