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

unitydev0008 gravatar image

unitydev0008
162 38 28 36

(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, 2011 at 08:42 AM

Izitmee gravatar image

Izitmee
1.7k 61 54 76

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 at 11:46 AM konsnos
(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:

x2103
x765
x223

asked: Feb 27, 2011 at 06:46 AM

Seen: 3443 times

Last Updated: Jun 26 at 11:46 AM