- Home /
Array elements are empty in the inspector?
I've stored around a thousand entries in arrays through code in C#. Problem is, when I have entered all of the array elements' values in code they do not show up in the inspector and I'm fairly sure they do not take effect in-game. Is this a Unity bug, or is there a workaround?
You will need to post your code so we can see what is wrong.
Indeed, post the pieces of code, so we can have a look. $$anonymous$$y guess is, you haven't assigned them properly or have re-initialized your arrays somehow after filling them up. If they don't show up, and have no effect in your code, you can be fairly sure, the data is not there.
Answer by asafsitner · Aug 12, 2013 at 06:18 PM
When you compile a component that was already attached to a game object with new default values, they will not be reflected in the inspector since the code was already serialized and saved.
Another option may be an array with types that are not serializable by Unity, thus not showing in the inspector.
Try to reset the component.
As a side question, why did you hardcode a thousand values?
I hardcoded all the values because I'm using the code as a procedural-generator for character bios, and I needed to choose a random one from a list. This seemed to be the simplest way to do so. Anyways, I "solved" the problem by just making the string[]s private rather than public.