| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using UnityEditor; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | namespace 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 |
| 0 | 14 | | for (int i = 0; i < config.layers.Count; i++) |
| | 15 | | { |
| | 16 | |
|
| 0 | 17 | | EditorGUILayout.BeginHorizontal(toolSize.leftPanelHorizontal); |
| | 18 | |
|
| 0 | 19 | | config.layers[i].enabled = EditorGUILayout.Toggle(config.layers[i].enabled, GUILayout.Width(toolSize.lay |
| | 20 | |
|
| 0 | 21 | | if (GUILayout.Button(config.layers[i].nameInEditor, GUILayout.Width(toolSize.layerButtonWidth))) |
| | 22 | | { |
| 0 | 23 | | AddToRightPanel(new RightPanelPins { part = SkyboxEditorToolsParts.Base_Skybox, name = config.layers |
| | 24 | | } |
| | 25 | |
|
| 0 | 26 | | config.layers[i].slotID = EditorGUILayout.Popup(config.layers[i].slotID, renderingOrderList.ToArray(), G |
| | 27 | |
|
| 0 | 28 | | if (i == 0) |
| | 29 | | { |
| 0 | 30 | | GUI.enabled = false; |
| | 31 | | } |
| 0 | 32 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.upArrow.ToString())) |
| | 33 | | { |
| 0 | 34 | | TextureLayer temp = null; |
| | 35 | |
|
| 0 | 36 | | if (i >= 1) |
| | 37 | | { |
| 0 | 38 | | temp = config.layers[i - 1]; |
| 0 | 39 | | config.layers[i - 1] = config.layers[i]; |
| 0 | 40 | | config.layers[i] = temp; |
| | 41 | | } |
| | 42 | | } |
| | 43 | |
|
| 0 | 44 | | GUI.enabled = true; |
| | 45 | |
|
| 0 | 46 | | if (i == config.layers.Count - 1) |
| | 47 | | { |
| 0 | 48 | | GUI.enabled = false; |
| | 49 | | } |
| | 50 | |
|
| 0 | 51 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.downArrow.ToString())) |
| | 52 | | { |
| 0 | 53 | | TextureLayer temp = null; |
| 0 | 54 | | if (i < (config.layers.Count - 1)) |
| | 55 | | { |
| 0 | 56 | | temp = config.layers[i + 1]; |
| 0 | 57 | | config.layers[i + 1] = config.layers[i]; |
| 0 | 58 | | config.layers[i] = temp; |
| | 59 | | } |
| 0 | 60 | | break; |
| | 61 | | } |
| | 62 | |
|
| 0 | 63 | | GUI.enabled = true; |
| | 64 | |
|
| 0 | 65 | | Color circleColor = Color.green; |
| 0 | 66 | | switch (config.layers[i].renderType) |
| | 67 | | { |
| | 68 | | case LayerRenderType.Rendering: |
| 0 | 69 | | circleColor = Color.green; |
| 0 | 70 | | break; |
| | 71 | | case LayerRenderType.NotRendering: |
| 0 | 72 | | circleColor = Color.gray; |
| 0 | 73 | | break; |
| | 74 | | case LayerRenderType.Conflict_Playing: |
| 0 | 75 | | circleColor = Color.yellow; |
| 0 | 76 | | break; |
| | 77 | | case LayerRenderType.Conflict_NotPlaying: |
| 0 | 78 | | circleColor = Color.red; |
| | 79 | | break; |
| | 80 | | default: |
| | 81 | | break; |
| | 82 | | } |
| | 83 | |
|
| 0 | 84 | | Color normalContentColor = GUI.color; |
| 0 | 85 | | GUI.color = circleColor; |
| | 86 | |
|
| 0 | 87 | | EditorGUILayout.LabelField(SkyboxEditorLiterals.Characters.renderMarker.ToString(), SkyboxEditorStyles.I |
| | 88 | |
|
| 0 | 89 | | GUI.color = normalContentColor; |
| | 90 | |
|
| | 91 | | // Dome context menu |
| 0 | 92 | | if (GUILayout.Button(":", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 93 | | { |
| 0 | 94 | | ArrayList list = new ArrayList(); |
| 0 | 95 | | list.Add(config.layers); |
| 0 | 96 | | list.Add(i); |
| | 97 | |
|
| | 98 | | // Anonymous method for delete operation |
| 0 | 99 | | GenericMenu.MenuFunction2 deleteBtnClicked = (object obj) => |
| | 100 | | { |
| 0 | 101 | | ArrayList list = obj as ArrayList; |
| 0 | 102 | | List<TextureLayer> layerList = list[0] as List<TextureLayer>; |
| 0 | 103 | | int index = (int)list[1]; |
| 0 | 104 | | layerList.RemoveAt(index); |
| 0 | 105 | | }; |
| | 106 | |
|
| | 107 | | // Anonymous method for Add operation |
| 0 | 108 | | GenericMenu.MenuFunction2 addBtnClicked = (object obj) => |
| | 109 | | { |
| 0 | 110 | | ArrayList list = obj as ArrayList; |
| 0 | 111 | | List<TextureLayer> layerList = list[0] as List<TextureLayer>; |
| 0 | 112 | | int index = (int)list[1]; |
| 0 | 113 | | layerList.Insert(index + 1, new TextureLayer("New Layer")); |
| 0 | 114 | | }; |
| | 115 | |
|
| | 116 | | // Anonymous method for copy layer |
| 0 | 117 | | GenericMenu.MenuFunction2 copyBtnClicked = (object obj) => |
| | 118 | | { |
| 0 | 119 | | ArrayList list = obj as ArrayList; |
| 0 | 120 | | List<TextureLayer> layerList = list[0] as List<TextureLayer>; |
| 0 | 121 | | int index = (int)list[1]; |
| 0 | 122 | | copyPasteObj.SetTextureLayer(layerList[index]); |
| 0 | 123 | | }; |
| | 124 | |
|
| | 125 | | // Anonymous method for Paste layer |
| 0 | 126 | | GenericMenu.MenuFunction2 pasteBtnClicked = (object obj) => |
| | 127 | | { |
| 0 | 128 | | ArrayList list = obj as ArrayList; |
| 0 | 129 | | List<TextureLayer> layerList = list[0] as List<TextureLayer>; |
| 0 | 130 | | int index = (int)list[1]; |
| 0 | 131 | | layerList[index] = copyPasteObj.GetCopiedTextureLayer().DeepCopy(); |
| 0 | 132 | | }; |
| 0 | 133 | | ShowBaseLayersContextMenu(copyPasteObj, deleteBtnClicked, addBtnClicked, copyBtnClicked, pasteBtnCli |
| | 134 | | } |
| 0 | 135 | | EditorGUILayout.EndHorizontal(); |
| | 136 | |
|
| 0 | 137 | | EditorGUILayout.Space(toolSize.leftPanelButtonSpace); |
| | 138 | | } |
| 0 | 139 | | Rect r = EditorGUILayout.BeginHorizontal(); |
| 0 | 140 | | if (GUI.Button(new Rect(r.width - 35, r.y, 25, 25), SkyboxEditorLiterals.Characters.sign_add)) |
| | 141 | | { |
| 0 | 142 | | config.layers.Add(new TextureLayer("New Layer")); |
| | 143 | | } |
| | 144 | |
|
| 0 | 145 | | EditorGUILayout.Space(25); |
| 0 | 146 | | EditorGUILayout.EndHorizontal(); |
| | 147 | |
|
| 0 | 148 | | } |
| | 149 | |
|
| | 150 | | private static void ShowBaseLayersContextMenu(CopyFunctionality copyPasteObj, GenericMenu.MenuFunction2 OnDelete |
| | 151 | | { |
| | 152 | | // Create menu |
| 0 | 153 | | GenericMenu menu = new GenericMenu(); |
| | 154 | |
|
| | 155 | | // Add option |
| 0 | 156 | | menu.AddItem(new GUIContent("Add"), false, OnAddBtnClicked, list); |
| | 157 | |
|
| | 158 | | // Copy option |
| 0 | 159 | | menu.AddItem(new GUIContent("Copy"), false, OnCopyBtnClicked, list); |
| | 160 | |
|
| | 161 | | // Paste option |
| 0 | 162 | | if (copyPasteObj.IsTextureLayerAvailable()) |
| | 163 | | { |
| 0 | 164 | | menu.AddItem(new GUIContent("Paste"), false, OnPasteBtnClicked, list); |
| 0 | 165 | | } |
| | 166 | | else |
| | 167 | | { |
| 0 | 168 | | menu.AddDisabledItem(new GUIContent("Paste")); |
| | 169 | | } |
| | 170 | |
|
| 0 | 171 | | menu.AddSeparator(""); |
| | 172 | | // Delete option |
| 0 | 173 | | menu.AddItem(new GUIContent("Delete"), false, OnDeleteBtnClicked, list); |
| | 174 | |
|
| 0 | 175 | | menu.ShowAsContext(); |
| 0 | 176 | | } |
| | 177 | | } |
| | 178 | | } |