UnityEngine.Rect' does not have a visible constructor that matches the....

So I am trying to make a stamina, Health, and Mana bar but when I save the script it says “UnityEngine.Rect ’ does not have a visible consturctor that matches the…” can someone help me in finding the problem because I cant find it. The errors are on 29,21 and I’m using a Javascript.

simple syntax error, in the bottom 3 you are including the string in the rect constructor. place a ) after the 20’s and remove one from the right end of each.


Rect has a Constructor that takes 4 parameters. ( see Rect Constructor for more information)
in your code you give too many parameters to the Rect Constructor.

your code:

Gui.Box(new Rect(45,30, barLength,20,currentHealth.ToString("0")+"/"+maxHealth));

the fix is simple. all you need to do is remove one parameter. i guess this is what you wanted to do:

Gui.Box(new Rect(45,30, barLength,20),currentHealth.ToString("0")+"/"+maxHealth);

notice that the Rect constructor now takes 4 parameters