Please help-me

this javascript is correct ? The unity says no.

#pragma strict
var PosiX :float;
var PosiY :float;
var altur :float;
var largu :float;

function Start () {

altur = 50;
largu = 50;
PosiX = Screen.width -50 ;
PosiY = Screen.height 30 ;

}

function Update ()
{

}

function OnGui () {
if(GUI.Button(Rect(PosiX,PosiY,altur,largu),“”)){

Application.LoadLevel(“Loja”);
}

}

It’s helpful to use the code format:

#pragma strict
var PosiX :float;
var PosiY :float;
var altur :float;
var largu :float;

function Start () {
  altur = 50;
  largu = 50;
  PosiX = Screen.width -50 ;
  PosiY = Screen.height 30 ;
}

function Update ()
{

}

function OnGui () {
  if(GUI.Button(Rect(PosiX,PosiY,altur,largu),"")) {
    Application.LoadLevel("Loja");
  }
}

Any chance you are using JavaScript in Visual Studio and not in Mono Develop or a JavaScript IDE?

1 Like

This line for sure won’t compile:

PosiY = Screen.height 30 ;

probably meant to be

PosiY = Screen.height - 30 ;

1 Like