Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by tigertrussell · Aug 15, 2013 at 10:06 PM · inspectorserializationclass

Inpsector missing variables from a Serializable class?

Hello. I am developing a game where the content is stored as an AudioClip paired to a string. I want to store several "Dictionaries" (meaning a compendium -- not a dictionary data structure), each which have a name and a collection of these words. I would prefer to not have to author my own editor extension for this, as I feel its something well-suited to Unity's built-in inspector features.

Within my Game Manager class, I have the following:

 public class SpellingBeeGameManager : MonoBehaviour {
 
     [System.Serializable]
     public class SpellingBeeDictionary {
         int dictIndex;
         string dictName;
         public SpellingBeeWord[] words;
     }
     public SpellingBeeDictionary[] dictionaries;

And the SpellingBeeWord class is simply:

 [System.Serializable]
 public class SpellingBeeWord : MonoBehaviour {
     public string word;
     public AudioClip wordAloud;
 }

I would expect to be able to modify everything I need to modify from the inspector, yet for some reason I am seeing this:

alt text

There are several things wrong with this picture:

  1. Before the "Words" variable there should be a dictIndex and dictName variable -- they are primitives within a Serializable class, but for some reason they will not show in the editor. If anything, I would have expected the SpellingBeeWord array to not show up.

  2. For some reason, the SpellingBeeWord array is expecting me to give it GameObjects with SpellingBeeWord scripts attached, when SpellingBeeWord is a serializable class. Is there no way for me to be able to drag&drop my audio clips and write the associated string directly into the inspector?

Thanks in advance for any help. And, if you read this and couldn't help, thanks for taking the time to read!

Have a wonderful day!

Comment
Add comment · Show 2
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 tigertrussell · Aug 15, 2013 at 10:20 PM 0
Share

I was able to solve #2 by NOT extending the $$anonymous$$onoBehaviour class on the SpellingBeeWord class. Reference: http://forum.unity3d.com/threads/137465-Exposed-Variable-HELP!!!!

Still can't figure out why the index/name are not showing up in the inspector, though :\

avatar image tigertrussell · Aug 15, 2013 at 10:21 PM 0
Share

I'm an idiot. #1 was caused because THE VARIABLES AREN'T PUBLIC.

I need a beer.

1 Reply

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

Answer by tigertrussell · Aug 15, 2013 at 10:22 PM

1: Variables are not public.

2: Do not extend MonoBehaviour in SpellingBeeWord.

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Serialization - Variables won't change on original construction 1 Answer

to point a selfwritten class in the inspector (drag n drop) 0 Answers

Public Array with a class not showing in Inspcetor 1 Answer

Child Class Inspector Issues 0 Answers

How to show the instance of a class's variables in the inspector. 0 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