Before updating to Windows 10 you may need to return your Pro license. More information here

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, 2011 at 06:46 AM

avatar image

162 39 30 40

(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:

public class MyClass
   // Class stuff
more ▼

answered Feb 27, 2011 at 08:42 AM

avatar image

1.9k 64 56 100

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, 2011 at 10:30 PM unitydev0008

Thank you, my mistake was the third step.

Mar 15, 2013 at 01:29 PM Real Multimidias

3rd step was my solution too. Had a problem with Instantiate but seems to be a static function so no problem fixing that :)

Jun 26, 2014 at 11:46 AM konsnos

"PUBLIC" made the array showable at the inspector, ty

Jun 11 at 07:10 PM Tsilliev
(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



Answers and Comments



asked: Feb 27, 2011 at 06:46 AM

Seen: 4333 times

Last Updated: Jun 11 at 07:10 PM