- Home /
Question by
unitydev0008 · Feb 27, 2011 at 06:46 AM ·
arrayinspectormonobehaviour
Display Non Monobehaviour array in inspector C#
Topic pretty much says it all, I have a Monobehaviour script with a array of a class i created that does not inherit from monobehaviour and the array is not showing up in the inspector.
Anyone know why or how to fix this?
Thanks in advanced
Comment
Best Answer
Answer by Demigiant · Feb 27, 2011 at 08:42 AM
- Check that your Array is public and non-static.
- Place the
[System.Serializable]
attribute before the arrayed class declaration - If your arrayed class inherits from Object, don't write it (that is: "
public class MyClass:Object
" is wrong, "public class MyClass
" is right). Don't know exactly why, but I had the same issue, and finally realized that removing the Object inheritance made my class being serialized (I was using a List instead of an Array, but I suppose it's the same).
Sample serialized Class:
[System.Serializable]
public class MyClass
{
// Class stuff
}
Thanks a ton for this! I did read about the System.Serialiable but i was putting it on the wrong script lol thanks again man!
3rd step was my solution too. Had a problem with Instantiate but seems to be a static function so no problem fixing that :)