Скрипт на С Sharp Script Делал на MonoDevelop
Буду крайн благодарен за исправленный скрипт!
- Код: Выделить всё
using UnityEngine;
using System.Collections;
public class PlayerHealth : MonoBehaviour {
public int maxHealth = 100;
private int _ourHealth = 100;
private float healthBarLenght;
void Start () {
AddjustCorrentHealth(_curHealth);
HealthBarLenght = Screen.width /2;
_curHealth = maxHealth;
}
void Update () {
AddjustCorrentHealth(_curHealth);
}
void OnGUI () {
GUI.Box(new Rect(10,10,healthBarLenght,20),_curHealth + "/" + maxHealth);
}
public void AddjustCorrentHealth (int adj){
_curHealth = adj;
if(_curHealth<0) _curHealth = 0;
if(_curHealth>maxHealth) _curHealth = maxHealth;
healthBarLenght = (Screen.width /2) * (_curHealth / (float)maxHealth);
}
}
}
ОШИБКИ
- Код: Выделить всё
Assets/PlayerHealth.cs(13,37): error CS0103: The name `_curHealth' does not exist in the current context
Assets/PlayerHealth.cs(13,17): error CS1502: The best overloaded method match for `PlayerHealth.AddjustCorrentHeath(int)' has some invalid arguments
Assets/PlayerHealth.cs(13,17): error CS1503: Argument `#1' cannot convert `object' expression to type `int'
Assets/PlayerHealth.cs(14,17): error CS0103: The name `HealthBarLenght' does not exist in the current context
Assets/PlayerHealth.cs(16,30): error CS0103: The name `maxHeath' does not exist in the current context
Assets/PlayerHealth.cs(16,17): error CS0103: The name `_curHealth' does not exist in the current context