ngui health bar, vital bar
Unity3D 2012. 8. 8. 21:21http://www.youtube.com/watch?v=h0x5196mWlk
using UnityEngine;
using System.Collections;
public class VitalBar : MonoBehaviour {
private UISlider _slider;
private float _maxWidth;
public float health = 1f;
void Awake() {
_slider = GetComponent<UISlider>();
if(_slider==null)
{
Debug.LogError("Could not find the UISlider Component!");
return;
}
_maxWidth = _slider.foreground.localScale.x;
Debug.Log(_maxWidth);
}
void Update(){
UpdateDisplay(health);
}
public void UpdateDisplay(float x){
_slider.foreground.localScale = new Vector3(_maxWidth*x,_slider.foreground.localScale.y, _slider.foreground.localScale.z);
}
}
'Unity3D' 카테고리의 다른 글
Asset Store구입해서 다운받은 패키지들은 어디있는것인가. (0) | 2012.08.10 |
---|---|
10.7: Un-hide the User Library folder (0) | 2012.08.10 |
NGUI VS. EZGUI (0) | 2012.08.08 |
Tater's Weapon Load Out (0) | 2012.08.08 |
EZGUI (0) | 2012.08.06 |