- Home /
Question by
benfattino · Jul 09, 2011 at 07:40 PM ·
button
Script button.
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;
}
}
Comment
@benfattino Do you get any errors in the error console?
wire.active
is set to false
in both GUI.Button()
calls.
Best Answer
Answer by Dreamblur · Jul 09, 2011 at 10:18 PM
"active" is not a member of MonoBehaviour. Use "enabled". Change the type declaration of "wire" to your script's class.
Your answer
![](https://koobas.hobune.stream/wayback/20220612140116im_/https://answers.unity.com/themes/thub/images/avi.jpg)