• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
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

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Demigiant · Feb 27, 2011 at 08:42 AM

  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
}

Comment
unitydev0008
amd2002a
Tsilliev
Tom-Kazansky
DivainUnity
onetimepad
dero273

People who like this

7 Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unitydev0008 · Feb 27, 2011 at 10:30 PM 0
Share

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!

avatar image Real Multimidias · Mar 15, 2013 at 01:29 PM 0
Share

Thank you, my mistake was the third step.

avatar image konsnos · Jun 26, 2014 at 11:46 AM 0
Share

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

avatar image Tsilliev · Jun 11, 2015 at 07:10 PM 0
Share

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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How to place a non monobehaviour script into an array in inspector 1 Answer

Edit array element properties in editor 0 Answers

Calling MonoBehaviour's Reset() method 0 Answers

Renaming Inspector 2D Array Element 0 , Element 1 1 Answer

NullRefenceException Using Arrays 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges