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; } }