- Home /
Re Enable C# script on camera
Hi there all would appreciate some insight. I have a 2 transform scripts i need to apply however one always obstructs the other. so i want have a button to turn one off when i want to use the other and reactivate it when im done. I have searched for hours to an answer unfortunately only finding work arounds such as parenting which are not useful in my case as the script is on a camera. I have moved the c# script to standard assets so javascript finds it.
var script : TouchOrbit = GetComponent(TouchOrbit);
function OnGUI() {
if (GUI.Button(Rect(360,50,50,30),"On"))
script.enabled = false;
}
I would like an on/off button ideally but even making a second button with scribt.enabled = true doesnt work. Unfortunately once i disable the script i can't re-enable it. I have also tried active instead of enable but that disables the whole camera. really appreciate some help in this matter
Answer by darthbator · May 24, 2013 at 04:16 PM
Place the script doing the activation on another object. Separate out that functionality. You can't have a disabled script re enable itself. The scipt is not executing. Hold the script functions on the buttons themselves and then contact the script remotely with GetComponent to enable or disable it.
Your answer
Follow this Question
Related Questions
Enable/Disable GameObject Button script 1 Answer
disable/enable script js 2 Answers
Gui.Enable transperancy 4 Answers
enable disable variable of a script from another script 4 Answers
Disable script from code 5 Answers