Gui.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using UnityEngine;
  2. using System.Collections;
  3. public class Gui : MonoBehaviour
  4. {
  5. public GameObject plane;
  6. public Material icePlane, iceBall;
  7. public Light dirLight;
  8. public Material day, night;
  9. private bool isDay;
  10. // Use this for initialization
  11. void Start () {
  12. }
  13. // Update is called once per frame
  14. void Update () {
  15. }
  16. private void OnGUI()
  17. {
  18. if (GUI.Button(new Rect(10, 10, 150, 25), "Freeze/Unfreeze plane")) {
  19. var freezeBehaviour = plane.GetComponent<FreezeBehaviour>();
  20. freezeBehaviour.isFrozen = !freezeBehaviour.isFrozen;
  21. }
  22. if (GUI.Button(new Rect(10, 50, 150, 25), "Day/Night"))
  23. {
  24. if (!isDay) {
  25. iceBall.SetFloat("_LightStr", 0.1f);
  26. icePlane.SetFloat("_LightStr", 0.1f);
  27. dirLight.intensity = 0.1f;
  28. RenderSettings.skybox = night;
  29. RenderSettings.ambientLight = new Color(10/255f, 10/255f, 10/255f);
  30. }
  31. else {
  32. iceBall.SetFloat("_LightStr", 1f);
  33. icePlane.SetFloat("_LightStr", 1f);
  34. dirLight.intensity = 0.5f;
  35. RenderSettings.skybox = day;
  36. RenderSettings.ambientLight = new Color(50/255f, 50/255f, 50/255f);
  37. }
  38. isDay = !isDay;
  39. }
  40. }
  41. }