| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | using System.Collections;using System.Collections.Generic;using UnityEngine;public enum WeatherType{    sun,    rain,    snow}public class WeatherTool : MonoBehaviour{    public WeatherType _CurrentWeatherType;    public GameObject _flare;    public ParticleSystem rain;    public ParticleSystem snow;    public static WeatherTool instance;    private void Awake()    {        instance = this;    }    // Update is called once per frame    void Update()    {        if (Input.GetKeyDown(KeyCode.Alpha1))        {            _CurrentWeatherType = WeatherType.sun;            UpdateWeather();        }        if (Input.GetKeyDown(KeyCode.Alpha2))        {            _CurrentWeatherType = WeatherType.rain;            UpdateWeather();        }        if (Input.GetKeyDown(KeyCode.Alpha3))        {            _CurrentWeatherType = WeatherType.snow;            UpdateWeather();        }    }    public void UpdateWeather()    {        var rainEmission = rain.emission;        var snowEmission = snow.emission;        switch (_CurrentWeatherType)        {            case WeatherType.sun:                _flare.SetActive(true);                rainEmission.rateOverTime = 0;                snowEmission.rateOverTime = 0;                break;            case WeatherType.rain:                _flare.SetActive(false);                rainEmission.rateOverTime = 1000;                snowEmission.rateOverTime = 0;                break;            case WeatherType.snow:                _flare.SetActive(false);                rainEmission.rateOverTime = 0;                snowEmission.rateOverTime = 1000;                break;        }    }}
 |