x


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

more ▼

asked Feb 27 '11 at 06:46 AM

unitydev0008 gravatar image

unitydev0008
162 14 14 22

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
  1. Check that your Array is public and non-static.
  2. Place the [System.Serializable] attribute before the arrayed class declaration
  3. 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
}
more ▼

answered Feb 27 '11 at 08:42 AM

Izitmee gravatar image

Izitmee
1.6k 23 28 45

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!

Feb 27 '11 at 10:30 PM unitydev0008

Thank you, my mistake was the third step.

Mar 15 '13 at 01:29 PM Real Multimidias
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1888
x692
x198

asked: Feb 27 '11 at 06:46 AM

Seen: 2927 times

Last Updated: Mar 15 '13 at 01:29 PM