< Summary

Class:DCL.Skybox.SkyboxEditorWindow
Assembly:SkyboxEditorAssembly
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/Editor/Procedural Skybox/SkyboxEditor.cs
Covered lines:0
Uncovered lines:719
Coverable lines:719
Total lines:1508
Line coverage:0% (0 of 719)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SkyboxEditorWindow()0%2100%
OnEnable()0%2100%
OnDestroy()0%20400%
OnFocus()0%2100%
OnGUI()0%72800%
Update()0%20400%
Init()0%2100%
InitializeWindow()0%2100%
EnsureDependencies()0%1561200%
CheckAndAssignAllStyles()0%30500%
TakeControlAtRuntime()0%6200%
InitializeMaterial()0%6200%
UpdateMaterial()0%2100%
AddNewConfiguration(...)0%2100%
RenderConfigurations()0%2721600%
UpdateConfigurationsList()0%56700%
RenderTimePanel()0%20400%
ResumeTime()0%2100%
PauseTime()0%2100%
RenderBackgroundColorLayer()0%2100%
RenderHorizonLayer()0%2100%
RenderAmbientLayer()0%6200%
RenderAvatarColorLayer()0%20400%
RenderFogLayer()0%12300%
RenderDirectionalLightLayer()0%6200%
GetDLDirection()0%2100%
RenderTimelineTags()0%42600%
RenderTextureLayers(...)0%2401500%
RenderTextureLayer(...)0%42600%
RenderCubemapLayer(...)0%6200%
RenderPlanarLayer(...)0%12300%
RenderSatelliteLayer(...)0%6200%
RenderParticleLayer(...)0%2100%
RenderDistortionVariables(...)0%6200%
RenderSepratedFloatFields(...)0%2100%
RenderFloatField(...)0%2100%
RenderFloatFieldAsSlider(...)0%2100%
RenderVector3Field(...)0%2100%
RenderVector2Field(...)0%2100%
RenderTexture(...)0%2100%
RenderCubemapTexture(...)0%2100%
RenderTransitioningVector3(...)0%1101000%
RenderTransitioningVector2(...)0%1101000%
RenderTransitioningFloat(...)0%1321100%
RenderColorGradientField(...)0%12300%
RenderTransitioningQuaternionAsVector3(...)0%90900%
RenderPercentagePart(...)0%2100%
ApplyOnMaterial()0%12300%
GetNormalizedDayTime()0%2100%
GetNormalizedLayerCurrentTime(...)0%12300%
GetDayTimeForLayerNormalizedTime(...)0%12300%
ClampToDayTime(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Rendering/ProceduralSkybox/ToolProceduralSkybox/Scripts/Editor/Procedural Skybox/SkyboxEditor.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using System.Linq;
 5using UnityEditor;
 6using UnityEngine;
 7
 8namespace DCL.Skybox
 9{
 10    public class SkyboxEditorWindow : EditorWindow
 11    {
 12        private List<SkyboxConfiguration> configurations;
 13        private List<string> configurationNames;
 14        private int selectedConfigurationIndex;
 15        private int newConfigIndex;
 16        private SkyboxConfiguration selectedConfiguration;
 17
 18        public bool isPaused;
 19        public float timeOfTheDay;
 020        public float lifecycleDuration = 1;
 21
 22        private Material selectedMat;
 23        private Vector2 panelScrollPos;
 24        private Light directionalLight;
 25        private bool creatingNewConfig;
 26        private string newConfigName;
 27        private bool overridingController;
 28
 29        private bool showBackgroundLayer;
 30        private bool showAmbienLayer;
 31        private bool showFogLayer;
 32        private bool showDLLayer;
 33        private bool showAvatarLayer;
 34        private bool showTimelineTags;
 35        private MaterialReferenceContainer.Mat_Layer matLayer = null;
 36
 37        private GUIStyle foldoutStyle;
 38        private GUIStyle renderingMarkerStyle;
 39        private GUIStyle configurationStyle;
 40        private GUIStyle percentagePartStyle;
 41
 42        private List<string> renderingOrderList;
 43
 044        public static SkyboxEditorWindow instance { get { return GetWindow<SkyboxEditorWindow>(); } }
 45
 46        #region Unity Callbacks
 47
 048        private void OnEnable() { EnsureDependencies(); }
 49
 50        private void OnDestroy()
 51        {
 52            // If in play mode and editor is closed
 53            // Transfer control back to skybox controller with the new values in the editor
 054            if (SkyboxController.i == null)
 55            {
 056                return;
 57            }
 58
 059            if (Application.isPlaying && SkyboxController.i != null)
 60            {
 061                overridingController = SkyboxController.i.GetControlBackFromEditor(selectedConfiguration.name, timeOfThe
 62            }
 063        }
 64
 065        void OnFocus() { EnsureDependencies(); }
 66
 67        void OnGUI()
 68        {
 069            GUILayout.BeginArea(new Rect(10, 0, position.width - 20, position.height));
 70
 071            GUILayout.Space(32);
 072            RenderConfigurations();
 073            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 74
 075            GUILayout.Space(32);
 076            RenderTimePanel();
 077            GUILayout.Space(12);
 78
 079            showTimelineTags = EditorGUILayout.Foldout(showTimelineTags, "Timeline Tags", true);
 80
 081            if (showTimelineTags)
 82            {
 083                EditorGUI.indentLevel++;
 084                RenderTimelineTags();
 085                EditorGUI.indentLevel--;
 86            }
 87
 088            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 089            GUILayout.Space(5);
 90
 091            panelScrollPos = EditorGUILayout.BeginScrollView(panelScrollPos, "box");
 92
 093            GUILayout.Space(10);
 94
 095            showBackgroundLayer = EditorGUILayout.Foldout(showBackgroundLayer, "BG Layer", true);
 096            if (showBackgroundLayer)
 97            {
 098                EditorGUI.indentLevel++;
 099                RenderBackgroundColorLayer();
 0100                EditorGUI.indentLevel--;
 101            }
 0102            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 103
 0104            GUILayout.Space(32);
 0105            showAmbienLayer = EditorGUILayout.Foldout(showAmbienLayer, "Ambient Layer", true);
 0106            if (showAmbienLayer)
 107            {
 0108                EditorGUI.indentLevel++;
 0109                RenderAmbientLayer();
 0110                EditorGUI.indentLevel--;
 111            }
 0112            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 113
 0114            GUILayout.Space(32);
 0115            showAvatarLayer = EditorGUILayout.Foldout(showAvatarLayer, "Avatar Layer", true);
 0116            if (showAvatarLayer)
 117            {
 0118                EditorGUI.indentLevel++;
 0119                RenderAvatarColorLayer();
 0120                EditorGUI.indentLevel--;
 121            }
 0122            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 123
 0124            GUILayout.Space(32);
 0125            showFogLayer = EditorGUILayout.Foldout(showFogLayer, "Fog Layer", true);
 0126            if (showFogLayer)
 127            {
 0128                EditorGUI.indentLevel++;
 0129                RenderFogLayer();
 0130                EditorGUI.indentLevel--;
 131            }
 0132            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 133
 0134            GUILayout.Space(32);
 0135            showDLLayer = EditorGUILayout.Foldout(showDLLayer, "Directional Light Layer", true);
 0136            if (showDLLayer)
 137            {
 0138                EditorGUI.indentLevel++;
 0139                RenderDirectionalLightLayer();
 0140                EditorGUI.indentLevel--;
 141            }
 0142            EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 143
 0144            GUILayout.Space(32);
 145
 146
 147            // Render Layers
 0148            RenderTextureLayers(selectedConfiguration.layers);
 149
 0150            EditorGUILayout.EndScrollView();
 0151            GUILayout.Space(10);
 0152            GUILayout.EndArea();
 153
 0154            if (GUI.changed)
 155            {
 0156                ApplyOnMaterial();
 157            }
 0158        }
 159
 160        private void Update()
 161        {
 0162            if (selectedConfiguration == null)
 163            {
 0164                return;
 165            }
 166
 0167            if (isPaused)
 168            {
 0169                return;
 170            }
 171
 0172            float timeNormalizationFactor = lifecycleDuration * 60 / 24;
 0173            timeOfTheDay += Time.deltaTime / timeNormalizationFactor;
 0174            timeOfTheDay = Mathf.Clamp(timeOfTheDay, 0.01f, 24);
 175
 0176            ApplyOnMaterial();
 177
 0178            if (timeOfTheDay >= 24)
 179            {
 0180                timeOfTheDay = 0.01f;
 0181                selectedConfiguration.CycleResets();
 182            }
 183
 0184            Repaint();
 0185        }
 186
 187        #endregion
 188
 189        [MenuItem("Window/Skybox Editor")]
 190        static void Init()
 191        {
 0192            SkyboxEditorWindow window = (SkyboxEditorWindow)EditorWindow.GetWindow(typeof(SkyboxEditorWindow));
 0193            window.minSize = new Vector2(500, 500);
 0194            window.Show();
 0195            window.InitializeWindow();
 0196        }
 197
 0198        public void InitializeWindow() { EnsureDependencies(); }
 199
 200        private void EnsureDependencies()
 201        {
 0202            if (!Application.isPlaying)
 203            {
 0204                overridingController = false;
 205            }
 206
 0207            if (Application.isPlaying && !overridingController)
 208            {
 0209                TakeControlAtRuntime();
 210            }
 211
 0212            if (selectedConfiguration == null)
 213            {
 0214                UpdateConfigurationsList();
 215            }
 216
 0217            if (matLayer == null || selectedMat == null)
 218            {
 0219                UpdateMaterial();
 220            }
 221
 0222            CheckAndAssignAllStyles();
 223
 0224            EditorUtility.SetDirty(selectedConfiguration);
 225
 226            // Fill rendering order array
 0227            if (renderingOrderList == null)
 228            {
 0229                renderingOrderList = new List<string>();
 230
 0231                for (int i = 0; i < 5; i++)
 232                {
 0233                    renderingOrderList.Add((i + 1).ToString());
 234                }
 235            }
 236
 0237            if (directionalLight != null)
 238            {
 0239                return;
 240            }
 241
 242            // Cache directional light reference
 0243            directionalLight = GameObject.FindObjectsOfType<Light>(true).Where(s => s.type == LightType.Directional).Fir
 244
 245            // Make a directional light object if can't find
 0246            if (directionalLight == null)
 247            {
 0248                GameObject temp = new GameObject("The Sun_Temp");
 249                // Add the light component
 0250                directionalLight = temp.AddComponent<Light>();
 0251                directionalLight.type = LightType.Directional;
 252            }
 0253        }
 254
 255        private void CheckAndAssignAllStyles()
 256        {
 0257            if (foldoutStyle == null)
 258            {
 0259                foldoutStyle = new GUIStyle(EditorStyles.foldout);
 0260                foldoutStyle.fixedWidth = 2;
 261            }
 262
 0263            if (renderingMarkerStyle == null)
 264            {
 0265                renderingMarkerStyle = new GUIStyle(EditorStyles.label);
 0266                renderingMarkerStyle.fontSize = 18;
 267            }
 268
 0269            if (configurationStyle == null)
 270            {
 0271                configurationStyle = new GUIStyle();
 0272                configurationStyle.alignment = TextAnchor.MiddleCenter;
 0273                configurationStyle.margin = new RectOffset(150, 200, 0, 0);
 274            }
 275
 0276            if (percentagePartStyle == null)
 277            {
 0278                percentagePartStyle = new GUIStyle();
 0279                percentagePartStyle.alignment = TextAnchor.MiddleCenter;
 280            }
 0281        }
 282
 283        void TakeControlAtRuntime()
 284        {
 0285            if (SkyboxController.i != null)
 286            {
 0287                isPaused = SkyboxController.i.IsPaused();
 0288                lifecycleDuration = (float)SkyboxController.i.lifecycleDuration;
 0289                selectedConfiguration = SkyboxController.i.GetCurrentConfiguration();
 0290                overridingController = SkyboxController.i.SetOverrideController(true);
 0291                timeOfTheDay = SkyboxController.i.GetCurrentTimeOfTheDay();
 0292                UpdateConfigurationsList();
 293            }
 0294        }
 295
 296        void InitializeMaterial()
 297        {
 0298            matLayer = MaterialReferenceContainer.i.GetMat_LayerForLayers(5);
 299
 0300            if (matLayer == null)
 301            {
 0302                matLayer = MaterialReferenceContainer.i.materials[0];
 303            }
 304
 0305            selectedMat = matLayer.material;
 0306            selectedConfiguration.ResetMaterial(selectedMat, matLayer.numberOfSlots);
 0307            RenderSettings.skybox = selectedMat;
 0308        }
 309
 0310        private void UpdateMaterial() { InitializeMaterial(); }
 311
 312        private SkyboxConfiguration AddNewConfiguration(string name)
 313        {
 314            SkyboxConfiguration temp = null;
 0315            temp = ScriptableObject.CreateInstance<SkyboxConfiguration>();
 0316            temp.skyboxID = name;
 317
 0318            string path = AssetDatabase.GenerateUniqueAssetPath("Assets/Rendering/ProceduralSkybox/Resources/Skybox Conf
 0319            AssetDatabase.CreateAsset(temp, path);
 0320            AssetDatabase.SaveAssets();
 321
 0322            return temp;
 323        }
 324
 325        private void RenderConfigurations()
 326        {
 0327            GUILayout.Label("Configurations", EditorStyles.boldLabel);
 328
 329
 0330            GUILayout.Label("Loaded: " + selectedConfiguration.skyboxID);
 0331            GUILayout.BeginHorizontal(configurationStyle);
 332
 0333            if (creatingNewConfig)
 334            {
 0335                GUILayout.Label("Name");
 0336                newConfigName = EditorGUILayout.TextField(newConfigName, GUILayout.Width(200));
 337
 0338                if (GUILayout.Button("Create", GUILayout.Width(50)))
 339                {
 340                    // Make new configuration
 0341                    selectedConfiguration = AddNewConfiguration(newConfigName);
 342
 343                    // Update configuration list
 0344                    UpdateConfigurationsList();
 0345                    creatingNewConfig = false;
 346
 0347                    if (Application.isPlaying && SkyboxController.i != null && overridingController)
 348                    {
 0349                        SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration);
 350                    }
 351                }
 352
 0353                if (GUILayout.Button("Cancel", GUILayout.Width(50)))
 354                {
 0355                    creatingNewConfig = false;
 356                }
 0357            }
 358            else
 359            {
 0360                EditorGUILayout.BeginVertical();
 0361                newConfigIndex = EditorGUILayout.Popup(selectedConfigurationIndex, configurationNames.ToArray(), GUILayo
 0362                selectedConfiguration = (SkyboxConfiguration)EditorGUILayout.ObjectField(selectedConfiguration, typeof(S
 363
 0364                EditorGUILayout.EndVertical();
 365
 0366                if (newConfigIndex != selectedConfigurationIndex)
 367                {
 0368                    selectedConfiguration = configurations[newConfigIndex];
 0369                    selectedConfigurationIndex = newConfigIndex;
 370
 0371                    if (Application.isPlaying && SkyboxController.i != null && overridingController)
 372                    {
 0373                        SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration);
 374                    }
 375                }
 376
 0377                if (selectedConfiguration != configurations[selectedConfigurationIndex])
 378                {
 0379                    UpdateConfigurationsList();
 380
 0381                    if (Application.isPlaying && SkyboxController.i != null && overridingController)
 382                    {
 0383                        SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration);
 384                    }
 385                }
 386
 0387                if (GUILayout.Button("+", GUILayout.Width(50)))
 388                {
 0389                    creatingNewConfig = true;
 390                }
 391            }
 392
 0393            GUILayout.EndHorizontal();
 0394        }
 395
 396        private void UpdateConfigurationsList()
 397        {
 0398            SkyboxConfiguration[] tConfigurations = Resources.LoadAll<SkyboxConfiguration>("Skybox Configurations/");
 0399            configurations = new List<SkyboxConfiguration>(tConfigurations);
 0400            configurationNames = new List<string>();
 401
 402            // If no configurations exist, make and select new one.
 0403            if (configurations == null || configurations.Count < 1)
 404            {
 0405                selectedConfiguration = AddNewConfiguration("Generic Skybox");
 406
 0407                configurations = new List<SkyboxConfiguration>();
 0408                configurations.Add(selectedConfiguration);
 409            }
 410
 0411            if (selectedConfiguration == null)
 412            {
 0413                selectedConfiguration = configurations[0];
 414            }
 415
 0416            for (int i = 0; i < configurations.Count; i++)
 417            {
 0418                configurations[i].skyboxID = configurations[i].name;
 419
 0420                configurationNames.Add(configurations[i].skyboxID);
 0421                if (selectedConfiguration == configurations[i])
 422                {
 0423                    selectedConfigurationIndex = i;
 424                }
 425            }
 426
 0427            InitializeMaterial();
 428
 0429            if (!Application.isPlaying)
 430            {
 0431                isPaused = true;
 432            }
 0433        }
 434
 435        private void RenderTimePanel()
 436        {
 437
 0438            GUILayout.Label("Preview", EditorStyles.boldLabel);
 439
 0440            GUILayout.BeginHorizontal();
 0441            EditorGUILayout.LabelField("Time : " + timeOfTheDay.ToString("f2"), EditorStyles.label, GUILayout.Width(70))
 442
 0443            EditorGUILayout.Space(20);
 444
 0445            EditorGUILayout.BeginVertical();
 0446            timeOfTheDay = EditorGUILayout.Slider(timeOfTheDay, 0.01f, 24.00f, GUILayout.MinWidth(150));
 0447            GUILayout.BeginHorizontal();
 0448            EditorGUILayout.LabelField("cycle (minutes)", GUILayout.Width(95));
 0449            lifecycleDuration = EditorGUILayout.FloatField(lifecycleDuration, GUILayout.Width(50));
 0450            EditorGUILayout.EndHorizontal();
 0451            EditorGUILayout.EndVertical();
 452
 0453            EditorGUILayout.LabelField((GetNormalizedDayTime() * 100).ToString("f2") + "%", GUILayout.MaxWidth(50));
 454
 0455            if (isPaused)
 456            {
 0457                if (GUILayout.Button("Play", GUILayout.ExpandWidth(false)))
 458                {
 0459                    ResumeTime();
 460                }
 0461            }
 462            else
 463            {
 0464                if (GUILayout.Button("Pause", GUILayout.ExpandWidth(false)))
 465                {
 0466                    PauseTime();
 467                }
 468            }
 469
 0470            GUILayout.EndHorizontal();
 0471        }
 472
 0473        void ResumeTime() { isPaused = false; }
 474
 0475        void PauseTime() { isPaused = true; }
 476
 477        #region Render Base Layeyrs
 478
 479        void RenderBackgroundColorLayer()
 480        {
 0481            RenderColorGradientField(selectedConfiguration.skyColor, "Sky Color", 0, 24);
 0482            RenderColorGradientField(selectedConfiguration.horizonColor, "Horizon Color", 0, 24);
 0483            RenderColorGradientField(selectedConfiguration.groundColor, "Ground Color", 0, 24);
 0484            RenderHorizonLayer();
 0485        }
 486
 487        void RenderHorizonLayer()
 488        {
 0489            EditorGUILayout.Separator();
 0490            RenderTransitioningFloat(selectedConfiguration.horizonHeight, "Horizon Height", "%", "value", true, -1, 1);
 491
 0492            EditorGUILayout.Space(10);
 0493            RenderTransitioningFloat(selectedConfiguration.horizonWidth, "Horizon Width", "%", "value", true, -1, 1);
 494
 0495            EditorGUILayout.Separator();
 496
 497            // Horizon Mask
 0498            RenderTexture("Texture", ref selectedConfiguration.horizonMask);
 499
 500            // Horizon mask values
 0501            RenderVector3Field("Horizon Mask Values", ref selectedConfiguration.horizonMaskValues);
 502
 503            // Horizon Plane color
 0504            RenderColorGradientField(selectedConfiguration.horizonPlaneColor, "Horizon Plane Color", 0, 24);
 505
 506            // Horizon Height
 0507            RenderTransitioningFloat(selectedConfiguration.horizonPlaneHeight, "Horizon Plane Height", "%", "value", tru
 0508        }
 509
 510        void RenderAmbientLayer()
 511        {
 0512            selectedConfiguration.ambientTrilight = EditorGUILayout.Toggle("Use Gradient", selectedConfiguration.ambient
 513
 0514            if (selectedConfiguration.ambientTrilight)
 515            {
 0516                RenderColorGradientField(selectedConfiguration.ambientSkyColor, "Ambient Sky Color", 0, 24, true);
 0517                RenderColorGradientField(selectedConfiguration.ambientEquatorColor, "Ambient Equator Color", 0, 24, true
 0518                RenderColorGradientField(selectedConfiguration.ambientGroundColor, "Ambient Ground Color", 0, 24, true);
 519            }
 520
 0521        }
 522
 523        void RenderAvatarColorLayer()
 524        {
 0525            EditorGUILayout.LabelField("In World", EditorStyles.boldLabel);
 0526            EditorGUI.indentLevel++;
 527            // Avatar Color
 0528            selectedConfiguration.useAvatarGradient = EditorGUILayout.Toggle("Color Gradient", selectedConfiguration.use
 529
 0530            if (selectedConfiguration.useAvatarGradient)
 531            {
 0532                RenderColorGradientField(selectedConfiguration.avatarTintGradient, "Tint Gradient", 0, 24, true);
 0533            }
 534            else
 535            {
 0536                selectedConfiguration.avatarTintColor = EditorGUILayout.ColorField("Tint Color", selectedConfiguration.a
 0537                EditorGUILayout.Separator();
 538            }
 539
 540            // Avatar Light Direction
 0541            selectedConfiguration.useAvatarRealtimeDLDirection = EditorGUILayout.Toggle("Realtime DL Direction", selecte
 542
 0543            if (!selectedConfiguration.useAvatarRealtimeDLDirection)
 544            {
 0545                RenderVector3Field("Light Direction", ref selectedConfiguration.avatarLightConstantDir);
 546            }
 547
 0548            EditorGUILayout.Separator();
 549
 550            // Avatar Light Color
 0551            selectedConfiguration.useAvatarRealtimeLightColor = EditorGUILayout.Toggle("Realtime Light Color", selectedC
 552
 0553            if (!selectedConfiguration.useAvatarRealtimeLightColor)
 554            {
 0555                RenderColorGradientField(selectedConfiguration.avatarLightColorGradient, "Light Color", 0, 24);
 0556                EditorGUILayout.Separator();
 557            }
 0558            EditorGUI.indentLevel--;
 559
 0560            EditorGUILayout.LabelField("In Editor (Backpack)", EditorStyles.boldLabel);
 0561            EditorGUI.indentLevel++;
 0562            selectedConfiguration.avatarEditorTintColor = EditorGUILayout.ColorField("Tint Color", selectedConfiguration
 0563            RenderVector3Field("Light Direction", ref selectedConfiguration.avatarEditorLightDir);
 0564            selectedConfiguration.avatarEditorLightColor = EditorGUILayout.ColorField("Light Color", selectedConfigurati
 0565            EditorGUILayout.Separator();
 0566            EditorGUI.indentLevel--;
 0567        }
 568
 569        void RenderFogLayer()
 570        {
 0571            selectedConfiguration.useFog = EditorGUILayout.Toggle("Use Fog", selectedConfiguration.useFog);
 0572            if (selectedConfiguration.useFog)
 573            {
 0574                RenderColorGradientField(selectedConfiguration.fogColor, "Fog Color", 0, 24);
 0575                selectedConfiguration.fogMode = (FogMode)EditorGUILayout.EnumPopup("Fog Mode", selectedConfiguration.fog
 576
 0577                switch (selectedConfiguration.fogMode)
 578                {
 579                    case FogMode.Linear:
 0580                        RenderFloatField("Start Distance:", ref selectedConfiguration.fogStartDistance);
 0581                        RenderFloatField("End Distance:", ref selectedConfiguration.fogEndDistance);
 0582                        break;
 583                    default:
 0584                        RenderFloatField("Density: ", ref selectedConfiguration.fogDensity);
 585                        break;
 586                }
 587            }
 588
 0589        }
 590
 591        void RenderDirectionalLightLayer()
 592        {
 0593            selectedConfiguration.useDirectionalLight = EditorGUILayout.Toggle("Use Directional Light", selectedConfigur
 594
 0595            if (!selectedConfiguration.useDirectionalLight)
 596            {
 0597                return;
 598            }
 0599            RenderColorGradientField(selectedConfiguration.directionalLightLayer.lightColor, "Light Color", 0, 24);
 0600            RenderColorGradientField(selectedConfiguration.directionalLightLayer.tintColor, "Tint Color", 0, 24, true);
 601
 0602            GUILayout.Space(10);
 603
 604            // Light Intesity
 0605            RenderTransitioningFloat(selectedConfiguration.directionalLightLayer.intensity, "Light Intensity", "%", "Int
 606
 0607            GUILayout.Space(10);
 608
 0609            RenderTransitioningQuaternionAsVector3(selectedConfiguration.directionalLightLayer.lightDirection, "Light Di
 0610        }
 611
 0612        private Quaternion GetDLDirection() { return directionalLight.transform.rotation; }
 613
 614        private void RenderTimelineTags()
 615        {
 0616            if (selectedConfiguration.timelineTags == null)
 617            {
 0618                selectedConfiguration.timelineTags = new List<TimelineTagsDuration>();
 619            }
 620
 0621            for (int i = 0; i < selectedConfiguration.timelineTags.Count; i++)
 622            {
 0623                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 624
 625                // Text field for name of event
 0626                EditorGUILayout.LabelField("Name: ", GUILayout.Width(50));
 0627                selectedConfiguration.timelineTags[i].tag = EditorGUILayout.TextField(selectedConfiguration.timelineTags
 628
 629                // Start time
 0630                EditorGUILayout.LabelField("Start", GUILayout.Width(45));
 0631                GUILayout.Space(0);
 0632                selectedConfiguration.timelineTags[i].startTime = EditorGUILayout.FloatField(selectedConfiguration.timel
 0633                ClampToDayTime(ref selectedConfiguration.timelineTags[i].startTime);
 634
 635                // End time
 0636                if (!selectedConfiguration.timelineTags[i].isTrigger)
 637                {
 0638                    EditorGUILayout.LabelField("End", GUILayout.Width(40));
 0639                    GUILayout.Space(0);
 0640                    selectedConfiguration.timelineTags[i].endTime = EditorGUILayout.FloatField(selectedConfiguration.tim
 0641                    ClampToDayTime(ref selectedConfiguration.timelineTags[i].endTime);
 0642                }
 643                else
 644                {
 0645                    GUILayout.Space(97);
 646                }
 647
 648                // no end time
 0649                selectedConfiguration.timelineTags[i].isTrigger = EditorGUILayout.ToggleLeft("Trigger", selectedConfigur
 650
 651                // Remove Button
 0652                if (GUILayout.Button("-", GUILayout.Width(30)))
 653                {
 0654                    selectedConfiguration.timelineTags.RemoveAt(i);
 655                }
 656
 0657                EditorGUILayout.EndHorizontal();
 658            }
 659
 0660            EditorGUILayout.BeginHorizontal();
 0661            GUILayout.Space(20);
 0662            if (GUILayout.Button("+", GUILayout.Width(30)))
 663            {
 0664                selectedConfiguration.timelineTags.Add(new TimelineTagsDuration(timeOfTheDay));
 665            }
 0666            EditorGUILayout.EndHorizontal();
 0667        }
 668
 669        #endregion
 670
 671        #region Render Slots and Layers
 672
 673        void RenderTextureLayers(List<TextureLayer> layers)
 674        {
 675
 0676            for (int i = 0; i < layers.Count; i++)
 677            {
 678                // Name and buttons
 0679                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0680                layers[i].enabled = EditorGUILayout.Toggle(layers[i].enabled, GUILayout.Width(20), GUILayout.Height(10))
 0681                GUILayout.Space(10);
 0682                layers[i].expandedInEditor = EditorGUILayout.Foldout(layers[i].expandedInEditor, GUIContent.none, true, 
 0683                layers[i].nameInEditor = EditorGUILayout.TextField(layers[i].nameInEditor, GUILayout.Width(100), GUILayo
 684
 685                // Slot ID
 0686                layers[i].slotID = EditorGUILayout.Popup(layers[i].slotID, renderingOrderList.ToArray(), GUILayout.Width
 687
 0688                if (i == 0)
 689                {
 0690                    GUI.enabled = false;
 691                }
 0692                if (GUILayout.Button(('\u25B2').ToString(), GUILayout.Width(50), GUILayout.ExpandWidth(false)))
 693                {
 0694                    TextureLayer temp = null;
 695
 0696                    if (i >= 1)
 697                    {
 0698                        temp = layers[i - 1];
 0699                        layers[i - 1] = layers[i];
 0700                        layers[i] = temp;
 701                    }
 702                }
 703
 0704                GUI.enabled = true;
 705
 0706                if (i == layers.Count - 1)
 707                {
 0708                    GUI.enabled = false;
 709                }
 710
 0711                if (GUILayout.Button(('\u25BC').ToString(), GUILayout.Width(50), GUILayout.ExpandWidth(false)))
 712                {
 0713                    TextureLayer temp = null;
 0714                    if (i < (layers.Count - 1))
 715                    {
 0716                        temp = layers[i + 1];
 0717                        layers[i + 1] = layers[i];
 0718                        layers[i] = temp;
 719                    }
 0720                    break;
 721                }
 722
 0723                GUI.enabled = true;
 724
 0725                if (GUILayout.Button("-", GUILayout.Width(50), GUILayout.ExpandWidth(false)))
 726                {
 0727                    layers.RemoveAt(i);
 0728                    break;
 729                }
 730
 0731                Color circleColor = Color.green;
 0732                switch (layers[i].renderType)
 733                {
 734                    case LayerRenderType.Rendering:
 0735                        circleColor = Color.green;
 0736                        break;
 737                    case LayerRenderType.NotRendering:
 0738                        circleColor = Color.gray;
 0739                        break;
 740                    case LayerRenderType.Conflict_Playing:
 0741                        circleColor = Color.yellow;
 0742                        break;
 743                    case LayerRenderType.Conflict_NotPlaying:
 0744                        circleColor = Color.red;
 745                        break;
 746                    default:
 747                        break;
 748                }
 749
 0750                Color normalContentColor = GUI.color;
 0751                GUI.color = circleColor;
 752
 0753                EditorGUILayout.LabelField(('\u29BF').ToString(), renderingMarkerStyle, GUILayout.Width(20), GUILayout.H
 754
 0755                GUI.color = normalContentColor;
 756
 0757                EditorGUILayout.EndHorizontal();
 758
 0759                if (layers[i].expandedInEditor)
 760                {
 0761                    EditorGUILayout.Separator();
 0762                    EditorGUI.indentLevel++;
 0763                    RenderTextureLayer(layers[i]);
 764
 0765                    EditorGUI.indentLevel--;
 766                }
 767
 0768                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 769
 0770                GUILayout.Space(32);
 771            }
 772
 0773            GUI.enabled = true;
 774
 0775            if (GUILayout.Button("+", GUILayout.MaxWidth(20)))
 776            {
 0777                layers.Add(new TextureLayer("Tex Layer " + (layers.Count + 1)));
 778            }
 0779        }
 780
 781        void RenderTextureLayer(TextureLayer layer)
 782        {
 0783            EditorGUILayout.Separator();
 784
 785            // Layer Type
 0786            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0787            EditorGUILayout.LabelField("Layer Type:", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0788            layer.layerType = (LayerType)EditorGUILayout.EnumPopup(layer.layerType, GUILayout.Width(200));
 0789            EditorGUILayout.EndHorizontal();
 790
 791
 0792            EditorGUILayout.Separator();
 793
 794            // Time Span
 0795            RenderSepratedFloatFields("Time Span", "Starts", ref layer.timeSpan_start, "Ends", ref layer.timeSpan_End);
 0796            ClampToDayTime(ref layer.timeSpan_start);
 0797            ClampToDayTime(ref layer.timeSpan_End);
 798
 799            // Fading
 0800            RenderSepratedFloatFields("Fading", "In", ref layer.fadingInTime, "Out", ref layer.fadingOutTime);
 801
 802            // Tint
 0803            RenderFloatFieldAsSlider("Tint", ref layer.tintPercentage, 0, 100);
 804
 0805            if (layer.layerType == LayerType.Cubemap)
 806            {
 0807                RenderCubemapLayer(layer);
 808
 0809            }
 0810            else if (layer.layerType == LayerType.Planar)
 811            {
 0812                RenderPlanarLayer(layer);
 813
 0814            }
 0815            else if (layer.layerType == LayerType.Radial)
 816            {
 0817                RenderPlanarLayer(layer, true);
 0818            }
 0819            else if (layer.layerType == LayerType.Satellite)
 820            {
 0821                RenderSatelliteLayer(layer);
 0822            }
 0823            else if (layer.layerType == LayerType.Particles)
 824            {
 0825                RenderParticleLayer(layer);
 826            }
 0827        }
 828
 829        void RenderCubemapLayer(TextureLayer layer)
 830        {
 831            // Cubemap
 0832            RenderCubemapTexture("Cubemap", ref layer.cubemap);
 833
 834            // Gradient
 0835            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 836
 0837            EditorGUILayout.Separator();
 838
 839            // Movement Type
 0840            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0841            EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0842            layer.movementTypeCubemap = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypeCubemap, GUILayout.Wid
 0843            EditorGUILayout.EndHorizontal();
 844
 0845            EditorGUILayout.Separator();
 846
 847            // Rotation
 0848            if (layer.movementTypeCubemap == MovementType.PointBased)
 849            {
 0850                RenderTransitioningVector3(layer.rotations_Vector3, "Rotation", "%", "Rot:", layer.timeSpan_start, layer
 851
 0852            }
 853            else
 854            {
 0855                RenderVector3Field("Speed", ref layer.speed_Vector3);
 856            }
 0857        }
 858
 859        void RenderPlanarLayer(TextureLayer layer, bool isRadial = false)
 860        {
 861            // Texture
 0862            RenderTexture("Texture", ref layer.texture);
 863
 864            // Row and Coloumns
 0865            RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns);
 866
 867            // Anim Speed
 0868            RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed);
 869
 870            // Normal Texture
 0871            RenderTexture("Normal Map", ref layer.textureNormal);
 872
 873            // Normal Intensity
 0874            RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1);
 875
 876            // Gradient
 0877            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 878
 879            // Tiling
 0880            RenderVector2Field("Tiling", ref layer.tiling);
 881
 882            // Movement Type
 0883            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0884            EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0885            layer.movementTypePlanar_Radial = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypePlanar_Radial, G
 0886            EditorGUILayout.EndHorizontal();
 887
 0888            EditorGUI.indentLevel++;
 0889            EditorGUILayout.Separator();
 890
 0891            if (layer.movementTypePlanar_Radial == MovementType.Speed)
 892            {
 893                // Speed
 0894                RenderVector2Field("Speed", ref layer.speed_Vector2);
 0895            }
 896            else
 897            {
 898                // Offset
 0899                RenderTransitioningVector2(layer.offset, "Position", "%", "", layer.timeSpan_start, layer.timeSpan_End);
 900            }
 901
 0902            EditorGUI.indentLevel--;
 903
 0904            EditorGUILayout.Space(15);
 905
 906            // Render Distance
 0907            RenderTransitioningFloat(layer.renderDistance, "Render Distance", "", "", true, 0, 20, layer.timeSpan_start,
 908
 0909            EditorGUILayout.Space(15);
 910
 911            // Rotation
 0912            if (!isRadial)
 913            {
 0914                RenderTransitioningFloat(layer.rotations_float, "Rotation", "", "", true, 0, 360, layer.timeSpan_start, 
 0915                EditorGUILayout.Separator();
 916            }
 917
 0918            RenderDistortionVariables(layer);
 919
 0920            EditorGUILayout.Space(10);
 0921        }
 922
 923        void RenderSatelliteLayer(TextureLayer layer)
 924        {
 925            // Texture
 0926            RenderTexture("Texture", ref layer.texture);
 927
 928            // Row and Coloumns
 0929            RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns);
 930
 931            // Anim Speed
 0932            RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed);
 933
 934            // Normal Texture
 0935            RenderTexture("Normal Map", ref layer.textureNormal);
 936
 937            // Normal Intensity
 0938            RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1);
 939
 940            // Gradient
 0941            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 942
 0943            EditorGUILayout.Space(10);
 0944            EditorGUILayout.Space(10);
 945
 0946            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0947            EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0948            layer.movementTypeSatellite = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypeSatellite, GUILayout
 0949            EditorGUILayout.EndHorizontal();
 950
 0951            EditorGUI.indentLevel++;
 0952            EditorGUILayout.Separator();
 953
 0954            if (layer.movementTypeSatellite == MovementType.Speed)
 955            {
 956                // Speed
 0957                RenderVector2Field("Speed", ref layer.speed_Vector2);
 0958            }
 959            else
 960            {
 961                // Offset
 0962                RenderTransitioningVector2(layer.offset, "Position", "%", "", layer.timeSpan_start, layer.timeSpan_End);
 963            }
 964
 0965            EditorGUI.indentLevel--;
 0966            EditorGUILayout.Space(20);
 967
 968            // Rotation
 0969            RenderTransitioningFloat(layer.rotations_float, "Rotation", "", "", true, 0, 360, layer.timeSpan_start, laye
 970
 0971            EditorGUILayout.Space(12);
 972
 973            // Size
 0974            RenderTransitioningVector2(layer.satelliteWidthHeight, "Width & Height", "%", "", layer.timeSpan_start, laye
 0975        }
 976
 977        void RenderParticleLayer(TextureLayer layer)
 978        {
 979            // Texture
 0980            RenderTexture("Texture", ref layer.texture);
 981
 982            // Row and Coloumns
 0983            RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns);
 984
 985            // Anim Speed
 0986            RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed);
 987
 988            // Normal Map
 0989            RenderTexture("Normal Map", ref layer.textureNormal);
 990
 991            // Normal Intensity
 0992            RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1);
 993
 994            // Gradient
 0995            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 996
 997            // Tiling
 0998            RenderVector2Field("Tiling", ref layer.particleTiling);
 999
 1000            // Offset
 01001            RenderVector2Field("Offset", ref layer.particlesOffset);
 1002
 1003            // Amount
 01004            RenderFloatField("Amount", ref layer.particlesAmount);
 1005
 1006            // Size
 01007            RenderSepratedFloatFields("Size", "Min", ref layer.particleMinSize, "Max", ref layer.particleMaxSize);
 1008
 1009            // Spread
 01010            RenderSepratedFloatFields("Spread", "Horizontal", ref layer.particlesHorizontalSpread, "Vertical", ref layer
 1011
 1012            // Fade
 01013            RenderSepratedFloatFields("Fade", "Min", ref layer.particleMinFade, "Max", ref layer.particleMaxFade);
 1014
 1015            // Particle Rotation
 01016            RenderTransitioningVector3(layer.particleRotation, "Rotation", "%", "value", layer.timeSpan_start, layer.tim
 01017        }
 1018
 1019        void RenderDistortionVariables(TextureLayer layer)
 1020        {
 01021            layer.distortionExpanded = EditorGUILayout.Foldout(layer.distortionExpanded, "Distortion Values", true, Edit
 1022
 01023            if (!layer.distortionExpanded)
 1024            {
 01025                return;
 1026            }
 1027
 01028            EditorGUILayout.Space(10);
 1029
 01030            EditorGUI.indentLevel++;
 1031
 1032            // Distortion Intensity
 01033            RenderTransitioningFloat(layer.distortIntensity, "Intensity", "%", "Value", false, 0, 1, layer.timeSpan_star
 1034
 01035            EditorGUILayout.Space(10);
 1036
 1037            // Distortion Size
 01038            RenderTransitioningFloat(layer.distortSize, "Size", "%", "Value", false, 0, 1, layer.timeSpan_start, layer.t
 1039
 01040            EditorGUILayout.Space(10);
 1041
 1042            // Distortion Speed
 01043            RenderTransitioningVector2(layer.distortSpeed, "Speed", "%", "Value", layer.timeSpan_start, layer.timeSpan_E
 1044
 01045            EditorGUILayout.Space(10);
 1046
 1047            // Distortion Sharpness
 01048            RenderTransitioningVector2(layer.distortSharpness, "Sharpness", "%", "Value", layer.timeSpan_start, layer.ti
 1049
 01050            EditorGUILayout.Space(10);
 1051
 01052            EditorGUI.indentLevel--;
 01053        }
 1054
 1055        #endregion
 1056
 1057        #region Render simple Variables
 1058
 1059        void RenderSepratedFloatFields(string label, string label1, ref float value1, string label2, ref float value2)
 1060        {
 01061            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01062            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01063            EditorGUILayout.LabelField(label1, GUILayout.Width(90), GUILayout.ExpandWidth(false));
 01064            value1 = EditorGUILayout.FloatField("", value1, GUILayout.Width(90));
 01065            EditorGUILayout.LabelField(label2, GUILayout.Width(90), GUILayout.ExpandWidth(false));
 01066            value2 = EditorGUILayout.FloatField("", value2, GUILayout.Width(90));
 01067            GUILayout.EndHorizontal();
 01068            EditorGUILayout.Separator();
 01069        }
 1070
 1071        void RenderFloatField(string label, ref float value)
 1072        {
 01073            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01074            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01075            value = EditorGUILayout.FloatField(value, GUILayout.Width(90));
 01076            EditorGUILayout.EndHorizontal();
 01077            EditorGUILayout.Separator();
 01078        }
 1079
 1080        void RenderFloatFieldAsSlider(string label, ref float value, float min, float max)
 1081        {
 01082            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01083            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01084            value = EditorGUILayout.Slider(value, min, max, GUILayout.Width(200));
 01085            EditorGUILayout.EndHorizontal();
 01086            EditorGUILayout.Separator();
 01087        }
 1088
 1089        void RenderVector3Field(string label, ref Vector3 value)
 1090        {
 01091            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01092            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01093            value = EditorGUILayout.Vector3Field("", value, GUILayout.Width(200), GUILayout.ExpandWidth(false));
 01094            GUILayout.EndHorizontal();
 01095            EditorGUILayout.Separator();
 01096        }
 1097
 1098        void RenderVector2Field(string label, ref Vector2 value)
 1099        {
 01100            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01101            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01102            value = EditorGUILayout.Vector2Field("", value, GUILayout.Width(200), GUILayout.ExpandWidth(false));
 01103            GUILayout.EndHorizontal();
 01104            EditorGUILayout.Separator();
 01105        }
 1106
 1107        void RenderTexture(string label, ref Texture2D tex)
 1108        {
 01109            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01110            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01111            tex = (Texture2D)EditorGUILayout.ObjectField(tex, typeof(Texture2D), false, GUILayout.Width(200));
 01112            GUILayout.EndHorizontal();
 01113            EditorGUILayout.Separator();
 01114        }
 1115
 1116        void RenderCubemapTexture(string label, ref Cubemap tex)
 1117        {
 01118            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01119            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01120            tex = (Cubemap)EditorGUILayout.ObjectField(tex, typeof(Cubemap), false, GUILayout.Width(200));
 01121            GUILayout.EndHorizontal();
 01122            EditorGUILayout.Separator();
 01123        }
 1124
 1125        #endregion
 1126
 1127        #region Render Transitioning Variables
 1128
 1129        void RenderTransitioningVector3(List<TransitioningVector3> list, string label, string percentTxt, string valueTe
 1130        {
 01131            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01132            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 01133            EditorGUILayout.BeginVertical();
 1134
 01135            if (list.Count == 0)
 1136            {
 01137                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1138                {
 01139                    Vector3 tLastPos = Vector3.zero;
 01140                    if (list.Count != 0)
 1141                    {
 01142                        tLastPos = list[list.Count - 1].value;
 1143                    }
 01144                    list.Add(new TransitioningVector3(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100,
 1145                }
 1146            }
 1147
 01148            for (int i = 0; i < list.Count; i++)
 1149            {
 01150                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 1151
 01152                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1153                {
 01154                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1155                }
 1156
 1157                // Percentage
 01158                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1159
 01160                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1161
 01162                GUILayout.Space(10);
 1163
 01164                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1165
 01166                GUILayout.Space(10);
 01167                list[i].value = EditorGUILayout.Vector3Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi
 1168
 01169                GUILayout.Space(20);
 01170                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1171                {
 01172                    list.RemoveAt(i);
 1173                }
 1174
 01175                if (i == (list.Count - 1))
 1176                {
 01177                    GUILayout.Space(20);
 01178                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1179                    {
 01180                        Vector3 tLastPos = Vector3.zero;
 01181                        if (list.Count != 0)
 1182                        {
 01183                            tLastPos = list[list.Count - 1].value;
 1184                        }
 01185                        list.Add(new TransitioningVector3(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 
 1186                    }
 1187                }
 1188
 01189                GUILayout.EndHorizontal();
 1190            }
 1191
 01192            EditorGUILayout.EndVertical();
 01193            GUILayout.EndHorizontal();
 1194
 01195            Rect lastRect = GUILayoutUtility.GetLastRect();
 01196            lastRect.y -= 5;
 01197            lastRect.height += 10;
 01198            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01199        }
 1200
 1201        void RenderTransitioningVector2(List<TransitioningVector2> list, string label, string percentTxt, string valueTe
 1202        {
 01203            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01204            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 01205            EditorGUILayout.BeginVertical();
 1206
 01207            if (list.Count == 0)
 1208            {
 01209                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1210                {
 01211                    Vector2 tLastPos = Vector2.zero;
 01212                    if (list.Count != 0)
 1213                    {
 01214                        tLastPos = list[list.Count - 1].value;
 1215                    }
 01216                    list.Add(new TransitioningVector2(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100,
 1217                }
 1218            }
 1219
 01220            for (int i = 0; i < list.Count; i++)
 1221            {
 01222                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 1223
 01224                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1225                {
 01226                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1227                }
 1228
 1229                // Percentage
 01230                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1231
 01232                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1233
 01234                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1235
 01236                GUILayout.Space(10);
 01237                list[i].value = EditorGUILayout.Vector2Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi
 1238
 01239                GUILayout.Space(20);
 01240                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1241                {
 01242                    list.RemoveAt(i);
 1243                }
 1244
 01245                if (i == (list.Count - 1))
 1246                {
 01247                    GUILayout.Space(20);
 01248                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1249                    {
 01250                        Vector2 tLastPos = Vector2.zero;
 01251                        if (list.Count != 0)
 1252                        {
 01253                            tLastPos = list[list.Count - 1].value;
 1254                        }
 01255                        list.Add(new TransitioningVector2(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 
 1256                    }
 1257                }
 1258
 01259                GUILayout.EndHorizontal();
 1260            }
 1261
 01262            EditorGUILayout.EndVertical();
 01263            GUILayout.EndHorizontal();
 1264
 01265            Rect lastRect = GUILayoutUtility.GetLastRect();
 01266            lastRect.y -= 5;
 01267            lastRect.height += 10;
 01268            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01269        }
 1270
 1271        void RenderTransitioningFloat(List<TransitioningFloat> list, string label, string percentTxt, string valueText, 
 1272        {
 01273            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01274            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 01275            EditorGUILayout.BeginVertical();
 1276
 01277            if (list.Count == 0)
 1278            {
 01279                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01280                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1281                {
 01282                    float tLast = 0;
 01283                    if (list.Count != 0)
 1284                    {
 01285                        tLast = list[list.Count - 1].value;
 1286                    }
 01287                    list.Add(new TransitioningFloat(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100, t
 1288                }
 01289                GUILayout.EndHorizontal();
 1290            }
 1291
 01292            for (int i = 0; i < list.Count; i++)
 1293            {
 01294                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 1295
 01296                GUILayout.Space(10);
 01297                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1298                {
 01299                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1300                }
 01301                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1302
 01303                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1304
 01305                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1306
 01307                if (slider)
 1308                {
 01309                    list[i].value = EditorGUILayout.Slider(list[i].value, min, max, GUILayout.Width(200), GUILayout.Expa
 01310                }
 1311                else
 1312                {
 01313                    list[i].value = EditorGUILayout.FloatField("", list[i].value, GUILayout.Width(200), GUILayout.Expand
 1314                }
 1315
 1316
 01317                GUILayout.Space(20);
 01318                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1319                {
 01320                    list.RemoveAt(i);
 1321                }
 1322
 01323                if (i == (list.Count - 1))
 1324                {
 01325                    GUILayout.Space(20);
 01326                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1327                    {
 01328                        float tLast = 0;
 01329                        if (list.Count != 0)
 1330                        {
 01331                            tLast = list[list.Count - 1].value;
 1332                        }
 01333                        list.Add(new TransitioningFloat(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 10
 1334                    }
 1335                }
 1336
 01337                GUILayout.EndHorizontal();
 1338            }
 1339
 01340            EditorGUILayout.EndVertical();
 01341            GUILayout.EndHorizontal();
 1342
 01343            Rect lastRect = GUILayoutUtility.GetLastRect();
 01344            lastRect.y -= 5;
 01345            lastRect.height += 10;
 01346            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01347        }
 1348
 1349        void RenderColorGradientField(Gradient color, string label = "color", float startTime = -1, float endTime = -1, 
 1350        {
 01351            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01352            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 1353
 01354            if (startTime != -1)
 1355            {
 01356                EditorGUILayout.LabelField(startTime + "Hr", GUILayout.Width(65), GUILayout.ExpandWidth(false));
 1357            }
 1358
 01359            color = EditorGUILayout.GradientField(new GUIContent(""), color, hdr, GUILayout.Width(250), GUILayout.Expand
 1360
 01361            if (endTime != 1)
 1362            {
 01363                EditorGUILayout.LabelField(endTime + "Hr", GUILayout.Width(65), GUILayout.ExpandWidth(false));
 1364            }
 01365            GUILayout.EndHorizontal();
 01366            EditorGUILayout.Separator();
 01367        }
 1368
 1369        void RenderTransitioningQuaternionAsVector3(List<TransitioningQuaternion> list, string label, string percentTxt,
 1370        {
 01371            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01372            GUILayout.Label(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 1373
 01374            GUILayout.BeginVertical();
 1375
 01376            if (list.Count == 0)
 1377            {
 01378                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01379                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1380                {
 01381                    list.Add(new TransitioningQuaternion(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 1
 1382                }
 01383                GUILayout.EndHorizontal();
 1384            }
 1385
 01386            for (int i = 0; i < list.Count; i++)
 1387            {
 01388                GUILayout.BeginHorizontal();
 01389                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1390                {
 01391                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1392                }
 1393
 01394                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1395
 01396                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1397
 01398                GUILayout.Space(10);
 1399
 01400                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1401
 1402                // Convert Quaternion to Vector3
 01403                list[i].value = Quaternion.Euler(EditorGUILayout.Vector3Field("", list[i].value.eulerAngles, GUILayout.E
 1404
 01405                if (GUILayout.Button("Capture", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1406                {
 01407                    selectedConfiguration.directionalLightLayer.lightDirection[i].percentage = GetNormalizedLayerCurrent
 01408                    selectedConfiguration.directionalLightLayer.lightDirection[i].value = GetCurrentRotation();
 01409                    break;
 1410                }
 1411
 01412                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1413                {
 01414                    list.RemoveAt(i);
 01415                    break;
 1416                }
 1417
 01418                if (i == (list.Count - 1))
 1419                {
 01420                    GUILayout.Space(20);
 01421                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1422                    {
 01423                        list.Add(new TransitioningQuaternion(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime)
 1424                    }
 1425                }
 1426
 01427                GUILayout.EndHorizontal();
 1428            }
 01429            GUILayout.EndVertical();
 01430            GUILayout.EndHorizontal();
 1431
 01432            Rect lastRect = GUILayoutUtility.GetLastRect();
 01433            lastRect.y -= 5;
 01434            lastRect.height += 10;
 01435            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01436        }
 1437
 1438        void RenderPercentagePart(float layerStartTime, float layerEndTime, ref float percentage)
 1439        {
 01440            GUILayout.Label(layerStartTime + "Hr", GUILayout.Width(35), GUILayout.ExpandWidth(false));
 1441
 01442            GUILayout.BeginVertical(percentagePartStyle, GUILayout.ExpandWidth(false), GUILayout.Width(150));
 01443            float time = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, percentage / 100);
 01444            GUILayout.Label(time.ToString("f2") + " Hr", GUILayout.ExpandWidth(false));
 01445            percentage = EditorGUILayout.Slider(percentage, 0, 100, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01446            GUILayout.EndVertical();
 1447
 01448            GUILayout.Label(layerEndTime + "Hr", GUILayout.Width(35), GUILayout.ExpandWidth(false));
 01449        }
 1450
 1451        #endregion
 1452
 1453        private void ApplyOnMaterial()
 1454        {
 01455            EnsureDependencies();
 01456            selectedConfiguration.ApplyOnMaterial(selectedMat, timeOfTheDay, GetNormalizedDayTime(), matLayer.numberOfSl
 1457
 1458            // If in play mode, call avatar color from skybox controller class
 01459            if (Application.isPlaying && SkyboxController.i != null)
 1460            {
 01461                SkyboxController.i.ApplyAvatarColor(GetNormalizedDayTime());
 1462            }
 01463        }
 1464
 1465        private float GetNormalizedDayTime()
 1466        {
 1467            float tTime = 0;
 01468            tTime = timeOfTheDay / 24;
 01469            tTime = Mathf.Clamp(tTime, 0, 1);
 01470            return tTime;
 1471        }
 1472
 1473        private float GetNormalizedLayerCurrentTime(float startTime, float endTime)
 1474        {
 01475            float editedEndTime = endTime;
 01476            float editedDayTime = timeOfTheDay;
 01477            if (endTime < startTime)
 1478            {
 01479                editedEndTime = 24 + endTime;
 01480                if (timeOfTheDay < startTime)
 1481                {
 01482                    editedDayTime = 24 + timeOfTheDay;
 1483                }
 1484            }
 01485            return Mathf.InverseLerp(startTime, editedEndTime, editedDayTime);
 1486        }
 1487
 1488        private float GetDayTimeForLayerNormalizedTime(float startTime, float endTime, float normalizeTime)
 1489        {
 01490            float editedEndTime = endTime;
 01491            if (endTime < startTime)
 1492            {
 01493                editedEndTime = 24 + endTime;
 1494            }
 01495            float time = Mathf.Lerp(startTime, editedEndTime, normalizeTime);
 1496
 01497            if (time > 24)
 1498            {
 01499                time -= 24;
 1500            }
 1501
 01502            return time;
 1503        }
 1504
 01505        private void ClampToDayTime(ref float value) { value = Mathf.Clamp(value, 0, 24); }
 1506    }
 1507
 1508}

Methods/Properties

SkyboxEditorWindow()
instance()
OnEnable()
OnDestroy()
OnFocus()
OnGUI()
Update()
Init()
InitializeWindow()
EnsureDependencies()
CheckAndAssignAllStyles()
TakeControlAtRuntime()
InitializeMaterial()
UpdateMaterial()
AddNewConfiguration(System.String)
RenderConfigurations()
UpdateConfigurationsList()
RenderTimePanel()
ResumeTime()
PauseTime()
RenderBackgroundColorLayer()
RenderHorizonLayer()
RenderAmbientLayer()
RenderAvatarColorLayer()
RenderFogLayer()
RenderDirectionalLightLayer()
GetDLDirection()
RenderTimelineTags()
RenderTextureLayers(System.Collections.Generic.List[TextureLayer])
RenderTextureLayer(DCL.Skybox.TextureLayer)
RenderCubemapLayer(DCL.Skybox.TextureLayer)
RenderPlanarLayer(DCL.Skybox.TextureLayer, System.Boolean)
RenderSatelliteLayer(DCL.Skybox.TextureLayer)
RenderParticleLayer(DCL.Skybox.TextureLayer)
RenderDistortionVariables(DCL.Skybox.TextureLayer)
RenderSepratedFloatFields(System.String, System.String, System.Single&, System.String, System.Single&)
RenderFloatField(System.String, System.Single&)
RenderFloatFieldAsSlider(System.String, System.Single&, System.Single, System.Single)
RenderVector3Field(System.String, UnityEngine.Vector3&)
RenderVector2Field(System.String, UnityEngine.Vector2&)
RenderTexture(System.String, UnityEngine.Texture2D&)
RenderCubemapTexture(System.String, UnityEngine.Cubemap&)
RenderTransitioningVector3(System.Collections.Generic.List[TransitioningVector3], System.String, System.String, System.String, System.Single, System.Single)
RenderTransitioningVector2(System.Collections.Generic.List[TransitioningVector2], System.String, System.String, System.String, System.Single, System.Single)
RenderTransitioningFloat(System.Collections.Generic.List[TransitioningFloat], System.String, System.String, System.String, System.Boolean, System.Single, System.Single, System.Single, System.Single)
RenderColorGradientField(UnityEngine.Gradient, System.String, System.Single, System.Single, System.Boolean)
RenderTransitioningQuaternionAsVector3(System.Collections.Generic.List[TransitioningQuaternion], System.String, System.String, System.String, System.Func[Quaternion], System.Single, System.Single)
RenderPercentagePart(System.Single, System.Single, System.Single&)
ApplyOnMaterial()
GetNormalizedDayTime()
GetNormalizedLayerCurrentTime(System.Single, System.Single)
GetDayTimeForLayerNormalizedTime(System.Single, System.Single, System.Single)
ClampToDayTime(System.Single&)