- Home /
Question by
Eduardoxyz · Feb 20, 2013 at 10:51 PM ·
errorcs1061
CS 1501 and 1061 appear and says No overload for method `Box' takes `1' arguments
UnityEngine.Rect' does not contain a definition for curHealth' and no extension method
curHealth' of type `UnityEngine.Rect' could be found
Also appears and i need help on this.
using UnityEngine; using System.Collections;
public class HealthBar : MonoBehaviour { public int maxHealth = 100; public int curHealth = 100; public float healthBarLength;
// Use this for initialization
void Start () {
healthBarLength = Screen.width / 2;
}
// Update is called once per frame
void Update () {
AdjustCurrentHealth(0);
}
void OnGUI() {
GUI.Box(new Rect (10, 10, healthBarLength, 20 ). curHealth + "/" + maxHealth);
}
public void AdjustCurrentHealth(int adj) {
curHealth += adj;
healthBarLength = (Screen.width / 2 ) * (curHealth / (float)maxHealth);
}
}
Comment
Answer by EliteMossy · Feb 21, 2013 at 12:10 AM
It should be
GUI.Box(new Rect (10, 10, healthBarLength, 20 ), curHealth + "/" + maxHealth);
You put a . not a ,
What was happening is that it thought you were looking for new Rect(x,x,x,x).curHealth which does not exist. Always double check for . or ,
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
"Takes `2' arguments" 2 Answers
Another way to reference scripts? 2 Answers
Scripting error #2! 2 Answers