- Home /
Error: Expression denotes a `X', where a `Y' was expected
Hello,
I don´t understand why these erros are comming up. Is the last code line.
-->(39,49): error CS0119: Expression denotes a type', where a
variable', value' or
method group' was expected
-->(39,31): error CS1502: The best overloaded method match for UnityEngine.GUI.HorizontalSlider(UnityEngine.Rect, float, float, float)' has some invalid arguments -->(39,31): error CS1503: Argument
#1' cannot convert object' expression to type
UnityEngine.Rect'
I am a newbie, so please answer with some explanation and code or I will not understand, thank you.
using UnityEngine;
using System.Collections;
public class BotonesMenu : MonoBehaviour {
public float puntMax;
float velChange;
// Use this for initialization
void Start () {
puntMax = 2000.0f;
}
// Update is called once per frame
void Update () {
}
void OnGUI () {
// Make a background box
GUI.Box(new Rect(Screen.width/2 - 150,10,300,300), "Menu");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if(GUI.Button(new Rect(Screen.width/2 - 40,40,80,20), "1 jugador")) {
Application.LoadLevel("PrimerEscenario-GuardadoManualmente");
}
// Make the second button.
if(GUI.Button(new Rect(Screen.width/2 - 40,70,80,20), "2 jugadores")) {
Application.LoadLevel(2);
}
GUI.Label (new Rect (Screen.width / 2 - 30, 120, 60, 20), "Opciones");
GUI.Label (new Rect (Screen.width / 2 - 90, 150, 180, 30), "Puntuacion para ganar: "+puntMax);
puntMax = GUI.HorizontalSlider (Rect(Screen.width / 2 - 100, 175, 200, 10), puntMax, 0, 50000);
}
}
Answer by ahaykal · Jan 17, 2014 at 10:18 AM
You should change :
puntMax = GUI.HorizontalSlider (Rect(Screen.width / 2 - 100, 175, 200, 10), puntMax, 0, 50000);
To this :
puntMax = GUI.HorizontalSlider (new Rect(Screen.width / 2 - 100, 175, 200, 10), puntMax, 0, 50000);
you should put "new" before Rect in c#
thank you very much, I was getting crazy... and mixing C# and JS I make failures like this... I will pay attention more often to this things... Thank you!!
I'm glad it helped. Could you please accept it as an answer
How do I do that?? Sorry I am new :-)
(the tick is already green and when I click on it this appears: You don't have permission to do this action. Please Login as another user )