| | 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 static class RenderTransitioningVariables |
| | 10 | | { |
| | 11 | | public static void RenderTransitioningVector3(ref float timeOfTheDay, List<TransitioningVector3> list, string la |
| | 12 | | { |
| 0 | 13 | | EditorGUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(fal |
| 0 | 14 | | EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| 0 | 15 | | EditorGUILayout.BeginVertical(); |
| | 16 | |
|
| 0 | 17 | | if (list.Count == 0) |
| | 18 | | { |
| 0 | 19 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 20 | | { |
| 0 | 21 | | Vector3 tLastPos = Vector3.zero; |
| 0 | 22 | | if (list.Count != 0) |
| | 23 | | { |
| 0 | 24 | | tLastPos = list[list.Count - 1].value; |
| | 25 | | } |
| 0 | 26 | | list.Add(new TransitioningVector3(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, laye |
| | 27 | | } |
| | 28 | | } |
| | 29 | |
|
| 0 | 30 | | for (int i = 0; i < list.Count; i++) |
| | 31 | | { |
| 0 | 32 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| | 33 | |
|
| 0 | 34 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false))) |
| | 35 | | { |
| 0 | 36 | | timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list |
| | 37 | | } |
| | 38 | |
|
| | 39 | | // Percentage |
| 0 | 40 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 41 | |
|
| 0 | 42 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 43 | |
|
| 0 | 44 | | GUILayout.Space(10); |
| | 45 | |
|
| 0 | 46 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 47 | |
|
| 0 | 48 | | GUILayout.Space(10); |
| 0 | 49 | | list[i].value = EditorGUILayout.Vector3Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi |
| | 50 | |
|
| 0 | 51 | | GUILayout.Space(10); |
| 0 | 52 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW |
| | 53 | | { |
| 0 | 54 | | list.RemoveAt(i); |
| | 55 | | } |
| | 56 | |
|
| 0 | 57 | | GUILayout.Space(10); |
| 0 | 58 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 59 | | { |
| 0 | 60 | | Vector3 tLastPos = Vector3.zero; |
| 0 | 61 | | if (list.Count != 0) |
| | 62 | | { |
| 0 | 63 | | tLastPos = list[i].value; |
| | 64 | | } |
| 0 | 65 | | list.Insert(i + 1, new TransitioningVector3(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTh |
| | 66 | | } |
| | 67 | |
|
| 0 | 68 | | EditorGUILayout.EndHorizontal(); |
| | 69 | | } |
| | 70 | |
|
| 0 | 71 | | EditorGUILayout.EndVertical(); |
| 0 | 72 | | EditorGUILayout.EndHorizontal(); |
| 0 | 73 | | } |
| | 74 | |
|
| | 75 | | public static void RenderTransitioningVector2(ref float timeOfTheDay, List<TransitioningVector2> list, string la |
| | 76 | | { |
| 0 | 77 | | EditorGUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(fal |
| 0 | 78 | | EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| 0 | 79 | | EditorGUILayout.BeginVertical(); |
| | 80 | |
|
| 0 | 81 | | if (list.Count == 0) |
| | 82 | | { |
| 0 | 83 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 84 | | { |
| 0 | 85 | | Vector2 tLastPos = Vector2.zero; |
| 0 | 86 | | if (list.Count != 0) |
| | 87 | | { |
| 0 | 88 | | tLastPos = list[list.Count - 1].value; |
| | 89 | | } |
| 0 | 90 | | list.Add(new TransitioningVector2(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, laye |
| | 91 | | } |
| | 92 | | } |
| | 93 | |
|
| 0 | 94 | | for (int i = 0; i < list.Count; i++) |
| | 95 | | { |
| 0 | 96 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| | 97 | |
|
| 0 | 98 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false))) |
| | 99 | | { |
| 0 | 100 | | timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list |
| | 101 | | } |
| | 102 | |
|
| | 103 | | // Percentage |
| 0 | 104 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 105 | |
|
| 0 | 106 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 107 | |
|
| 0 | 108 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 109 | |
|
| 0 | 110 | | list[i].value = EditorGUILayout.Vector2Field("", list[i].value, GUILayout.Width(120), GUILayout.ExpandWi |
| | 111 | |
|
| 0 | 112 | | GUILayout.Space(10); |
| 0 | 113 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW |
| | 114 | | { |
| 0 | 115 | | list.RemoveAt(i); |
| | 116 | | } |
| | 117 | |
|
| 0 | 118 | | GUILayout.Space(10); |
| 0 | 119 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 120 | | { |
| 0 | 121 | | Vector2 tLastPos = Vector2.zero; |
| 0 | 122 | | if (list.Count != 0) |
| | 123 | | { |
| 0 | 124 | | tLastPos = list[i].value; |
| | 125 | | } |
| 0 | 126 | | list.Insert(i + 1, new TransitioningVector2(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTh |
| | 127 | | } |
| 0 | 128 | | EditorGUILayout.EndHorizontal(); |
| | 129 | | } |
| 0 | 130 | | EditorGUILayout.EndVertical(); |
| 0 | 131 | | EditorGUILayout.EndHorizontal(); |
| 0 | 132 | | } |
| | 133 | |
|
| | 134 | | public static void RenderTransitioningFloat(EditorToolMeasurements toolSize, ref float timeOfTheDay, List<Transi |
| | 135 | | { |
| 0 | 136 | | SkyboxEditorStyles.Instance.transitioningBoxStyle.normal.background = toolSize.transitioningVariableBG.backg |
| | 137 | |
|
| 0 | 138 | | GUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(false)); |
| 0 | 139 | | EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| 0 | 140 | | EditorGUILayout.BeginVertical(); |
| | 141 | |
|
| 0 | 142 | | if (list.Count == 0) |
| | 143 | | { |
| 0 | 144 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 145 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 146 | | { |
| 0 | 147 | | float tLast = 0; |
| 0 | 148 | | if (list.Count != 0) |
| | 149 | | { |
| 0 | 150 | | tLast = list[list.Count - 1].value; |
| | 151 | | } |
| 0 | 152 | | list.Add(new TransitioningFloat(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, layerS |
| | 153 | | } |
| 0 | 154 | | GUILayout.EndHorizontal(); |
| | 155 | | } |
| | 156 | |
|
| 0 | 157 | | for (int i = 0; i < list.Count; i++) |
| | 158 | | { |
| 0 | 159 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| | 160 | |
|
| 0 | 161 | | GUILayout.Space(10); |
| 0 | 162 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false))) |
| | 163 | | { |
| 0 | 164 | | timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list |
| | 165 | | } |
| 0 | 166 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 167 | |
|
| 0 | 168 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 169 | |
|
| 0 | 170 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 171 | |
|
| 0 | 172 | | if (slider) |
| | 173 | | { |
| 0 | 174 | | list[i].value = EditorGUILayout.Slider(list[i].value, min, max, GUILayout.Width(120), GUILayout.Expa |
| 0 | 175 | | } |
| | 176 | | else |
| | 177 | | { |
| 0 | 178 | | list[i].value = EditorGUILayout.FloatField("", list[i].value, GUILayout.Width(70), GUILayout.ExpandW |
| | 179 | | } |
| | 180 | |
|
| | 181 | |
|
| 0 | 182 | | GUILayout.Space(10); |
| 0 | 183 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW |
| | 184 | | { |
| 0 | 185 | | list.RemoveAt(i); |
| | 186 | | } |
| | 187 | |
|
| 0 | 188 | | GUILayout.Space(10); |
| 0 | 189 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 190 | | { |
| 0 | 191 | | float tLast = 0; |
| 0 | 192 | | if (list.Count != 0) |
| | 193 | | { |
| 0 | 194 | | tLast = list[i].value; |
| | 195 | | } |
| 0 | 196 | | list.Insert(i + 1, new TransitioningFloat(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheD |
| | 197 | | } |
| | 198 | |
|
| 0 | 199 | | GUILayout.EndHorizontal(); |
| | 200 | | } |
| | 201 | |
|
| 0 | 202 | | EditorGUILayout.EndVertical(); |
| 0 | 203 | | GUILayout.EndHorizontal(); |
| 0 | 204 | | } |
| | 205 | |
|
| | 206 | | public static void RenderTransitioningQuaternionAsVector3(ref float timeOfTheDay, List<TransitioningQuaternion> |
| | 207 | | { |
| 0 | 208 | | EditorGUILayout.BeginHorizontal(SkyboxEditorStyles.Instance.transitioningBoxStyle, GUILayout.ExpandWidth(fal |
| | 209 | |
|
| 0 | 210 | | GUILayout.Label(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| | 211 | |
|
| 0 | 212 | | EditorGUILayout.BeginVertical(); |
| | 213 | |
|
| 0 | 214 | | if (list.Count == 0) |
| | 215 | | { |
| 0 | 216 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 217 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 218 | | { |
| 0 | 219 | | list.Add(new TransitioningQuaternion(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeOfTheDay, l |
| | 220 | | } |
| 0 | 221 | | EditorGUILayout.EndHorizontal(); |
| | 222 | | } |
| | 223 | |
|
| 0 | 224 | | for (int i = 0; i < list.Count; i++) |
| | 225 | | { |
| 0 | 226 | | EditorGUILayout.BeginHorizontal(); |
| 0 | 227 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_goto, GUILayout.ExpandWidth(false))) |
| | 228 | | { |
| 0 | 229 | | timeOfTheDay = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list |
| | 230 | | } |
| | 231 | |
|
| 0 | 232 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 233 | |
|
| 0 | 234 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 235 | |
|
| 0 | 236 | | GUILayout.Space(10); |
| | 237 | |
|
| 0 | 238 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 239 | |
|
| | 240 | | // Convert Quaternion to Vector3 |
| 0 | 241 | | list[i].value = Quaternion.Euler(EditorGUILayout.Vector3Field("", list[i].value.eulerAngles, GUILayout.E |
| | 242 | |
|
| 0 | 243 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_remove, GUILayout.Width(20), GUILayout.ExpandW |
| | 244 | | { |
| 0 | 245 | | list.RemoveAt(i); |
| 0 | 246 | | break; |
| | 247 | | } |
| | 248 | |
|
| 0 | 249 | | if (GUILayout.Button(SkyboxEditorLiterals.Characters.sign_add, GUILayout.Width(20), GUILayout.ExpandWidt |
| | 250 | | { |
| 0 | 251 | | list.Insert(i + 1, new TransitioningQuaternion(SkyboxEditorUtils.GetNormalizedLayerCurrentTime(timeO |
| | 252 | | } |
| | 253 | |
|
| 0 | 254 | | EditorGUILayout.EndHorizontal(); |
| | 255 | | } |
| 0 | 256 | | EditorGUILayout.EndVertical(); |
| 0 | 257 | | EditorGUILayout.EndHorizontal(); |
| 0 | 258 | | } |
| | 259 | |
|
| | 260 | | public static void RenderPercentagePart(float layerStartTime, float layerEndTime, ref float percentage) |
| | 261 | | { |
| 0 | 262 | | GUILayout.Label(layerStartTime + SkyboxEditorLiterals.short_Hour, GUILayout.Width(35), GUILayout.ExpandWidth |
| | 263 | |
|
| 0 | 264 | | GUILayout.BeginVertical(SkyboxEditorStyles.Instance.percentagePartStyle, GUILayout.ExpandWidth(false), GUILa |
| 0 | 265 | | float time = SkyboxEditorUtils.GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, percentage / 1 |
| 0 | 266 | | GUILayout.Label(time.ToString("f2") + SkyboxEditorLiterals.short_Hour, GUILayout.ExpandWidth(false)); |
| 0 | 267 | | percentage = EditorGUILayout.Slider(percentage, 0, 100, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 268 | | GUILayout.EndVertical(); |
| | 269 | |
|
| 0 | 270 | | GUILayout.Label(layerEndTime + SkyboxEditorLiterals.short_Hour, GUILayout.Width(35), GUILayout.ExpandWidth(f |
| 0 | 271 | | } |
| | 272 | | } |
| | 273 | | } |