error with GUI in c sharp

GUI.Box(new Rect(10.0, 10.0, Screen.width * (2.5/6.55), Screen.height * (1.0/6.3)),"Welcome "+ loginArray[1]); it shows error CS1502: The best overloaded method match for `UnityEngine.Rect.Rect(float, float, float, float)' has some invalid arguments

error CS1503: Argument `#3' cannot convert`double' expression to type `float' error CS1502: The best overloaded method match for`UnityEngine.GUI.Box(UnityEngine.Rect, string)' has some invalid arguments error CS1503: Argument `#1' cannot convert`object' expression to type `UnityEngine.Rect'

errors help me sort out this

@umerslilla , You havent defined the renderer property; you need to use GetComponent. declare a Gameobject[] egg; define a public Renderer ren; And in the Start method ren = egg[0].GetComponent();

2 Answers

2

The problem is you're giving the function doubles instead of floats

Change all the 10.0 etc values to 10.0f and it should work

thanks!!!!!!!!!

public void OnGUI () {
GUI.Box (new Rect (0, 0, 250, 50), maxSpeed);
transform.Translate(0,0,maxSpeed * Time.deltaTime);

	}