纳金网
标题:
unity3d 血条制作
[打印本页]
作者:
yeu1233
时间:
2012-8-24 17:26
标题:
unity3d 血条制作
1.using UnityEngine;
2.using System.Collections;
3.
4.public class BloodBarTest : MonoBehaviour {
5.
6. public GUISkin theSkin;
7. public float bloodValue = 0.0f;
8. private float tmpValue;
9. private Rect rctBloodBar;
10. private Rect rctUpButton;
11. private Rect rctDownButton;
12. private bool onoff;
13.
14. // Use this for initialization
15. void Start () {
16. rctBloodBar = new Rect (20,20,20,200);
17. rctUpButton = new Rect (50,20,40,20);
18. rctDownButton = new Rect (50,50,40,20);
19. tmpValue = bloodValue;
20. }
21.
22. void OnGUI (){
23. GUI.skin = theSkin;
24. if (GUI.Button (rctUpButton,"加血")){
25. tmpValue = -1.0f;
26. }
27. if (GUI.Button (rctDownButton,"减血")){
28. tmpValue += 0.1f;
29. }
30. if (bloodValue > 0.0f) tmpValue = 0.0f;
31. if (bloodValue < -1.0f) tmpValue = -1.0f;
32. bloodValue = Mathf.Lerp(bloodValue,tmpValue,0.05f);
33. //~ Debug.Log (bloodValue + " " + tmpValue);
34. GUI.VerticalScrollbar(rctBloodBar, 1.0f, bloodValue,0.0f, 1.0f,GUI.skin.GetStyle("verticalScrollbar"));
35. }
36.
37. // Update is called once per frame
38. void Update () {
39.
40. }
41.}
欢迎光临 纳金网 (http://rs.narkii.com/club/)
Powered by Discuz! X2.5