12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace Enviro
- {
- [System.Serializable]
- public class GeneralObjects
- {
- public GameObject sun;
- public GameObject moon;
- public GameObject stars;
- public Light directionalLight;
- public Light additionalDirectionalLight;
- public EnviroReflectionProbe globalReflectionProbe;
- public GameObject effects;
- public GameObject audio;
- }
- [System.Serializable]
- public class EnviroCameras
- {
- public Camera camera;
- public EnviroQuality quality;
- }
- public class EnviroManagerBase : MonoBehaviour
- {
- //Modules
- public EnviroConfiguration configuration;
-
- [SerializeField]
- private EnviroConfiguration lastConfiguration;
- public EnviroTimeModule Time;
- public EnviroLightingModule Lighting;
- public EnviroSkyModule Sky;
- public EnviroFogModule Fog;
- public EnviroVolumetricCloudsModule VolumetricClouds;
- public EnviroFlatCloudsModule FlatClouds;
- public EnviroWeatherModule Weather;
- public EnviroAuroraModule Aurora;
- public EnviroAudioModule Audio;
- public EnviroEffectsModule Effects;
- public EnviroLightningModule Lightning;
- public EnviroQualityModule Quality;
- public EnviroEnvironmentModule Environment;
- public EnviroEventModule Events;
- //Enum
- public enum ModuleType
- {
- Time,
- Lighting,
- Sky,
- Fog,
- VolumetricClouds,
- FlatClouds,
- Weather,
- Aurora,
- Effects,
- Lightning,
- Environment,
- Audio,
- Quality,
- Events
- }
- public void EnableModules()
- {
- if(Time != null)
- Time.Enable();
- if(Sky != null)
- Sky.Enable();
- if(Lighting != null)
- Lighting.Enable();
-
- if(VolumetricClouds != null)
- VolumetricClouds.Enable();
-
- if(FlatClouds != null)
- FlatClouds.Enable();
- if(Fog != null)
- Fog.Enable();
- if(Weather != null)
- Weather.Enable();
- if(Aurora != null)
- Aurora.Enable();
- if(Environment != null)
- Environment.Enable();
- if(Audio != null)
- Audio.Enable();
- if(Effects != null)
- Effects.Enable();
- if(Lightning != null)
- Lightning.Enable();
- if(Quality != null)
- Quality.Enable();
-
- if(Events != null)
- Events.Enable();
- }
- public void DisableModules()
- {
- if(Time != null)
- Time.Disable();
- if(Sky != null)
- Sky.Disable();
- if(Lighting != null)
- Lighting.Disable();
-
- if(VolumetricClouds != null)
- VolumetricClouds.Disable();
- if(FlatClouds != null)
- FlatClouds.Disable();
- if(Fog != null)
- Fog.Disable();
- if(Weather != null)
- Weather.Disable();
- if(Aurora != null)
- Aurora.Disable();
- if(Environment != null)
- Environment.Disable();
- if(Audio != null)
- Audio.Disable();
- if(Effects != null)
- Effects.Disable();
-
- if(Lightning != null)
- Lightning.Disable();
- if(Quality != null)
- Quality.Disable();
- if(Events != null)
- Events.Disable();
- }
- public void DisableAndRemoveModules()
- {
- if(Time != null)
- {
- Time.Disable();
- Time = null;
- }
- if(Sky != null)
- {
- Sky.Disable();
- Sky = null;
- }
- if(Lighting != null)
- {
- Lighting.Disable();
- Lighting = null;
- }
-
- if(VolumetricClouds != null)
- {
- VolumetricClouds.Disable();
- VolumetricClouds = null;
- }
- if(FlatClouds != null)
- {
- FlatClouds.Disable();
- FlatClouds = null;
- }
- if(Fog != null)
- {
- Fog.Disable();
- Fog = null;
- }
- if(Weather != null)
- {
- Weather.Disable();
- Weather = null;
- }
- if(Aurora != null)
- {
- Aurora.Disable();
- Aurora = null;
- }
- if(Environment != null)
- {
- Environment.Disable();
- Environment = null;
- }
- if(Audio != null)
- {
- Audio.Disable();
- Audio = null;
- }
- if(Effects != null)
- {
- Effects.Disable();
- Effects = null;
- }
- if(Lightning != null)
- {
- Lightning.Disable();
- Lightning = null;
- }
- if(Quality != null)
- {
- Quality.Disable();
- Quality = null;
- }
- if(Events != null)
- {
- Events.Disable();
- Events = null;
- }
- }
- public void StartModules ()
- {
- if(Time != null)
- {
- Time = Instantiate(Time);
- }
- if(Sky != null)
- {
- Sky = Instantiate(Sky);
- }
- if(Lighting != null)
- {
- Lighting = Instantiate(Lighting);
- }
- if(Fog != null)
- {
- Fog = Instantiate(Fog);
- }
- if(VolumetricClouds != null)
- {
- VolumetricClouds = Instantiate(VolumetricClouds);
- }
- if(FlatClouds != null)
- {
- FlatClouds = Instantiate(FlatClouds);
- }
- if(Weather != null)
- {
- Weather = Instantiate(Weather);
- }
- if(Aurora != null)
- {
- Aurora = Instantiate(Aurora);
- }
- if(Environment != null)
- {
- Environment = Instantiate(Environment);
- }
- if(Audio != null)
- {
- Audio = Instantiate(Audio);
- }
- if(Effects != null)
- {
- Effects = Instantiate(Effects);
- }
- if(Lightning != null)
- {
- Lightning = Instantiate(Lightning);
- }
- if(Quality != null)
- {
- Quality = Instantiate(Quality);
- }
- if(Events != null)
- {
- Events = Instantiate(Events);
- }
- }
- public void UpdateModules ()
- {
- if(Time != null)
- Time.UpdateModule();
- if(Sky != null)
- Sky.UpdateModule();
- if(Lighting != null)
- Lighting.UpdateModule();
- if(Fog != null)
- Fog.UpdateModule();
- if(VolumetricClouds != null)
- VolumetricClouds.UpdateModule();
- if(FlatClouds != null)
- FlatClouds.UpdateModule();
- if(Weather != null)
- Weather.UpdateModule();
-
- if(Aurora != null)
- Aurora.UpdateModule();
-
- if(Environment != null)
- Environment.UpdateModule();
- if(Audio != null)
- Audio.UpdateModule();
- if(Effects != null)
- Effects.UpdateModule();
- if(Lightning != null)
- Lightning.UpdateModule();
- if(Quality != null)
- Quality.UpdateModule();
- if(Events != null)
- Events.UpdateModule();
- }
- //Saves all the modules settings to its assigned presets.
- public void SaveAllModules()
- {
- if(Time != null && Time.preset != null)
- Time.SaveModuleValues(Time.preset);
- if(Sky != null && Sky.preset != null)
- Sky.SaveModuleValues(Sky.preset);
- if(Lighting != null && Lighting.preset != null)
- Lighting.SaveModuleValues(Lighting.preset);
- if(Fog != null && Fog.preset != null)
- Fog.SaveModuleValues(Fog.preset);
- if(VolumetricClouds != null && VolumetricClouds.preset != null)
- VolumetricClouds.SaveModuleValues(VolumetricClouds.preset);
- if(FlatClouds != null && FlatClouds.preset != null)
- FlatClouds.SaveModuleValues(FlatClouds.preset);
- if(Weather != null && Weather.preset != null)
- Weather.SaveModuleValues(Weather.preset);
- if(Aurora != null && Aurora.preset != null)
- Aurora.SaveModuleValues(Aurora.preset);
- if(Environment != null && Environment.preset != null)
- Environment.SaveModuleValues(Environment.preset);
-
- if(Audio != null && Audio.preset != null)
- Audio.SaveModuleValues(Audio.preset);
- if(Effects != null && Effects.preset != null)
- Effects.SaveModuleValues(Effects.preset);
- if(Lightning != null && Lightning.preset != null)
- Lightning.SaveModuleValues(Lightning.preset);
- if(Quality != null && Quality.preset != null)
- Quality.SaveModuleValues(Quality.preset);
- if(Events != null && Events.preset != null)
- Events.SaveModuleValues(Events.preset);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- #endif
- }
- //Loads all the modules settings from its assigned presets.
- public void LoadAllModules()
- {
- if(Time != null)
- Time.LoadModuleValues();
- if(Sky != null)
- Sky.LoadModuleValues();
- if(Lighting != null)
- Lighting.LoadModuleValues();
- if(Fog != null)
- Fog.LoadModuleValues();
- if(VolumetricClouds != null)
- VolumetricClouds.LoadModuleValues();
- if(FlatClouds != null)
- FlatClouds.LoadModuleValues();
-
- if(Weather != null)
- Weather.LoadModuleValues();
-
- if(Aurora != null)
- Aurora.LoadModuleValues();
-
- if(Environment != null)
- Environment.LoadModuleValues();
- if(Audio != null)
- Audio.LoadModuleValues();
- if(Effects != null)
- Effects.LoadModuleValues();
- if(Lightning != null)
- Lightning.LoadModuleValues();
- if(Quality != null)
- Quality.LoadModuleValues();
-
- if(Events != null)
- Events.LoadModuleValues();
- #if UNITY_EDITOR
- //Set the head configuration dirty to not loose our child values!
- UnityEditor.EditorUtility.SetDirty(configuration);
- #endif
- }
- public void LoadConfiguration()
- {
- if(configuration != null)
- {
- if(configuration != lastConfiguration)
- DisableModules();
- Time = configuration.timeModule;
- Sky = configuration.Sky;
- Lighting = configuration.lightingModule;
- VolumetricClouds = configuration.volumetricCloudModule;
- FlatClouds = configuration.flatCloudModule;
- Fog = configuration.fogModule;
- Weather = configuration.Weather;
- Aurora = configuration.Aurora;
- Environment = configuration.Environment;
- Audio = configuration.Audio;
- Effects = configuration.Effects;
- Lightning = configuration.Lightning;
- Quality = configuration.Quality;
- Events = configuration.Events;
- if(configuration != lastConfiguration)
- EnableModules();
-
- lastConfiguration = configuration;
- }
- else if (configuration == null)
- DisableAndRemoveModules();
- }
- //Adds a module based on ModelType
- public void AddModule (ModuleType type)
- {
- switch (type)
- {
- case ModuleType.Time:
- if(Time != null)
- {
- Debug.Log("Time module already attached!");
- return;
- }
- else
- {
- Time = ScriptableObject.CreateInstance<EnviroTimeModule>();
- Time.name = "Time Module";
- Time.preset = (EnviroTimeModule)EnviroHelper.GetDefaultPreset("Default Time Preset");
- Time.LoadModuleValues();
- Time.Enable();
- #if UNITY_EDITOR
- if(configuration != null && !Application.isPlaying)
- {
- configuration.timeModule = Time;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Time,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- #endif
- }
- break;
- case ModuleType.Sky:
- if(Sky != null)
- {
- Debug.Log("Sky module already attached!");
- return;
- }
- else
- {
- Sky = ScriptableObject.CreateInstance<EnviroSkyModule>();
- Sky.name = "Sky Module";
- Sky.preset = (EnviroSkyModule)EnviroHelper.GetDefaultPreset("Default Sky Preset");
- Sky.LoadModuleValues();
- Sky.Enable();
-
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Sky = Sky;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Sky,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Lighting:
- if(Lighting != null)
- {
- Debug.Log("Lighting module already attached!");
- return;
- }
- else
- {
- Lighting = ScriptableObject.CreateInstance<EnviroLightingModule>();
- Lighting.name = "Lighting Module";
- Lighting.preset = (EnviroLightingModule)EnviroHelper.GetDefaultPreset("Default Lighting Preset");
- Lighting.LoadModuleValues();
- Lighting.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.lightingModule = Lighting;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Lighting,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Fog:
- if(Fog != null)
- {
- Debug.Log("Fog module already attached!");
- return;
- }
- else
- {
- Fog = ScriptableObject.CreateInstance<EnviroFogModule>();
- Fog.name = "Fog Module";
- Fog.preset = (EnviroFogModule)EnviroHelper.GetDefaultPreset("Default Fog Preset");
- Fog.LoadModuleValues();
- Fog.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.fogModule = Fog;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Fog,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.VolumetricClouds:
- if(VolumetricClouds != null)
- {
- Debug.Log("Volumetric clouds module already attached!");
- return;
- }
- else
- {
- VolumetricClouds = ScriptableObject.CreateInstance<EnviroVolumetricCloudsModule>();
- VolumetricClouds.name = "Volumetric Cloud Module";
- VolumetricClouds.preset = (EnviroVolumetricCloudsModule)EnviroHelper.GetDefaultPreset("Default Volumetric Clouds Preset");
- VolumetricClouds.LoadModuleValues();
- VolumetricClouds.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.volumetricCloudModule = VolumetricClouds;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(VolumetricClouds,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.FlatClouds:
- if(FlatClouds != null)
- {
- Debug.Log("Flat clouds module already attached!");
- return;
- }
- else
- {
- FlatClouds = ScriptableObject.CreateInstance<EnviroFlatCloudsModule>();
- FlatClouds.name = "Flat Clouds Module";
- FlatClouds.preset = (EnviroFlatCloudsModule)EnviroHelper.GetDefaultPreset("Default Flat Clouds Preset");
- FlatClouds.LoadModuleValues();
- FlatClouds.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.flatCloudModule = FlatClouds;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(FlatClouds,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Weather:
- if(Weather != null)
- {
- Debug.Log("Weather module already attached!");
- return;
- }
- else
- {
- Weather = ScriptableObject.CreateInstance<EnviroWeatherModule>();
- Weather.name = "Weather Module";
- Weather.preset = (EnviroWeatherModule)EnviroHelper.GetDefaultPreset("Default Weather Preset");
- Weather.LoadModuleValues();
- Weather.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Weather = Weather;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Weather,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Aurora:
- if(Aurora != null)
- {
- Debug.Log("Aurora module already attached!");
- return;
- }
- else
- {
- Aurora = ScriptableObject.CreateInstance<EnviroAuroraModule>();
- Aurora.name = "Aurora Module";
- Aurora.preset = (EnviroAuroraModule)EnviroHelper.GetDefaultPreset("Default Aurora Preset");
- Aurora.LoadModuleValues();
- Aurora.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Aurora = Aurora;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Aurora,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Environment:
- if(Environment != null)
- {
- Debug.Log("Environment module already attached!");
- return;
- }
- else
- {
- Environment = ScriptableObject.CreateInstance<EnviroEnvironmentModule>();
- Environment.name = "Environment Module";
- Environment.preset = (EnviroEnvironmentModule)EnviroHelper.GetDefaultPreset("Default Environment Preset");
- Environment.LoadModuleValues();
- Environment.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Environment = Environment;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Environment,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Audio:
- if(Audio != null)
- {
- Debug.Log("Audio module already attached!");
- return;
- }
- else
- {
- Audio = ScriptableObject.CreateInstance<EnviroAudioModule>();
- Audio.name = "Audio Module";
- Audio.preset = (EnviroAudioModule)EnviroHelper.GetDefaultPreset("Default Audio Preset");
- Audio.LoadModuleValues();
- Audio.Enable();
-
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Audio = Audio;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Audio,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Effects:
- if(Effects != null)
- {
- Debug.Log("Effects module already attached!");
- return;
- }
- else
- {
- Effects = ScriptableObject.CreateInstance<EnviroEffectsModule>();
- Effects.name = "Effects Module";
- Effects.preset = (EnviroEffectsModule)EnviroHelper.GetDefaultPreset("Default Effects Preset");
- Effects.LoadModuleValues();
- Effects.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Effects = Effects;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Effects,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Lightning:
- if(Lightning != null)
- {
- Debug.Log("Lighting module already attached!");
- return;
- }
- else
- {
- Lightning = ScriptableObject.CreateInstance<EnviroLightningModule>();
- Lightning.name = "Lightning Module";
- Lightning.preset = (EnviroLightningModule)EnviroHelper.GetDefaultPreset("Default Lightning Preset");
- Lightning.LoadModuleValues();
- Lightning.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Lightning = Lightning;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Lightning,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Quality:
- if(Quality != null)
- {
- Debug.Log("Quality module already attached!");
- return;
- }
- else
- {
- Quality = ScriptableObject.CreateInstance<EnviroQualityModule>();
- Quality.name = "Quality Module";
- Quality.preset = (EnviroQualityModule)EnviroHelper.GetDefaultPreset("Default Quality Module Preset");
- Quality.LoadModuleValues();
- Quality.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Quality = Quality;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Quality,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- case ModuleType.Events:
- if(Events != null)
- {
- Debug.Log("Event module already attached!");
- return;
- }
- else
- {
- Events = ScriptableObject.CreateInstance<EnviroEventModule>();
- Events.name = "Event Module";
- Events.preset = (EnviroEventModule)EnviroHelper.GetDefaultPreset("Default Event Preset");
- Events.LoadModuleValues();
- Events.Enable();
- if(configuration != null && !Application.isPlaying)
- {
- configuration.Events = Events;
- #if UNITY_EDITOR
- UnityEditor.AssetDatabase.AddObjectToAsset(Events,configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- break;
- }
- }
- //Removes a module
- public void RemoveModule (ModuleType type)
- {
- switch (type)
- {
- case ModuleType.Time:
- if(Time != null)
- {
- Time.Disable();
- DestroyImmediate(Time,true);
-
- if(!Application.isPlaying)
- {
- #if UNITY_EDITOR
- DestroyImmediate(configuration.timeModule,true);
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No time module attached!");
- return;
- }
- break;
- case ModuleType.Sky:
- if(Sky != null)
- {
- Sky.Disable();
- DestroyImmediate(Sky,true);
- if(!Application.isPlaying)
- {
- DestroyImmediate(configuration.Sky,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No sky module attached!");
- return;
- }
- break;
- case ModuleType.Lighting:
- if(Lighting != null)
- {
- Lighting.Disable();
- DestroyImmediate(Lighting,true);
-
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.lightingModule,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No lighting module attached!");
- return;
- }
- break;
- case ModuleType.Fog:
- if(Fog != null)
- {
- Fog.Disable();
- DestroyImmediate(Fog,true);
-
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.fogModule,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No fog module attached!");
- return;
- }
- break;
- case ModuleType.VolumetricClouds:
- if(VolumetricClouds != null)
- {
- VolumetricClouds.Disable();
- DestroyImmediate(VolumetricClouds,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.volumetricCloudModule,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No volumetric cloud module attached!");
- return;
- }
- break;
- case ModuleType.FlatClouds:
- if(FlatClouds != null)
- {
- FlatClouds.Disable();
- DestroyImmediate(FlatClouds,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.flatCloudModule,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No flat cloud module attached!");
- return;
- }
- break;
- case ModuleType.Weather:
- if(Weather != null)
- {
- Weather.Disable();
- DestroyImmediate(Weather,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Weather,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No weather module attached!");
- return;
- }
- break;
- case ModuleType.Aurora:
- if(Aurora != null)
- {
- Aurora.Disable();
- DestroyImmediate(Aurora,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Aurora,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No aurora module attached!");
- return;
- }
- break;
- case ModuleType.Environment:
- if(Environment != null)
- {
- Environment.Disable();
- DestroyImmediate(Environment,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Environment,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No environment module attached!");
- return;
- }
- break;
- case ModuleType.Audio:
- if(Audio != null)
- {
- Audio.Disable();
- DestroyImmediate(Audio,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Audio,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No audio module attached!");
- return;
- }
- break;
- case ModuleType.Effects:
- if(Effects != null)
- {
- Effects.Disable();
- DestroyImmediate(Effects,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Effects,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No effects module attached!");
- return;
- }
- break;
- case ModuleType.Lightning:
- if(Lightning != null)
- {
- Lightning.Disable();
- DestroyImmediate(Lightning,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Lightning,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No lightning module attached!");
- return;
- }
- break;
- case ModuleType.Quality:
- if(Quality != null)
- {
- Quality.Disable();
- DestroyImmediate(Quality,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Quality,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No quality module attached!");
- return;
- }
- break;
-
- case ModuleType.Events:
- if(Events != null)
- {
- Events.Disable();
- DestroyImmediate(Events,true);
- if(!Application.isPlaying)
- {
- if(configuration != null)
- DestroyImmediate(configuration.Events,true);
- #if UNITY_EDITOR
- UnityEditor.EditorUtility.SetDirty(configuration);
- UnityEditor.AssetDatabase.SaveAssets();
- UnityEditor.AssetDatabase.Refresh();
- #endif
- }
- }
- else
- {
- Debug.Log("No events module attached!");
- return;
- }
- break;
- }
- }
- }
- }
|