- Home /
BCE0051 Error
I have this code:
#pragma strict
var difficulty:String;
var val1:float = 10;
var val2:float = 10;
var val3:float = 10;
var val4:float = 10;
var customskin:GUISkin;
var stile:GUIStyle;
var banner:Texture2D;
var start:Texture2D;
var options:Texture2D;
var credits:Texture2D;
var diff:String=PlayerPrefs.GetString("difficulty");
enum MainMenu {Main,Options, Credits}
var menu = MainMenu.Main;
function OnGUI () {
GUI.skin=customskin;
switch (MainMenu) {
case MainMenu.Main:
GUI.DrawTexture(Rect(150,55,580,130), banner);
if(GUI.Button(Rect (300, 300, 219, 58), start, "buttonstart" )){
LevelChecker();
}
if(GUI.Button(Rect(300,370,219,58),options, "buttonoptions")){
menu=MainMenu.Options;
}
if(GUI.Button(Rect(300,440,219,58),credits,"buttoncredits")){
menu=MainMenu.Credits;
}
GUI.Label(Rect(750,580,240,20), "©447261676D65746F68656C6C");
break;
case MainMenu.Options:
GUI.DrawTexture(Rect(150,55,580,130), banner);
if (GUI.Button(Rect(300,200,219,58), options, "buttonoptions")){
menu = MainMenu.Main; }
if (GUI.Button(Rect(630,290,130,50), difficulty)){
PlayerPrefs.SetString("difficulty","easy");
difficulty=PlayerPrefs.GetString("difficulty");
if (difficulty=="easy"){
difficulty="hard";
PlayerPrefs.SetString("difficulty", difficulty); }
else if (difficulty=="hard") {
difficulty="fearless";
PlayerPrefs.SetString("difficulty", difficulty); }
else (difficulty=="fearless");
difficulty="easy";
PlayerPrefs.SetString("difficulty", difficulty); }
break;
case MainMenu.Credits:
GUI.skin=customskin;
GUI.Label (Rect(val1,val2,val3,val4), "Testo di prova");
break;
}
}
function LevelChecker () {
if (diff=="easy") {
Application.LoadLevel("nighthouse"); }
else if (diff=="hard") {
Application.LoadLevel("nighthouse"); }
else if (diff=="fearless"){
Application.LoadLevel("nighthouse"); }
}
But in the Console i get this error:
BCE0051: Operator '==' cannot be used with
a left hand side of type 'System.Type' and a right hand side of type 'MainMenu'.
How can i fix it?
Answer by Graham-Dunnett · Apr 16, 2013 at 03:16 PM
So, the error message you get will come with two numbers in brackets. You have chosen to not supply this information, which makes helping you somewhat difficult. The first of these two numbers is the line number that has the problem. With this information you should trivially be able to work out the problem. Double-clicking on the error message in Unity should even open MonoDevelop and position the cursor on the line.
My guess about what your problem is is that your variable menu
does not have a type. You use this somewhere, perhaps in the switch statement, and the compiler doesn't know that menu
is meant to be a MainMenu
.
Agreed that the line where the code is throwing the error would be very helpful.
Your answer
Follow this Question
Related Questions
Enum is thought to be a float? 2 Answers
error BCE0022: Cannot convert error, please help 3 Answers
Enum switch statement error 2 Answers
Enum and Variable with similar name resulting in error 1 Answer
Why can't I use the Asset Store Manager? 0 Answers