- Home /
Array of structures not viewable in inspector
Hi, I have a structure which contain arrays:
public struct myStructure
{
public Vector3 vertex;
public Color[] firstColour;
public Color[] secondColour;
public float[] blendTime;
}
I am then creating an array of these structures. The issue I'm having, is that the vertex, firstColour, secondColour and blendTime variables aren't viewable in the inspector, I assume because I haven't defined there size, which I do later in the code (as far as I am aware I can't declare the size of the arrays when I declare the structure?).
So is there any way to make these variables viewable in the inspector? Thanks
Answer by Eric5h5 · Oct 12, 2011 at 11:12 AM
That should be a class, not a struct. Also, http://unity3d.com/support/documentation/ScriptReference/Serializable.html
Thanks for the response - can I ask why it should be a class?
Thanks very much!
http://discuss.joelonsoftware.com/default.asp?dotnet.12.489354.15 Some of the more pertinent points: "16 bytes or less" (for a struct), "if it acts like an int, make it a struct". It's not always 100% obvious at first which to use, but when you're using arrays as elements, that's clearly a class and not a struct.