- Home /
Question by
benjimazza · Mar 22, 2012 at 09:09 PM ·
howto
Activating the camera with a toggle button
Okay all i want is that when i hit the toggle button a camera activates, when i untick the toggle button, it deactivates the camera here is the code i tryed ?
var camera: Transform;
var showMap = false;
var xAxis : int;
var yAxis : int;
function Start()
{
camera.enabled = false; // hide it
}
function OnGUI()
{
showMap = (GUI.Toggle (Rect (xAxis, yAxis, 100, 20), showMap, "Map"));
camera.enabled = showMap;
}
Thanks
Comment
Answer by FLASHDENMARK · Mar 22, 2012 at 09:19 PM
var cam : Camera;
var showMap = false;
var xAxis : int;
var yAxis : int;
function Start()
{
cam.enabled = false; // hide it
}
function OnGUI(){
showMap = GUI.Toggle(Rect(xAxis, yAxis, 100, 20), showMap, "Map");
cam.enabled = showMap;
}
There you go.
Be careful naming a variable as e.g Camera or anything that is predefined in Unity. It can cause some problems.
Your answer
Follow this Question
Related Questions
Animation Help!!!!! 1 Answer
Animation stoping!! 1 Answer
Randomize health loss 1 Answer
Collider Animation 1 Answer