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?
ok i have found the error and i fixed it. Thanks C:
– CraxAgreed that the line where the code is throwing the error would be very helpful.
– Glister