• 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
1
Question by Balours · Aug 06, 2015 at 11:40 PM · gameobjectclass

Custom class not displayed in the inspector (Serializable)

Hi,

I'm using two customs classes that I want to be displayed in the inspector. I followed a lot of tutorial but it is not working. This tuts from Unity3D (http://docs.unity3d.com/Manual/editor-PropertyDrawers.html) is not working, the examples are wrong. (I'm still not at the propertyDrawers part because I can't manage to display values in the inspector.)

Here are my customs classes:

 using UnityEngine;
 using System;
 
 [Serializable]
 public class Season {
     ESeasons season; //Enum
     Weather[] weathersProb = new Weather[4];
 }
 
 [Serializable]
 public class Weather {
     EWeather weather; //Enum
     int probability;
 }


I think it is simple to understand, is for my configuration file/script where I initialized the seasons like this:

 [Header("Seasons and weather settings")]
 public Season[] seasons;

Here is the result in the inspector: Here is my result:

What I want is something like this: Seasons Size 4 WINTER RAIN 50 SUN 30 SPRING RAIN 70 SUN 30 ...

Where am I wrong ? Thanks for your help !

unityinspector.png (3.0 kB)
Comment
Add comment
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

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by zach-r-d · Aug 06, 2015 at 11:45 PM

The examples were indeed translated into C# incorrectly; fields are private/nonserialized by default, unlike in Unityscript, where they are.

The solution is to make the fields of the Serializable classes public, or mark them with [SerializeField] if you'd prefer they not be public.

Comment
Add comment · Show 1 · 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 Balours · Aug 07, 2015 at 11:30 AM 1
Share

That was simple ... Thanks a lot !

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

SendMessage with class. 0 Answers

Converting a GameObject to a class? 1 Answer

Resource specific class with values 1 Answer

Spawning GameObjects with help of classes --- Attaching classes to GameObjects 1 Answer

Extending MonoBehavior and GameObject? 1 Answer


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