< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Render(...)0%3801900%
ShowBaseLayersContextMenu(...)0%6200%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using UnityEditor;
 5using UnityEngine;
 6
 7namespace DCL.Skybox
 8{
 9    public class RenderLeftPanelBaseSkyboxLayers
 10    {
 11        public static void Render(ref float timeOfTheDay, EditorToolMeasurements toolSize, SkyboxConfiguration config, A
 12        {
 13            // Loop through texture layer and print the name of all layers
 014            for (int i = 0; i < config.layers.Count; i++)
 15            {
 16
 017                EditorGUILayout.BeginHorizontal(toolSize.leftPanelHorizontal);
 18
 019                config.layers[i].enabled = EditorGUILayout.Toggle(config.layers[i].enabled, GUILayout.Width(toolSize.lay
 20
 021                if (GUILayout.Button(config.layers[i].nameInEditor, GUILayout.Width(toolSize.layerButtonWidth)))
 22                {
 023                    AddToRightPanel(new RightPanelPins { part = SkyboxEditorToolsParts.Base_Skybox, name = config.layers
 24                }
 25
 026                config.layers[i].slotID = EditorGUILayout.Popup(config.layers[i].slotID, renderingOrderList.ToArray(), G
 27
 028                if (i == 0)
 29                {
 030                    GUI.enabled = false;
 31                }
 032                if (GUILayout.Button(SkyboxEditorLiterals.Characters.upArrow.ToString()))
 33                {
 034                    TextureLayer temp = null;
 35
 036                    if (i >= 1)
 37                    {
 038                        temp = config.layers[i - 1];
 039                        config.layers[i - 1] = config.layers[i];
 040                        config.layers[i] = temp;
 41                    }
 42                }
 43
 044                GUI.enabled = true;
 45
 046                if (i == config.layers.Count - 1)
 47                {
 048                    GUI.enabled = false;
 49                }
 50
 051                if (GUILayout.Button(SkyboxEditorLiterals.Characters.downArrow.ToString()))
 52                {
 053                    TextureLayer temp = null;
 054                    if (i < (config.layers.Count - 1))
 55                    {
 056                        temp = config.layers[i + 1];
 057                        config.layers[i + 1] = config.layers[i];
 058                        config.layers[i] = temp;
 59                    }
 060                    break;
 61                }
 62
 063                GUI.enabled = true;
 64
 065                Color circleColor = Color.green;
 066                switch (config.layers[i].renderType)
 67                {
 68                    case LayerRenderType.Rendering:
 069                        circleColor = Color.green;
 070                        break;
 71                    case LayerRenderType.NotRendering:
 072                        circleColor = Color.gray;
 073                        break;
 74                    case LayerRenderType.Conflict_Playing:
 075                        circleColor = Color.yellow;
 076                        break;
 77                    case LayerRenderType.Conflict_NotPlaying:
 078                        circleColor = Color.red;
 79                        break;
 80                    default:
 81                        break;
 82                }
 83
 084                Color normalContentColor = GUI.color;
 085                GUI.color = circleColor;
 86
 087                EditorGUILayout.LabelField(SkyboxEditorLiterals.Characters.renderMarker.ToString(), SkyboxEditorStyles.I
 88
 089                GUI.color = normalContentColor;
 90
 91                // Dome context menu
 092                if (GUILayout.Button(":", GUILayout.Width(20), GUILayout.ExpandWidth(false)))
 93                {
 094                    ArrayList list = new ArrayList();
 095                    list.Add(config.layers);
 096                    list.Add(i);
 97
 98                    // Anonymous method for delete operation
 099                    GenericMenu.MenuFunction2 deleteBtnClicked = (object obj) =>
 100                    {
 0101                        ArrayList list = obj as ArrayList;
 0102                        List<TextureLayer> layerList = list[0] as List<TextureLayer>;
 0103                        int index = (int)list[1];
 0104                        layerList.RemoveAt(index);
 0105                    };
 106
 107                    // Anonymous method for Add operation
 0108                    GenericMenu.MenuFunction2 addBtnClicked = (object obj) =>
 109                    {
 0110                        ArrayList list = obj as ArrayList;
 0111                        List<TextureLayer> layerList = list[0] as List<TextureLayer>;
 0112                        int index = (int)list[1];
 0113                        layerList.Insert(index + 1, new TextureLayer("New Layer"));
 0114                    };
 115
 116                    // Anonymous method for copy layer
 0117                    GenericMenu.MenuFunction2 copyBtnClicked = (object obj) =>
 118                    {
 0119                        ArrayList list = obj as ArrayList;
 0120                        List<TextureLayer> layerList = list[0] as List<TextureLayer>;
 0121                        int index = (int)list[1];
 0122                        copyPasteObj.SetTextureLayer(layerList[index]);
 0123                    };
 124
 125                    // Anonymous method for Paste layer
 0126                    GenericMenu.MenuFunction2 pasteBtnClicked = (object obj) =>
 127                    {
 0128                        ArrayList list = obj as ArrayList;
 0129                        List<TextureLayer> layerList = list[0] as List<TextureLayer>;
 0130                        int index = (int)list[1];
 0131                        layerList[index] = copyPasteObj.GetCopiedTextureLayer().DeepCopy();
 0132                    };
 0133                    ShowBaseLayersContextMenu(copyPasteObj, deleteBtnClicked, addBtnClicked, copyBtnClicked, pasteBtnCli
 134                }
 0135                EditorGUILayout.EndHorizontal();
 136
 0137                EditorGUILayout.Space(toolSize.leftPanelButtonSpace);
 138            }
 0139            Rect r = EditorGUILayout.BeginHorizontal();
 0140            if (GUI.Button(new Rect(r.width - 35, r.y, 25, 25), SkyboxEditorLiterals.Characters.sign_add))
 141            {
 0142                config.layers.Add(new TextureLayer("New Layer"));
 143            }
 144
 0145            EditorGUILayout.Space(25);
 0146            EditorGUILayout.EndHorizontal();
 147
 0148        }
 149
 150        private static void ShowBaseLayersContextMenu(CopyFunctionality copyPasteObj, GenericMenu.MenuFunction2 OnDelete
 151        {
 152            // Create menu
 0153            GenericMenu menu = new GenericMenu();
 154
 155            // Add option
 0156            menu.AddItem(new GUIContent("Add"), false, OnAddBtnClicked, list);
 157
 158            // Copy option
 0159            menu.AddItem(new GUIContent("Copy"), false, OnCopyBtnClicked, list);
 160
 161            // Paste option
 0162            if (copyPasteObj.IsTextureLayerAvailable())
 163            {
 0164                menu.AddItem(new GUIContent("Paste"), false, OnPasteBtnClicked, list);
 165            }
 166            else
 167            {
 0168                menu.AddDisabledItem(new GUIContent("Paste"));
 169            }
 170
 0171            menu.AddSeparator("");
 172            // Delete option
 0173            menu.AddItem(new GUIContent("Delete"), false, OnDeleteBtnClicked, list);
 174
 0175            menu.ShowAsContext();
 0176        }
 177    }
 178}