< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RenderTransitioningVector3(...)0%90900%
RenderTransitioningVector2(...)0%90900%
RenderTransitioningFloat(...)0%1101000%
RenderTransitioningQuaternionAsVector3(...)0%56700%
RenderPercentagePart(...)0%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEditor;
 5using UnityEngine;
 6
 7namespace DCL.Skybox
 8{
 9    public static class RenderTransitioningVariables
 10    {
 11        public static void RenderTransitioningVector3(ref float timeOfTheDay, List<TransitioningVector3> list, string la
 12        {
 013            EditorGUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(fal
 014            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 015            EditorGUILayout.BeginVertical();
 16
 017            if (list.Count == 0)
 18            {
 019                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 20                {
 021                    Vector3 tLastPos = Vector3.zero;
 022                    if (list.Count != 0)
 23                    {
 024                        tLastPos = list[list.Count - 1].value;
 25                    }
 026                    list.Add(new TransitioningVector3(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, laye
 27                }
 28            }
 29
 030            for (int i = 0; i < list.Count; i++)
 31            {
 032                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 33
 034                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false)))
 35                {
 036                    timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list
 37                }
 38
 39                // Percentage
 040                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 41
 042                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 43
 044                GUILayout.Space(10);
 45
 046                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 47
 048                GUILayout.Space(10);
 049                list[i].value = EditorGUILayout.Vector3Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi
 50
 051                GUILayout.Space(10);
 052                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW
 53                {
 054                    list.RemoveAt(i);
 55                }
 56
 057                GUILayout.Space(10);
 058                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 59                {
 060                    Vector3 tLastPos = Vector3.zero;
 061                    if (list.Count != 0)
 62                    {
 063                        tLastPos = list[i].value;
 64                    }
 065                    list.Insert(i + 1, new TransitioningVector3(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTh
 66                }
 67
 068                EditorGUILayout.EndHorizontal();
 69            }
 70
 071            EditorGUILayout.EndVertical();
 072            EditorGUILayout.EndHorizontal();
 073        }
 74
 75        public static void RenderTransitioningVector2(ref float timeOfTheDay, List<TransitioningVector2> list, string la
 76        {
 077            EditorGUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(fal
 078            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 079            EditorGUILayout.BeginVertical();
 80
 081            if (list.Count == 0)
 82            {
 083                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 84                {
 085                    Vector2 tLastPos = Vector2.zero;
 086                    if (list.Count != 0)
 87                    {
 088                        tLastPos = list[list.Count - 1].value;
 89                    }
 090                    list.Add(new TransitioningVector2(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, laye
 91                }
 92            }
 93
 094            for (int i = 0; i < list.Count; i++)
 95            {
 096                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 97
 098                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false)))
 99                {
 0100                    timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list
 101                }
 102
 103                // Percentage
 0104                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 105
 0106                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 107
 0108                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 109
 0110                list[i].value = EditorGUILayout.Vector2Field("", list[i].value, GUILayout.Width(120), GUILayout.ExpandWi
 111
 0112                GUILayout.Space(10);
 0113                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW
 114                {
 0115                    list.RemoveAt(i);
 116                }
 117
 0118                GUILayout.Space(10);
 0119                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 120                {
 0121                    Vector2 tLastPos = Vector2.zero;
 0122                    if (list.Count != 0)
 123                    {
 0124                        tLastPos = list[i].value;
 125                    }
 0126                    list.Insert(i + 1, new TransitioningVector2(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTh
 127                }
 0128                EditorGUILayout.EndHorizontal();
 129            }
 0130            EditorGUILayout.EndVertical();
 0131            EditorGUILayout.EndHorizontal();
 0132        }
 133
 134        public static void RenderTransitioningFloat(EditorToolMeasurements toolSize, ref float timeOfTheDay, List<Transi
 135        {
 0136            SkyboxEditorStyles.Instance.transitioningBoxStyle.normal.background = toolSize.transitioningVariableBG.backg
 137
 0138            GUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(false));
 0139            EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 0140            EditorGUILayout.BeginVertical();
 141
 0142            if (list.Count == 0)
 143            {
 0144                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0145                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 146                {
 0147                    float tLast = 0;
 0148                    if (list.Count != 0)
 149                    {
 0150                        tLast = list[list.Count - 1].value;
 151                    }
 0152                    list.Add(new TransitioningFloat(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, layerS
 153                }
 0154                GUILayout.EndHorizontal();
 155            }
 156
 0157            for (int i = 0; i < list.Count; i++)
 158            {
 0159                GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 160
 0161                GUILayout.Space(10);
 0162                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false)))
 163                {
 0164                    timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list
 165                }
 0166                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 167
 0168                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 169
 0170                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 171
 0172                if (slider)
 173                {
 0174                    list[i].value = EditorGUILayout.Slider(list[i].value, min, max, GUILayout.Width(120), GUILayout.Expa
 175                }
 176                else
 177                {
 0178                    list[i].value = EditorGUILayout.FloatField("", list[i].value, GUILayout.Width(70), GUILayout.ExpandW
 179                }
 180
 181
 0182                GUILayout.Space(10);
 0183                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW
 184                {
 0185                    list.RemoveAt(i);
 186                }
 187
 0188                GUILayout.Space(10);
 0189                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 190                {
 0191                    float tLast = 0;
 0192                    if (list.Count != 0)
 193                    {
 0194                        tLast = list[i].value;
 195                    }
 0196                    list.Insert(i + 1, new TransitioningFloat(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheD
 197                }
 198
 0199                GUILayout.EndHorizontal();
 200            }
 201
 0202            EditorGUILayout.EndVertical();
 0203            GUILayout.EndHorizontal();
 0204        }
 205
 206        public static void RenderTransitioningQuaternionAsVector3(ref float timeOfTheDay, List<TransitioningQuaternion> 
 207        {
 0208            EditorGUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(fal
 209
 0210            GUILayout.Label(label, GUILayout.Width(120), GUILayout.ExpandWidth(false));
 211
 0212            EditorGUILayout.BeginVertical();
 213
 0214            if (list.Count == 0)
 215            {
 0216                EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false));
 0217                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 218                {
 0219                    list.Add(new TransitioningQuaternion(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, l
 220                }
 0221                EditorGUILayout.EndHorizontal();
 222            }
 223
 0224            for (int i = 0; i < list.Count; i++)
 225            {
 0226                EditorGUILayout.BeginHorizontal();
 0227                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false)))
 228                {
 0229                    timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list
 230                }
 231
 0232                GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false));
 233
 0234                RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage);
 235
 0236                GUILayout.Space(10);
 237
 0238                GUILayout.Label(valueText, GUILayout.ExpandWidth(false));
 239
 240                // Convert Quaternion to Vector3
 0241                list[i].value = Quaternion.Euler(EditorGUILayout.Vector3Field("", list[i].value.eulerAngles, GUILayout.E
 242
 0243                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW
 244                {
 0245                    list.RemoveAt(i);
 0246                    break;
 247                }
 248
 0249                if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt
 250                {
 0251                    list.Insert(i + 1, new TransitioningQuaternion(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeO
 252                }
 253
 0254                EditorGUILayout.EndHorizontal();
 255            }
 0256            EditorGUILayout.EndVertical();
 0257            EditorGUILayout.EndHorizontal();
 0258        }
 259
 260        public static void RenderPercentagePart(float layerStartTime, float layerEndTime, ref float percentage)
 261        {
 0262            GUILayout.Label(layerStartTime + SkyboxEditorLiterals.short_Hour, GUILayout.Width(35), GUILayout.ExpandWidth
 263
 0264            GUILayout.BeginVertical(SkyboxEditorStyles.Instance.percentagePartStyle, GUILayout.ExpandWidth(false), GUILa
 0265            float time = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, percentage / 1
 0266            GUILayout.Label(time.ToString("f2") + SkyboxEditorLiterals.short_Hour, GUILayout.ExpandWidth(false));
 0267            percentage = EditorGUILayout.Slider(percentage, 0, 100, GUILayout.Width(150), GUILayout.ExpandWidth(false));
 0268            GUILayout.EndVertical();
 269
 0270            GUILayout.Label(layerEndTime + SkyboxEditorLiterals.short_Hour, GUILayout.Width(35), GUILayout.ExpandWidth(f
 0271        }
 272    }
 273}