using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class FogCameraToggle : MonoBehaviour { static bool isOn = true; DayToNight dayToNight; Toggle toggle; void Start() { dayToNight = this.transform.GetComponentInParent(); toggle = this.transform.GetComponent(); toggle.onValueChanged.AddListener(delegate(bool value) { isOn = value; dayToNight.SetFogCamera(isOn); }); toggle.isOn = isOn; } }