Readd missing import files

This commit is contained in:
Lucien
2026-05-07 10:14:44 +02:00
parent ecb44e63d8
commit cd608d5796
810 changed files with 263144 additions and 1 deletions
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2f6c9dafb37031e4682fe13b528e52f7
folderAsset: yes
timeCreated: 1532145582
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
using System;
using System.Linq;
using UnityEditor;
[InitializeOnLoad]
sealed class EnviroAddDefineSymbolsLW
{
const string k_Define = "ENVIRO_LW";
static EnviroAddDefineSymbolsLW()
{
var targets = Enum.GetValues(typeof(BuildTargetGroup))
.Cast<BuildTargetGroup>()
.Where(x => x != BuildTargetGroup.Unknown)
.Where(x => !IsObsolete(x));
foreach (var target in targets)
{
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(target).Trim();
var list = defines.Split(';', ' ')
.Where(x => !string.IsNullOrEmpty(x))
.ToList();
if (list.Contains(k_Define))
continue;
list.Add(k_Define);
defines = list.Aggregate((a, b) => a + ";" + b);
PlayerSettings.SetScriptingDefineSymbolsForGroup(target, defines);
}
}
static bool IsObsolete(BuildTargetGroup group)
{
var attrs = typeof(BuildTargetGroup)
.GetField(group.ToString())
.GetCustomAttributes(typeof(ObsoleteAttribute), false);
return attrs != null && attrs.Length > 0;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 557774f7678317f40b67bb1212f72f60
timeCreated: 1532145482
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,917 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditorInternal;
[CustomEditor(typeof(EnviroSkyLite))]
public class EnviroSkyLiteEditor : Editor {
private string latestVersion = "2.3.2";
// GUI Styles
private GUIStyle boxStyle;
private GUIStyle boxStyleModified;
private GUIStyle wrapStyle;
private GUIStyle headerStyle;
private GUIStyle headerFoldout;
private GUIStyle popUpStyle;
//Target
private EnviroSkyLite myTarget;
private Color modifiedColor;
private Color greenColor;
private Color boxColor1;
private bool showWeatherMap;
//Profile Properties
SerializedObject serializedObj;
SerializedProperty AdditionalDirectLight,Sun, Moon,DirectLight,GlobalReflectionProbe, windZone, LightningGenerator, satellites, starsRotation;
SerializedProperty Player,Camera,PlayerTag,CameraTag, AssignOnRuntime, tonemapping;
SerializedProperty cycleLenghtInMinutes,ProgressMode, Years,Days,Hours,Minutes,Seconds,Longitude,Latitude, DayLength,NightLength,UTC, UpdateSeason, CurrentSeason, DaysInYear;
SerializedProperty UpdateWeather,StartWeather, EnableSunShafts,EnableMoonShafts,AmbientVolume,WeatherVolume;
SerializedProperty lightIntensityToLumen, stopRotationAtHigh, rotationStopHigh, angleOffset,lightColorGradient, lightIntensityCurveSun,lightIntensityCurveMoon, shadowStrength, globalReflectionsUpdateOnPosition, globalReflectionsUpdateOnGameTime;
SerializedProperty directionalLightMode,lightIntensityTransitionSpeed, ambientMode, ambientIntensityCurve, ambientSkyGradient, ambientEquatorGradient, ambientGroundGradient;
SerializedProperty globalReflectionLayers, globalReflectionResolution, globalReflectionsScale, reflectionBool, reflectionIntensity, reflectionUpdate;
SerializedProperty blackGroundMode,sunDiskSizeSimple, simpleSunColor, simpleSkyColor, simpleHorizonColor, renderMoon, skyboxMode, customSkyboxMaterial, customSkyboxColor, rayleigh, scatteringCurve, scatteringColor, sunMoonPos, moonPhaseMode, moonSize, moonTexture, currentMoonPhase, skyLuminance, skyColorPower, skyExposure, cloudsExposure, fogExposure,starsCubemap, starsIntensity,moonColor;
SerializedProperty cirrusCloudsAltitude, cirrusCloudsColor, cirrusCloudsTexture, particleCloudsHeight1, particleCloudsColor1, particleCloudsHeight2, particleCloudsColor2;
SerializedProperty useTag, wetnessAccumulationSpeed,wetnessDryingSpeed, snowAccumulationSpeed,snowMeltingSpeed,cloudTransitionSpeed,fogTransitionSpeed,effectTransitionSpeed,audioTransitionSpeed, useWindZoneDirection,windTimeScale,windIntensity,windDirectionX,windDirectionY;
SerializedProperty useSimpleFog, simpleFogColor, fogMie, fogG, fogmode, distanceFog, startDistance, distanceFogIntensity,maximumFogIntensity, heightFog, height, heightFogIntensity;
SerializedProperty resolution, screenBlendMode, useDepthTexture, lightShaftsColorSun, lightShaftsColorMoon, treshholdColorSun, treshholdColorMoon, blurRadius, shaftsIntensity, maxRadius;
SerializedProperty SpringStart, SpringEnd, SummerStart, SummerEnd, AutumnStart, AutumnEnd, WinterStart, WinterEnd;
SerializedProperty effectQuality, updateInterval, lightningEffect, lightningRange, lightningHeight, cirrusWindIntensity;
SerializedProperty dualLayerParticleClouds, renderClouds, particleClouds, dayNightSwitch, usePostEffectFog, useUnityFog, sunIntensity, reflectionUpdatePos, showFogInEditor;
SerializedProperty springBaseTemperature, summerBaseTemperature, autumnBaseTemperature, winterBaseTemperature, temperatureChangingSpeed, snowMeltingTresholdTemperature, windIntensityTransitionSpeed, setCameraClearFlags;
SerializedProperty flatCloudsBaseTexture, flatCloudsDetailTexture, flatCloudsDirectLightColor, flatCloudsAmbientLightColor, flatCloudsAltitude, flatCloudsBaseTextureTiling, flatCloudsDetailTextureTiling, cloudsDetailWindIntensity;
ReorderableList thunderSFX;
void OnEnable()
{
myTarget = (EnviroSkyLite)target;
serializedObj = new SerializedObject (myTarget);
//Components
Sun = serializedObj.FindProperty ("Components.Sun");
Moon = serializedObj.FindProperty ("Components.Moon");
DirectLight = serializedObj.FindProperty ("Components.DirectLight");
GlobalReflectionProbe = serializedObj.FindProperty ("Components.GlobalReflectionProbe");
windZone = serializedObj.FindProperty ("Components.windZone");
LightningGenerator = serializedObj.FindProperty ("Components.LightningGenerator");
satellites = serializedObj.FindProperty ("Components.satellites");
starsRotation = serializedObj.FindProperty ("Components.starsRotation");
particleClouds = serializedObj.FindProperty("Components.particleClouds");
AdditionalDirectLight = serializedObj.FindProperty("Components.AdditionalDirectLight");
// Setup
Player = serializedObj.FindProperty ("Player");
Camera = serializedObj.FindProperty ("PlayerCamera");
PlayerTag = serializedObj.FindProperty ("PlayerTag");
CameraTag = serializedObj.FindProperty ("CameraTag");
AssignOnRuntime = serializedObj.FindProperty ("AssignInRuntime");
tonemapping = serializedObj.FindProperty ("tonemapping");
setCameraClearFlags = serializedObj.FindProperty("setCameraClearFlags");
// Weather Controls
UpdateWeather = serializedObj.FindProperty ("Weather.updateWeather");
StartWeather = serializedObj.FindProperty ("Weather.startWeatherPreset");
//Feature Controls:
EnableSunShafts = serializedObj.FindProperty ("LightShafts.sunLightShafts");
EnableMoonShafts = serializedObj.FindProperty ("LightShafts.moonLightShafts");
usePostEffectFog = serializedObj.FindProperty("usePostEffectFog");
useUnityFog = serializedObj.FindProperty("fogSettings.useUnityFog");
// Audio Controls
AmbientVolume = serializedObj.FindProperty ("Audio.ambientSFXVolume");
WeatherVolume = serializedObj.FindProperty ("Audio.weatherSFXVolume");
// Time Controls
ProgressMode = serializedObj.FindProperty ("GameTime.ProgressTime");
DayLength = serializedObj.FindProperty("GameTime.dayLengthModifier");
NightLength = serializedObj.FindProperty("GameTime.nightLengthModifier");
cycleLenghtInMinutes = serializedObj.FindProperty("GameTime.cycleLengthInMinutes");
UpdateSeason = serializedObj.FindProperty ("Seasons.calcSeasons");
CurrentSeason = serializedObj.FindProperty ("Seasons.currentSeasons");
Years = serializedObj.FindProperty ("GameTime.Years");
Days = serializedObj.FindProperty ("GameTime.Days");
Hours = serializedObj.FindProperty ("GameTime.Hours");
Minutes = serializedObj.FindProperty ("GameTime.Minutes");
Seconds = serializedObj.FindProperty ("GameTime.Seconds");
Longitude = serializedObj.FindProperty ("GameTime.Longitude");
Latitude = serializedObj.FindProperty ("GameTime.Latitude");
UTC = serializedObj.FindProperty ("GameTime.utcOffset");
DaysInYear = serializedObj.FindProperty("GameTime.DaysInYear");
dayNightSwitch = serializedObj.FindProperty("GameTime.dayNightSwitch");
//Lighting Category
lightColorGradient = serializedObj.FindProperty ("lightSettings.LightColor");
lightIntensityCurveSun = serializedObj.FindProperty ("lightSettings.directLightSunIntensity");
lightIntensityCurveMoon = serializedObj.FindProperty ("lightSettings.directLightMoonIntensity");
shadowStrength = serializedObj.FindProperty ("lightSettings.shadowIntensity");
angleOffset = serializedObj.FindProperty("lightSettings.directLightAngleOffset");
ambientMode = serializedObj.FindProperty ("lightSettings.ambientMode");
ambientIntensityCurve = serializedObj.FindProperty ("lightSettings.ambientIntensity");
ambientSkyGradient = serializedObj.FindProperty ("lightSettings.ambientSkyColor");
ambientEquatorGradient = serializedObj.FindProperty ("lightSettings.ambientEquatorColor");
ambientGroundGradient = serializedObj.FindProperty ("lightSettings.ambientGroundColor");
lightIntensityToLumen = serializedObj.FindProperty("lightSettings.lightIntensityToLumen");
stopRotationAtHigh = serializedObj.FindProperty("lightSettings.stopRotationAtHigh");
rotationStopHigh = serializedObj.FindProperty("lightSettings.rotationStopHigh");
reflectionBool = serializedObj.FindProperty ("reflectionSettings.globalReflections");
reflectionIntensity = serializedObj.FindProperty ("reflectionSettings.globalReflectionsIntensity");
reflectionUpdate = serializedObj.FindProperty("reflectionSettings.globalReflectionsTimeTreshold");
reflectionUpdatePos = serializedObj.FindProperty("reflectionSettings.globalReflectionsPositionTreshold");
globalReflectionsScale = serializedObj.FindProperty("reflectionSettings.globalReflectionsScale");
globalReflectionsUpdateOnPosition = serializedObj.FindProperty("reflectionSettings.globalReflectionsUpdateOnPosition");
globalReflectionsUpdateOnGameTime = serializedObj.FindProperty("reflectionSettings.globalReflectionsUpdateOnGameTime");
globalReflectionResolution = serializedObj.FindProperty("reflectionSettings.globalReflectionResolution");
globalReflectionLayers = serializedObj.FindProperty("reflectionSettings.globalReflectionLayers");
lightIntensityTransitionSpeed = serializedObj.FindProperty("lightSettings.lightIntensityTransitionSpeed");
directionalLightMode = serializedObj.FindProperty("lightSettings.directionalLightMode");
//Sky Category
skyboxMode = serializedObj.FindProperty ("skySettings.skyboxModeLW");
customSkyboxMaterial = serializedObj.FindProperty ("skySettings.customSkyboxMaterial");
customSkyboxColor = serializedObj.FindProperty ("skySettings.customSkyboxColor");
rayleigh = serializedObj.FindProperty ("skySettings.rayleigh");
scatteringCurve = serializedObj.FindProperty ("skySettings.scatteringCurve");
scatteringColor = serializedObj.FindProperty ("skySettings.scatteringColor");
sunMoonPos = serializedObj.FindProperty ("skySettings.sunAndMoonPosition");
sunIntensity = serializedObj.FindProperty ("skySettings.sunIntensity");
renderMoon = serializedObj.FindProperty("skySettings.renderMoon");
moonPhaseMode = serializedObj.FindProperty ("skySettings.moonPhaseMode");
moonTexture = serializedObj.FindProperty ("skySettings.moonTexture");
moonSize = serializedObj.FindProperty("skySettings.moonSize");
currentMoonPhase = serializedObj.FindProperty ("customMoonPhase");
skyLuminance = serializedObj.FindProperty ("skySettings.skyLuminence");
skyColorPower = serializedObj.FindProperty ("skySettings.skyColorPower");
skyExposure = serializedObj.FindProperty ("skySettings.skyExposure");
starsCubemap = serializedObj.FindProperty ("skySettings.starsCubeMap");
starsIntensity = serializedObj.FindProperty ("skySettings.starsIntensity");
moonColor = serializedObj.FindProperty ("skySettings.moonColor");
simpleSkyColor = serializedObj.FindProperty("skySettings.simpleSkyColor");
simpleHorizonColor = serializedObj.FindProperty("skySettings.simpleHorizonColor");
sunDiskSizeSimple = serializedObj.FindProperty("skySettings.simpleSunDiskSize");
simpleSunColor = serializedObj.FindProperty("skySettings.simpleSunColor");
blackGroundMode = serializedObj.FindProperty("skySettings.blackGroundMode");
//Clouds Category
particleCloudsHeight1 = serializedObj.FindProperty("cloudsSettings.ParticleCloudsLayer1.height");
particleCloudsColor1 = serializedObj.FindProperty("cloudsSettings.ParticleCloudsLayer1.particleCloudsColor");
particleCloudsHeight2 = serializedObj.FindProperty("cloudsSettings.ParticleCloudsLayer2.height");
particleCloudsColor2 = serializedObj.FindProperty("cloudsSettings.ParticleCloudsLayer2.particleCloudsColor");
cirrusCloudsTexture = serializedObj.FindProperty ("cloudsSettings.cirrusCloudsTexture");
cirrusCloudsAltitude = serializedObj.FindProperty ("cloudsSettings.cirrusCloudsAltitude");
cirrusCloudsColor = serializedObj.FindProperty ("cloudsSettings.cirrusCloudsColor");
dualLayerParticleClouds = serializedObj.FindProperty("cloudsSettings.dualLayerParticleClouds");
flatCloudsBaseTexture = serializedObj.FindProperty("cloudsSettings.flatCloudsBaseTexture");
flatCloudsDetailTexture = serializedObj.FindProperty("cloudsSettings.flatCloudsDetailTexture");
flatCloudsDirectLightColor = serializedObj.FindProperty("cloudsSettings.flatCloudsDirectLightColor");
flatCloudsAmbientLightColor = serializedObj.FindProperty("cloudsSettings.flatCloudsAmbientLightColor");
flatCloudsAltitude = serializedObj.FindProperty("cloudsSettings.flatCloudsAltitude");
flatCloudsBaseTextureTiling = serializedObj.FindProperty("cloudsSettings.flatCloudsBaseTextureTiling");
flatCloudsDetailTextureTiling = serializedObj.FindProperty("cloudsSettings.flatCloudsDetailTextureTiling");
cloudsDetailWindIntensity = serializedObj.FindProperty("cloudsSettings.cloudsDetailWindIntensity");
cloudsExposure = serializedObj.FindProperty("cloudsSettings.cloudsExposure");
// Weather Category
useTag = serializedObj.FindProperty ("weatherSettings.useTag");
wetnessAccumulationSpeed = serializedObj.FindProperty ("weatherSettings.wetnessAccumulationSpeed");
wetnessDryingSpeed = serializedObj.FindProperty ("weatherSettings.wetnessDryingSpeed");
snowAccumulationSpeed = serializedObj.FindProperty ("weatherSettings.snowAccumulationSpeed");
snowMeltingSpeed = serializedObj.FindProperty ("weatherSettings.snowMeltingSpeed");
cloudTransitionSpeed = serializedObj.FindProperty ("weatherSettings.cloudTransitionSpeed");
fogTransitionSpeed = serializedObj.FindProperty ("weatherSettings.fogTransitionSpeed");
effectTransitionSpeed = serializedObj.FindProperty ("weatherSettings.effectTransitionSpeed");
audioTransitionSpeed = serializedObj.FindProperty ("weatherSettings.audioTransitionSpeed");
snowMeltingTresholdTemperature = serializedObj.FindProperty("weatherSettings.snowMeltingTresholdTemperature");
windIntensityTransitionSpeed = serializedObj.FindProperty("weatherSettings.windIntensityTransitionSpeed");
temperatureChangingSpeed = serializedObj.FindProperty("weatherSettings.temperatureChangingSpeed");
lightningEffect = serializedObj.FindProperty("weatherSettings.lightningEffect");
lightningRange = serializedObj.FindProperty("weatherSettings.lightningRange");
lightningHeight = serializedObj.FindProperty("weatherSettings.lightningHeight");
useWindZoneDirection = serializedObj.FindProperty ("cloudsSettings.useWindZoneDirection");
renderClouds = serializedObj.FindProperty ("useParticleClouds");
windTimeScale = serializedObj.FindProperty ("cloudsSettings.cloudsTimeScale");
windIntensity = serializedObj.FindProperty ("cloudsSettings.cloudsWindIntensity");
cirrusWindIntensity = serializedObj.FindProperty("cloudsSettings.cirrusWindIntensity");
windDirectionX = serializedObj.FindProperty ("cloudsSettings.cloudsWindDirectionX");
windDirectionY = serializedObj.FindProperty ("cloudsSettings.cloudsWindDirectionY");
fogmode = serializedObj.FindProperty ("fogSettings.Fogmode");
distanceFog = serializedObj.FindProperty ("fogSettings.distanceFog");
startDistance = serializedObj.FindProperty ("fogSettings.startDistance");
distanceFogIntensity = serializedObj.FindProperty ("fogSettings.distanceFogIntensity");
maximumFogIntensity = serializedObj.FindProperty ("fogSettings.maximumFogDensity");
heightFog = serializedObj.FindProperty ("fogSettings.heightFog");
height = serializedObj.FindProperty ("fogSettings.height");
heightFogIntensity = serializedObj.FindProperty ("fogSettings.heightFogIntensity");
fogMie = serializedObj.FindProperty ("fogSettings.mie");
fogG = serializedObj.FindProperty ("fogSettings.g");
fogExposure = serializedObj.FindProperty("fogSettings.fogExposure");
useSimpleFog = serializedObj.FindProperty("fogSettings.useSimpleFog");
simpleFogColor = serializedObj.FindProperty("fogSettings.simpleFogColor");
showFogInEditor = serializedObj.FindProperty("showFogInEditor");
//LightShafts
resolution = serializedObj.FindProperty ("lightshaftsSettings.resolution");
screenBlendMode = serializedObj.FindProperty ("lightshaftsSettings.screenBlendMode");
useDepthTexture = serializedObj.FindProperty ("lightshaftsSettings.useDepthTexture");
lightShaftsColorSun = serializedObj.FindProperty ("lightshaftsSettings.lightShaftsColorSun");
lightShaftsColorMoon = serializedObj.FindProperty ("lightshaftsSettings.lightShaftsColorMoon");
treshholdColorSun = serializedObj.FindProperty ("lightshaftsSettings.thresholdColorSun");
treshholdColorMoon = serializedObj.FindProperty ("lightshaftsSettings.thresholdColorMoon");
blurRadius = serializedObj.FindProperty ("lightshaftsSettings.blurRadius");
shaftsIntensity = serializedObj.FindProperty ("lightshaftsSettings.intensity");
maxRadius = serializedObj.FindProperty ("lightshaftsSettings.maxRadius");
//Season
SpringStart = serializedObj.FindProperty("seasonsSettings.SpringStart");
SpringEnd = serializedObj.FindProperty("seasonsSettings.SpringEnd");
SummerStart = serializedObj.FindProperty("seasonsSettings.SummerStart");
SummerEnd = serializedObj.FindProperty("seasonsSettings.SummerEnd");
AutumnStart = serializedObj.FindProperty("seasonsSettings.AutumnStart");
AutumnEnd = serializedObj.FindProperty("seasonsSettings.AutumnEnd");
WinterStart = serializedObj.FindProperty("seasonsSettings.WinterStart");
WinterEnd = serializedObj.FindProperty("seasonsSettings.WinterEnd");
springBaseTemperature = serializedObj.FindProperty("seasonsSettings.springBaseTemperature");
summerBaseTemperature = serializedObj.FindProperty("seasonsSettings.summerBaseTemperature");
autumnBaseTemperature = serializedObj.FindProperty("seasonsSettings.autumnBaseTemperature");
winterBaseTemperature = serializedObj.FindProperty("seasonsSettings.winterBaseTemperature");
//Quality
effectQuality = serializedObj.FindProperty ("qualitySettings.GlobalParticleEmissionRates");
updateInterval= serializedObj.FindProperty ("qualitySettings.UpdateInterval");
//Audio
thunderSFX = new ReorderableList(serializedObject,
serializedObject.FindProperty("audioSettings.ThunderSFX"),
true, true, true, true);
thunderSFX.drawHeaderCallback = (Rect rect) =>
{
EditorGUI.LabelField(rect, "Thunder SFX");
};
thunderSFX.drawElementCallback =
(Rect rect, int index, bool isActive, bool isFocused) =>
{
var element = thunderSFX.serializedProperty.GetArrayElementAtIndex(index);
rect.y += 2;
EditorGUI.PropertyField(
new Rect(rect.x, rect.y, Screen.width*.8f, EditorGUIUtility.singleLineHeight),
element, GUIContent.none);
};
thunderSFX.onAddCallback = (ReorderableList l) =>
{
var index = l.serializedProperty.arraySize;
l.serializedProperty.arraySize++;
l.index = index;
//var element = l.serializedProperty.GetArrayElementAtIndex(index);
};
modifiedColor = Color.red;
modifiedColor.a = 0.5f;
greenColor = Color.green;
greenColor.a = 0.5f;
#if UNITY_2019_3_OR_NEWER
boxColor1 = new Color(0.95f, 0.95f, 0.95f,1f);
#else
boxColor1 = new Color(0.85f, 0.85f, 0.85f, 1f);
#endif
////
}
/// <summary>
/// Applies the changes and set profile to modifed but not saved.
/// </summary>
private void ApplyChanges ()
{
if (EditorGUI.EndChangeCheck ()) {
serializedObj.ApplyModifiedProperties ();
myTarget.profile.modified = true;
}
}
public override void OnInspectorGUI ()
{
myTarget = (EnviroSkyLite)target;
//int daysInyear = (int)(myTarget.seasonsSettings.SpringInDays + myTarget.seasonsSettings.SummerInDays + myTarget.seasonsSettings.AutumnInDays + myTarget.seasonsSettings.WinterInDays);
//Set up the box style
if (boxStyle == null)
{
boxStyle = new GUIStyle(GUI.skin.box);
boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
boxStyle.fontStyle = FontStyle.Bold;
boxStyle.alignment = TextAnchor.UpperLeft;
}
if (boxStyleModified == null)
{
boxStyleModified = new GUIStyle(EditorStyles.helpBox);
boxStyleModified.normal.textColor = GUI.skin.label.normal.textColor;
boxStyleModified.fontStyle = FontStyle.Bold;
boxStyleModified.fontSize = 11;
boxStyleModified.alignment = TextAnchor.UpperLeft;
}
//Setup the wrap style
if (wrapStyle == null)
{
wrapStyle = new GUIStyle(GUI.skin.label);
wrapStyle.fontStyle = FontStyle.Bold;
wrapStyle.wordWrap = true;
}
if (headerStyle == null) {
headerStyle = new GUIStyle(GUI.skin.label);
headerStyle.fontStyle = FontStyle.Bold;
headerStyle.alignment = TextAnchor.UpperLeft;
}
if (headerFoldout == null)
{
headerFoldout = new GUIStyle(EditorStyles.foldout);
headerFoldout.fontStyle = FontStyle.Bold;
}
if (popUpStyle == null)
{
popUpStyle = new GUIStyle(EditorStyles.popup);
popUpStyle.alignment = TextAnchor.MiddleCenter;
popUpStyle.fixedHeight = 20f;
popUpStyle.fontStyle = FontStyle.Bold;
}
GUILayout.BeginVertical("EnviroSky - Lite " + latestVersion, boxStyle);
GUILayout.Space(20);
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical("Profile", boxStyleModified);
GUI.backgroundColor = Color.white;
GUILayout.Space(20);
myTarget.profile = (EnviroProfile)EditorGUILayout.ObjectField (myTarget.profile, typeof(EnviroProfile), false);
GUILayout.Space(10);
if (myTarget.profile != null)
EditorGUILayout.LabelField ("Profile Version:", myTarget.profile.version,headerStyle);
else
EditorGUILayout.LabelField ("No Profile Assigned!");
GUILayout.Space(5);
if(myTarget.profile != null && myTarget.profile.version != latestVersion)
if (GUILayout.Button ("Update Profile")) {
if (EnviroProfileCreation.UpdateProfile (myTarget.profile, myTarget.profile.version, latestVersion) == true)
myTarget.ApplyProfile (myTarget.profile);
}
// Runtime Settings
if (GUILayout.Button ("Apply all Settings")) {
myTarget.enabled = false;
myTarget.enabled = true;
}
GUILayout.EndHorizontal ();
if (myTarget.profile != null) {
if (myTarget.profile.modified) // Change color when modified
GUI.backgroundColor = modifiedColor;
else
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical ("", boxStyleModified);
GUI.backgroundColor = Color.white;
serializedObj.UpdateIfRequiredOrScript ();
myTarget.showSettings = GUILayout.Toggle(myTarget.showSettings, "Edit Profile", headerFoldout);
if (myTarget.showSettings) {
GUILayout.BeginVertical ("", boxStyleModified);
GUILayout.BeginHorizontal ();
if (GUILayout.Button ("Save to Profile")) {
myTarget.SaveProfile ();
myTarget.profile.modified = false;
}
if (GUILayout.Button ("Load from Profile")) {
myTarget.ApplyProfile (myTarget.profile);
myTarget.profile.modified = false;
serializedObj.UpdateIfRequiredOrScript ();
}
GUILayout.EndHorizontal ();
GUILayout.Space (5);
EditorGUILayout.LabelField ("Category", headerStyle);
myTarget.profile.viewModeLW = (EnviroProfile.settingsModeLW)EditorGUILayout.EnumPopup(myTarget.profile.viewModeLW, popUpStyle);
GUILayout.Space(10);
GUILayout.EndVertical ();
switch (myTarget.profile.viewModeLW) {
case EnviroProfile.settingsModeLW.Lighting:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(directionalLightMode, true, null);
EditorGUILayout.PropertyField (lightColorGradient, true, null);
EditorGUILayout.PropertyField (lightIntensityCurveSun, true, null);
EditorGUILayout.PropertyField (lightIntensityCurveMoon, true, null);
EditorGUILayout.PropertyField(lightIntensityTransitionSpeed, true, null);
#if ENVIRO_HDRP
EditorGUILayout.PropertyField(lightIntensityToLumen, true, null);
#endif
EditorGUILayout.PropertyField(shadowStrength, true, null);
EditorGUILayout.PropertyField(angleOffset, true, null);
EditorGUILayout.PropertyField(stopRotationAtHigh, true, null);
if (myTarget.lightSettings.stopRotationAtHigh)
EditorGUILayout.PropertyField(rotationStopHigh, true, null);
EditorGUILayout.PropertyField (ambientMode, true, null);
EditorGUILayout.PropertyField (ambientIntensityCurve, true, null);
EditorGUILayout.PropertyField (ambientSkyGradient, true, null);
EditorGUILayout.PropertyField (ambientEquatorGradient, true, null);
EditorGUILayout.PropertyField (ambientGroundGradient, true, null);
ApplyChanges ();
GUILayout.EndVertical();
break;
case EnviroProfile.settingsModeLW.Sky:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck ();
EditorGUILayout.PropertyField (skyboxMode, true, null);
if (myTarget.skySettings.skyboxModeLW == EnviroSkySettings.SkyboxModiLW.Simple)
EditorGUILayout.PropertyField (blackGroundMode, true, null);
if (myTarget.skySettings.skyboxModeLW == EnviroSkySettings.SkyboxModiLW.CustomSkybox)
EditorGUILayout.PropertyField (customSkyboxMaterial, true, null);
if (myTarget.skySettings.skyboxModeLW == EnviroSkySettings.SkyboxModiLW.CustomColor)
EditorGUILayout.PropertyField (customSkyboxColor, true, null);
GUILayout.Space (10);
if (myTarget.skySettings.skyboxModeLW == EnviroSkySettings.SkyboxModiLW.Simple)
{
EditorGUILayout.LabelField("Color", headerStyle);
EditorGUILayout.PropertyField(simpleSkyColor, true, null);
EditorGUILayout.PropertyField(simpleHorizonColor, true, null);
EditorGUILayout.PropertyField(simpleSunColor, true, null);
}
EditorGUILayout.PropertyField (sunMoonPos, true, null);
if(myTarget.skySettings.skyboxModeLW == EnviroSkySettings.SkyboxModiLW.Simple)
EditorGUILayout.PropertyField(sunDiskSizeSimple, true, null);
EditorGUILayout.PropertyField(renderMoon, true, null);
EditorGUILayout.PropertyField (moonPhaseMode, true, null);
EditorGUILayout.PropertyField (moonTexture, true, null);
EditorGUILayout.PropertyField(moonSize, true, null);
EditorGUILayout.PropertyField (moonColor, true, null);
if (myTarget.skySettings.moonPhaseMode == EnviroSkySettings.MoonPhases.Custom) {
// EditorGUILayout.PropertyField (startMoonPhase, true, null);
EditorGUILayout.PropertyField (currentMoonPhase, true, null);
}
EditorGUILayout.PropertyField (starsCubemap, true, null);
EditorGUILayout.PropertyField (starsIntensity, true, null);
//EditorGUILayout.PropertyField(galaxyCubeMap, true, null);
//EditorGUILayout.PropertyField(galaxyIntensity, true, null);
ApplyChanges ();
GUILayout.EndVertical();
break;
// CLouds Category
case EnviroProfile.settingsModeLW.Clouds:
EditorGUI.BeginChangeCheck ();
GUILayout.BeginVertical("2D Clouds", boxStyleModified);
GUILayout.Space(20);
EditorGUILayout.PropertyField(flatCloudsBaseTexture, true, null);
EditorGUILayout.PropertyField(flatCloudsBaseTextureTiling, true, null);
EditorGUILayout.PropertyField(flatCloudsDetailTexture, true, null);
EditorGUILayout.PropertyField(flatCloudsDetailTextureTiling, true, null);
EditorGUILayout.PropertyField(flatCloudsDirectLightColor, true, null);
EditorGUILayout.PropertyField(flatCloudsAmbientLightColor, true, null);
EditorGUILayout.PropertyField(flatCloudsAltitude, true, null);
EditorGUILayout.PropertyField(cloudsExposure, true, null);
EditorGUILayout.EndVertical();
GUILayout.BeginVertical ("Particle Clouds", boxStyleModified);
GUILayout.Space (20);
EditorGUILayout.PropertyField(dualLayerParticleClouds, true, null);
GUILayout.Space(5);
EditorGUILayout.LabelField("Layer 1", headerStyle);
EditorGUILayout.PropertyField(particleCloudsHeight1, true, null);
EditorGUILayout.PropertyField(particleCloudsColor1, true, null);
if (myTarget.cloudsSettings.dualLayerParticleClouds)
{
GUILayout.Space(5);
EditorGUILayout.LabelField("Layer 2", headerStyle);
EditorGUILayout.PropertyField(particleCloudsHeight2, true, null);
EditorGUILayout.PropertyField(particleCloudsColor2, true, null);
}
EditorGUILayout.EndVertical();
GUILayout.BeginVertical ("Cirrus Clouds", boxStyleModified);
GUILayout.Space (20);
EditorGUILayout.PropertyField (cirrusCloudsTexture, true, null);
EditorGUILayout.PropertyField (cirrusCloudsColor, true, null);
EditorGUILayout.PropertyField (cirrusCloudsAltitude, true, null);
EditorGUILayout.EndVertical ();
GUILayout.BeginVertical("", boxStyleModified);
EditorGUILayout.PropertyField (useWindZoneDirection, true, null);
EditorGUILayout.PropertyField (windTimeScale, true, null);
EditorGUILayout.PropertyField (windIntensity, true, null);
EditorGUILayout.PropertyField(cloudsDetailWindIntensity, true, null);
EditorGUILayout.PropertyField(cirrusWindIntensity, true, null);
if (useWindZoneDirection.boolValue == false) {
EditorGUILayout.PropertyField (windDirectionX, true, null);
EditorGUILayout.PropertyField (windDirectionY, true, null);
}
EditorGUILayout.EndVertical();
ApplyChanges ();
break;
case EnviroProfile.settingsModeLW.Weather:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck ();
EditorGUILayout.PropertyField (useTag, true, null);
EditorGUILayout.PropertyField (wetnessAccumulationSpeed, true, null);
EditorGUILayout.PropertyField (wetnessDryingSpeed, true, null);
EditorGUILayout.PropertyField (snowAccumulationSpeed, true, null);
EditorGUILayout.PropertyField (snowMeltingSpeed, true, null);
EditorGUILayout.PropertyField(snowMeltingTresholdTemperature, true, null);
GUILayout.Space (10);
EditorGUILayout.PropertyField (cloudTransitionSpeed, true, null);
EditorGUILayout.PropertyField (fogTransitionSpeed, true, null);
EditorGUILayout.PropertyField(windIntensityTransitionSpeed, true, null);
EditorGUILayout.PropertyField (effectTransitionSpeed, true, null);
EditorGUILayout.PropertyField (audioTransitionSpeed, true, null);
EditorGUILayout.PropertyField(lightningEffect, true, null);
EditorGUILayout.PropertyField(lightningRange, true, null);
EditorGUILayout.PropertyField(lightningHeight, true, null);
EditorGUILayout.PropertyField(temperatureChangingSpeed, true, null);
ApplyChanges ();
GUILayout.EndVertical();
break;
case EnviroProfile.settingsModeLW.Reflections:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(reflectionBool, true, null);
if (myTarget.reflectionSettings.globalReflections)
{
GUILayout.Space(5);
EditorGUILayout.PropertyField(globalReflectionsUpdateOnGameTime, true, null);
if (myTarget.reflectionSettings.globalReflectionsUpdateOnGameTime)
EditorGUILayout.PropertyField(reflectionUpdate, true, null);
EditorGUILayout.PropertyField(globalReflectionsUpdateOnPosition, true, null);
if (myTarget.reflectionSettings.globalReflectionsUpdateOnPosition)
EditorGUILayout.PropertyField(reflectionUpdatePos, true, null);
GUILayout.Space(5);
EditorGUILayout.PropertyField(reflectionIntensity, true, null);
EditorGUILayout.PropertyField(globalReflectionsScale, true, null);
EditorGUILayout.PropertyField(globalReflectionResolution, true, null);
EditorGUILayout.PropertyField(globalReflectionLayers, true, null);
}
ApplyChanges();
GUILayout.EndVertical();
break;
case EnviroProfile.settingsModeLW.Season:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck ();
EditorGUILayout.PropertyField(SpringStart, true, null);
EditorGUILayout.PropertyField(SpringEnd, true, null);
EditorGUILayout.PropertyField(springBaseTemperature, true, null);
EditorGUILayout.PropertyField(SummerStart, true, null);
EditorGUILayout.PropertyField(SummerEnd, true, null);
EditorGUILayout.PropertyField(summerBaseTemperature, true, null);
EditorGUILayout.PropertyField(AutumnStart, true, null);
EditorGUILayout.PropertyField(AutumnEnd, true, null);
EditorGUILayout.PropertyField(autumnBaseTemperature, true, null);
EditorGUILayout.PropertyField(WinterStart, true, null);
EditorGUILayout.PropertyField(WinterEnd, true, null);
EditorGUILayout.PropertyField(winterBaseTemperature, true, null);
ApplyChanges ();
GUILayout.EndVertical();
break;
case EnviroProfile.settingsModeLW.Fog:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck ();
EditorGUILayout.PropertyField(useUnityFog, true, null);
if (!myTarget.fogSettings.useUnityFog)
EditorGUILayout.PropertyField(useSimpleFog, true, null);
EditorGUILayout.PropertyField (fogmode, true, null);
if (!myTarget.fogSettings.useUnityFog)
{
EditorGUILayout.PropertyField(distanceFog, true, null);
EditorGUILayout.PropertyField(startDistance, true, null);
EditorGUILayout.PropertyField(distanceFogIntensity, true, null);
EditorGUILayout.PropertyField(maximumFogIntensity, true, null);
}
if (!myTarget.fogSettings.useSimpleFog && !myTarget.fogSettings.useUnityFog)
{
EditorGUILayout.PropertyField (heightFog, true, null);
EditorGUILayout.PropertyField (height, true, null);
EditorGUILayout.PropertyField (heightFogIntensity, true, null);
GUILayout.Space(10);
EditorGUILayout.LabelField("Scattering", headerStyle);
myTarget.skySettings.waveLength = EditorGUILayout.Vector3Field("Wave Length", myTarget.skySettings.waveLength);
EditorGUILayout.PropertyField(rayleigh, true, null);
EditorGUILayout.PropertyField(fogG, true, null);
EditorGUILayout.PropertyField(fogMie, true, null);
EditorGUILayout.PropertyField(sunIntensity, true, null);
EditorGUILayout.PropertyField(scatteringCurve, true, null);
EditorGUILayout.PropertyField(scatteringColor, true, null);
EditorGUILayout.PropertyField(skyLuminance, true, null);
EditorGUILayout.PropertyField(skyColorPower, true, null);
EditorGUILayout.PropertyField(fogExposure, true, null);
}
else
{
EditorGUILayout.PropertyField(simpleFogColor, true, null);
}
ApplyChanges ();
GUILayout.EndVertical();
break;
case EnviroProfile.settingsModeLW.Lightshafts:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck ();
EditorGUILayout.PropertyField (resolution, true, null);
EditorGUILayout.PropertyField (screenBlendMode, true, null);
EditorGUILayout.PropertyField (useDepthTexture, true, null);
EditorGUILayout.PropertyField (lightShaftsColorSun, true, null);
EditorGUILayout.PropertyField (lightShaftsColorMoon, true, null);
EditorGUILayout.PropertyField (treshholdColorSun, true, null);
EditorGUILayout.PropertyField (treshholdColorMoon, true, null);
EditorGUILayout.PropertyField (blurRadius, true, null);
EditorGUILayout.PropertyField (shaftsIntensity, true, null);
EditorGUILayout.PropertyField (maxRadius, true, null);
ApplyChanges ();
GUILayout.EndVertical();
break;
case EnviroProfile.settingsModeLW.Audio:
GUILayout.BeginVertical("", boxStyleModified);
myTarget.Audio.SFXHolderPrefab = (GameObject)EditorGUILayout.ObjectField ("SFX Prefab:", myTarget.Audio.SFXHolderPrefab, typeof(GameObject), false);
serializedObject.Update ();
thunderSFX.DoLayoutList ();
serializedObject.ApplyModifiedProperties ();
GUILayout.EndVertical();
break;
case EnviroProfile.settingsModeLW.Satellites:
GUILayout.BeginVertical (" Layer Setup", boxStyleModified);
GUILayout.Space (20);
if (GUILayout.Button ("Add Satellite")) {
myTarget.satelliteSettings.additionalSatellites.Add (new EnviroSatellite ());
}
if (GUILayout.Button ("Apply Changes")) {
myTarget.CheckSatellites ();
}
for (int i = 0; i < myTarget.satelliteSettings.additionalSatellites.Count; i++) {
GUILayout.BeginVertical ("", boxStyleModified);
GUILayout.Space (10);
myTarget.satelliteSettings.additionalSatellites [i].name = EditorGUILayout.TextField ("Name", myTarget.satelliteSettings.additionalSatellites [i].name);
GUILayout.Space (10);
myTarget.satelliteSettings.additionalSatellites [i].prefab = (GameObject)EditorGUILayout.ObjectField ("Prefab", myTarget.satelliteSettings.additionalSatellites [i].prefab, typeof(GameObject), false);
myTarget.satelliteSettings.additionalSatellites[i].xRot = EditorGUILayout.Slider("XRot", myTarget.satelliteSettings.additionalSatellites[i].xRot, 0f, 360f);
myTarget.satelliteSettings.additionalSatellites[i].yRot = EditorGUILayout.Slider("YRot", myTarget.satelliteSettings.additionalSatellites[i].yRot, 0f, 360f);
myTarget.satelliteSettings.additionalSatellites[i].zRot = EditorGUILayout.Slider("ZRot", myTarget.satelliteSettings.additionalSatellites[i].zRot, 0f, 360f);
if (GUILayout.Button ("Remove"))
{
myTarget.satelliteSettings.additionalSatellites.Remove (myTarget.satelliteSettings.additionalSatellites [i]);
myTarget.CheckSatellites ();
}
GUILayout.EndVertical ();
}
serializedObj.Update ();
GUILayout.EndVertical ();
break;
case EnviroProfile.settingsModeLW.Quality:
GUILayout.BeginVertical("", boxStyleModified);
EditorGUI.BeginChangeCheck ();
EditorGUILayout.PropertyField (effectQuality, true, null);
EditorGUILayout.PropertyField (updateInterval, true, null);
ApplyChanges ();
GUILayout.EndVertical();
break;
}
}
GUILayout.EndVertical ();
}
GUILayout.EndVertical ();
if (myTarget.profile != null) {
EditorGUI.BeginChangeCheck ();
// Begin Setup
GUILayout.BeginVertical ("", boxStyle);
// Player Setup
if ((myTarget.Player == null || myTarget.PlayerCamera == null) && !myTarget.AssignInRuntime)
GUI.backgroundColor = modifiedColor;
else if ((myTarget.Player != null && myTarget.PlayerCamera != null) || myTarget.AssignInRuntime)
GUI.backgroundColor = greenColor;
GUILayout.BeginVertical ("", boxStyleModified);
GUI.backgroundColor = Color.white;
myTarget.profile.showPlayerSetup = GUILayout.Toggle(myTarget.profile.showPlayerSetup, "Player & Camera Setup", headerFoldout);
if (myTarget.profile.showPlayerSetup) {
GUILayout.BeginVertical("", boxStyleModified);
EditorGUILayout.PropertyField (Player, true, null);
EditorGUILayout.PropertyField (Camera, true, null);
GUILayout.EndVertical();
GUILayout.BeginVertical("", boxStyleModified);
AssignOnRuntime.boolValue = EditorGUILayout.BeginToggleGroup ("Assign On Runtime", AssignOnRuntime.boolValue);
PlayerTag.stringValue = EditorGUILayout.TagField ("Player Tag", PlayerTag.stringValue);
CameraTag.stringValue = EditorGUILayout.TagField ("Camera Tag", CameraTag.stringValue);
EditorGUILayout.EndToggleGroup ();
GUILayout.EndVertical();
}
GUILayout.EndVertical ();
/// Render Setup
if (myTarget.tonemapping)
GUI.backgroundColor = modifiedColor;
else
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical ("", boxStyleModified);
GUI.backgroundColor = Color.white;
myTarget.profile.showRenderingSetup = GUILayout.Toggle(myTarget.profile.showRenderingSetup, "Rendering Setup", headerFoldout);
if (myTarget.profile.showRenderingSetup) {
GUILayout.BeginVertical("", boxStyleModified);
EditorGUILayout.LabelField("Tonemapping Settings", headerStyle, null);
EditorGUILayout.PropertyField(tonemapping, true, null);
if (myTarget.tonemapping)
{
GUILayout.BeginVertical("", boxStyleModified);
EditorGUILayout.LabelField("Please consider to deactivate tonemapping option here and use post processing tonemapping instead for best results!", wrapStyle, null);
GUILayout.EndVertical();
}
GUILayout.EndVertical();
GUILayout.BeginVertical("", boxStyleModified);
EditorGUILayout.PropertyField(setCameraClearFlags, true, null);
GUILayout.EndVertical();
}
GUILayout.EndVertical ();
/// Components Setup
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical ("", boxStyleModified);
GUI.backgroundColor = Color.white;
myTarget.profile.showComponentsSetup = GUILayout.Toggle(myTarget.profile.showComponentsSetup, "Component Setup", headerFoldout);
if (myTarget.profile.showComponentsSetup)
{
GUILayout.BeginVertical("", boxStyleModified);
EditorGUILayout.PropertyField (Sun, true, null);
EditorGUILayout.PropertyField (Moon, true, null);
EditorGUILayout.PropertyField (DirectLight, true, null);
EditorGUILayout.PropertyField(AdditionalDirectLight, true, null);
EditorGUILayout.PropertyField (LightningGenerator, true, null);
EditorGUILayout.PropertyField (windZone, true, null);
EditorGUILayout.PropertyField (GlobalReflectionProbe, true, null);
EditorGUILayout.PropertyField (satellites, true, null);
EditorGUILayout.PropertyField (starsRotation, true, null);
EditorGUILayout.PropertyField (particleClouds, true, null);
GUILayout.EndVertical();
}
GUILayout.EndVertical ();
GUILayout.EndVertical ();
////////////
// Begin Controls
GUILayout.BeginVertical ("", boxStyle);
// Time Control
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical ("", boxStyleModified);
GUI.backgroundColor = Color.white;
myTarget.profile.showTimeUI = GUILayout.Toggle(myTarget.profile.showTimeUI, "Time and Location Controls", headerFoldout);
if (myTarget.profile.showTimeUI) {
GUILayout.BeginVertical ("Time", boxStyleModified);
GUILayout.Space (20);
EditorGUILayout.PropertyField (ProgressMode, true, null);
GUILayout.Space (5);
EditorGUILayout.PropertyField (Seconds, true, null);
EditorGUILayout.PropertyField (Minutes, true, null);
EditorGUILayout.PropertyField (Hours, true, null);
EditorGUILayout.PropertyField (Days, true, null);
EditorGUILayout.PropertyField (Years, true, null);
GUILayout.Space(10);
EditorGUILayout.PropertyField (DaysInYear, true, null);
GUILayout.Space(10);
EditorGUILayout.PropertyField(cycleLenghtInMinutes, true, null);
EditorGUILayout.PropertyField (DayLength, true, null);
EditorGUILayout.PropertyField (NightLength, true, null);
EditorGUILayout.PropertyField(dayNightSwitch, true, null);
GUILayout.EndVertical ();
GUILayout.BeginVertical ("Season", boxStyleModified);
GUILayout.Space (20);
EditorGUILayout.PropertyField (UpdateSeason, true, null);
EditorGUILayout.PropertyField (CurrentSeason, true, null);
GUILayout.EndVertical ();
GUILayout.BeginVertical ("Location", boxStyleModified);
GUILayout.Space (20);
EditorGUILayout.PropertyField (UTC, true, null);
GUILayout.Space (10);
EditorGUILayout.PropertyField (Latitude, true, null);
EditorGUILayout.PropertyField (Longitude, true, null);
GUILayout.EndVertical ();
}
GUILayout.EndVertical ();
// Time End
// Weather Control
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical ("", boxStyleModified);
GUI.backgroundColor = Color.white;
myTarget.profile.showWeatherUI = GUILayout.Toggle(myTarget.profile.showWeatherUI, "Weather Controls", headerFoldout);
if (myTarget.profile.showWeatherUI) {
GUILayout.BeginVertical ("Weather", boxStyleModified);
GUILayout.Space (20);
EditorGUILayout.PropertyField(UpdateWeather, true, null);
EditorGUILayout.PropertyField (StartWeather, true, null);
GUILayout.Space (15);
if (Application.isPlaying) {
if (myTarget.Weather.weatherPresets.Count > 0) {
GUIContent[] zonePrefabs = new GUIContent[myTarget.Weather.weatherPresets.Count];
for (int idx = 0; idx < zonePrefabs.Length; idx++) {
zonePrefabs [idx] = new GUIContent (myTarget.Weather.weatherPresets [idx].Name);
}
int weatherID = EditorGUILayout.Popup (new GUIContent ("Current Weather"), myTarget.GetActiveWeatherID (), zonePrefabs);
myTarget.ChangeWeather (weatherID);
}
} else
EditorGUILayout.LabelField ("Weather can only be changed in runtime!");
if (GUILayout.Button ("Edit current Weather Preset")) {
if(myTarget.Weather.currentActiveWeatherPreset != null)
Selection.activeObject = myTarget.Weather.currentActiveWeatherPreset;
else if(myTarget.Weather.startWeatherPreset != null)
Selection.activeObject = myTarget.Weather.startWeatherPreset;
}
GUILayout.EndVertical ();
GUILayout.BeginVertical ("Zones", boxStyleModified);
GUILayout.Space (20);
myTarget.Weather.currentActiveZone = (EnviroZone)EditorGUILayout.ObjectField ("Current Zone", myTarget.Weather.currentActiveZone, typeof(EnviroZone), true);
GUILayout.EndVertical ();
}
GUILayout.EndVertical ();
// Weather End
// Effects Control
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical ("", boxStyleModified);
GUI.backgroundColor = Color.white;
myTarget.profile.showEffectsUI = GUILayout.Toggle(myTarget.profile.showEffectsUI, "Feature Controls", headerFoldout);
if (myTarget.profile.showEffectsUI) {
GUILayout.BeginVertical("Features", boxStyleModified);
GUILayout.Space(20);
EditorGUILayout.PropertyField (usePostEffectFog, true, null);
EditorGUILayout.PropertyField (renderClouds, true, null);
EditorGUILayout.PropertyField (EnableSunShafts, true, null);
EditorGUILayout.PropertyField (EnableMoonShafts, true, null);
GUILayout.EndVertical();
GUILayout.BeginVertical("Scene Preview", boxStyleModified);
GUILayout.Space(20);
EditorGUILayout.PropertyField(showFogInEditor, true, null);
GUILayout.EndVertical();
}
GUILayout.EndVertical ();
// Effects End
// Audio Control
GUI.backgroundColor = boxColor1;
GUILayout.BeginVertical("", boxStyleModified);
GUI.backgroundColor = Color.white;
myTarget.profile.showAudioUI = GUILayout.Toggle(myTarget.profile.showAudioUI, "Audio Controls", headerFoldout);
if (myTarget.profile.showAudioUI) {
GUILayout.BeginVertical ("", boxStyleModified);
EditorGUILayout.PropertyField (AmbientVolume, true, null);
EditorGUILayout.PropertyField (WeatherVolume, true, null);
GUILayout.EndVertical ();
}
GUILayout.EndVertical ();
// Audio End
/////////////
EditorGUILayout.EndVertical ();
} else {
GUILayout.BeginVertical ("", boxStyle);
EditorGUILayout.LabelField ("No profile assigned!");
if (GUILayout.Button ("Create and assign new profile!")) {
myTarget.profile = EnviroProfileCreation.CreateNewEnviroProfile ();
myTarget.ApplyProfile (myTarget.profile);
myTarget.ReInit ();
}
GUILayout.EndVertical ();
}
if (EditorGUI.EndChangeCheck())
{
serializedObj.ApplyModifiedProperties();
EditorUtility.SetDirty(target);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0c71f3f9e9cb0c340b07643659cb7656
timeCreated: 1497912081
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,965 @@
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////// EnviroSky- Renders sky with sun, moon, clouds and weather. ////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Collections;
[ExecuteInEditMode]
public class EnviroSkyLite : EnviroCore
{
#region Var
private static EnviroSkyLite _instance; // Creat a static instance for easy access!
public static EnviroSkyLite instance
{
get
{
//If _instance hasn't been set yet, we grab it from the scene!
//This will only happen the first time this reference is used.
if (_instance == null)
_instance = GameObject.FindObjectOfType<EnviroSkyLite>();
return _instance;
}
}
public bool useParticleClouds = false;
public bool usePostEffectFog = true;
public bool showFogInEditor = true;
//Camera Components
[HideInInspector]public EnviroSkyRenderingLW EnviroSkyRender;
//Materials
[HideInInspector]public Material skyMat;
private double lastMoonUpdate;
//Inspector
[HideInInspector]public bool showSettings = false;
#endregion
void Start()
{
//Check for Manager first!
if (EnviroSkyMgr.instance == null)
{
Debug.Log("Please use the EnviroSky Manager!");
gameObject.SetActive(false);
return;
}
//Time
SetTime(GameTime.Years, GameTime.Days, GameTime.Hours, GameTime.Minutes, GameTime.Seconds);
lastHourUpdate = Mathf.RoundToInt(internalHour);
currentTimeInHours = GetInHours(internalHour, GameTime.Days, GameTime.Years, GameTime.DaysInYear);
Weather.weatherFullyChanged = false;
thunder = 0f;
// Check for Profile
if (profileLoaded)
{
InvokeRepeating("UpdateEnviroment", 0, qualitySettings.UpdateInterval);// Vegetation Updates
CreateEffects("Enviro Effects LW"); //Create Weather Effects Holder
// Instantiate Lightning Effect
if (weatherSettings.lightningEffect != null && lightningEffect == null)
lightningEffect = Instantiate(weatherSettings.lightningEffect, EffectsHolder.transform).GetComponent<ParticleSystem>();
if (PlayerCamera != null && Player != null && AssignInRuntime == false && profile != null)
{
Init();
}
}
StartCoroutine(SetSkyBoxLateAdditive());
}
private IEnumerator SetSkyBoxLateAdditive()
{
yield return 0;
if (skyMat != null && RenderSettings.skybox != skyMat)
SetupSkybox();
}
void OnEnable()
{
//Check for Manager first!
if (EnviroSkyMgr.instance == null)
{
return;
}
if (Weather.zones.Count < 1)
Weather.zones.Add(GetComponent<EnviroZone>());
//Set Weather
Weather.currentActiveWeatherPreset = Weather.zones[0].currentActiveZoneWeatherPreset;
Weather.lastActiveWeatherPreset = Weather.currentActiveWeatherPreset;
if (profile == null)
{
Debug.LogError("No profile assigned!");
return;
}
// Auto Load profile
if (profileLoaded == false)
ApplyProfile(profile);
PreInit();
if (AssignInRuntime)
{
started = false; //Wait for assignment
}
else if (PlayerCamera != null && Player != null)
{
Init();
}
}
/// <summary>
/// Re-Initilize the system.
/// </summary>
public void ReInit()
{
OnEnable();
}
/// <summary>
/// Pee-Initilize the system.
/// </summary>
private void PreInit()
{
// Check time
if (GameTime.solarTime < GameTime.dayNightSwitch)
isNight = true;
else
isNight = false;
//return when in server mode!
if (serverMode)
return;
CheckSatellites();
// Setup Fog Mode
RenderSettings.fogMode = fogSettings.Fogmode;
// Setup Skybox Material
SetupSkybox();
// Set ambient mode
RenderSettings.ambientMode = lightSettings.ambientMode;
// Set Fog
//RenderSettings.fogDensity = 0f;
//RenderSettings.fogStartDistance = 0f;
//RenderSettings.fogEndDistance = 1000f;
// Setup ReflectionProbe
if (Components.GlobalReflectionProbe == null)
{
GameObject temp;
foreach (Transform child in transform)
{
if (child.name == "GlobalReflections")
{
temp = child.gameObject;
Components.GlobalReflectionProbe = temp.GetComponent<EnviroReflectionProbe>();
if (Components.GlobalReflectionProbe == null)
Components.GlobalReflectionProbe = temp.AddComponent<EnviroReflectionProbe>();
}
}
}
if (!Components.Sun)
{
Debug.LogError("Please set sun object in inspector!");
}
if (!Components.satellites)
{
Debug.LogError("Please set satellite object in inspector!");
}
if (Components.Moon)
{
MoonTransform = Components.Moon.transform;
//Deactivate old moon for now.
if (MoonTransform.GetComponent<MeshRenderer>())
MoonTransform.GetComponent<MeshRenderer>().enabled = false;
}
else { Debug.LogError("Please set moon object in inspector!"); }
if (lightSettings.directionalLightMode == EnviroLightSettings.LightingMode.Single)
{
SetupMainLight();
}
else
{
SetupMainLight();
SetupAdditionalLight();
}
if (Components.particleClouds)
{
ParticleSystem[] systems = Components.particleClouds.GetComponentsInChildren<ParticleSystem>();
if (systems.Length > 0)
particleClouds.layer1System = systems[0];
if (systems.Length > 1)
particleClouds.layer2System = systems[1];
if (particleClouds.layer1System != null)
particleClouds.layer1Material = particleClouds.layer1System.GetComponent<ParticleSystemRenderer>().sharedMaterial;
if (particleClouds.layer2System != null)
particleClouds.layer2Material = particleClouds.layer2System.GetComponent<ParticleSystemRenderer>().sharedMaterial;
}
else
{
Debug.LogError("Please set particleCLouds object in inspector!");
}
}
/// <summary>
/// Creation and assignment of skybox
/// </summary>
public void SetupSkybox()
{
if (skySettings.skyboxModeLW == EnviroSkySettings.SkyboxModiLW.Simple)
{
if (skyMat != null)
DestroyImmediate(skyMat);
skyMat = new Material(Shader.Find("Enviro/Lite/SkyboxSimple"));
if (skySettings.starsCubeMap != null)
skyMat.SetTexture("_Stars", skySettings.starsCubeMap);
if (skySettings.galaxyCubeMap != null)
skyMat.SetTexture("_Galaxy", skySettings.galaxyCubeMap);
RenderSettings.skybox = skyMat;
}
else if (skySettings.skyboxMode == EnviroSkySettings.SkyboxModi.CustomSkybox)
{
if (skySettings.customSkyboxMaterial != null)
RenderSettings.skybox = skySettings.customSkyboxMaterial;
}
//Update environment texture in next frame!
if (lightSettings.ambientMode == UnityEngine.Rendering.AmbientMode.Skybox)
StartCoroutine(UpdateAmbientLightWithDelay());
}
/// <summary>
/// Update the environment texture for skybox ambient mode with one frame delay. Somehow not working in same frame as we create the skybox material.
/// </summary>
private IEnumerator UpdateAmbientLightWithDelay()
{
yield return 0;
DynamicGI.UpdateEnvironment();
}
/// <summary>
/// Final Initilization and startup.
/// </summary>
private void Init()
{
if (profile == null)
return;
if (serverMode)
{
started = true;
return;
}
InitImageEffects();
// Setup Camera
if (PlayerCamera != null)
{
if (setCameraClearFlags)
PlayerCamera.clearFlags = CameraClearFlags.Skybox;
Components.GlobalReflectionProbe.myProbe.farClipPlane = PlayerCamera.farClipPlane;
}
started = true;
}
/// <summary>
/// Creation and setup of post processing components.
/// </summary>
private void InitImageEffects()
{
EnviroSkyRender = PlayerCamera.gameObject.GetComponent<EnviroSkyRenderingLW>();
if (EnviroSkyRender == null)
EnviroSkyRender = PlayerCamera.gameObject.AddComponent<EnviroSkyRenderingLW>();
EnviroPostProcessing = PlayerCamera.gameObject.GetComponent<EnviroPostProcessing>();
if (EnviroPostProcessing == null)
EnviroPostProcessing = PlayerCamera.gameObject.AddComponent<EnviroPostProcessing>();
}
/// <summary>
/// Setup Main light that is eather used for sun and moon or only sun based on used lighting mode.
/// </summary>
private void SetupMainLight()
{
if (Components.DirectLight)
{
MainLight = Components.DirectLight.GetComponent<Light>();
if (EnviroSkyMgr.instance.dontDestroy && Application.isPlaying)
DontDestroyOnLoad(Components.DirectLight);
}
else
{
GameObject oldLight = GameObject.Find("Enviro Directional Light");
if (oldLight != null)
Components.DirectLight = oldLight.transform;
else
Components.DirectLight = CreateDirectionalLight(false);
MainLight = Components.DirectLight.GetComponent<Light>();
if (EnviroSkyMgr.instance.dontDestroy && Application.isPlaying)
DontDestroyOnLoad(Components.DirectLight);
}
//Remove the additional light if in single mode
if (lightSettings.directionalLightMode == EnviroLightSettings.LightingMode.Single)
{
if (Components.AdditionalDirectLight != null)
DestroyImmediate(Components.AdditionalDirectLight.gameObject);
}
}
/// <summary>
/// Setup additional light that is used for moon in dual lighting mode.
/// </summary>
private void SetupAdditionalLight()
{
if (Components.AdditionalDirectLight)
{
AdditionalLight = Components.AdditionalDirectLight.GetComponent<Light>();
if (EnviroSkyMgr.instance.dontDestroy && Application.isPlaying)
DontDestroyOnLoad(Components.AdditionalDirectLight);
}
else
{
GameObject oldLight = GameObject.Find("Enviro Directional Light - Moon");
if (oldLight != null)
Components.AdditionalDirectLight = oldLight.transform;
else
Components.AdditionalDirectLight = CreateDirectionalLight(true);
AdditionalLight = Components.DirectLight.GetComponent<Light>();
if (EnviroSkyMgr.instance.dontDestroy && Application.isPlaying)
DontDestroyOnLoad(Components.AdditionalDirectLight);
}
}
void Update()
{
if (profile == null)
{
Debug.Log("No profile applied! Please create and assign a profile.");
return;
}
if (!started && !serverMode)
{
UpdateTime(GameTime.DaysInYear);
UpdateSunAndMoonPosition();
UpdateSceneView();
CalculateDirectLight();
UpdateAmbientLight();
UpdateReflections();
if (AssignInRuntime && PlayerTag != "" && CameraTag != "" && Application.isPlaying)
{
// Search for Player by tag
GameObject plr = GameObject.FindGameObjectWithTag(PlayerTag);
if (plr != null)
Player = plr;
// Search for camera by tag
for (int i = 0; i < Camera.allCameras.Length; i++)
{
if (Camera.allCameras[i].tag == CameraTag)
PlayerCamera = Camera.allCameras[i];
}
if (Player != null && PlayerCamera != null)
{
Init();
started = true;
}
else { started = false; return; }
}
else { started = false; return; }
}
UpdateTime(GameTime.DaysInYear);
ValidateParameters();
if (!serverMode)
{
UpdateSceneView();
if (!Application.isPlaying && Weather.startWeatherPreset != null && startMode == EnviroStartMode.Started)
{
UpdateClouds(Weather.startWeatherPreset, false);
UpdateFog(Weather.startWeatherPreset, false);
UpdateWeatherVariables(Weather.startWeatherPreset);
#if AURA_IN_PROJECT
if(EnviroSkyMgr.instance.aura2Support)
UpdateAura2(Weather.startWeatherPreset, true);
#endif
}
UpdateAmbientLight();
UpdateReflections();
UpdateWeather();
UpdateParticleClouds(useParticleClouds);
UpdateSunAndMoonPosition();
CalculateDirectLight();
SetMaterialsVariables();
#if !ENVIRO_HDRP
if (RenderSettings.skybox != skyMat)
SetupSkybox();
#endif
if (EnviroSkyRender == null && PlayerCamera != null)
InitImageEffects();
// Switch to Unity forward fog for best performance.
if(fogSettings.useUnityFog && PlayerCamera != null && PlayerCamera.actualRenderingPath == RenderingPath.Forward)
{
RenderSettings.fog = true;
if(EnviroSkyRender != null && EnviroSkyRender.isActiveAndEnabled)
EnviroSkyRender.enabled = false;
}
else
{
//Enable or Disable Enviro Fog Post Effect
if (usePostEffectFog && EnviroSkyRender != null && !EnviroSkyRender.isActiveAndEnabled)
EnviroSkyRender.enabled = true;
else if (!usePostEffectFog && EnviroSkyRender != null && EnviroSkyRender.isActiveAndEnabled)
EnviroSkyRender.enabled = false;
}
if (!isNight && GameTime.solarTime < GameTime.dayNightSwitch)
{
isNight = true;
if (Audio.AudioSourceAmbient != null)
TryPlayAmbientSFX();
EnviroSkyMgr.instance.NotifyIsNight();
}
else if (isNight && GameTime.solarTime >= GameTime.dayNightSwitch)
{
isNight = false;
if (Audio.AudioSourceAmbient != null)
TryPlayAmbientSFX();
EnviroSkyMgr.instance.NotifyIsDay();
}
}
else
{
UpdateWeather();
if (!isNight && GameTime.solarTime < GameTime.dayNightSwitch)
{
isNight = true;
EnviroSkyMgr.instance.NotifyIsNight();
}
else if (isNight && GameTime.solarTime >= GameTime.dayNightSwitch)
{
isNight = false;
EnviroSkyMgr.instance.NotifyIsDay();
}
}
}
void LateUpdate()
{
if (!serverMode && PlayerCamera != null && Player != null)
{
transform.position = Player.transform.position;
float scale = PlayerCamera.farClipPlane - (PlayerCamera.farClipPlane * 0.1f);
transform.localScale = new Vector3(scale, scale, scale);
if (EffectsHolder != null)
EffectsHolder.transform.position = Player.transform.position;
}
}
private void SetMaterialsVariables()
{
//Simple
skyMat.SetFloat("_BlackGround", skySettings.blackGroundMode ? 1f : 0f);
skyMat.SetColor("_SkyColor", skySettings.simpleSkyColor.Evaluate(GameTime.solarTime));
skyMat.SetColor("_HorizonColor", skySettings.simpleHorizonColor.Evaluate(GameTime.solarTime));
skyMat.SetColor("_SunColor", skySettings.simpleSunColor.Evaluate(GameTime.solarTime));
skyMat.SetFloat("_SunDiskSizeSimple", skySettings.simpleSunDiskSize.Evaluate(GameTime.solarTime));
skyMat.SetFloat("_StarsIntensity", skySettings.starsIntensity.Evaluate(GameTime.solarTime));
if (skySettings.moonPhaseMode == EnviroSkySettings.MoonPhases.Realistic)
{
float angle = Vector3.SignedAngle(Components.Moon.transform.forward, Components.Sun.transform.forward, transform.forward);
if (GameTime.Latitude >= 0)
{
if (angle < 0)
{
customMoonPhase = Remap(angle, 0f, -180f, -2f, 0f);
}
else
{
customMoonPhase = Remap(angle, 0f, 180f, 2f, 0f);
}
}
else
{
if (angle < 0)
{
customMoonPhase = Remap(angle, 0f, -180f, 2f, 0f);
}
else
{
customMoonPhase = Remap(angle, 0f, 180f, -2f, 0f);
}
}
}
skyMat.SetVector("_moonParams", new Vector4(skySettings.moonSize, skySettings.glowSize, skySettings.moonGlow.Evaluate(GameTime.solarTime), customMoonPhase));
skyMat.SetVector("_MoonDir", Components.Moon.transform.forward);
skyMat.SetColor("_MoonColor", skySettings.moonColor);
if (skySettings.renderMoon)
{
if(skySettings.moonTexture != null)
skyMat.SetTexture("_MoonTex", skySettings.moonTexture);
}
else
{
skyMat.SetTexture("_MoonTex", null);
}
//Clouds
skyMat.SetVector("_CloudAnimation", cirrusAnim);
//cirrus
if (cloudsSettings.cirrusCloudsTexture != null)
skyMat.SetTexture("_CloudMap", cloudsSettings.cirrusCloudsTexture);
skyMat.SetColor("_CloudColor", cloudsSettings.cirrusCloudsColor.Evaluate(GameTime.solarTime));
skyMat.SetFloat("_CloudAltitude", cloudsSettings.cirrusCloudsAltitude);
skyMat.SetFloat("_CloudAlpha", cloudsConfig.cirrusAlpha);
skyMat.SetFloat("_CloudCoverage", cloudsConfig.cirrusCoverage);
skyMat.SetFloat("_CloudColorPower", cloudsConfig.cirrusColorPow);
//Flat Clouds
if (cloudsSettings.flatCloudsBaseTexture != null)
skyMat.SetTexture("_FlatCloudsBaseTexture", cloudsSettings.flatCloudsBaseTexture);
if (cloudsSettings.flatCloudsDetailTexture != null)
skyMat.SetTexture("_FlatCloudsDetailTexture", cloudsSettings.flatCloudsDetailTexture);
skyMat.SetVector("_FlatCloudsLightDirection", Components.DirectLight.transform.forward);
skyMat.SetColor("_FlatCloudsLightColor", cloudsSettings.flatCloudsDirectLightColor.Evaluate(GameTime.solarTime));
skyMat.SetColor("_FlatCloudsAmbientColor", cloudsSettings.flatCloudsAmbientLightColor.Evaluate(GameTime.solarTime));
skyMat.SetVector("_FlatCloudsParams", new Vector4(cloudsConfig.flatCoverage, cloudsConfig.flatCloudsDensity, cloudsSettings.flatCloudsAltitude,tonemapping ? 1f : 0f));
skyMat.SetVector("_FlatCloudsTiling", new Vector4(cloudsSettings.flatCloudsBaseTextureTiling, cloudsSettings.flatCloudsDetailTextureTiling, 0f,0f));
skyMat.SetVector("_FlatCloudsLightingParams", new Vector4(cloudsConfig.flatCloudsDirectLightIntensity, cloudsConfig.flatCloudsAmbientLightIntensity, cloudsConfig.flatCloudsAbsorbtion, cloudsConfig.flatCloudsHGPhase));
skyMat.SetVector("_FlatCloudsAnimation", new Vector4(cloudFlatBaseAnim.x, cloudFlatBaseAnim.y, cloudFlatDetailAnim.x, cloudFlatDetailAnim.y));
skyMat.SetFloat("_CloudsExposure", cloudsSettings.cloudsExposure);
//Globals
Shader.SetGlobalVector("_SunDir", -Components.Sun.transform.forward);
Shader.SetGlobalColor("_EnviroLighting", lightSettings.LightColor.Evaluate(GameTime.solarTime));
// Moon
Shader.SetGlobalVector("_SunPosition", Components.Sun.transform.localPosition + (-Components.Sun.transform.forward * 10000f));
Shader.SetGlobalVector("_MoonPosition", Components.Moon.transform.localPosition);
//Color Mods
Shader.SetGlobalColor("_weatherSkyMod", Color.Lerp(currentWeatherSkyMod, interiorZoneSettings.currentInteriorSkyboxMod, interiorZoneSettings.currentInteriorSkyboxMod.a));
Shader.SetGlobalColor("_weatherFogMod", Color.Lerp(currentWeatherFogMod, interiorZoneSettings.currentInteriorFogColorMod, interiorZoneSettings.currentInteriorFogColorMod.a));
//Fog
Shader.SetGlobalVector("_EnviroSkyFog", new Vector4(Fog.skyFogHeight, Fog.skyFogIntensity, Fog.skyFogStart, fogSettings.heightFogIntensity));
Shader.SetGlobalFloat("_distanceFogIntensity", fogSettings.distanceFogIntensity);
Shader.SetGlobalFloat("_maximumFogDensity", 1 - fogSettings.maximumFogDensity);
if (fogSettings.useSimpleFog)
{
Shader.EnableKeyword("ENVIRO_SIMPLE_FOG");
Shader.SetGlobalVector("_EnviroParams", new Vector4(Mathf.Clamp(1f - GameTime.solarTime, 0.5f, 1f), fogSettings.distanceFog ? 1f : 0f, 0f, tonemapping ? 1f : 0f));
}
else
{
Shader.SetGlobalColor("_scatteringColor", skySettings.scatteringColor.Evaluate(GameTime.solarTime));
Shader.SetGlobalFloat("_scatteringStrenght", Fog.scatteringStrenght);
Shader.SetGlobalFloat("_scatteringPower", skySettings.scatteringCurve.Evaluate(GameTime.solarTime));
Shader.SetGlobalFloat("_SunBlocking", Fog.sunBlocking);
Shader.SetGlobalVector("_EnviroParams", new Vector4(Mathf.Clamp(1f - GameTime.solarTime, 0.5f, 1f), fogSettings.distanceFog ? 1f : 0f, fogSettings.heightFog ? 1f : 0f, tonemapping ? 1f : 0f));
Shader.SetGlobalVector("_Bm", BetaMie(skySettings.turbidity, skySettings.waveLength) * (skySettings.mie * (Fog.scatteringStrenght * GameTime.solarTime)));
Shader.SetGlobalVector("_BmScene", BetaMie(skySettings.turbidity, skySettings.waveLength) * (fogSettings.mie * (Fog.scatteringStrenght * GameTime.solarTime)));
Shader.SetGlobalVector("_Br", BetaRay(skySettings.waveLength) * skySettings.rayleigh);
Shader.SetGlobalVector("_mieG", GetMieG(skySettings.g));
Shader.SetGlobalVector("_mieGScene", GetMieGScene(skySettings.g));
Shader.SetGlobalVector("_SunParameters", new Vector4(skySettings.sunIntensity, skySettings.sunDiskScale, skySettings.sunDiskIntensity, 0f));
Shader.SetGlobalFloat("_FogExposure", fogSettings.fogExposure);
Shader.SetGlobalFloat("_SkyLuminance", skySettings.skyLuminence.Evaluate(GameTime.solarTime));
Shader.SetGlobalFloat("_SkyColorPower", skySettings.skyColorPower.Evaluate(GameTime.solarTime));
Shader.SetGlobalFloat("_heightFogIntensity", fogSettings.heightFogIntensity);
Shader.SetGlobalFloat("_lightning", thunder);
Shader.DisableKeyword("ENVIRO_SIMPLE_FOG");
}
Shader.DisableKeyword("ENVIROVOLUMELIGHT");
}
// Make the parameters stay in reasonable range
private void ValidateParameters()
{
// Keep GameTime Parameters right!
internalHour = Mathf.Repeat(internalHour, 24f);
GameTime.Longitude = Mathf.Clamp(GameTime.Longitude, -180, 180);
GameTime.Latitude = Mathf.Clamp(GameTime.Latitude, -90, 90);
#if UNITY_EDITOR
if (GameTime.cycleLengthInMinutes <= 0f)
{
if (GameTime.cycleLengthInMinutes < 0f)
GameTime.cycleLengthInMinutes = 0f;
internalHour = 12f;
customMoonPhase = 0f;
}
if (GameTime.Days < 0)
GameTime.Days = 0;
if (GameTime.Years < 0)
GameTime.Years = 0;
#endif
}
private void UpdateClouds(EnviroWeatherPreset i, bool withTransition)
{
if (i == null)
return;
float speed = 500f * Time.deltaTime;
if (withTransition)
speed = weatherSettings.cloudTransitionSpeed * Time.deltaTime;
cloudsConfig.cirrusAlpha = Mathf.Lerp(cloudsConfig.cirrusAlpha, i.cloudsConfig.cirrusAlpha, speed);
cloudsConfig.cirrusCoverage = Mathf.Lerp(cloudsConfig.cirrusCoverage, i.cloudsConfig.cirrusCoverage, speed);
cloudsConfig.cirrusColorPow = Mathf.Lerp(cloudsConfig.cirrusColorPow, i.cloudsConfig.cirrusColorPow, speed);
cloudsConfig.particleLayer1Alpha = Mathf.Lerp(cloudsConfig.particleLayer1Alpha, i.cloudsConfig.particleLayer1Alpha, speed);
cloudsConfig.particleLayer1Brightness = Mathf.Lerp(cloudsConfig.particleLayer1Brightness, i.cloudsConfig.particleLayer1Brightness, speed);
cloudsConfig.particleLayer1ColorPow = Mathf.Lerp(cloudsConfig.particleLayer1ColorPow, i.cloudsConfig.particleLayer1ColorPow, speed);
cloudsConfig.particleLayer2Alpha = Mathf.Lerp(cloudsConfig.particleLayer2Alpha, i.cloudsConfig.particleLayer2Alpha, speed);
cloudsConfig.particleLayer2Brightness = Mathf.Lerp(cloudsConfig.particleLayer2Brightness, i.cloudsConfig.particleLayer2Brightness, speed);
cloudsConfig.particleLayer2ColorPow = Mathf.Lerp(cloudsConfig.particleLayer2ColorPow, i.cloudsConfig.particleLayer2ColorPow, speed);
cloudsConfig.flatCloudsAbsorbtion = Mathf.Lerp(cloudsConfig.flatCloudsAbsorbtion, i.cloudsConfig.flatCloudsAbsorbtion, speed);
cloudsConfig.flatCoverage = Mathf.Lerp(cloudsConfig.flatCoverage, i.cloudsConfig.flatCoverage, speed);
cloudsConfig.flatCloudsAmbientLightIntensity = Mathf.Lerp(cloudsConfig.flatCloudsAmbientLightIntensity, i.cloudsConfig.flatCloudsAmbientLightIntensity, speed);
cloudsConfig.flatCloudsDirectLightIntensity = Mathf.Lerp(cloudsConfig.flatCloudsDirectLightIntensity, i.cloudsConfig.flatCloudsDirectLightIntensity, speed);
cloudsConfig.flatCloudsDensity = Mathf.Lerp(cloudsConfig.flatCloudsDensity, i.cloudsConfig.flatCloudsDensity, speed);
cloudsConfig.flatCloudsHGPhase = Mathf.Lerp(cloudsConfig.flatCloudsHGPhase, i.cloudsConfig.flatCloudsHGPhase, speed);
shadowIntensityMod = Mathf.Lerp(shadowIntensityMod, i.shadowIntensityMod, speed);
currentWeatherSkyMod = Color.Lerp(currentWeatherSkyMod, i.weatherSkyMod.Evaluate(GameTime.solarTime), speed);
currentWeatherFogMod = Color.Lerp(currentWeatherFogMod, i.weatherFogMod.Evaluate(GameTime.solarTime), speed * 10);
currentWeatherLightMod = Color.Lerp(currentWeatherLightMod, i.weatherLightMod.Evaluate(GameTime.solarTime), speed);
}
private void UpdateFog(EnviroWeatherPreset i, bool withTransition)
{
// Set the Fog color to light color to match Day-Night cycle and weather
Color fogClr = Color.Lerp(fogSettings.simpleFogColor.Evaluate(GameTime.solarTime), customFogColor, customFogIntensity);
RenderSettings.fogColor = Color.Lerp(fogClr, currentWeatherFogMod, currentWeatherFogMod.a);
if (i != null)
{
float speed = 500f * Time.deltaTime;
if (withTransition)
speed = weatherSettings.fogTransitionSpeed * Time.deltaTime;
if (fogSettings.Fogmode == FogMode.Linear)
{
RenderSettings.fogEndDistance = Mathf.Lerp(RenderSettings.fogEndDistance, i.fogDistance, speed);
RenderSettings.fogStartDistance = Mathf.Lerp(RenderSettings.fogStartDistance, i.fogStartDistance, speed);
}
else
{
float targetDensity = i.fogDensity;
if (fogSettings.useUnityFog)
targetDensity *= fogSettings.distanceFogIntensity;
if (updateFogDensity)
RenderSettings.fogDensity = Mathf.Lerp(RenderSettings.fogDensity, targetDensity, speed) * interiorZoneSettings.currentInteriorFogMod;
}
Fog.scatteringStrenght = Mathf.Lerp(Fog.scatteringStrenght, i.FogScatteringIntensity, speed);
Fog.sunBlocking = Mathf.Lerp(Fog.sunBlocking, i.fogSunBlocking, speed);
Fog.moonIntensity = Mathf.Lerp(Fog.moonIntensity, i.moonIntensity, speed);
fogSettings.heightDensity = Mathf.Lerp(fogSettings.heightDensity, i.heightFogDensity, speed);
Fog.skyFogStart = Mathf.Lerp(Fog.skyFogStart, i.skyFogStart, speed);
Fog.skyFogHeight = Mathf.Lerp(Fog.skyFogHeight, i.SkyFogHeight, speed);
Fog.skyFogIntensity = Mathf.Lerp(Fog.skyFogIntensity, i.SkyFogIntensity, speed);
}
}
private void UpdateEffectSystems(EnviroWeatherPrefab id, bool withTransition)
{
if (id != null)
{
float speed = 500f * Time.deltaTime;
if (withTransition)
speed = weatherSettings.effectTransitionSpeed * Time.deltaTime;
for (int i = 0; i < id.effectSystems.Count; i++)
{
if (id.effectSystems[i].isStopped)
id.effectSystems[i].Play();
// Set EmissionRate
float val = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(id.effectSystems[i]), id.effectEmmisionRates[i] * qualitySettings.GlobalParticleEmissionRates, speed) * interiorZoneSettings.currentInteriorWeatherEffectMod;
EnviroSkyMgr.instance.SetEmissionRate(id.effectSystems[i], val);
}
for (int i = 0; i < Weather.WeatherPrefabs.Count; i++)
{
if (Weather.WeatherPrefabs[i].gameObject != id.gameObject)
{
for (int i2 = 0; i2 < Weather.WeatherPrefabs[i].effectSystems.Count; i2++)
{
float val2 = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(Weather.WeatherPrefabs[i].effectSystems[i2]), 0f, speed);
if (val2 < 1f)
val2 = 0f;
EnviroSkyMgr.instance.SetEmissionRate(Weather.WeatherPrefabs[i].effectSystems[i2], val2);
if (val2 == 0f && !Weather.WeatherPrefabs[i].effectSystems[i2].isStopped)
{
Weather.WeatherPrefabs[i].effectSystems[i2].Stop();
}
}
}
}
UpdateWeatherVariables(id.weatherPreset);
}
}
private void UpdateWeather()
{
//Current active weather not matching current zones weather
if (Weather.currentActiveWeatherPreset != Weather.currentActiveZone.currentActiveZoneWeatherPreset)
{
Weather.lastActiveWeatherPreset = Weather.currentActiveWeatherPreset;
Weather.lastActiveWeatherPrefab = Weather.currentActiveWeatherPrefab;
Weather.currentActiveWeatherPreset = Weather.currentActiveZone.currentActiveZoneWeatherPreset;
Weather.currentActiveWeatherPrefab = Weather.currentActiveZone.currentActiveZoneWeatherPrefab;
if (Weather.currentActiveWeatherPreset != null)
{
EnviroSkyMgr.instance.NotifyWeatherChanged(Weather.currentActiveWeatherPreset);
Weather.weatherFullyChanged = false;
if (!serverMode)
{
TryPlayAmbientSFX();
UpdateAudioSource(Weather.currentActiveWeatherPreset);
if (Weather.currentActiveWeatherPreset.isLightningStorm)
StartCoroutine(PlayThunderRandom());
else
{
StopCoroutine(PlayThunderRandom());
Components.LightningGenerator.StopLightning();
}
}
}
}
if (Weather.currentActiveWeatherPrefab != null && !serverMode)
{
UpdateClouds(Weather.currentActiveWeatherPreset, true);
UpdateFog(Weather.currentActiveWeatherPreset, true);
UpdateEffectSystems(Weather.currentActiveWeatherPrefab, true);
if (!Weather.weatherFullyChanged)
CalcWeatherTransitionState();
}
else if (Weather.currentActiveWeatherPrefab != null)
{
UpdateWeatherVariables(Weather.currentActiveWeatherPrefab.weatherPreset);
}
}
#region API
/// <summary>
/// Changes clouds, fog and particle effects to current weather settings instantly.
/// </summary>
public void InstantWeatherChange(EnviroWeatherPreset preset, EnviroWeatherPrefab prefab)
{
UpdateClouds(preset, false);
UpdateFog(preset, false);
UpdateEffectSystems(prefab, false);
}
/// <summary>
/// Assign your Player and Camera and Initilize.////
/// </summary>
public void AssignAndStart(GameObject player, Camera Camera)
{
this.Player = player;
PlayerCamera = Camera;
Init();
started = true;
}
/// <summary>
/// Assign your Player and Camera and Initilize.////
/// </summary>
public void StartAsServer()
{
Player = gameObject;
serverMode = true;
Init();
}
/// <summary>
/// Changes focus on other Player or Camera on runtime.////
/// </summary>
/// <param name="Player">Player.</param>
/// <param name="Camera">Camera.</param>
public void ChangeFocus(GameObject player, Camera Camera)
{
this.Player = player;
if(PlayerCamera != null)
RemoveEnviroCameraComponents(PlayerCamera);
PlayerCamera = Camera;
InitImageEffects();
}
/// <summary>
/// Destroy all enviro related camera components on this camera.
/// </summary>
private void RemoveEnviroCameraComponents(Camera cam)
{
EnviroSkyRenderingLW renderComponent;
EnviroPostProcessing postProcessingComponent;
renderComponent = cam.GetComponent<EnviroSkyRenderingLW>();
if (renderComponent != null)
Destroy(renderComponent);
postProcessingComponent = cam.GetComponent<EnviroPostProcessing>();
if (postProcessingComponent != null)
Destroy(postProcessingComponent);
}
public void Play(EnviroTime.TimeProgressMode progressMode = EnviroTime.TimeProgressMode.Simulated)
{
SetupSkybox();
if (!Components.DirectLight.gameObject.activeSelf)
Components.DirectLight.gameObject.SetActive(true);
GameTime.ProgressTime = progressMode;
if (EffectsHolder != null)
EffectsHolder.SetActive(true);
if (EnviroSkyRender != null)
EnviroSkyRender.enabled = true;
started = true;
TryPlayAmbientSFX();
}
public void Stop(bool disableLight = false, bool stopTime = true)
{
if (disableLight)
Components.DirectLight.gameObject.SetActive(false);
if (stopTime)
GameTime.ProgressTime = EnviroTime.TimeProgressMode.None;
if(EffectsHolder != null)
EffectsHolder.SetActive(false);
if (EnviroSkyRender != null)
EnviroSkyRender.enabled = false;
if (EnviroPostProcessing != null)
EnviroPostProcessing.enabled = false;
started = false;
}
public void Deactivate(bool disableLight = false)
{
if (disableLight)
Components.DirectLight.gameObject.SetActive(false);
if (EffectsHolder != null)
EffectsHolder.SetActive(false);
if (EnviroSkyRender != null)
EnviroSkyRender.enabled = false;
if (EnviroPostProcessing != null)
EnviroPostProcessing.enabled = false;
}
public void Activate()
{
Components.DirectLight.gameObject.SetActive(true);
if (EffectsHolder != null)
EffectsHolder.SetActive(true);
if (EnviroSkyRender != null)
EnviroSkyRender.enabled = true;
if (EnviroPostProcessing != null)
EnviroPostProcessing.enabled = true;
TryPlayAmbientSFX();
if(Weather.currentAudioSource != null)
Weather.currentAudioSource.audiosrc.Play();
}
#endregion
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: dca2c2a635e065d47910f2afb90a17a9
timeCreated: 1502205622
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,209 @@
using UnityEngine;
using UnityEngine.Rendering;
using System.Collections;
using System;
[ExecuteInEditMode]
[ImageEffectAllowedInSceneView]
[RequireComponent(typeof(Camera))]
public class EnviroSkyRenderingLW : MonoBehaviour
{
[HideInInspector]
public bool isAddionalCamera = false;
private Camera myCam;
[HideInInspector]
public Material material;
[HideInInspector]
public bool simpleFog = false;
private bool currentSimpleFog = false;
/// <summary>
///
/// </summary>
void OnEnable()
{
#if ENVIRO_LW
if (EnviroSkyMgr.instance == null || EnviroSkyMgr.instance.currentEnviroSkyVersion != EnviroSkyMgr.EnviroSkyVersion.LW)
{
// Debug.Log("Deactivated EnviroSkyRenderingLW component. Not in LW mode or Manager missing.");
this.enabled = false;
return;
}
#endif
myCam = GetComponent<Camera>();
if (myCam.actualRenderingPath == RenderingPath.Forward)
myCam.depthTextureMode = DepthTextureMode.Depth;
CreateFogMaterial();
}
/// <summary>
///
/// </summary>
void OnDisable()
{
DestroyFogMaterial();
//Reset to default depth mode.
if (myCam != null && myCam.actualRenderingPath == RenderingPath.Forward)
{
if (myCam.depthTextureMode == DepthTextureMode.Depth)
myCam.depthTextureMode = DepthTextureMode.None;
}
}
private void CreateFogMaterial ()
{
if (material != null)
DestroyImmediate(material);
if (!EnviroSkyMgr.instance.FogSettings.useSimpleFog)
{
Shader shader = Shader.Find("Enviro/Lite/EnviroFogRendering");
if (shader == null)
throw new Exception("Critical Error: \"Enviro/EnviroFogRendering\" shader is missing.");
material = new Material(shader);
}
else
{
Shader shader = Shader.Find("Enviro/Lite/EnviroFogRenderingSimple");
if (shader == null)
throw new Exception("Critical Error: \"Enviro/EnviroFogRendering\" shader is missing.");
material = new Material(shader);
}
if (EnviroSkyMgr.instance.FogSettings.useSimpleFog)
{
Shader.EnableKeyword("ENVIRO_SIMPLE_FOG");
}
else
{
Shader.DisableKeyword("ENVIRO_SIMPLE_FOG");
}
}
private void DestroyFogMaterial()
{
if (material != null)
DestroyImmediate(material);
}
private void Update()
{
if (EnviroSkyMgr.instance == null)
return;
if (!EnviroSkyMgr.instance.IsAvailable())
return;
if (currentSimpleFog != EnviroSkyMgr.instance.FogSettings.useSimpleFog)
{
CreateFogMaterial();
currentSimpleFog = EnviroSkyMgr.instance.FogSettings.useSimpleFog;
}
}
void OnPreRender ()
{
///////////////////Matrix Information
if (myCam.stereoEnabled)
{
// Both stereo eye inverse view matrices
Matrix4x4 left_world_from_view = myCam.GetStereoViewMatrix(Camera.StereoscopicEye.Left).inverse;
Matrix4x4 right_world_from_view = myCam.GetStereoViewMatrix(Camera.StereoscopicEye.Right).inverse;
// Both stereo eye inverse projection matrices, plumbed through GetGPUProjectionMatrix to compensate for render texture
Matrix4x4 left_screen_from_view = myCam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);
Matrix4x4 right_screen_from_view = myCam.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right);
Matrix4x4 left_view_from_screen = GL.GetGPUProjectionMatrix(left_screen_from_view, true).inverse;
Matrix4x4 right_view_from_screen = GL.GetGPUProjectionMatrix(right_screen_from_view, true).inverse;
// Negate [1,1] to reflect Unity's CBuffer state
if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore && SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 && SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2)
{
left_view_from_screen[1, 1] *= -1;
right_view_from_screen[1, 1] *= -1;
}
Shader.SetGlobalMatrix("_LeftWorldFromView", left_world_from_view);
Shader.SetGlobalMatrix("_RightWorldFromView", right_world_from_view);
Shader.SetGlobalMatrix("_LeftViewFromScreen", left_view_from_screen);
Shader.SetGlobalMatrix("_RightViewFromScreen", right_view_from_screen);
}
else
{
// Main eye inverse view matrix
Matrix4x4 left_world_from_view = myCam.cameraToWorldMatrix;
// Inverse projection matrices, plumbed through GetGPUProjectionMatrix to compensate for render texture
Matrix4x4 screen_from_view = myCam.projectionMatrix;
Matrix4x4 left_view_from_screen = GL.GetGPUProjectionMatrix(screen_from_view, true).inverse;
// Negate [1,1] to reflect Unity's CBuffer state
if (SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore && SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 && SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2)
left_view_from_screen[1, 1] *= -1;
// Store matrices
Shader.SetGlobalMatrix("_LeftWorldFromView", left_world_from_view);
Shader.SetGlobalMatrix("_LeftViewFromScreen", left_view_from_screen);
}
//////////////////////////////
}
[ImageEffectOpaque]
public void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (EnviroSkyLite.instance == null) {
Graphics.Blit(source, destination);
return;
}
// Set Camera to render depth in forward
if (myCam.actualRenderingPath == RenderingPath.Forward)
myCam.depthTextureMode |= DepthTextureMode.Depth;
if(material == null)
CreateFogMaterial();
if (!Application.isPlaying && EnviroSkyLite.instance.showFogInEditor || Application.isPlaying)
{
RenderFog(source, destination);
}
else
{
Graphics.Blit(source, destination);
}
}
private void RenderFog(RenderTexture source, RenderTexture destination)
{
float FdotC = myCam.transform.position.y - EnviroSkyLite.instance.fogSettings.height;
float paramK = (FdotC <= 0.0f ? 1.0f : 0.0f);
var sceneMode = RenderSettings.fogMode;
var sceneDensity = RenderSettings.fogDensity;
var sceneStart = RenderSettings.fogStartDistance;
var sceneEnd = RenderSettings.fogEndDistance;
Vector4 sceneParams;
bool linear = (sceneMode == FogMode.Linear);
float diff = linear ? sceneEnd - sceneStart : 0.0f;
float invDiff = Mathf.Abs(diff) > 0.0001f ? 1.0f / diff : 0.0f;
sceneParams.x = sceneDensity * 1.2011224087f; // density / sqrt(ln(2)), used by Exp2 fog mode
sceneParams.y = sceneDensity * 1.4426950408f; // density / ln(2), used by Exp fog mode
sceneParams.z = linear ? -invDiff : 0.0f;
sceneParams.w = linear ? sceneEnd * invDiff : 0.0f;
Shader.SetGlobalVector("_SceneFogParams", sceneParams);
Shader.SetGlobalVector("_SceneFogMode", new Vector4((int)sceneMode, EnviroSkyLite.instance.fogSettings.useRadialDistance ? 1 : 0, 0, 0));
Shader.SetGlobalVector("_HeightParams", new Vector4(EnviroSkyLite.instance.fogSettings.height, FdotC, paramK, EnviroSkyLite.instance.fogSettings.heightDensity * 0.5f));
Shader.SetGlobalVector("_DistanceParams", new Vector4(-Mathf.Max(EnviroSkyLite.instance.fogSettings.startDistance, 0.0f), 0, 0, 0));
material.SetTexture("_MainTex", source);
Graphics.Blit(source, destination, material);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4ab5cbdc1174f4243900ca83356d9f5d
timeCreated: 1493723296
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8711fbf908956444db795750960deaa9
folderAsset: yes
timeCreated: 1571061611
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,241 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
[AddComponentMenu("Enviro/Lite/AddionalCamera")]
public class EnviroLiteAdditionalCamera : MonoBehaviour {
#if ENVIRO_LW
public bool addEnviroSkyRendering = true;
public bool addEnviroSkyPostProcessing = true;
public bool addWeatherEffects = true;
private Camera myCam;
private EnviroSkyRenderingLW skyRender;
private EnviroPostProcessing enviroPostProcessing;
private GameObject EffectHolder;
private GameObject VFX;
private List<EnviroWeatherPrefab> zoneWeather = new List<EnviroWeatherPrefab>();
private EnviroWeatherPrefab currentWeather;
private void OnEnable()
{
myCam = GetComponent<Camera>();
if (myCam != null)
InitImageEffects();
}
private void Start()
{
if (addWeatherEffects)
{
CreateEffectHolder();
StartCoroutine(SetupWeatherEffects());
}
}
void Update ()
{
if (addWeatherEffects)
UpdateWeatherEffects();
if (EnviroSkyLite.instance != null)
UpdateSkyRenderer();
}
private void CreateEffectHolder ()
{
int childs = myCam.transform.childCount;
for (int i = childs - 1; i >= 0; i--)
{
if(myCam.transform.GetChild(i).gameObject.name == "Effect Holder")
DestroyImmediate(myCam.transform.GetChild(i).gameObject);
}
EffectHolder = new GameObject();
EffectHolder.name = "Effect Holder";
EffectHolder.transform.SetParent(myCam.transform,false);
VFX = new GameObject();
VFX.name = "VFX";
VFX.transform.SetParent(EffectHolder.transform, false);
}
IEnumerator SetupWeatherEffects()
{
yield return new WaitForSeconds(1f);
for (int i = 0; i < EnviroSkyMgr.instance.Weather.weatherPresets.Count; i++)
{
//Create Weather Prefab
GameObject wPrefab = new GameObject();
EnviroWeatherPrefab wP = wPrefab.AddComponent<EnviroWeatherPrefab>();
wP.weatherPreset = EnviroSkyMgr.instance.Weather.weatherPresets[i];
wPrefab.name = wP.weatherPreset.Name;
//Add Particle Effects
for (int w = 0; w < wP.weatherPreset.effectSystems.Count; w++)
{
if (wP.weatherPreset.effectSystems[w] == null || wP.weatherPreset.effectSystems[w].prefab == null)
{
Debug.Log("Warning! Missing Particle System Entry: " + wP.weatherPreset.Name);
Destroy(wPrefab);
break;
}
GameObject eS = (GameObject)Instantiate(wP.weatherPreset.effectSystems[w].prefab, wPrefab.transform);
eS.transform.localPosition = wP.weatherPreset.effectSystems[w].localPositionOffset;
eS.transform.localEulerAngles = wP.weatherPreset.effectSystems[w].localRotationOffset;
ParticleSystem pS = eS.GetComponent<ParticleSystem>();
if (pS != null)
wP.effectSystems.Add(pS);
else
{
pS = eS.GetComponentInChildren<ParticleSystem>();
if (pS != null)
wP.effectSystems.Add(pS);
else
{
Debug.Log("No Particle System found in prefab in weather preset: " + wP.weatherPreset.Name);
Destroy(wPrefab);
break;
}
}
}
wP.effectEmmisionRates.Clear();
wPrefab.transform.parent = VFX.transform;
wPrefab.transform.localPosition = Vector3.zero;
wPrefab.transform.localRotation = Quaternion.identity;
zoneWeather.Add(wP);
}
// Setup Particle Systems Emission Rates
for (int i = 0; i < zoneWeather.Count; i++)
{
for (int i2 = 0; i2 < zoneWeather[i].effectSystems.Count; i2++)
{
zoneWeather[i].effectEmmisionRates.Add(EnviroSkyMgr.instance.GetEmissionRate(zoneWeather[i].effectSystems[i2]));
EnviroSkyMgr.instance.SetEmissionRate(zoneWeather[i].effectSystems[i2], 0f);
}
}
//Set Current Weather
if (EnviroSkyMgr.instance.Weather.currentActiveWeatherPrefab != null)
{
for (int i = 0; i < zoneWeather.Count; i++)
{
if (zoneWeather[i].weatherPreset == EnviroSkyMgr.instance.Weather.currentActiveWeatherPrefab.weatherPreset)
currentWeather = zoneWeather[i];
}
}
}
private void UpdateWeatherEffects()
{
if (EnviroSkyMgr.instance.Weather.currentActiveWeatherPrefab == null || currentWeather == null)
return;
if(EnviroSkyMgr.instance.Weather.currentActiveWeatherPrefab.weatherPreset != currentWeather.weatherPreset)
{
for(int i = 0; i < zoneWeather.Count; i++)
{
if (zoneWeather[i].weatherPreset == EnviroSkyMgr.instance.Weather.currentActiveWeatherPrefab.weatherPreset)
currentWeather = zoneWeather[i];
}
}
UpdateEffectSystems(currentWeather, true);
}
private void UpdateEffectSystems(EnviroWeatherPrefab id, bool withTransition)
{
if (id != null)
{
float speed = 500f * Time.deltaTime;
if (withTransition)
speed = EnviroSkyMgr.instance.WeatherSettings.effectTransitionSpeed * Time.deltaTime;
for (int i = 0; i < id.effectSystems.Count; i++)
{
if (id.effectSystems[i].isStopped)
id.effectSystems[i].Play();
// Set EmissionRate
float val = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(id.effectSystems[i]), id.effectEmmisionRates[i] * EnviroSkyLite.instance.qualitySettings.GlobalParticleEmissionRates, speed) * EnviroSkyMgr.instance.InteriorZoneSettings.currentInteriorWeatherEffectMod;
EnviroSkyMgr.instance.SetEmissionRate(id.effectSystems[i], val);
}
for (int i = 0; i < zoneWeather.Count; i++)
{
if (zoneWeather[i].gameObject != id.gameObject)
{
for (int i2 = 0; i2 < zoneWeather[i].effectSystems.Count; i2++)
{
float val2 = Mathf.Lerp(EnviroSkyMgr.instance.GetEmissionRate(zoneWeather[i].effectSystems[i2]), 0f, speed);
if (val2 < 1f)
val2 = 0f;
EnviroSkyMgr.instance.SetEmissionRate(zoneWeather[i].effectSystems[i2], val2);
if (val2 == 0f && !zoneWeather[i].effectSystems[i2].isStopped)
{
zoneWeather[i].effectSystems[i2].Stop();
}
}
}
}
}
}
private void InitImageEffects()
{
if (addEnviroSkyRendering)
{
skyRender = myCam.gameObject.GetComponent<EnviroSkyRenderingLW>();
if (skyRender == null)
skyRender = myCam.gameObject.AddComponent<EnviroSkyRenderingLW>();
skyRender.isAddionalCamera = true;
}
if (addEnviroSkyPostProcessing)
{
enviroPostProcessing = myCam.gameObject.GetComponent<EnviroPostProcessing>();
if (enviroPostProcessing == null)
enviroPostProcessing = myCam.gameObject.AddComponent<EnviroPostProcessing>();
}
}
private void UpdateSkyRenderer()
{
if (EnviroSkyMgr.instance.FogSettings.useUnityFog && EnviroSkyMgr.instance.Camera != null && EnviroSkyMgr.instance.Camera.renderingPath == RenderingPath.Forward)
{
RenderSettings.fog = true;
if (skyRender != null && skyRender.isActiveAndEnabled)
skyRender.enabled = false;
}
else
{
//Enable or Disable Enviro Fog Post Effect
if (EnviroSkyLite.instance.usePostEffectFog && skyRender != null && !skyRender.isActiveAndEnabled)
skyRender.enabled = true;
else if (!EnviroSkyLite.instance.usePostEffectFog && skyRender != null && skyRender.isActiveAndEnabled)
skyRender.enabled = false;
}
}
#endif
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ce39a1be7e2417a4c9dc86e1b20c8518
timeCreated: 1510847875
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: