I try to create GUI button that activate/deactivate a script attached to an object.
I try different solution, but I don’t understand where I’m wrong. Somebody help? Thanks.
var solido: GameObject;
var wire: GameObject ;
function Start(){
solido = GameObject.Find("E C Base");
wire = GameObject.Find("Wireframe/L1").GetComponent("C-L1");
solido.renderer.enabled = false;
wire.active = false;
}
function OnGUI () {
if (GUI.Button (new Rect (0, 0, 100, 40), "solido")){
print ("rosso");
solido.renderer.enabled = true;
wire.active = false;
}
if (GUI.Button (new Rect (110, 0, 100, 40), "wire")){
print ("giallo");
solido.renderer.enabled = false;
wire.active= false;
}
}