Javascript variables not being called up in the inspector???

Hey all,

So I was working on some of the tutorials in the book “Unity Game Development Essentials” by Will Goldstone and for some reason the variables in one of the GUI scripts won’t show up in the inspector…HELP!

Here’s the code:

static var charge : int = 0

var charge1tex : Texture2D;
var charge2tex : Texture2D;
var charge3tex : Texture2D;
var charge4tex : Texture2D; 
var charge0tex : Texture2D;

function Start(){
	guiTexture.enabled = false;
	charge = 0;
}

function Update () {
	if(charge == 1){
		guiTexture.texture = charge1tex;
		guiTexture.enabled = true;
	}
	else if(charge == 2){
		guiTexture.texture = charge2tex;
	}
	else if(charge == 3){
		guiTexture.texture = charge3tex;
	}
	else if(charge == 4){
		guiTexture.texture = charge4tex;
	}
	else{
		guiTexture.texture = charge0tex;
	}
}

I’m using the free version of Unity…not sure if that matters. I’m actually pretty new to coding and have mostly been doing game dev from the art side of things.

Well, it should be working. Make sure it is saved!

Also, try putting public before the variables and see if that makes a difference. EX:

public var moneyIsGood:Int = 4535345;

I was just typing out the same suggestion killer1390 gave you. Ah well! But here are a couple tricks to “refresh” Unity Inspector variables:

  1. open another scene, then reopen this scene. And if that doesn’t do anything,
  2. close and reopen Unity

I fixed it…apparently I was missing some semicolons…

Good.