- Home /
Why aren't some variables appearing in the Inspector?
I just added a public variable with the type String to a script. However the variable is not appearing in the Inspector. The same goes for other types such as boolean,float,int. Is this a bug or am I doing something wrong?
This is a javascript script
var quitButton: boolean = false;
var normalTexture : Texture2D;
var rollOverTexture : Texture2D;
var levelToLoad : String;
var beep : AudioClip;
I have actually found that the boolean and String will be visible and assignable once I have attached it to an object. I guess the question is solved but I would like to know why the Texture and Audioclip can be assigned even when the script is not attached to any object?
You've probably already done this, but selecting another element in the inspector and then the script that has been edited will generally refresh it.
Other than that, how are the variables being declared? This could possibly be the cause.
Please attach sample code so that we can see if you are doing anything wrong. With just a symptom description, there really is nothing we can do to diagnose it.
and you also probably know this, but static vars and private vars can't be edited in the inspector, as far as i know.
nor can properties or readonly variables (not sure why you would want to display them anyway :) )
Will post the sample code once I get back home, owh n thanks for the comments;
Answer by Mike 3 · Jan 01, 2011 at 09:38 AM
To answer your edit - you can edit the default values in the script for string and boolean, but you can't do the same for audio clip, textures and the like, so unity provides a way to set up default references which will be set when you add the script to a gameobject, just as the default values in the script will be set for booleans and strings