FogCameraToggle.cs 560 B

123456789101112131415161718192021
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class FogCameraToggle : MonoBehaviour
  6. {
  7. static bool isOn = true;
  8. DayToNight dayToNight;
  9. Toggle toggle;
  10. void Start()
  11. {
  12. dayToNight = this.transform.GetComponentInParent<DayToNight>();
  13. toggle = this.transform.GetComponent<Toggle>();
  14. toggle.onValueChanged.AddListener(delegate(bool value) {
  15. isOn = value;
  16. dayToNight.SetFogCamera(isOn);
  17. });
  18. toggle.isOn = isOn;
  19. }
  20. }