Little Problem with GUI

Hey guys, i get a problem with this part of code (I know its this part because when i take it out it works fine)
The problem is that in this GUI, the button doesnt appear untill i hover over it or click on it, im following the tower defense tutorial from cgcookie and am on tutorial 3B (Here is the link):
http://cgcookie.com/unity/2012/08/27/unity-tower-defense-tutorial-part-03b-turret-placement/

Please help. Here is the code:

#pragma strict

//NGUI Items
var buildPanelOpen : boolean = false;
var buildPanelTweener : TweenPosition;
var buildPanelArrowTweener : TweenRotation;

// Placement Plane Items
var placementPlanesRoot : Transform;
var hoverMat : Material;
var placementLayerMask : LayerMask;
private var originalMat : Material;
private var lastHitObj : GameObject;

//Build Selection Items
var onColor : Color;
var offColor : Color;
var allStructures : GameObject[];
var buildBtnGraphics : UISlicedSprite[];
private var structureIndex : int = 0;

function Start()
{
	//Refresh the GUI
	structureIndex = 0;
	UpdateGUI();
}

function Update()
{
if(buildPanelOpen)
{
	var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	var hit : RaycastHit;
	if(Physics.Raycast(ray, hit, 1000, placementLayerMask))
	{
		if(lastHitObj)//if prev hit object
		{
			lastHitObj.renderer.material = originalMat; //Visually Deselect that object
		}
		
		lastHitObj = hit.collider.gameObject;
		originalMat = lastHitObj.renderer.material;
		lastHitObj.renderer.material = hoverMat;
	}
	else
	{
		if(lastHitObj)
		{
			lastHitObj.renderer.material = originalMat;
			lastHitObj = null;
		}
	}
	
	if(Input.GetMouseButtonDown(0) lastHitObj)
	{
		if(lastHitObj.tag == "PlacementPlane_Open")
		{
			var newStructure : GameObject = Instantiate(allStructures[structureIndex], lastHitObj.transform.position, Quaternion.identity);
			newStructure. transform.localEulerAngles.y = (Random.Range(0,360));
			lastHitObj.tag = "PlacementPlane_Taken";
		}
	}
}
}

function UpdateGUI()
{
	//Set the buttons to "off"
	for(var theBtnGraphic : UISlicedSprite in buildBtnGraphics)
	{
		theBtnGraphic.color = offColor;
	}
	
	//Set the selected build button to "on"
	buildBtnGraphics[structureIndex].color = onColor;
}

function SetBuildChoice(btnObj : GameObject)
{
	var btnName : String = btnObj.name;
	
	if(btnName == "Btn_Cannon")
	{
		structureIndex = 0;
	}
//	if(btnName == "Btn_Missile")
//	{
//		structureIndex = 0;
//	}
//	if(btnName == "Btn_Mine")
//	{
//		structureIndex = 0;
//	}
	
	UpdateGUI();
}

//When the build panel arrow is clicked
function ToggleBuildPanel()
{
	if(buildPanelOpen)
	{
		//hide the tiles
		for(var thePlane : Transform in placementPlanesRoot)
		{
			thePlane.gameObject.renderer.enabled = false;
		}
		
		//Bring the panel out
		buildPanelTweener.Play(false);
		//Rotate the arrow
		buildPanelArrowTweener.Play(false);
		//Mark panel as closed
		buildPanelOpen = false;
	}
	else //the build panel was close, so do this...
	{
		//show the tiles
		for(var thePlane : Transform in placementPlanesRoot)
		{
			thePlane.gameObject.renderer.enabled = true;
		}
		//Bring the panel in
		buildPanelTweener.Play(true);
		//Rotate the arrow
		buildPanelArrowTweener.Play(true);
		//Mark panel as open
		buildPanelOpen = true;
	}
}

BUMP, please? I just wanted to bump before i go to sleep

u need to link the original tutorial. Other than that it just looks like it turns off all the graphics then turns on the 1 that is active.

I believe that your problem is in the way your getting structureIndex, not this part.

Ok, edited the main post with the full script and the link to the tutorial.

UpdateGUI appears to be called in Start, and could be called in SetBuildChoice, but nothing calls SetBuildChoice.

UpdateGUI is called in Start and in SetBuildChoice, Nothing is calling SetBuildChoice but it is calling the index from it.

yes, but nothing ever calls SetBuildChoice, therefore the index is never being set.

There is actually some confusion in the script. you have a “layer” of tools, and you can click on them, then you have a gui layer of tools. very confusing.

Haha, it is confusing, but it is what he types out in the tutorial, But i dont know how to fix this problem :frowning:

How do i fix this? Or is everything there right or something?