using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; public class WeatherTest : MonoBehaviour { public string weatherName; UnityAction weatherInitOver; // Start is called before the first frame update void Start() { EnviroSkyMgr.instance.OnWeatherChanged += Instance_OnWeatherChanged; } private void Instance_OnWeatherChanged(EnviroWeatherPreset weatherType) { } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { InitWeather(); } if (Input.GetKeyDown(KeyCode.S)) { EnviroSkyMgr.instance.enviroHDInstance.Stop(); } //if (EnviroSkyMgr.instance.IsStarted()) //{ // Debug.Log(EnviroSkyMgr.instance.Weather.weatherPresets.Count); //} } private void InitWeather() { GameObject dirLight = GameObject.Find("Directional Light"); if (dirLight) GameObject.Destroy(dirLight);//删除原有的 方向光源 //EnviroSkyMgr.instance.Weather.startWeatherPreset = EnviroSkyMgr.instance.Weather.weatherPresets[weatherIndex]; EnviroSkyMgr.instance.AssignAndStart(Camera.main.gameObject, Camera.main); EnviroSkyMgr.instance.enviroHDInstance.Play(EnviroTime.TimeProgressMode.None); EnviroSkyMgr.instance.useVolumeLighting = false; Debug.Log(weatherName); StartCoroutine(ChangeWeather()); } IEnumerator ChangeWeather() { yield return new WaitForEndOfFrame(); Debug.Log("aa"); if (EnviroSkyMgr.instance.Weather.weatherPresets.Count != 0) { int weatherIndex = 0; switch (weatherName) { case "晴": break; case "雨": weatherIndex = 3; break; case "雪": weatherIndex = 4; break; case "雷雨": weatherIndex = 5; break; default: break; } EnviroSkyMgr.instance.ChangeWeatherInstant(weatherIndex); } //else // StartCoroutine(ChangeWeather()); } }