- 最后登录
- 2013-9-29
- 注册时间
- 2012-8-20
- 阅读权限
- 90
- 积分
- 6371
- 纳金币
- 6372
- 精华
- 0
|
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.}
|
|