- Home /
Toggle script with button
Trying to TOGGLE between two scripts using a button, but any reference to the script gives me error, same with "enable". is enabled wrong?
public myScript script1;
public myScriptTwo script2;
void Start(){
script1 = GetComponent<myScript>();
script2 = GetComponent<myScriptTwo>();
}
void Update(){
if(Input.GetButtonDown("Whatever")){
script1.enabled = true;
script2.enabled = false;
}
else
if(Input.GetButtonUp("Whatever")){
script1.enabled = false;
script2.enabled = true;
}
}
}
I was gonna do that, but its not really a console error, weirdly nothing shows up in console but looking at the script on the inspector, (in a box) it says "Script cannot be loaded. please fix compile errors". Which I assume is everything marked red. "Enabled" "myScript""myscriptTwo" are marked red.
Do you have 2 scripts actually called myScript and myScriptTwo?
haha no I don't, I wrote those in there just for this Question. BUT problem solved, I pasted the broken script here, seen an error, fixed it and didn't change my own script after lol. Sorry guys. problem solved.... dumb mistake like I said.
Your answer
Follow this Question
Related Questions
how do i toggle image effects on my camera with a script 1 Answer
Enabled not working on Mac 2 Answers
How do I enable my scripts on default?? 3 Answers
Please Help!!! Enable/Disable Script!!! 3 Answers
How to change Toggle Text using C#? 2 Answers