- Home /
BCE0023: No appropriate version of 'UnityEngine.GUI.Button' for the argument list '(UnityEngine.Rect, int)' was found.
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
I highly recommend always na$$anonymous$$g variables with camelCase, and classes/types with PascalCase.
if (GUI.Button(Rect(20,35,50,30), CameraView.ToString()))
Answer by flaviusxvii · Dec 18, 2013 at 05:40 PM
http://docs.unity3d.com/Documentation/ScriptReference/GUI.Button.html
The error message is telling you that there is no version of Button that takes a Rect and an int. See the link for a list of allowed arguments.
Your answer

Follow this Question
Related Questions
How To Make A Floating Health Bar 1 Answer
picture in picture 3d. 0 Answers
Runescape style window? 1 Answer
Gui object to mouse position 1 Answer