< 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:1507
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        static void Init()
 190        {
 0191            SkyboxEditorWindow window = (SkyboxEditorWindow)EditorWindow.GetWindow(typeof(SkyboxEditorWindow));
 0192            window.minSize = new Vector2(500, 500);
 0193            window.Show();
 0194            window.InitializeWindow();
 0195        }
 196
 0197        public void InitializeWindow() { EnsureDependencies(); }
 198
 199        private void EnsureDependencies()
 200        {
 0201            if (!Application.isPlaying)
 202            {
 0203                overridingController = false;
 204            }
 205
 0206            if (Application.isPlaying && !overridingController)
 207            {
 0208                TakeControlAtRuntime();
 209            }
 210
 0211            if (selectedConfiguration == null)
 212            {
 0213                UpdateConfigurationsList();
 214            }
 215
 0216            if (matLayer == null || selectedMat == null)
 217            {
 0218                UpdateMaterial();
 219            }
 220
 0221            CheckAndAssignAllStyles();
 222
 0223            EditorUtility.SetDirty(selectedConfiguration);
 224
 225            // Fill rendering order array
 0226            if (renderingOrderList == null)
 227            {
 0228                renderingOrderList = new List<string>();
 229
 0230                for (int i = 0; i < 5; i++)
 231                {
 0232                    renderingOrderList.Add((i + 1).ToString());
 233                }
 234            }
 235
 0236            if (directionalLight != null)
 237            {
 0238                return;
 239            }
 240
 241            // Cache directional light reference
 0242            directionalLight = GameObject.FindObjectsOfType<Light>(true).Where(s => s.type == LightType.Directional).Fir
 243
 244            // Make a directional light object if can't find
 0245            if (directionalLight == null)
 246            {
 0247                GameObject temp = new GameObject("The Sun_Temp");
 248                // Add the light component
 0249                directionalLight = temp.AddComponent<Light>();
 0250                directionalLight.type = LightType.Directional;
 251            }
 0252        }
 253
 254        private void CheckAndAssignAllStyles()
 255        {
 0256            if (foldoutStyle == null)
 257            {
 0258                foldoutStyle = new GUIStyle(EditorStyles.foldout);
 0259                foldoutStyle.fixedWidth = 2;
 260            }
 261
 0262            if (renderingMarkerStyle == null)
 263            {
 0264                renderingMarkerStyle = new GUIStyle(EditorStyles.label);
 0265                renderingMarkerStyle.fontSize = 18;
 266            }
 267
 0268            if (configurationStyle == null)
 269            {
 0270                configurationStyle = new GUIStyle();
 0271                configurationStyle.alignment = TextAnchor.MiddleCenter;
 0272                configurationStyle.margin = new RectOffset(150, 200, 0, 0);
 273            }
 274
 0275            if (percentagePartStyle == null)
 276            {
 0277                percentagePartStyle = new GUIStyle();
 0278                percentagePartStyle.alignment = TextAnchor.MiddleCenter;
 279            }
 0280        }
 281
 282        void TakeControlAtRuntime()
 283        {
 0284            if (SkyboxController.i != null)
 285            {
 0286                isPaused = SkyboxController.i.IsPaused();
 0287                lifecycleDuration = (float)SkyboxController.i.lifecycleDuration;
 0288                selectedConfiguration = SkyboxController.i.GetCurrentConfiguration();
 0289                overridingController = SkyboxController.i.SetOverrideController(true);
 0290                timeOfTheDay = SkyboxController.i.GetCurrentTimeOfTheDay();
 0291                UpdateConfigurationsList();
 292            }
 0293        }
 294
 295        void InitializeMaterial()
 296        {
 0297            matLayer = MaterialReferenceContainer.i.GetMat_LayerForLayers(5);
 298
 0299            if (matLayer == null)
 300            {
 0301                matLayer = MaterialReferenceContainer.i.materials[0];
 302            }
 303
 0304            selectedMat = matLayer.material;
 0305            selectedConfiguration.ResetMaterial(selectedMat, matLayer.numberOfSlots);
 0306            RenderSettings.skybox = selectedMat;
 0307        }
 308
 0309        private void UpdateMaterial() { InitializeMaterial(); }
 310
 311        private SkyboxConfiguration AddNewConfiguration(string name)
 312        {
 313            SkyboxConfiguration temp = null;
 0314            temp = ScriptableObject.CreateInstance<SkyboxConfiguration>();
 0315            temp.skyboxID = name;
 316
 0317            string path = AssetDatabase.GenerateUniqueAssetPath("Assets/Rendering/ProceduralSkybox/Resources/Skybox Conf
 0318            AssetDatabase.CreateAsset(temp, path);
 0319            AssetDatabase.SaveAssets();
 320
 0321            return temp;
 322        }
 323
 324        private void RenderConfigurations()
 325        {
 0326            GUILayout.Label("Configurations", EditorStyles.boldLabel);
 327
 328
 0329            GUILayout.Label("Loaded: " + selectedConfiguration.skyboxID);
 0330            GUILayout.BeginHorizontal(configurationStyle);
 331
 0332            if (creatingNewConfig)
 333            {
 0334                GUILayout.Label("Name");
 0335                newConfigName = EditorGUILayout.TextField(newConfigName, GUILayout.Width(200));
 336
 0337                if (GUILayout.Button("Create", GUILayout.Width(50)))
 338                {
 339                    // Make new configuration
 0340                    selectedConfiguration = AddNewConfiguration(newConfigName);
 341
 342                    // Update configuration list
 0343                    UpdateConfigurationsList();
 0344                    creatingNewConfig = false;
 345
 0346                    if (Application.isPlaying && SkyboxController.i != null && overridingController)
 347                    {
 0348                        SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration);
 349                    }
 350                }
 351
 0352                if (GUILayout.Button("Cancel", GUILayout.Width(50)))
 353                {
 0354                    creatingNewConfig = false;
 355                }
 0356            }
 357            else
 358            {
 0359                EditorGUILayout.BeginVertical();
 0360                newConfigIndex = EditorGUILayout.Popup(selectedConfigurationIndex, configurationNames.ToArray(), GUILayo
 0361                selectedConfiguration = (SkyboxConfiguration)EditorGUILayout.ObjectField(selectedConfiguration, typeof(S
 362
 0363                EditorGUILayout.EndVertical();
 364
 0365                if (newConfigIndex != selectedConfigurationIndex)
 366                {
 0367                    selectedConfiguration = configurations[newConfigIndex];
 0368                    selectedConfigurationIndex = newConfigIndex;
 369
 0370                    if (Application.isPlaying && SkyboxController.i != null && overridingController)
 371                    {
 0372                        SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration);
 373                    }
 374                }
 375
 0376                if (selectedConfiguration != configurations[selectedConfigurationIndex])
 377                {
 0378                    UpdateConfigurationsList();
 379
 0380                    if (Application.isPlaying && SkyboxController.i != null && overridingController)
 381                    {
 0382                        SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration);
 383                    }
 384                }
 385
 0386                if (GUILayout.Button("+", GUILayout.Width(50)))
 387                {
 0388                    creatingNewConfig = true;
 389                }
 390            }
 391
 0392            GUILayout.EndHorizontal();
 0393        }
 394
 395        private void UpdateConfigurationsList()
 396        {
 0397            SkyboxConfiguration[] tConfigurations = Resources.LoadAll<SkyboxConfiguration>("Skybox Configurations/");
 0398            configurations = new List<SkyboxConfiguration>(tConfigurations);
 0399            configurationNames = new List<string>();
 400
 401            // If no configurations exist, make and select new one.
 0402            if (configurations == null || configurations.Count < 1)
 403            {
 0404                selectedConfiguration = AddNewConfiguration("Generic Skybox");
 405
 0406                configurations = new List<SkyboxConfiguration>();
 0407                configurations.Add(selectedConfiguration);
 408            }
 409
 0410            if (selectedConfiguration == null)
 411            {
 0412                selectedConfiguration = configurations[0];
 413            }
 414
 0415            for (int i = 0; i < configurations.Count; i++)
 416            {
 0417                configurations[i].skyboxID = configurations[i].name;
 418
 0419                configurationNames.Add(configurations[i].skyboxID);
 0420                if (selectedConfiguration == configurations[i])
 421                {
 0422                    selectedConfigurationIndex = i;
 423                }
 424            }
 425
 0426            InitializeMaterial();
 427
 0428            if (!Application.isPlaying)
 429            {
 0430                isPaused = true;
 431            }
 0432        }
 433
 434        private void RenderTimePanel()
 435        {
 436
 0437            GUILayout.Label("Preview", EditorStyles.boldLabel);
 438
 0439            GUILayout.BeginHorizontal();
 0440            EditorGUILayout.LabelField("Time : " + timeOfTheDay.ToString("f2"), EditorStyles.label, GUILayout.Width(70))
 441
 0442            EditorGUILayout.Space(20);
 443
 0444            EditorGUILayout.BeginVertical();
 0445            timeOfTheDay = EditorGUILayout.Slider(timeOfTheDay, 0.01f, 24.00f, GUILayout.MinWidth(150));
 0446            GUILayout.BeginHorizontal();
 0447            EditorGUILayout.LabelField("cycle (minutes)", GUILayout.Width(95));
 0448            lifecycleDuration = EditorGUILayout.FloatField(lifecycleDuration, GUILayout.Width(50));
 0449            EditorGUILayout.EndHorizontal();
 0450            EditorGUILayout.EndVertical();
 451
 0452            EditorGUILayout.LabelField((GetNormalizedDayTime() * 100).ToString("f2") + "%", GUILayout.MaxWidth(50));
 453
 0454            if (isPaused)
 455            {
 0456                if (GUILayout.Button("Play", GUILayout.ExpandWidth(false)))
 457                {
 0458                    ResumeTime();
 459                }
 0460            }
 461            else
 462            {
 0463                if (GUILayout.Button("Pause", GUILayout.ExpandWidth(false)))
 464                {
 0465                    PauseTime();
 466                }
 467            }
 468
 0469            GUILayout.EndHorizontal();
 0470        }
 471
 0472        void ResumeTime() { isPaused = false; }
 473
 0474        void PauseTime() { isPaused = true; }
 475
 476        #region Render Base Layeyrs
 477
 478        void RenderBackgroundColorLayer()
 479        {
 0480            RenderColorGradientField(selectedConfiguration.skyColor, "Sky Color", 0, 24);
 0481            RenderColorGradientField(selectedConfiguration.horizonColor, "Horizon Color", 0, 24);
 0482            RenderColorGradientField(selectedConfiguration.groundColor, "Ground Color", 0, 24);
 0483            RenderHorizonLayer();
 0484        }
 485
 486        void RenderHorizonLayer()
 487        {
 0488            EditorGUILayout.Separator();
 0489            RenderTransitioningFloat(selectedConfiguration.horizonHeight, "Horizon Height", "%", "value", true, -1, 1);
 490
 0491            EditorGUILayout.Space(10);
 0492            RenderTransitioningFloat(selectedConfiguration.horizonWidth, "Horizon Width", "%", "value", true, -1, 1);
 493
 0494            EditorGUILayout.Separator();
 495
 496            // Horizon Mask
 0497            RenderTexture("Texture", ref selectedConfiguration.horizonMask);
 498
 499            // Horizon mask values
 0500            RenderVector3Field("Horizon Mask Values", ref selectedConfiguration.horizonMaskValues);
 501
 502            // Horizon Plane color
 0503            RenderColorGradientField(selectedConfiguration.horizonPlaneColor, "Horizon Plane Color", 0, 24);
 504
 505            // Horizon Height
 0506            RenderTransitioningFloat(selectedConfiguration.horizonPlaneHeight, "Horizon Plane Height", "%", "value", tru
 0507        }
 508
 509        void RenderAmbientLayer()
 510        {
 0511            selectedConfiguration.ambientTrilight = EditorGUILayout.Toggle("Use Gradient", selectedConfiguration.ambient
 512
 0513            if (selectedConfiguration.ambientTrilight)
 514            {
 0515                RenderColorGradientField(selectedConfiguration.ambientSkyColor, "Ambient Sky Color", 0, 24, true);
 0516                RenderColorGradientField(selectedConfiguration.ambientEquatorColor, "Ambient Equator Color", 0, 24, true
 0517                RenderColorGradientField(selectedConfiguration.ambientGroundColor, "Ambient Ground Color", 0, 24, true);
 518            }
 519
 0520        }
 521
 522        void RenderAvatarColorLayer()
 523        {
 0524            EditorGUILayout.LabelField("In World", EditorStyles.boldLabel);
 0525            EditorGUI.indentLevel++;
 526            // Avatar Color
 0527            selectedConfiguration.useAvatarGradient = EditorGUILayout.Toggle("Color Gradient", selectedConfiguration.use
 528
 0529            if (selectedConfiguration.useAvatarGradient)
 530            {
 0531                RenderColorGradientField(selectedConfiguration.avatarTintGradient, "Tint Gradient", 0, 24, true);
 0532            }
 533            else
 534            {
 0535                selectedConfiguration.avatarTintColor = EditorGUILayout.ColorField("Tint Color", selectedConfiguration.a
 0536                EditorGUILayout.Separator();
 537            }
 538
 539            // Avatar Light Direction
 0540            selectedConfiguration.useAvatarRealtimeDLDirection = EditorGUILayout.Toggle("Realtime DL Direction", selecte
 541
 0542            if (!selectedConfiguration.useAvatarRealtimeDLDirection)
 543            {
 0544                RenderVector3Field("Light Direction", ref selectedConfiguration.avatarLightConstantDir);
 545            }
 546
 0547            EditorGUILayout.Separator();
 548
 549            // Avatar Light Color
 0550            selectedConfiguration.useAvatarRealtimeLightColor = EditorGUILayout.Toggle("Realtime Light Color", selectedC
 551
 0552            if (!selectedConfiguration.useAvatarRealtimeLightColor)
 553            {
 0554                RenderColorGradientField(selectedConfiguration.avatarLightColorGradient, "Light Color", 0, 24);
 0555                EditorGUILayout.Separator();
 556            }
 0557            EditorGUI.indentLevel--;
 558
 0559            EditorGUILayout.LabelField("In Editor (Backpack)", EditorStyles.boldLabel);
 0560            EditorGUI.indentLevel++;
 0561            selectedConfiguration.avatarEditorTintColor = EditorGUILayout.ColorField("Tint Color", selectedConfiguration
 0562            RenderVector3Field("Light Direction", ref selectedConfiguration.avatarEditorLightDir);
 0563            selectedConfiguration.avatarEditorLightColor = EditorGUILayout.ColorField("Light Color", selectedConfigurati
 0564            EditorGUILayout.Separator();
 0565            EditorGUI.indentLevel--;
 0566        }
 567
 568        void RenderFogLayer()
 569        {
 0570            selectedConfiguration.useFog = EditorGUILayout.Toggle("Use Fog", selectedConfiguration.useFog);
 0571            if (selectedConfiguration.useFog)
 572            {
 0573                RenderColorGradientField(selectedConfiguration.fogColor, "Fog Color", 0, 24);
 0574                selectedConfiguration.fogMode = (FogMode)EditorGUILayout.EnumPopup("Fog Mode", selectedConfiguration.fog
 575
 0576                switch (selectedConfiguration.fogMode)
 577                {
 578                    case FogMode.Linear:
 0579                        RenderFloatField("Start Distance:", ref selectedConfiguration.fogStartDistance);
 0580                        RenderFloatField("End Distance:", ref selectedConfiguration.fogEndDistance);
 0581                        break;
 582                    default:
 0583                        RenderFloatField("Density: ", ref selectedConfiguration.fogDensity);
 584                        break;
 585                }
 586            }
 587
 0588        }
 589
 590        void RenderDirectionalLightLayer()
 591        {
 0592            selectedConfiguration.useDirectionalLight = EditorGUILayout.Toggle("Use Directional Light", selectedConfigur
 593
 0594            if (!selectedConfiguration.useDirectionalLight)
 595            {
 0596                return;
 597            }
 0598            RenderColorGradientField(selectedConfiguration.directionalLightLayer.lightColor, "Light Color", 0, 24);
 0599            RenderColorGradientField(selectedConfiguration.directionalLightLayer.tintColor, "Tint Color", 0, 24, true);
 600
 0601            GUILayout.Space(10);
 602
 603            // Light Intesity
 0604            RenderTransitioningFloat(selectedConfiguration.directionalLightLayer.intensity, "Light Intensity", "%", "Int
 605
 0606            GUILayout.Space(10);
 607
 0608            RenderTransitioningQuaternionAsVector3(selectedConfiguration.directionalLightLayer.lightDirection, "Light Di
 0609        }
 610
 0611        private Quaternion GetDLDirection() { return directionalLight.transform.rotation; }
 612
 613        private void RenderTimelineTags()
 614        {
 0615            if (selectedConfiguration.timelineTags == null)
 616            {
 0617                selectedConfiguration.timelineTags = new List<TimelineTagsDuration>();
 618            }
 619
 0620            for (int i = 0; i < selectedConfiguration.timelineTags.Count; i++)
 621            {
 0622                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 623
 624                // Text field for name of event
 0625                EditorGUILayout.LabelField("Name: ", GUILayout.Width(50));
 0626                selectedConfiguration.timelineTags[i].tag = EditorGUILayout.TextField(selectedConfiguration.timelineTags
 627
 628                // Start time
 0629                EditorGUILayout.LabelField("Start", GUILayout.Width(45));
 0630                GUILayout.Space(0);
 0631                selectedConfiguration.timelineTags[i].startTime = EditorGUILayout.FloatField(selectedConfiguration.timel
 0632                ClampToDayTime(ref selectedConfiguration.timelineTags[i].startTime);
 633
 634                // End time
 0635                if (!selectedConfiguration.timelineTags[i].isTrigger)
 636                {
 0637                    EditorGUILayout.LabelField("End", GUILayout.Width(40));
 0638                    GUILayout.Space(0);
 0639                    selectedConfiguration.timelineTags[i].endTime = EditorGUILayout.FloatField(selectedConfiguration.tim
 0640                    ClampToDayTime(ref selectedConfiguration.timelineTags[i].endTime);
 0641                }
 642                else
 643                {
 0644                    GUILayout.Space(97);
 645                }
 646
 647                // no end time
 0648                selectedConfiguration.timelineTags[i].isTrigger = EditorGUILayout.ToggleLeft("Trigger", selectedConfigur
 649
 650                // Remove Button
 0651                if (GUILayout.Button("-", GUILayout.Width(30)))
 652                {
 0653                    selectedConfiguration.timelineTags.RemoveAt(i);
 654                }
 655
 0656                EditorGUILayout.EndHorizontal();
 657            }
 658
 0659            EditorGUILayout.BeginHorizontal();
 0660            GUILayout.Space(20);
 0661            if (GUILayout.Button("+", GUILayout.Width(30)))
 662            {
 0663                selectedConfiguration.timelineTags.Add(new TimelineTagsDuration(timeOfTheDay));
 664            }
 0665            EditorGUILayout.EndHorizontal();
 0666        }
 667
 668        #endregion
 669
 670        #region Render Slots and Layers
 671
 672        void RenderTextureLayers(List<TextureLayer> layers)
 673        {
 674
 0675            for (int i = 0; i < layers.Count; i++)
 676            {
 677                // Name and buttons
 0678                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0679                layers[i].enabled = EditorGUILayout.Toggle(layers[i].enabled, GUILayout.Width(20), GUILayout.Height(10))
 0680                GUILayout.Space(10);
 0681                layers[i].expandedInEditor = EditorGUILayout.Foldout(layers[i].expandedInEditor, GUIContent.none, true, 
 0682                layers[i].nameInEditor = EditorGUILayout.TextField(layers[i].nameInEditor, GUILayout.Width(100), GUILayo
 683
 684                // Slot ID
 0685                layers[i].slotID = EditorGUILayout.Popup(layers[i].slotID, renderingOrderList.ToArray(), GUILayout.Width
 686
 0687                if (i == 0)
 688                {
 0689                    GUI.enabled = false;
 690                }
 0691                if (GUILayout.Button(('\u25B2').ToString(), GUILayout.Width(50), GUILayout.ExpandWidth(false)))
 692                {
 0693                    TextureLayer temp = null;
 694
 0695                    if (i >= 1)
 696                    {
 0697                        temp = layers[i - 1];
 0698                        layers[i - 1] = layers[i];
 0699                        layers[i] = temp;
 700                    }
 701                }
 702
 0703                GUI.enabled = true;
 704
 0705                if (i == layers.Count - 1)
 706                {
 0707                    GUI.enabled = false;
 708                }
 709
 0710                if (GUILayout.Button(('\u25BC').ToString(), GUILayout.Width(50), GUILayout.ExpandWidth(false)))
 711                {
 0712                    TextureLayer temp = null;
 0713                    if (i < (layers.Count - 1))
 714                    {
 0715                        temp = layers[i + 1];
 0716                        layers[i + 1] = layers[i];
 0717                        layers[i] = temp;
 718                    }
 0719                    break;
 720                }
 721
 0722                GUI.enabled = true;
 723
 0724                if (GUILayout.Button("-", GUILayout.Width(50), GUILayout.ExpandWidth(false)))
 725                {
 0726                    layers.RemoveAt(i);
 0727                    break;
 728                }
 729
 0730                Color circleColor = Color.green;
 0731                switch (layers[i].renderType)
 732                {
 733                    case LayerRenderType.Rendering:
 0734                        circleColor = Color.green;
 0735                        break;
 736                    case LayerRenderType.NotRendering:
 0737                        circleColor = Color.gray;
 0738                        break;
 739                    case LayerRenderType.Conflict_Playing:
 0740                        circleColor = Color.yellow;
 0741                        break;
 742                    case LayerRenderType.Conflict_NotPlaying:
 0743                        circleColor = Color.red;
 744                        break;
 745                    default:
 746                        break;
 747                }
 748
 0749                Color normalContentColor = GUI.color;
 0750                GUI.color = circleColor;
 751
 0752                EditorGUILayout.LabelField(('\u29BF').ToString(), renderingMarkerStyle, GUILayout.Width(20), GUILayout.H
 753
 0754                GUI.color = normalContentColor;
 755
 0756                EditorGUILayout.EndHorizontal();
 757
 0758                if (layers[i].expandedInEditor)
 759                {
 0760                    EditorGUILayout.Separator();
 0761                    EditorGUI.indentLevel++;
 0762                    RenderTextureLayer(layers[i]);
 763
 0764                    EditorGUI.indentLevel--;
 765                }
 766
 0767                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
 768
 0769                GUILayout.Space(32);
 770            }
 771
 0772            GUI.enabled = true;
 773
 0774            if (GUILayout.Button("+", GUILayout.MaxWidth(20)))
 775            {
 0776                layers.Add(new TextureLayer("Tex Layer " + (layers.Count + 1)));
 777            }
 0778        }
 779
 780        void RenderTextureLayer(TextureLayer layer)
 781        {
 0782            EditorGUILayout.Separator();
 783
 784            // Layer Type
 0785            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0786            EditorGUILayout.LabelField("Layer Type:", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0787            layer.layerType = (LayerType)EditorGUILayout.EnumPopup(layer.layerType, GUILayout.Width(200));
 0788            EditorGUILayout.EndHorizontal();
 789
 790
 0791            EditorGUILayout.Separator();
 792
 793            // Time Span
 0794            RenderSepratedFloatFields("Time Span", "Starts", ref layer.timeSpan_start, "Ends", ref layer.timeSpan_End);
 0795            ClampToDayTime(ref layer.timeSpan_start);
 0796            ClampToDayTime(ref layer.timeSpan_End);
 797
 798            // Fading
 0799            RenderSepratedFloatFields("Fading", "In", ref layer.fadingInTime, "Out", ref layer.fadingOutTime);
 800
 801            // Tint
 0802            RenderFloatFieldAsSlider("Tint", ref layer.tintPercentage, 0, 100);
 803
 0804            if (layer.layerType == LayerType.Cubemap)
 805            {
 0806                RenderCubemapLayer(layer);
 807
 0808            }
 0809            else if (layer.layerType == LayerType.Planar)
 810            {
 0811                RenderPlanarLayer(layer);
 812
 0813            }
 0814            else if (layer.layerType == LayerType.Radial)
 815            {
 0816                RenderPlanarLayer(layer, true);
 0817            }
 0818            else if (layer.layerType == LayerType.Satellite)
 819            {
 0820                RenderSatelliteLayer(layer);
 0821            }
 0822            else if (layer.layerType == LayerType.Particles)
 823            {
 0824                RenderParticleLayer(layer);
 825            }
 0826        }
 827
 828        void RenderCubemapLayer(TextureLayer layer)
 829        {
 830            // Cubemap
 0831            RenderCubemapTexture("Cubemap", ref layer.cubemap);
 832
 833            // Gradient
 0834            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 835
 0836            EditorGUILayout.Separator();
 837
 838            // Movement Type
 0839            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0840            EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0841            layer.movementTypeCubemap = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypeCubemap, GUILayout.Wid
 0842            EditorGUILayout.EndHorizontal();
 843
 0844            EditorGUILayout.Separator();
 845
 846            // Rotation
 0847            if (layer.movementTypeCubemap == MovementType.PointBased)
 848            {
 0849                RenderTransitioningVector3(layer.rotations_Vector3, "Rotation", "%", "Rot:", layer.timeSpan_start, layer
 850
 0851            }
 852            else
 853            {
 0854                RenderVector3Field("Speed", ref layer.speed_Vector3);
 855            }
 0856        }
 857
 858        void RenderPlanarLayer(TextureLayer layer, bool isRadial = false)
 859        {
 860            // Texture
 0861            RenderTexture("Texture", ref layer.texture);
 862
 863            // Row and Coloumns
 0864            RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns);
 865
 866            // Anim Speed
 0867            RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed);
 868
 869            // Normal Texture
 0870            RenderTexture("Normal Map", ref layer.textureNormal);
 871
 872            // Normal Intensity
 0873            RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1);
 874
 875            // Gradient
 0876            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 877
 878            // Tiling
 0879            RenderVector2Field("Tiling", ref layer.tiling);
 880
 881            // Movement Type
 0882            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0883            EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0884            layer.movementTypePlanar_Radial = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypePlanar_Radial, G
 0885            EditorGUILayout.EndHorizontal();
 886
 0887            EditorGUI.indentLevel++;
 0888            EditorGUILayout.Separator();
 889
 0890            if (layer.movementTypePlanar_Radial == MovementType.Speed)
 891            {
 892                // Speed
 0893                RenderVector2Field("Speed", ref layer.speed_Vector2);
 0894            }
 895            else
 896            {
 897                // Offset
 0898                RenderTransitioningVector2(layer.offset, "Position", "%", "", layer.timeSpan_start, layer.timeSpan_End);
 899            }
 900
 0901            EditorGUI.indentLevel--;
 902
 0903            EditorGUILayout.Space(15);
 904
 905            // Render Distance
 0906            RenderTransitioningFloat(layer.renderDistance, "Render Distance", "", "", true, 0, 20, layer.timeSpan_start,
 907
 0908            EditorGUILayout.Space(15);
 909
 910            // Rotation
 0911            if (!isRadial)
 912            {
 0913                RenderTransitioningFloat(layer.rotations_float, "Rotation", "", "", true, 0, 360, layer.timeSpan_start, 
 0914                EditorGUILayout.Separator();
 915            }
 916
 0917            RenderDistortionVariables(layer);
 918
 0919            EditorGUILayout.Space(10);
 0920        }
 921
 922        void RenderSatelliteLayer(TextureLayer layer)
 923        {
 924            // Texture
 0925            RenderTexture("Texture", ref layer.texture);
 926
 927            // Row and Coloumns
 0928            RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns);
 929
 930            // Anim Speed
 0931            RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed);
 932
 933            // Normal Texture
 0934            RenderTexture("Normal Map", ref layer.textureNormal);
 935
 936            // Normal Intensity
 0937            RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1);
 938
 939            // Gradient
 0940            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 941
 0942            EditorGUILayout.Space(10);
 0943            EditorGUILayout.Space(10);
 944
 0945            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0946            EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0947            layer.movementTypeSatellite = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypeSatellite, GUILayout
 0948            EditorGUILayout.EndHorizontal();
 949
 0950            EditorGUI.indentLevel++;
 0951            EditorGUILayout.Separator();
 952
 0953            if (layer.movementTypeSatellite == MovementType.Speed)
 954            {
 955                // Speed
 0956                RenderVector2Field("Speed", ref layer.speed_Vector2);
 0957            }
 958            else
 959            {
 960                // Offset
 0961                RenderTransitioningVector2(layer.offset, "Position", "%", "", layer.timeSpan_start, layer.timeSpan_End);
 962            }
 963
 0964            EditorGUI.indentLevel--;
 0965            EditorGUILayout.Space(20);
 966
 967            // Rotation
 0968            RenderTransitioningFloat(layer.rotations_float, "Rotation", "", "", true, 0, 360, layer.timeSpan_start, laye
 969
 0970            EditorGUILayout.Space(12);
 971
 972            // Size
 0973            RenderTransitioningVector2(layer.satelliteWidthHeight, "Width & Height", "%", "", layer.timeSpan_start, laye
 0974        }
 975
 976        void RenderParticleLayer(TextureLayer layer)
 977        {
 978            // Texture
 0979            RenderTexture("Texture", ref layer.texture);
 980
 981            // Row and Coloumns
 0982            RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns);
 983
 984            // Anim Speed
 0985            RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed);
 986
 987            // Normal Map
 0988            RenderTexture("Normal Map", ref layer.textureNormal);
 989
 990            // Normal Intensity
 0991            RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1);
 992
 993            // Gradient
 0994            RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true);
 995
 996            // Tiling
 0997            RenderVector2Field("Tiling", ref layer.particleTiling);
 998
 999            // Offset
 01000            RenderVector2Field("Offset", ref layer.particlesOffset);
 1001
 1002            // Amount
 01003            RenderFloatField("Amount", ref layer.particlesAmount);
 1004
 1005            // Size
 01006            RenderSepratedFloatFields("Size", "Min", ref layer.particleMinSize, "Max", ref layer.particleMaxSize);
 1007
 1008            // Spread
 01009            RenderSepratedFloatFields("Spread", "Horizontal", ref layer.particlesHorizontalSpread, "Vertical", ref layer
 1010
 1011            // Fade
 01012            RenderSepratedFloatFields("Fade", "Min", ref layer.particleMinFade, "Max", ref layer.particleMaxFade);
 1013
 1014            // Particle Rotation
 01015            RenderTransitioningVector3(layer.particleRotation, "Rotation", "%", "value", layer.timeSpan_start, layer.tim
 01016        }
 1017
 1018        void RenderDistortionVariables(TextureLayer layer)
 1019        {
 01020            layer.distortionExpanded = EditorGUILayout.Foldout(layer.distortionExpanded, "Distortion Values", true, Edit
 1021
 01022            if (!layer.distortionExpanded)
 1023            {
 01024                return;
 1025            }
 1026
 01027            EditorGUILayout.Space(10);
 1028
 01029            EditorGUI.indentLevel++;
 1030
 1031            // Distortion Intensity
 01032            RenderTransitioningFloat(layer.distortIntensity, "Intensity", "%", "Value", false, 0, 1, layer.timeSpan_star
 1033
 01034            EditorGUILayout.Space(10);
 1035
 1036            // Distortion Size
 01037            RenderTransitioningFloat(layer.distortSize, "Size", "%", "Value", false, 0, 1, layer.timeSpan_start, layer.t
 1038
 01039            EditorGUILayout.Space(10);
 1040
 1041            // Distortion Speed
 01042            RenderTransitioningVector2(layer.distortSpeed, "Speed", "%", "Value", layer.timeSpan_start, layer.timeSpan_E
 1043
 01044            EditorGUILayout.Space(10);
 1045
 1046            // Distortion Sharpness
 01047            RenderTransitioningVector2(layer.distortSharpness, "Sharpness", "%", "Value", layer.timeSpan_start, layer.ti
 1048
 01049            EditorGUILayout.Space(10);
 1050
 01051            EditorGUI.indentLevel--;
 01052        }
 1053
 1054        #endregion
 1055
 1056        #region Render simple Variables
 1057
 1058        void RenderSepratedFloatFields(string label, string label1, ref float value1, string label2, ref float value2)
 1059        {
 01060            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01061            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01062            EditorGUILayout.LabelField(label1, GUILayout.Width(90), GUILayout.ExpandWidth(false));
 01063            value1 = EditorGUILayout.FloatField("", value1, GUILayout.Width(90));
 01064            EditorGUILayout.LabelField(label2, GUILayout.Width(90), GUILayout.ExpandWidth(false));
 01065            value2 = EditorGUILayout.FloatField("", value2, GUILayout.Width(90));
 01066            GUILayout.EndHorizontal();
 01067            EditorGUILayout.Separator();
 01068        }
 1069
 1070        void RenderFloatField(string label, ref float value)
 1071        {
 01072            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01073            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01074            value = EditorGUILayout.FloatField(value, GUILayout.Width(90));
 01075            EditorGUILayout.EndHorizontal();
 01076            EditorGUILayout.Separator();
 01077        }
 1078
 1079        void RenderFloatFieldAsSlider(string label, ref float value, float min, float max)
 1080        {
 01081            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01082            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01083            value = EditorGUILayout.Slider(value, min, max, GUILayout.Width(200));
 01084            EditorGUILayout.EndHorizontal();
 01085            EditorGUILayout.Separator();
 01086        }
 1087
 1088        void RenderVector3Field(string label, ref Vector3 value)
 1089        {
 01090            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01091            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01092            value = EditorGUILayout.Vector3Field("", value, GUILayout.Width(200), GUILayout.ExpandWidth(false));
 01093            GUILayout.EndHorizontal();
 01094            EditorGUILayout.Separator();
 01095        }
 1096
 1097        void RenderVector2Field(string label, ref Vector2 value)
 1098        {
 01099            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01100            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01101            value = EditorGUILayout.Vector2Field("", value, GUILayout.Width(200), GUILayout.ExpandWidth(false));
 01102            GUILayout.EndHorizontal();
 01103            EditorGUILayout.Separator();
 01104        }
 1105
 1106        void RenderTexture(string label, ref Texture2D tex)
 1107        {
 01108            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01109            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01110            tex = (Texture2D)EditorGUILayout.ObjectField(tex, typeof(Texture2D), false, GUILayout.Width(200));
 01111            GUILayout.EndHorizontal();
 01112            EditorGUILayout.Separator();
 01113        }
 1114
 1115        void RenderCubemapTexture(string label, ref Cubemap tex)
 1116        {
 01117            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01118            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01119            tex = (Cubemap)EditorGUILayout.ObjectField(tex, typeof(Cubemap), false, GUILayout.Width(200));
 01120            GUILayout.EndHorizontal();
 01121            EditorGUILayout.Separator();
 01122        }
 1123
 1124        #endregion
 1125
 1126        #region Render Transitioning Variables
 1127
 1128        void RenderTransitioningVector3(List<TransitioningVector3> list, string label, string percentTxt, string valueTe
 1129        {
 01130            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01131            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 01132            EditorGUILayout.BeginVertical();
 1133
 01134            if (list.Count == 0)
 1135            {
 01136                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1137                {
 01138                    Vector3 tLastPos = Vector3.zero;
 01139                    if (list.Count != 0)
 1140                    {
 01141                        tLastPos = list[list.Count - 1].value;
 1142                    }
 01143                    list.Add(new TransitioningVector3(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100,
 1144                }
 1145            }
 1146
 01147            for (int i = 0; i < list.Count; i++)
 1148            {
 01149                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 1150
 01151                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1152                {
 01153                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1154                }
 1155
 1156                // Percentage
 01157                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1158
 01159                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1160
 01161                GUILayout.Space(10);
 1162
 01163                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1164
 01165                GUILayout.Space(10);
 01166                list[i].value = EditorGUILayout.Vector3Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi
 1167
 01168                GUILayout.Space(20);
 01169                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1170                {
 01171                    list.RemoveAt(i);
 1172                }
 1173
 01174                if (i == (list.Count - 1))
 1175                {
 01176                    GUILayout.Space(20);
 01177                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1178                    {
 01179                        Vector3 tLastPos = Vector3.zero;
 01180                        if (list.Count != 0)
 1181                        {
 01182                            tLastPos = list[list.Count - 1].value;
 1183                        }
 01184                        list.Add(new TransitioningVector3(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 
 1185                    }
 1186                }
 1187
 01188                GUILayout.EndHorizontal();
 1189            }
 1190
 01191            EditorGUILayout.EndVertical();
 01192            GUILayout.EndHorizontal();
 1193
 01194            Rect lastRect = GUILayoutUtility.GetLastRect();
 01195            lastRect.y -= 5;
 01196            lastRect.height += 10;
 01197            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01198        }
 1199
 1200        void RenderTransitioningVector2(List<TransitioningVector2> list, string label, string percentTxt, string valueTe
 1201        {
 01202            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01203            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 01204            EditorGUILayout.BeginVertical();
 1205
 01206            if (list.Count == 0)
 1207            {
 01208                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1209                {
 01210                    Vector2 tLastPos = Vector2.zero;
 01211                    if (list.Count != 0)
 1212                    {
 01213                        tLastPos = list[list.Count - 1].value;
 1214                    }
 01215                    list.Add(new TransitioningVector2(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100,
 1216                }
 1217            }
 1218
 01219            for (int i = 0; i < list.Count; i++)
 1220            {
 01221                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 1222
 01223                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1224                {
 01225                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1226                }
 1227
 1228                // Percentage
 01229                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1230
 01231                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1232
 01233                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1234
 01235                GUILayout.Space(10);
 01236                list[i].value = EditorGUILayout.Vector2Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi
 1237
 01238                GUILayout.Space(20);
 01239                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1240                {
 01241                    list.RemoveAt(i);
 1242                }
 1243
 01244                if (i == (list.Count - 1))
 1245                {
 01246                    GUILayout.Space(20);
 01247                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1248                    {
 01249                        Vector2 tLastPos = Vector2.zero;
 01250                        if (list.Count != 0)
 1251                        {
 01252                            tLastPos = list[list.Count - 1].value;
 1253                        }
 01254                        list.Add(new TransitioningVector2(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 
 1255                    }
 1256                }
 1257
 01258                GUILayout.EndHorizontal();
 1259            }
 1260
 01261            EditorGUILayout.EndVertical();
 01262            GUILayout.EndHorizontal();
 1263
 01264            Rect lastRect = GUILayoutUtility.GetLastRect();
 01265            lastRect.y -= 5;
 01266            lastRect.height += 10;
 01267            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01268        }
 1269
 1270        void RenderTransitioningFloat(List<TransitioningFloat> list, string label, string percentTxt, string valueText, 
 1271        {
 01272            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01273            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 01274            EditorGUILayout.BeginVertical();
 1275
 01276            if (list.Count == 0)
 1277            {
 01278                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01279                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1280                {
 01281                    float tLast = 0;
 01282                    if (list.Count != 0)
 1283                    {
 01284                        tLast = list[list.Count - 1].value;
 1285                    }
 01286                    list.Add(new TransitioningFloat(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100, t
 1287                }
 01288                GUILayout.EndHorizontal();
 1289            }
 1290
 01291            for (int i = 0; i < list.Count; i++)
 1292            {
 01293                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 1294
 01295                GUILayout.Space(10);
 01296                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1297                {
 01298                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1299                }
 01300                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1301
 01302                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1303
 01304                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1305
 01306                if (slider)
 1307                {
 01308                    list[i].value = EditorGUILayout.Slider(list[i].value, min, max, GUILayout.Width(200), GUILayout.Expa
 01309                }
 1310                else
 1311                {
 01312                    list[i].value = EditorGUILayout.FloatField("", list[i].value, GUILayout.Width(200), GUILayout.Expand
 1313                }
 1314
 1315
 01316                GUILayout.Space(20);
 01317                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1318                {
 01319                    list.RemoveAt(i);
 1320                }
 1321
 01322                if (i == (list.Count - 1))
 1323                {
 01324                    GUILayout.Space(20);
 01325                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1326                    {
 01327                        float tLast = 0;
 01328                        if (list.Count != 0)
 1329                        {
 01330                            tLast = list[list.Count - 1].value;
 1331                        }
 01332                        list.Add(new TransitioningFloat(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 10
 1333                    }
 1334                }
 1335
 01336                GUILayout.EndHorizontal();
 1337            }
 1338
 01339            EditorGUILayout.EndVertical();
 01340            GUILayout.EndHorizontal();
 1341
 01342            Rect lastRect = GUILayoutUtility.GetLastRect();
 01343            lastRect.y -= 5;
 01344            lastRect.height += 10;
 01345            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01346        }
 1347
 1348        void RenderColorGradientField(Gradient color, string label = "color", float startTime = -1, float endTime = -1, 
 1349        {
 01350            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01351            EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 1352
 01353            if (startTime != -1)
 1354            {
 01355                EditorGUILayout.LabelField(startTime + "Hr", GUILayout.Width(65), GUILayout.ExpandWidth(false));
 1356            }
 1357
 01358            color = EditorGUILayout.GradientField(new GUIContent(""), color, hdr, GUILayout.Width(250), GUILayout.Expand
 1359
 01360            if (endTime != 1)
 1361            {
 01362                EditorGUILayout.LabelField(endTime + "Hr", GUILayout.Width(65), GUILayout.ExpandWidth(false));
 1363            }
 01364            GUILayout.EndHorizontal();
 01365            EditorGUILayout.Separator();
 01366        }
 1367
 1368        void RenderTransitioningQuaternionAsVector3(List<TransitioningQuaternion> list, string label, string percentTxt,
 1369        {
 01370            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01371            GUILayout.Label(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 1372
 01373            GUILayout.BeginVertical();
 1374
 01375            if (list.Count == 0)
 1376            {
 01377                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 01378                if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1379                {
 01380                    list.Add(new TransitioningQuaternion(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 1
 1381                }
 01382                GUILayout.EndHorizontal();
 1383            }
 1384
 01385            for (int i = 0; i < list.Count; i++)
 1386            {
 01387                GUILayout.BeginHorizontal();
 01388                if (GUILayout.Button(">", GUILayout.ExpandWidth(false)))
 1389                {
 01390                    timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1
 1391                }
 1392
 01393                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 1394
 01395                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 1396
 01397                GUILayout.Space(10);
 1398
 01399                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 1400
 1401                // Convert Quaternion to Vector3
 01402                list[i].value = Quaternion.Euler(EditorGUILayout.Vector3Field("", list[i].value.eulerAngles, GUILayout.E
 1403
 01404                if (GUILayout.Button("Capture", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1405                {
 01406                    selectedConfiguration.directionalLightLayer.lightDirection[i].percentage = GetNormalizedLayerCurrent
 01407                    selectedConfiguration.directionalLightLayer.lightDirection[i].value = GetCurrentRotation();
 01408                    break;
 1409                }
 1410
 01411                if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false)))
 1412                {
 01413                    list.RemoveAt(i);
 01414                    break;
 1415                }
 1416
 01417                if (i == (list.Count - 1))
 1418                {
 01419                    GUILayout.Space(20);
 01420                    if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 1421                    {
 01422                        list.Add(new TransitioningQuaternion(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime)
 1423                    }
 1424                }
 1425
 01426                GUILayout.EndHorizontal();
 1427            }
 01428            GUILayout.EndVertical();
 01429            GUILayout.EndHorizontal();
 1430
 01431            Rect lastRect = GUILayoutUtility.GetLastRect();
 01432            lastRect.y -= 5;
 01433            lastRect.height += 10;
 01434            GUI.Box(lastRect, "", EditorStyles.helpBox);
 01435        }
 1436
 1437        void RenderPercentagePart(float layerStartTime, float layerEndTime, ref float percentage)
 1438        {
 01439            GUILayout.Label(layerStartTime + "Hr", GUILayout.Width(35), GUILayout.ExpandWidth(false));
 1440
 01441            GUILayout.BeginVertical(percentagePartStyle, GUILayout.ExpandWidth(false), GUILayout.Width(150));
 01442            float time = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, percentage / 100);
 01443            GUILayout.Label(time.ToString("f2") + " Hr", GUILayout.ExpandWidth(false));
 01444            percentage = EditorGUILayout.Slider(percentage, 0, 100, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 01445            GUILayout.EndVertical();
 1446
 01447            GUILayout.Label(layerEndTime + "Hr", GUILayout.Width(35), GUILayout.ExpandWidth(false));
 01448        }
 1449
 1450        #endregion
 1451
 1452        private void ApplyOnMaterial()
 1453        {
 01454            EnsureDependencies();
 01455            selectedConfiguration.ApplyOnMaterial(selectedMat, timeOfTheDay, GetNormalizedDayTime(), matLayer.numberOfSl
 1456
 1457            // If in play mode, call avatar color from skybox controller class
 01458            if (Application.isPlaying && SkyboxController.i != null)
 1459            {
 01460                SkyboxController.i.ApplyAvatarColor(GetNormalizedDayTime());
 1461            }
 01462        }
 1463
 1464        private float GetNormalizedDayTime()
 1465        {
 1466            float tTime = 0;
 01467            tTime = timeOfTheDay / 24;
 01468            tTime = Mathf.Clamp(tTime, 0, 1);
 01469            return tTime;
 1470        }
 1471
 1472        private float GetNormalizedLayerCurrentTime(float startTime, float endTime)
 1473        {
 01474            float editedEndTime = endTime;
 01475            float editedDayTime = timeOfTheDay;
 01476            if (endTime < startTime)
 1477            {
 01478                editedEndTime = 24 + endTime;
 01479                if (timeOfTheDay < startTime)
 1480                {
 01481                    editedDayTime = 24 + timeOfTheDay;
 1482                }
 1483            }
 01484            return Mathf.InverseLerp(startTime, editedEndTime, editedDayTime);
 1485        }
 1486
 1487        private float GetDayTimeForLayerNormalizedTime(float startTime, float endTime, float normalizeTime)
 1488        {
 01489            float editedEndTime = endTime;
 01490            if (endTime < startTime)
 1491            {
 01492                editedEndTime = 24 + endTime;
 1493            }
 01494            float time = Mathf.Lerp(startTime, editedEndTime, normalizeTime);
 1495
 01496            if (time > 24)
 1497            {
 01498                time -= 24;
 1499            }
 1500
 01501            return time;
 1502        }
 1503
 01504        private void ClampToDayTime(ref float value) { value = Mathf.Clamp(value, 0, 24); }
 1505    }
 1506
 1507}

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&)