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