I am trying to switch camera when a button is pressed
Here is my code
var Main_Camera : Camera;
var Main_Camera_2 : Camera;
var Main_Camera_3 : Camera;
var Main_Camera_4 : Camera;
var Main_Camera_5 : Camera;
public var CameraView = 1;
public var Speed = 0;
var updateInterval = 1.0;
private var accum = 0.0; // FPS accumulated over the interval
private var frames = 0; // Frames drawn over the interval
private var timeleft : float; // Left time for current interval
private var fps = 15.0; // Current FPS
private var lastSample : double;
private var gotIntervals = 0;
function Start()
{
}
function Update()
{
Speed = rigidbody.velocity.magnitude * 2.237;
}
function OnGUI()
{
GUI.Box(new Rect(Screen.width-160, 10, 150, 27), "Speed : " + Speed + ": MPH");
if (GUI.Button(Rect(20,35,50,30), CameraView))
if(CameraView < 5) CameraView++;
else CameraView = 1;
}
if( CameraView == 1){
Main_Camera.enabled = true;
Main_Camera_2.enabled = false;
Main_Camera_3.enabled = false;
Main_Camera_4.enabled = false;
Main_Camera_5.enabled = false;
}
else if ( CameraView == 2) {
Main_Camera.enabled = false;
Main_Camera_2.enabled = true;
Main_Camera_3.enabled = false;
Main_Camera_4.enabled = false;
Main_Camera_5.enabled = false;
}
else if ( CameraView == 3){
Main_Camera.enabled = false;
Main_Camera_2.enabled = false;
Main_Camera_3.enabled = true;
Main_Camera_4.enabled = false;
Main_Camera_5.enabled = false;
}
else if ( CameraView == 4){
Main_Camera.enabled = false;
Main_Camera_2.enabled = false;
Main_Camera_3.enabled = false;
Main_Camera_4.enabled = true;
Main_Camera_5.enabled = false;
}
else if ( CameraView == 5){
Main_Camera.enabled = false;
Main_Camera_2.enabled = false;
Main_Camera_3.enabled = false;
Main_Camera_4.enabled = false;
Main_Camera_5.enabled = true;
}
(dont mind some of the variables theyre there for something else)
I have attached the cameras and everything and it should working but when I try to get the button to display Camera View variable I get
“BCE0023: No appropriate version of ‘UnityEngine.GUI.Button’ for the argument list ‘(UnityEngine.Rect, int)’ was found.”
Its probably something simple but if anyone knows what the problem is please answer
Thank you