- Home /
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:
There are several things wrong with this picture:
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.
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!
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 :\
I'm an idiot. #1 was caused because THE VARIABLES AREN'T PUBLIC.
I need a beer.
Answer by tigertrussell · Aug 15, 2013 at 10:22 PM
1: Variables are not public.
2: Do not extend MonoBehaviour in SpellingBeeWord.
Your answer
Follow this Question
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