GuiExample.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using UnityEngine;
  2. using System.Collections;
  3. public class GuiExample : MonoBehaviour {
  4. public Material[] liquidMaterial;
  5. private GameObject _liquid;
  6. private HTLiquidSpriteSheet liquidSpriteSheet;
  7. void Start(){
  8. _liquid = GameObject.Find("WaterPlane");
  9. liquidSpriteSheet = _liquid.GetComponent<HTLiquidSpriteSheet>();
  10. }
  11. void OnGUI(){
  12. for (int i=0;i<liquidMaterial.Length/2;i++){
  13. //GUI.color = new Color(1f,0.75f,0.5f);
  14. if (GUI.Button(new Rect( 10,10+i*30,110,20),liquidMaterial[i].name)){
  15. _liquid.GetComponent<Renderer>().material = liquidMaterial[i];
  16. liquidSpriteSheet = _liquid.GetComponent<HTLiquidSpriteSheet>();
  17. liquidSpriteSheet.InitSpriteTexture();
  18. }
  19. }
  20. int j=0;
  21. for (int i=liquidMaterial.Length/2;i<liquidMaterial.Length;i++){
  22. if (GUI.Button(new Rect( Screen.width-120,10+j*30,110,20),liquidMaterial[i].name)){
  23. _liquid.GetComponent<Renderer>().material = liquidMaterial[i];
  24. liquidSpriteSheet = _liquid.GetComponent<HTLiquidSpriteSheet>();
  25. liquidSpriteSheet.InitSpriteTexture();
  26. }
  27. j++;
  28. }
  29. GUI.Label( new Rect(10,Screen.height-50,150,25),"Animation speed : " + liquidSpriteSheet.framesPerSecond);
  30. liquidSpriteSheet.framesPerSecond = (int)GUI.HorizontalSlider( new Rect(10,Screen.height-30,125,20), liquidSpriteSheet.framesPerSecond,1,100);
  31. GUI.Label( new Rect(175,Screen.height-50,150,25),"X size: " + liquidSpriteSheet.textureSize.x);
  32. liquidSpriteSheet.textureSize.x = (int)GUI.HorizontalSlider( new Rect(175,Screen.height-30,125,20), liquidSpriteSheet.textureSize.x,1,500);
  33. GUI.Label( new Rect(340,Screen.height-50,150,25),"Y size: " + liquidSpriteSheet.textureSize.y);
  34. liquidSpriteSheet.textureSize.y = (int)GUI.HorizontalSlider( new Rect(340,Screen.height-30,125,20), liquidSpriteSheet.textureSize.y,1,500);
  35. GUI.Label( new Rect(505,Screen.height-50,150,25),"X scroll: " + liquidSpriteSheet.scrollSpeed.x);
  36. liquidSpriteSheet.scrollSpeed.x = GUI.HorizontalSlider( new Rect(505,Screen.height-30,125,20), liquidSpriteSheet.scrollSpeed.x,0,5);
  37. GUI.Label( new Rect(670,Screen.height-50,150,25),"Y Scroll: " + liquidSpriteSheet.scrollSpeed.y);
  38. liquidSpriteSheet.scrollSpeed.y = GUI.HorizontalSlider( new Rect(670,Screen.height-30,125,20), liquidSpriteSheet.scrollSpeed.y,0,5);
  39. }
  40. }