I cant seem to figure out how to call the Toggle.isOn. Character walks on object and icon changes from grey to color. I figured this was the isOn command but keep getting.

Assets/personal/changeWeapons.js(52,34): BCE0019: ‘isOn’ is not a member of ‘Object’.

here is the relevant stuff

var ExtinguisherIcon;

ExtinguisherIcon = GameObject.Find("ExtinguisherIcon").GetComponent.<UnityEngine.UI.Toggle>();

ExtinguisherIcon.isOn = true;

Looking on web, I’ve seen several ways people did it but I’m doing something wrong. I may be mixing up C# code with JS (I’ve only been at this a couple weeks). Here is everything on that script just in case that helps. Right now for testing the icon just turns on but i will make it it’s own function after it works.

#pragma strict

var weapons : GameObject[]; // array of weapons
public static var extinguisher = false;
public static var teapot = false; 
public var armGO : GameObject;
var anim: Animation;
private var state = 0;
var ExtinguisherIcon;

function Start(){
	SelectWeapon(0);
	armGO = GameObject.Find("Weapons");
	anim = armGO.GetComponent.<Animation>();
	ExtinguisherIcon = GameObject.Find("ExtinguisherIcon").GetComponent.<UnityEngine.UI.Toggle>();
}

function Update () {
	
	if(Input.GetKeyDown("1"))
	{
		armGO.GetComponent.<Animation>().Play("armDown");
		state = 1;				
	}	
	if(Input.GetKeyDown("2"))
		{
			if(teapot == true)
			{
				armGO.GetComponent.<Animation>().Play("armDown");
				state = 2;		
			}
		}
	if(Input.GetKeyDown("3"))
		{		
			if(extinguisher == true)
			{
				armGO.GetComponent.<Animation>().Play("armDown");
				state = 3;		
			}
		}
		
		if (!anim.IsPlaying("armDown"))
		{
			if(state != 0)
			{
				SelectWeapon(state - 1);
				armGO.GetComponent.<Animation>().Play("armUp");
				state = 0;
			}
		}
		
		ExtinguisherIcon.isOn = true;
		
}

function SelectWeapon(index : int){
	for(var obj:GameObject in weapons)obj.SetActive(false);
	weapons[index].SetActive(true);
}

Thanks for the help.

OK, got an old friend to help with this and he showed me an alternative way to do it. But I am stubborn so I goofed around with my way some more. The first post is garbage, I took all GUI code out of the script to switch items and made a new one to put on Toggle items. Here is what I got to work.

GO = GameObject.Find(name);
GO.GetComponent(UnityEngine.UI.Toggle).isOn = true;

or

GameObject.Find(name).GetComponent(UnityEngine.UI.Toggle).isOn = true;

The GetComponent… = true has to be on one line. Not sure why but this is what worked. Let me know if there is a better way.