- Home /
Public variable not appearing in the inspector (C#)
Why isn't this public variable being showed in the inspector?
 public class controleInventario : MonoBehaviour {
     
     [System.Serializable]
     public class Configuracoes {
         
         public int Espacamento;
         public Vector2 posicaoNaTela;
         public int Altura, Largura;
         public int larguraIcone, alturaIcone;
         public int Linhas, Colunas;
         
         [HideInInspector]
         public Rect retanguloFinal;
         
     }
     
     [System.Serializable]
     public class icones {
         
         public Texture2D Nulo = null;
         public Texture2D Machado;
         public Texture2D Espada;
         public Texture2D Amuleto;
         
     }
     
     [System.Serializable]
     public class objetos {
         
         public GameObject Nulo = null;
         public GameObject Machado;
         public GameObject Espada;
         public GameObject Amuleto;
         
     }
     
     public Configuracoes configInventario;
     public icones Icones;
     public objetos Objetos;
     public slot[] Slots; // THIS ONE!
     
     public bool inventarioAberto;
     public KeyCode teclaDeAbertura;
[...]
And here's the slot class:
 public class slot {
 
         public int itemID;
         public Texture2D representacaoGrafica;
         public GameObject objetoReferente;
         public int quantidadeNesteSlot;
         public Rect Posicao;
         public bool emUso;
 
 }
Here's the image that show the variable not being displayed:
Can someone explain me this? Thanks from now!
Does it work if you change slot to public class slot : System.ValueType { ? What I can think of is that the editor might not serialise a class unless it is a struct (`System.ValueType`). Just a theory though.
It gave me an error saying that slot can not derive from Special Class System.ValueType. When I tried to create an public array of type 'icones' it works and it appear in the inspector. The problem seems to be just with 'slot' class.
Answer by GutoThomas · May 01, 2012 at 10:56 PM
Sorry everyone!
That was a totally newbie part of me because I didn't set slot to a serializableAttribute.
Now it's working. So obvious... Sorry again!
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                