Hello, i need help with this code, it is a simple code that receive the vars cut and objeto from other script, and put a gui on the screen position equivalent to object position.
this part works well, but the part that calculate the gui width and height based on text is giving me a lot of trouble. Im trying to fix this for hours now but every time i solve a error 3 new errors appear. it looks like it is a simple problem, but i dont get what is wrong.
code:
#pragma strict
static var cut = false;
static var objeto : GameObject;
private var myStyle : GUIStyle;
function Start () {
myStyle = new GUIStyle;
}
function Update () {
}
function OnGUI(){
if(cut == true){
var pos2 = Camera.main.WorldToScreenPoint(objeto.transform.position);
var guipos = GUIUtility.ScreenToGUIPoint(new Vector2(pos2.x,pos2.y));
var cont = new GUIContent("Click to Chop Down");
var f1 = 50;
var f2 = 1000;
var width = myStyle.CalcMinMaxWidth(cont,f1,f2);
var height = myStyle.CalcHeight(cont,width);
GUI.Box(Rect(guipos.x,guipos.y,height,width),"Click to Chop Down");
}
}
errors:
Assets/CameraGui.js(20,96): BCE0044: expecting ), found ‘50’.
Assets/CameraGui.js(20,98): BCE0043: Unexpected token: ,.
Assets/CameraGui.js(20,103): UCE0001: ‘;’ expected. Insert a semicolon at the end.
Assets/CameraGui.js(20,104): BCE0043: Unexpected token: 1000.
Please help,
Thanks