- Home /
HELP PLEASE
Getting MANY Errors!!! Here they are! BCE0022: Cannot convert 'int' to 'System.Type'. The type 'UnityEngine.Rect' does not have a visible constructor that matches the argument list '(float, System.Type, int, int)'. BCE0051: Operator '-' cannot be used with a left hand side of type 'System.Type' and a right hand side of type 'int'.BCE0051: Operator '+' cannot be used with a left hand side of type 'System.Type' and a right hand side of type 'int'. Here is my code.
#pragma strict
var RedPlayer : GameObject;
var BluePlayer : GameObject;
var CurTeam : String = "";
var SpawnPointRed : GameObject;
var SpawnPointBlue : GameObject;
var CenterW : float;
var CenterH = float;
function Start ()
{
CurTeam = "";
CenterW = Screen.width / 2 - 150;
CenterH = Screen.height / 2 - 80;
}
function OnGUI ()
{
GUI.Box(Rect(CenterW, CenterH, 300, 160), "Select a Team");
if(CurTeam == "")
{
if(GUI.Button(Rect(CenterW + 5, CenterH - 20, 290, 65),"Red Team"))
{
}
if(GUI.Button(Rect(CenterW + 5, CenterH + 120, 290, 65),"Blue Team"))
{
}
}
else
{
if(GUI.Button(Rect(CenterW + 5, CenterH + 20, 290, 130),"Respawn"))
{
}
}
}
STOP TAGGING POSTS WITH "JAVA". It's javascript. JAVASCRIPT. I repeat JAVASCRIPT!
Also, it is better to refer to it as UnityScript. It isn't even Javascript. Also, please be more respectful and think of a better title than 'HELP PLEASE'. This is frowned upon as it doesn't help anyone figure out what might be in your question, aside from it being obnoxious. Oh and welcome to Unity Answers ;)
Usually we are not that pedantic about that, but since Java is something completely different from JavaScript or UnityScript it does matter. Especially if you develop for Android you can use real Java classes, that's why it's important to distinguish Java from JavaScript.
It's referring to the line starting at number 14. I haven't figured out what it means, but I do know that line 14 is causing it (that entire function). Apparently using the screen's dimentions is counted as a float. $$anonymous$$y code is "childsPlay.guiTexture.pixelInset = Rect((Screen.width * -0.39), (Screen.height - Screen.height / 0.75));" and is recieving a similar error. childsPlay is a texture that I'm trying to place on the screen with support for different types of screens. Otherwise, the textures will float off. I've already used this method for GUITexts, and no problem. But when I try to use the methods for images, it gets reeeal sketchy.
Answer by Bunny83 · Feb 17, 2013 at 02:32 AM
Instead of:
var CenterH = float;
you need:
var CenterH : float;
Your answer
![](https://koobas.hobune.stream/wayback/20220613092830im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Javascript Snakegame Error Cannot convert ....Gameobject to .....Transform 1 Answer
BCE0043: Unexpected token: }. 1 Answer
Uploading webgl version of the game error 1 Answer
JScript problem 1 Answer
Weird error every frame 1 Answer