| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.Linq; |
| | 5 | | using UnityEditor; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | namespace DCL.Skybox |
| | 9 | | { |
| | 10 | | public class SkyboxEditorWindow : EditorWindow |
| | 11 | | { |
| | 12 | | private List<SkyboxConfiguration> configurations; |
| | 13 | | private List<string> configurationNames; |
| | 14 | | private int selectedConfigurationIndex; |
| | 15 | | private int newConfigIndex; |
| | 16 | | private SkyboxConfiguration selectedConfiguration; |
| | 17 | |
|
| | 18 | | public bool isPaused; |
| | 19 | | public float timeOfTheDay; |
| 0 | 20 | | public float lifecycleDuration = 1; |
| | 21 | |
|
| | 22 | | private Material selectedMat; |
| | 23 | | private Vector2 panelScrollPos; |
| | 24 | | private Light directionalLight; |
| | 25 | | private bool creatingNewConfig; |
| | 26 | | private string newConfigName; |
| | 27 | | private bool overridingController; |
| | 28 | |
|
| | 29 | | private bool showBackgroundLayer; |
| | 30 | | private bool showAmbienLayer; |
| | 31 | | private bool showFogLayer; |
| | 32 | | private bool showDLLayer; |
| | 33 | | private bool showAvatarLayer; |
| | 34 | | private bool showTimelineTags; |
| | 35 | | private MaterialReferenceContainer.Mat_Layer matLayer = null; |
| | 36 | |
|
| | 37 | | private GUIStyle foldoutStyle; |
| | 38 | | private GUIStyle renderingMarkerStyle; |
| | 39 | | private GUIStyle configurationStyle; |
| | 40 | | private GUIStyle percentagePartStyle; |
| | 41 | |
|
| | 42 | | private List<string> renderingOrderList; |
| | 43 | |
|
| 0 | 44 | | public static SkyboxEditorWindow instance { get { return GetWindow<SkyboxEditorWindow>(); } } |
| | 45 | |
|
| | 46 | | #region Unity Callbacks |
| | 47 | |
|
| 0 | 48 | | private void OnEnable() { EnsureDependencies(); } |
| | 49 | |
|
| | 50 | | private void OnDestroy() |
| | 51 | | { |
| | 52 | | // If in play mode and editor is closed |
| | 53 | | // Transfer control back to skybox controller with the new values in the editor |
| 0 | 54 | | if (SkyboxController.i == null) |
| | 55 | | { |
| 0 | 56 | | return; |
| | 57 | | } |
| | 58 | |
|
| 0 | 59 | | if (Application.isPlaying && SkyboxController.i != null) |
| | 60 | | { |
| 0 | 61 | | overridingController = SkyboxController.i.GetControlBackFromEditor(selectedConfiguration.name, timeOfThe |
| | 62 | | } |
| 0 | 63 | | } |
| | 64 | |
|
| 0 | 65 | | void OnFocus() { EnsureDependencies(); } |
| | 66 | |
|
| | 67 | | void OnGUI() |
| | 68 | | { |
| 0 | 69 | | GUILayout.BeginArea(new Rect(10, 0, position.width - 20, position.height)); |
| | 70 | |
|
| 0 | 71 | | GUILayout.Space(32); |
| 0 | 72 | | RenderConfigurations(); |
| 0 | 73 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| | 74 | |
|
| 0 | 75 | | GUILayout.Space(32); |
| 0 | 76 | | RenderTimePanel(); |
| 0 | 77 | | GUILayout.Space(12); |
| | 78 | |
|
| 0 | 79 | | showTimelineTags = EditorGUILayout.Foldout(showTimelineTags, "Timeline Tags", true); |
| | 80 | |
|
| 0 | 81 | | if (showTimelineTags) |
| | 82 | | { |
| 0 | 83 | | EditorGUI.indentLevel++; |
| 0 | 84 | | RenderTimelineTags(); |
| 0 | 85 | | EditorGUI.indentLevel--; |
| | 86 | | } |
| | 87 | |
|
| 0 | 88 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| 0 | 89 | | GUILayout.Space(5); |
| | 90 | |
|
| 0 | 91 | | panelScrollPos = EditorGUILayout.BeginScrollView(panelScrollPos, "box"); |
| | 92 | |
|
| 0 | 93 | | GUILayout.Space(10); |
| | 94 | |
|
| 0 | 95 | | showBackgroundLayer = EditorGUILayout.Foldout(showBackgroundLayer, "BG Layer", true); |
| 0 | 96 | | if (showBackgroundLayer) |
| | 97 | | { |
| 0 | 98 | | EditorGUI.indentLevel++; |
| 0 | 99 | | RenderBackgroundColorLayer(); |
| 0 | 100 | | EditorGUI.indentLevel--; |
| | 101 | | } |
| 0 | 102 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| | 103 | |
|
| 0 | 104 | | GUILayout.Space(32); |
| 0 | 105 | | showAmbienLayer = EditorGUILayout.Foldout(showAmbienLayer, "Ambient Layer", true); |
| 0 | 106 | | if (showAmbienLayer) |
| | 107 | | { |
| 0 | 108 | | EditorGUI.indentLevel++; |
| 0 | 109 | | RenderAmbientLayer(); |
| 0 | 110 | | EditorGUI.indentLevel--; |
| | 111 | | } |
| 0 | 112 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| | 113 | |
|
| 0 | 114 | | GUILayout.Space(32); |
| 0 | 115 | | showAvatarLayer = EditorGUILayout.Foldout(showAvatarLayer, "Avatar Layer", true); |
| 0 | 116 | | if (showAvatarLayer) |
| | 117 | | { |
| 0 | 118 | | EditorGUI.indentLevel++; |
| 0 | 119 | | RenderAvatarColorLayer(); |
| 0 | 120 | | EditorGUI.indentLevel--; |
| | 121 | | } |
| 0 | 122 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| | 123 | |
|
| 0 | 124 | | GUILayout.Space(32); |
| 0 | 125 | | showFogLayer = EditorGUILayout.Foldout(showFogLayer, "Fog Layer", true); |
| 0 | 126 | | if (showFogLayer) |
| | 127 | | { |
| 0 | 128 | | EditorGUI.indentLevel++; |
| 0 | 129 | | RenderFogLayer(); |
| 0 | 130 | | EditorGUI.indentLevel--; |
| | 131 | | } |
| 0 | 132 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| | 133 | |
|
| 0 | 134 | | GUILayout.Space(32); |
| 0 | 135 | | showDLLayer = EditorGUILayout.Foldout(showDLLayer, "Directional Light Layer", true); |
| 0 | 136 | | if (showDLLayer) |
| | 137 | | { |
| 0 | 138 | | EditorGUI.indentLevel++; |
| 0 | 139 | | RenderDirectionalLightLayer(); |
| 0 | 140 | | EditorGUI.indentLevel--; |
| | 141 | | } |
| 0 | 142 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| | 143 | |
|
| 0 | 144 | | GUILayout.Space(32); |
| | 145 | |
|
| | 146 | |
|
| | 147 | | // Render Layers |
| 0 | 148 | | RenderTextureLayers(selectedConfiguration.layers); |
| | 149 | |
|
| 0 | 150 | | EditorGUILayout.EndScrollView(); |
| 0 | 151 | | GUILayout.Space(10); |
| 0 | 152 | | GUILayout.EndArea(); |
| | 153 | |
|
| 0 | 154 | | if (GUI.changed) |
| | 155 | | { |
| 0 | 156 | | ApplyOnMaterial(); |
| | 157 | | } |
| 0 | 158 | | } |
| | 159 | |
|
| | 160 | | private void Update() |
| | 161 | | { |
| 0 | 162 | | if (selectedConfiguration == null) |
| | 163 | | { |
| 0 | 164 | | return; |
| | 165 | | } |
| | 166 | |
|
| 0 | 167 | | if (isPaused) |
| | 168 | | { |
| 0 | 169 | | return; |
| | 170 | | } |
| | 171 | |
|
| 0 | 172 | | float timeNormalizationFactor = lifecycleDuration * 60 / 24; |
| 0 | 173 | | timeOfTheDay += Time.deltaTime / timeNormalizationFactor; |
| 0 | 174 | | timeOfTheDay = Mathf.Clamp(timeOfTheDay, 0.01f, 24); |
| | 175 | |
|
| 0 | 176 | | ApplyOnMaterial(); |
| | 177 | |
|
| 0 | 178 | | if (timeOfTheDay >= 24) |
| | 179 | | { |
| 0 | 180 | | timeOfTheDay = 0.01f; |
| 0 | 181 | | selectedConfiguration.CycleResets(); |
| | 182 | | } |
| | 183 | |
|
| 0 | 184 | | Repaint(); |
| 0 | 185 | | } |
| | 186 | |
|
| | 187 | | #endregion |
| | 188 | |
|
| | 189 | | static void Init() |
| | 190 | | { |
| 0 | 191 | | SkyboxEditorWindow window = (SkyboxEditorWindow)EditorWindow.GetWindow(typeof(SkyboxEditorWindow)); |
| 0 | 192 | | window.minSize = new Vector2(500, 500); |
| 0 | 193 | | window.Show(); |
| 0 | 194 | | window.InitializeWindow(); |
| 0 | 195 | | } |
| | 196 | |
|
| 0 | 197 | | public void InitializeWindow() { EnsureDependencies(); } |
| | 198 | |
|
| | 199 | | private void EnsureDependencies() |
| | 200 | | { |
| 0 | 201 | | if (!Application.isPlaying) |
| | 202 | | { |
| 0 | 203 | | overridingController = false; |
| | 204 | | } |
| | 205 | |
|
| 0 | 206 | | if (Application.isPlaying && !overridingController) |
| | 207 | | { |
| 0 | 208 | | TakeControlAtRuntime(); |
| | 209 | | } |
| | 210 | |
|
| 0 | 211 | | if (selectedConfiguration == null) |
| | 212 | | { |
| 0 | 213 | | UpdateConfigurationsList(); |
| | 214 | | } |
| | 215 | |
|
| 0 | 216 | | if (matLayer == null || selectedMat == null) |
| | 217 | | { |
| 0 | 218 | | UpdateMaterial(); |
| | 219 | | } |
| | 220 | |
|
| 0 | 221 | | CheckAndAssignAllStyles(); |
| | 222 | |
|
| 0 | 223 | | EditorUtility.SetDirty(selectedConfiguration); |
| | 224 | |
|
| | 225 | | // Fill rendering order array |
| 0 | 226 | | if (renderingOrderList == null) |
| | 227 | | { |
| 0 | 228 | | renderingOrderList = new List<string>(); |
| | 229 | |
|
| 0 | 230 | | for (int i = 0; i < 5; i++) |
| | 231 | | { |
| 0 | 232 | | renderingOrderList.Add((i + 1).ToString()); |
| | 233 | | } |
| | 234 | | } |
| | 235 | |
|
| 0 | 236 | | if (directionalLight != null) |
| | 237 | | { |
| 0 | 238 | | return; |
| | 239 | | } |
| | 240 | |
|
| | 241 | | // Cache directional light reference |
| 0 | 242 | | directionalLight = GameObject.FindObjectsOfType<Light>(true).Where(s => s.type == LightType.Directional).Fir |
| | 243 | |
|
| | 244 | | // Make a directional light object if can't find |
| 0 | 245 | | if (directionalLight == null) |
| | 246 | | { |
| 0 | 247 | | GameObject temp = new GameObject("The Sun_Temp"); |
| | 248 | | // Add the light component |
| 0 | 249 | | directionalLight = temp.AddComponent<Light>(); |
| 0 | 250 | | directionalLight.type = LightType.Directional; |
| | 251 | | } |
| 0 | 252 | | } |
| | 253 | |
|
| | 254 | | private void CheckAndAssignAllStyles() |
| | 255 | | { |
| 0 | 256 | | if (foldoutStyle == null) |
| | 257 | | { |
| 0 | 258 | | foldoutStyle = new GUIStyle(EditorStyles.foldout); |
| 0 | 259 | | foldoutStyle.fixedWidth = 2; |
| | 260 | | } |
| | 261 | |
|
| 0 | 262 | | if (renderingMarkerStyle == null) |
| | 263 | | { |
| 0 | 264 | | renderingMarkerStyle = new GUIStyle(EditorStyles.label); |
| 0 | 265 | | renderingMarkerStyle.fontSize = 18; |
| | 266 | | } |
| | 267 | |
|
| 0 | 268 | | if (configurationStyle == null) |
| | 269 | | { |
| 0 | 270 | | configurationStyle = new GUIStyle(); |
| 0 | 271 | | configurationStyle.alignment = TextAnchor.MiddleCenter; |
| 0 | 272 | | configurationStyle.margin = new RectOffset(150, 200, 0, 0); |
| | 273 | | } |
| | 274 | |
|
| 0 | 275 | | if (percentagePartStyle == null) |
| | 276 | | { |
| 0 | 277 | | percentagePartStyle = new GUIStyle(); |
| 0 | 278 | | percentagePartStyle.alignment = TextAnchor.MiddleCenter; |
| | 279 | | } |
| 0 | 280 | | } |
| | 281 | |
|
| | 282 | | void TakeControlAtRuntime() |
| | 283 | | { |
| 0 | 284 | | if (SkyboxController.i != null) |
| | 285 | | { |
| 0 | 286 | | isPaused = SkyboxController.i.IsPaused(); |
| 0 | 287 | | lifecycleDuration = (float)SkyboxController.i.lifecycleDuration; |
| 0 | 288 | | selectedConfiguration = SkyboxController.i.GetCurrentConfiguration(); |
| 0 | 289 | | overridingController = SkyboxController.i.SetOverrideController(true); |
| 0 | 290 | | timeOfTheDay = SkyboxController.i.GetCurrentTimeOfTheDay(); |
| 0 | 291 | | UpdateConfigurationsList(); |
| | 292 | | } |
| 0 | 293 | | } |
| | 294 | |
|
| | 295 | | void InitializeMaterial() |
| | 296 | | { |
| 0 | 297 | | matLayer = MaterialReferenceContainer.i.GetMat_LayerForLayers(5); |
| | 298 | |
|
| 0 | 299 | | if (matLayer == null) |
| | 300 | | { |
| 0 | 301 | | matLayer = MaterialReferenceContainer.i.materials[0]; |
| | 302 | | } |
| | 303 | |
|
| 0 | 304 | | selectedMat = matLayer.material; |
| 0 | 305 | | selectedConfiguration.ResetMaterial(selectedMat, matLayer.numberOfSlots); |
| 0 | 306 | | RenderSettings.skybox = selectedMat; |
| 0 | 307 | | } |
| | 308 | |
|
| 0 | 309 | | private void UpdateMaterial() { InitializeMaterial(); } |
| | 310 | |
|
| | 311 | | private SkyboxConfiguration AddNewConfiguration(string name) |
| | 312 | | { |
| | 313 | | SkyboxConfiguration temp = null; |
| 0 | 314 | | temp = ScriptableObject.CreateInstance<SkyboxConfiguration>(); |
| 0 | 315 | | temp.skyboxID = name; |
| | 316 | |
|
| 0 | 317 | | string path = AssetDatabase.GenerateUniqueAssetPath("Assets/Rendering/ProceduralSkybox/Resources/Skybox Conf |
| 0 | 318 | | AssetDatabase.CreateAsset(temp, path); |
| 0 | 319 | | AssetDatabase.SaveAssets(); |
| | 320 | |
|
| 0 | 321 | | return temp; |
| | 322 | | } |
| | 323 | |
|
| | 324 | | private void RenderConfigurations() |
| | 325 | | { |
| 0 | 326 | | GUILayout.Label("Configurations", EditorStyles.boldLabel); |
| | 327 | |
|
| | 328 | |
|
| 0 | 329 | | GUILayout.Label("Loaded: " + selectedConfiguration.skyboxID); |
| 0 | 330 | | GUILayout.BeginHorizontal(configurationStyle); |
| | 331 | |
|
| 0 | 332 | | if (creatingNewConfig) |
| | 333 | | { |
| 0 | 334 | | GUILayout.Label("Name"); |
| 0 | 335 | | newConfigName = EditorGUILayout.TextField(newConfigName, GUILayout.Width(200)); |
| | 336 | |
|
| 0 | 337 | | if (GUILayout.Button("Create", GUILayout.Width(50))) |
| | 338 | | { |
| | 339 | | // Make new configuration |
| 0 | 340 | | selectedConfiguration = AddNewConfiguration(newConfigName); |
| | 341 | |
|
| | 342 | | // Update configuration list |
| 0 | 343 | | UpdateConfigurationsList(); |
| 0 | 344 | | creatingNewConfig = false; |
| | 345 | |
|
| 0 | 346 | | if (Application.isPlaying && SkyboxController.i != null && overridingController) |
| | 347 | | { |
| 0 | 348 | | SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration); |
| | 349 | | } |
| | 350 | | } |
| | 351 | |
|
| 0 | 352 | | if (GUILayout.Button("Cancel", GUILayout.Width(50))) |
| | 353 | | { |
| 0 | 354 | | creatingNewConfig = false; |
| | 355 | | } |
| 0 | 356 | | } |
| | 357 | | else |
| | 358 | | { |
| 0 | 359 | | EditorGUILayout.BeginVertical(); |
| 0 | 360 | | newConfigIndex = EditorGUILayout.Popup(selectedConfigurationIndex, configurationNames.ToArray(), GUILayo |
| 0 | 361 | | selectedConfiguration = (SkyboxConfiguration)EditorGUILayout.ObjectField(selectedConfiguration, typeof(S |
| | 362 | |
|
| 0 | 363 | | EditorGUILayout.EndVertical(); |
| | 364 | |
|
| 0 | 365 | | if (newConfigIndex != selectedConfigurationIndex) |
| | 366 | | { |
| 0 | 367 | | selectedConfiguration = configurations[newConfigIndex]; |
| 0 | 368 | | selectedConfigurationIndex = newConfigIndex; |
| | 369 | |
|
| 0 | 370 | | if (Application.isPlaying && SkyboxController.i != null && overridingController) |
| | 371 | | { |
| 0 | 372 | | SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration); |
| | 373 | | } |
| | 374 | | } |
| | 375 | |
|
| 0 | 376 | | if (selectedConfiguration != configurations[selectedConfigurationIndex]) |
| | 377 | | { |
| 0 | 378 | | UpdateConfigurationsList(); |
| | 379 | |
|
| 0 | 380 | | if (Application.isPlaying && SkyboxController.i != null && overridingController) |
| | 381 | | { |
| 0 | 382 | | SkyboxController.i.UpdateConfigurationTimelineEvent(selectedConfiguration); |
| | 383 | | } |
| | 384 | | } |
| | 385 | |
|
| 0 | 386 | | if (GUILayout.Button("+", GUILayout.Width(50))) |
| | 387 | | { |
| 0 | 388 | | creatingNewConfig = true; |
| | 389 | | } |
| | 390 | | } |
| | 391 | |
|
| 0 | 392 | | GUILayout.EndHorizontal(); |
| 0 | 393 | | } |
| | 394 | |
|
| | 395 | | private void UpdateConfigurationsList() |
| | 396 | | { |
| 0 | 397 | | SkyboxConfiguration[] tConfigurations = Resources.LoadAll<SkyboxConfiguration>("Skybox Configurations/"); |
| 0 | 398 | | configurations = new List<SkyboxConfiguration>(tConfigurations); |
| 0 | 399 | | configurationNames = new List<string>(); |
| | 400 | |
|
| | 401 | | // If no configurations exist, make and select new one. |
| 0 | 402 | | if (configurations == null || configurations.Count < 1) |
| | 403 | | { |
| 0 | 404 | | selectedConfiguration = AddNewConfiguration("Generic Skybox"); |
| | 405 | |
|
| 0 | 406 | | configurations = new List<SkyboxConfiguration>(); |
| 0 | 407 | | configurations.Add(selectedConfiguration); |
| | 408 | | } |
| | 409 | |
|
| 0 | 410 | | if (selectedConfiguration == null) |
| | 411 | | { |
| 0 | 412 | | selectedConfiguration = configurations[0]; |
| | 413 | | } |
| | 414 | |
|
| 0 | 415 | | for (int i = 0; i < configurations.Count; i++) |
| | 416 | | { |
| 0 | 417 | | configurations[i].skyboxID = configurations[i].name; |
| | 418 | |
|
| 0 | 419 | | configurationNames.Add(configurations[i].skyboxID); |
| 0 | 420 | | if (selectedConfiguration == configurations[i]) |
| | 421 | | { |
| 0 | 422 | | selectedConfigurationIndex = i; |
| | 423 | | } |
| | 424 | | } |
| | 425 | |
|
| 0 | 426 | | InitializeMaterial(); |
| | 427 | |
|
| 0 | 428 | | if (!Application.isPlaying) |
| | 429 | | { |
| 0 | 430 | | isPaused = true; |
| | 431 | | } |
| 0 | 432 | | } |
| | 433 | |
|
| | 434 | | private void RenderTimePanel() |
| | 435 | | { |
| | 436 | |
|
| 0 | 437 | | GUILayout.Label("Preview", EditorStyles.boldLabel); |
| | 438 | |
|
| 0 | 439 | | GUILayout.BeginHorizontal(); |
| 0 | 440 | | EditorGUILayout.LabelField("Time : " + timeOfTheDay.ToString("f2"), EditorStyles.label, GUILayout.Width(70)) |
| | 441 | |
|
| 0 | 442 | | EditorGUILayout.Space(20); |
| | 443 | |
|
| 0 | 444 | | EditorGUILayout.BeginVertical(); |
| 0 | 445 | | timeOfTheDay = EditorGUILayout.Slider(timeOfTheDay, 0.01f, 24.00f, GUILayout.MinWidth(150)); |
| 0 | 446 | | GUILayout.BeginHorizontal(); |
| 0 | 447 | | EditorGUILayout.LabelField("cycle (minutes)", GUILayout.Width(95)); |
| 0 | 448 | | lifecycleDuration = EditorGUILayout.FloatField(lifecycleDuration, GUILayout.Width(50)); |
| 0 | 449 | | EditorGUILayout.EndHorizontal(); |
| 0 | 450 | | EditorGUILayout.EndVertical(); |
| | 451 | |
|
| 0 | 452 | | EditorGUILayout.LabelField((GetNormalizedDayTime() * 100).ToString("f2") + "%", GUILayout.MaxWidth(50)); |
| | 453 | |
|
| 0 | 454 | | if (isPaused) |
| | 455 | | { |
| 0 | 456 | | if (GUILayout.Button("Play", GUILayout.ExpandWidth(false))) |
| | 457 | | { |
| 0 | 458 | | ResumeTime(); |
| | 459 | | } |
| 0 | 460 | | } |
| | 461 | | else |
| | 462 | | { |
| 0 | 463 | | if (GUILayout.Button("Pause", GUILayout.ExpandWidth(false))) |
| | 464 | | { |
| 0 | 465 | | PauseTime(); |
| | 466 | | } |
| | 467 | | } |
| | 468 | |
|
| 0 | 469 | | GUILayout.EndHorizontal(); |
| 0 | 470 | | } |
| | 471 | |
|
| 0 | 472 | | void ResumeTime() { isPaused = false; } |
| | 473 | |
|
| 0 | 474 | | void PauseTime() { isPaused = true; } |
| | 475 | |
|
| | 476 | | #region Render Base Layeyrs |
| | 477 | |
|
| | 478 | | void RenderBackgroundColorLayer() |
| | 479 | | { |
| 0 | 480 | | RenderColorGradientField(selectedConfiguration.skyColor, "Sky Color", 0, 24); |
| 0 | 481 | | RenderColorGradientField(selectedConfiguration.horizonColor, "Horizon Color", 0, 24); |
| 0 | 482 | | RenderColorGradientField(selectedConfiguration.groundColor, "Ground Color", 0, 24); |
| 0 | 483 | | RenderHorizonLayer(); |
| 0 | 484 | | } |
| | 485 | |
|
| | 486 | | void RenderHorizonLayer() |
| | 487 | | { |
| 0 | 488 | | EditorGUILayout.Separator(); |
| 0 | 489 | | RenderTransitioningFloat(selectedConfiguration.horizonHeight, "Horizon Height", "%", "value", true, -1, 1); |
| | 490 | |
|
| 0 | 491 | | EditorGUILayout.Space(10); |
| 0 | 492 | | RenderTransitioningFloat(selectedConfiguration.horizonWidth, "Horizon Width", "%", "value", true, -1, 1); |
| | 493 | |
|
| 0 | 494 | | EditorGUILayout.Separator(); |
| | 495 | |
|
| | 496 | | // Horizon Mask |
| 0 | 497 | | RenderTexture("Texture", ref selectedConfiguration.horizonMask); |
| | 498 | |
|
| | 499 | | // Horizon mask values |
| 0 | 500 | | RenderVector3Field("Horizon Mask Values", ref selectedConfiguration.horizonMaskValues); |
| | 501 | |
|
| | 502 | | // Horizon Plane color |
| 0 | 503 | | RenderColorGradientField(selectedConfiguration.horizonPlaneColor, "Horizon Plane Color", 0, 24); |
| | 504 | |
|
| | 505 | | // Horizon Height |
| 0 | 506 | | RenderTransitioningFloat(selectedConfiguration.horizonPlaneHeight, "Horizon Plane Height", "%", "value", tru |
| 0 | 507 | | } |
| | 508 | |
|
| | 509 | | void RenderAmbientLayer() |
| | 510 | | { |
| 0 | 511 | | selectedConfiguration.ambientTrilight = EditorGUILayout.Toggle("Use Gradient", selectedConfiguration.ambient |
| | 512 | |
|
| 0 | 513 | | if (selectedConfiguration.ambientTrilight) |
| | 514 | | { |
| 0 | 515 | | RenderColorGradientField(selectedConfiguration.ambientSkyColor, "Ambient Sky Color", 0, 24, true); |
| 0 | 516 | | RenderColorGradientField(selectedConfiguration.ambientEquatorColor, "Ambient Equator Color", 0, 24, true |
| 0 | 517 | | RenderColorGradientField(selectedConfiguration.ambientGroundColor, "Ambient Ground Color", 0, 24, true); |
| | 518 | | } |
| | 519 | |
|
| 0 | 520 | | } |
| | 521 | |
|
| | 522 | | void RenderAvatarColorLayer() |
| | 523 | | { |
| 0 | 524 | | EditorGUILayout.LabelField("In World", EditorStyles.boldLabel); |
| 0 | 525 | | EditorGUI.indentLevel++; |
| | 526 | | // Avatar Color |
| 0 | 527 | | selectedConfiguration.useAvatarGradient = EditorGUILayout.Toggle("Color Gradient", selectedConfiguration.use |
| | 528 | |
|
| 0 | 529 | | if (selectedConfiguration.useAvatarGradient) |
| | 530 | | { |
| 0 | 531 | | RenderColorGradientField(selectedConfiguration.avatarTintGradient, "Tint Gradient", 0, 24, true); |
| 0 | 532 | | } |
| | 533 | | else |
| | 534 | | { |
| 0 | 535 | | selectedConfiguration.avatarTintColor = EditorGUILayout.ColorField("Tint Color", selectedConfiguration.a |
| 0 | 536 | | EditorGUILayout.Separator(); |
| | 537 | | } |
| | 538 | |
|
| | 539 | | // Avatar Light Direction |
| 0 | 540 | | selectedConfiguration.useAvatarRealtimeDLDirection = EditorGUILayout.Toggle("Realtime DL Direction", selecte |
| | 541 | |
|
| 0 | 542 | | if (!selectedConfiguration.useAvatarRealtimeDLDirection) |
| | 543 | | { |
| 0 | 544 | | RenderVector3Field("Light Direction", ref selectedConfiguration.avatarLightConstantDir); |
| | 545 | | } |
| | 546 | |
|
| 0 | 547 | | EditorGUILayout.Separator(); |
| | 548 | |
|
| | 549 | | // Avatar Light Color |
| 0 | 550 | | selectedConfiguration.useAvatarRealtimeLightColor = EditorGUILayout.Toggle("Realtime Light Color", selectedC |
| | 551 | |
|
| 0 | 552 | | if (!selectedConfiguration.useAvatarRealtimeLightColor) |
| | 553 | | { |
| 0 | 554 | | RenderColorGradientField(selectedConfiguration.avatarLightColorGradient, "Light Color", 0, 24); |
| 0 | 555 | | EditorGUILayout.Separator(); |
| | 556 | | } |
| 0 | 557 | | EditorGUI.indentLevel--; |
| | 558 | |
|
| 0 | 559 | | EditorGUILayout.LabelField("In Editor (Backpack)", EditorStyles.boldLabel); |
| 0 | 560 | | EditorGUI.indentLevel++; |
| 0 | 561 | | selectedConfiguration.avatarEditorTintColor = EditorGUILayout.ColorField("Tint Color", selectedConfiguration |
| 0 | 562 | | RenderVector3Field("Light Direction", ref selectedConfiguration.avatarEditorLightDir); |
| 0 | 563 | | selectedConfiguration.avatarEditorLightColor = EditorGUILayout.ColorField("Light Color", selectedConfigurati |
| 0 | 564 | | EditorGUILayout.Separator(); |
| 0 | 565 | | EditorGUI.indentLevel--; |
| 0 | 566 | | } |
| | 567 | |
|
| | 568 | | void RenderFogLayer() |
| | 569 | | { |
| 0 | 570 | | selectedConfiguration.useFog = EditorGUILayout.Toggle("Use Fog", selectedConfiguration.useFog); |
| 0 | 571 | | if (selectedConfiguration.useFog) |
| | 572 | | { |
| 0 | 573 | | RenderColorGradientField(selectedConfiguration.fogColor, "Fog Color", 0, 24); |
| 0 | 574 | | selectedConfiguration.fogMode = (FogMode)EditorGUILayout.EnumPopup("Fog Mode", selectedConfiguration.fog |
| | 575 | |
|
| 0 | 576 | | switch (selectedConfiguration.fogMode) |
| | 577 | | { |
| | 578 | | case FogMode.Linear: |
| 0 | 579 | | RenderFloatField("Start Distance:", ref selectedConfiguration.fogStartDistance); |
| 0 | 580 | | RenderFloatField("End Distance:", ref selectedConfiguration.fogEndDistance); |
| 0 | 581 | | break; |
| | 582 | | default: |
| 0 | 583 | | RenderFloatField("Density: ", ref selectedConfiguration.fogDensity); |
| | 584 | | break; |
| | 585 | | } |
| | 586 | | } |
| | 587 | |
|
| 0 | 588 | | } |
| | 589 | |
|
| | 590 | | void RenderDirectionalLightLayer() |
| | 591 | | { |
| 0 | 592 | | selectedConfiguration.useDirectionalLight = EditorGUILayout.Toggle("Use Directional Light", selectedConfigur |
| | 593 | |
|
| 0 | 594 | | if (!selectedConfiguration.useDirectionalLight) |
| | 595 | | { |
| 0 | 596 | | return; |
| | 597 | | } |
| 0 | 598 | | RenderColorGradientField(selectedConfiguration.directionalLightLayer.lightColor, "Light Color", 0, 24); |
| 0 | 599 | | RenderColorGradientField(selectedConfiguration.directionalLightLayer.tintColor, "Tint Color", 0, 24, true); |
| | 600 | |
|
| 0 | 601 | | GUILayout.Space(10); |
| | 602 | |
|
| | 603 | | // Light Intesity |
| 0 | 604 | | RenderTransitioningFloat(selectedConfiguration.directionalLightLayer.intensity, "Light Intensity", "%", "Int |
| | 605 | |
|
| 0 | 606 | | GUILayout.Space(10); |
| | 607 | |
|
| 0 | 608 | | RenderTransitioningQuaternionAsVector3(selectedConfiguration.directionalLightLayer.lightDirection, "Light Di |
| 0 | 609 | | } |
| | 610 | |
|
| 0 | 611 | | private Quaternion GetDLDirection() { return directionalLight.transform.rotation; } |
| | 612 | |
|
| | 613 | | private void RenderTimelineTags() |
| | 614 | | { |
| 0 | 615 | | if (selectedConfiguration.timelineTags == null) |
| | 616 | | { |
| 0 | 617 | | selectedConfiguration.timelineTags = new List<TimelineTagsDuration>(); |
| | 618 | | } |
| | 619 | |
|
| 0 | 620 | | for (int i = 0; i < selectedConfiguration.timelineTags.Count; i++) |
| | 621 | | { |
| 0 | 622 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| | 623 | |
|
| | 624 | | // Text field for name of event |
| 0 | 625 | | EditorGUILayout.LabelField("Name: ", GUILayout.Width(50)); |
| 0 | 626 | | selectedConfiguration.timelineTags[i].tag = EditorGUILayout.TextField(selectedConfiguration.timelineTags |
| | 627 | |
|
| | 628 | | // Start time |
| 0 | 629 | | EditorGUILayout.LabelField("Start", GUILayout.Width(45)); |
| 0 | 630 | | GUILayout.Space(0); |
| 0 | 631 | | selectedConfiguration.timelineTags[i].startTime = EditorGUILayout.FloatField(selectedConfiguration.timel |
| 0 | 632 | | ClampToDayTime(ref selectedConfiguration.timelineTags[i].startTime); |
| | 633 | |
|
| | 634 | | // End time |
| 0 | 635 | | if (!selectedConfiguration.timelineTags[i].isTrigger) |
| | 636 | | { |
| 0 | 637 | | EditorGUILayout.LabelField("End", GUILayout.Width(40)); |
| 0 | 638 | | GUILayout.Space(0); |
| 0 | 639 | | selectedConfiguration.timelineTags[i].endTime = EditorGUILayout.FloatField(selectedConfiguration.tim |
| 0 | 640 | | ClampToDayTime(ref selectedConfiguration.timelineTags[i].endTime); |
| 0 | 641 | | } |
| | 642 | | else |
| | 643 | | { |
| 0 | 644 | | GUILayout.Space(97); |
| | 645 | | } |
| | 646 | |
|
| | 647 | | // no end time |
| 0 | 648 | | selectedConfiguration.timelineTags[i].isTrigger = EditorGUILayout.ToggleLeft("Trigger", selectedConfigur |
| | 649 | |
|
| | 650 | | // Remove Button |
| 0 | 651 | | if (GUILayout.Button("-", GUILayout.Width(30))) |
| | 652 | | { |
| 0 | 653 | | selectedConfiguration.timelineTags.RemoveAt(i); |
| | 654 | | } |
| | 655 | |
|
| 0 | 656 | | EditorGUILayout.EndHorizontal(); |
| | 657 | | } |
| | 658 | |
|
| 0 | 659 | | EditorGUILayout.BeginHorizontal(); |
| 0 | 660 | | GUILayout.Space(20); |
| 0 | 661 | | if (GUILayout.Button("+", GUILayout.Width(30))) |
| | 662 | | { |
| 0 | 663 | | selectedConfiguration.timelineTags.Add(new TimelineTagsDuration(timeOfTheDay)); |
| | 664 | | } |
| 0 | 665 | | EditorGUILayout.EndHorizontal(); |
| 0 | 666 | | } |
| | 667 | |
|
| | 668 | | #endregion |
| | 669 | |
|
| | 670 | | #region Render Slots and Layers |
| | 671 | |
|
| | 672 | | void RenderTextureLayers(List<TextureLayer> layers) |
| | 673 | | { |
| | 674 | |
|
| 0 | 675 | | for (int i = 0; i < layers.Count; i++) |
| | 676 | | { |
| | 677 | | // Name and buttons |
| 0 | 678 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 679 | | layers[i].enabled = EditorGUILayout.Toggle(layers[i].enabled, GUILayout.Width(20), GUILayout.Height(10)) |
| 0 | 680 | | GUILayout.Space(10); |
| 0 | 681 | | layers[i].expandedInEditor = EditorGUILayout.Foldout(layers[i].expandedInEditor, GUIContent.none, true, |
| 0 | 682 | | layers[i].nameInEditor = EditorGUILayout.TextField(layers[i].nameInEditor, GUILayout.Width(100), GUILayo |
| | 683 | |
|
| | 684 | | // Slot ID |
| 0 | 685 | | layers[i].slotID = EditorGUILayout.Popup(layers[i].slotID, renderingOrderList.ToArray(), GUILayout.Width |
| | 686 | |
|
| 0 | 687 | | if (i == 0) |
| | 688 | | { |
| 0 | 689 | | GUI.enabled = false; |
| | 690 | | } |
| 0 | 691 | | if (GUILayout.Button(('\u25B2').ToString(), GUILayout.Width(50), GUILayout.ExpandWidth(false))) |
| | 692 | | { |
| 0 | 693 | | TextureLayer temp = null; |
| | 694 | |
|
| 0 | 695 | | if (i >= 1) |
| | 696 | | { |
| 0 | 697 | | temp = layers[i - 1]; |
| 0 | 698 | | layers[i - 1] = layers[i]; |
| 0 | 699 | | layers[i] = temp; |
| | 700 | | } |
| | 701 | | } |
| | 702 | |
|
| 0 | 703 | | GUI.enabled = true; |
| | 704 | |
|
| 0 | 705 | | if (i == layers.Count - 1) |
| | 706 | | { |
| 0 | 707 | | GUI.enabled = false; |
| | 708 | | } |
| | 709 | |
|
| 0 | 710 | | if (GUILayout.Button(('\u25BC').ToString(), GUILayout.Width(50), GUILayout.ExpandWidth(false))) |
| | 711 | | { |
| 0 | 712 | | TextureLayer temp = null; |
| 0 | 713 | | if (i < (layers.Count - 1)) |
| | 714 | | { |
| 0 | 715 | | temp = layers[i + 1]; |
| 0 | 716 | | layers[i + 1] = layers[i]; |
| 0 | 717 | | layers[i] = temp; |
| | 718 | | } |
| 0 | 719 | | break; |
| | 720 | | } |
| | 721 | |
|
| 0 | 722 | | GUI.enabled = true; |
| | 723 | |
|
| 0 | 724 | | if (GUILayout.Button("-", GUILayout.Width(50), GUILayout.ExpandWidth(false))) |
| | 725 | | { |
| 0 | 726 | | layers.RemoveAt(i); |
| 0 | 727 | | break; |
| | 728 | | } |
| | 729 | |
|
| 0 | 730 | | Color circleColor = Color.green; |
| 0 | 731 | | switch (layers[i].renderType) |
| | 732 | | { |
| | 733 | | case LayerRenderType.Rendering: |
| 0 | 734 | | circleColor = Color.green; |
| 0 | 735 | | break; |
| | 736 | | case LayerRenderType.NotRendering: |
| 0 | 737 | | circleColor = Color.gray; |
| 0 | 738 | | break; |
| | 739 | | case LayerRenderType.Conflict_Playing: |
| 0 | 740 | | circleColor = Color.yellow; |
| 0 | 741 | | break; |
| | 742 | | case LayerRenderType.Conflict_NotPlaying: |
| 0 | 743 | | circleColor = Color.red; |
| | 744 | | break; |
| | 745 | | default: |
| | 746 | | break; |
| | 747 | | } |
| | 748 | |
|
| 0 | 749 | | Color normalContentColor = GUI.color; |
| 0 | 750 | | GUI.color = circleColor; |
| | 751 | |
|
| 0 | 752 | | EditorGUILayout.LabelField(('\u29BF').ToString(), renderingMarkerStyle, GUILayout.Width(20), GUILayout.H |
| | 753 | |
|
| 0 | 754 | | GUI.color = normalContentColor; |
| | 755 | |
|
| 0 | 756 | | EditorGUILayout.EndHorizontal(); |
| | 757 | |
|
| 0 | 758 | | if (layers[i].expandedInEditor) |
| | 759 | | { |
| 0 | 760 | | EditorGUILayout.Separator(); |
| 0 | 761 | | EditorGUI.indentLevel++; |
| 0 | 762 | | RenderTextureLayer(layers[i]); |
| | 763 | |
|
| 0 | 764 | | EditorGUI.indentLevel--; |
| | 765 | | } |
| | 766 | |
|
| 0 | 767 | | EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); |
| | 768 | |
|
| 0 | 769 | | GUILayout.Space(32); |
| | 770 | | } |
| | 771 | |
|
| 0 | 772 | | GUI.enabled = true; |
| | 773 | |
|
| 0 | 774 | | if (GUILayout.Button("+", GUILayout.MaxWidth(20))) |
| | 775 | | { |
| 0 | 776 | | layers.Add(new TextureLayer("Tex Layer " + (layers.Count + 1))); |
| | 777 | | } |
| 0 | 778 | | } |
| | 779 | |
|
| | 780 | | void RenderTextureLayer(TextureLayer layer) |
| | 781 | | { |
| 0 | 782 | | EditorGUILayout.Separator(); |
| | 783 | |
|
| | 784 | | // Layer Type |
| 0 | 785 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 786 | | EditorGUILayout.LabelField("Layer Type:", GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 787 | | layer.layerType = (LayerType)EditorGUILayout.EnumPopup(layer.layerType, GUILayout.Width(200)); |
| 0 | 788 | | EditorGUILayout.EndHorizontal(); |
| | 789 | |
|
| | 790 | |
|
| 0 | 791 | | EditorGUILayout.Separator(); |
| | 792 | |
|
| | 793 | | // Time Span |
| 0 | 794 | | RenderSepratedFloatFields("Time Span", "Starts", ref layer.timeSpan_start, "Ends", ref layer.timeSpan_End); |
| 0 | 795 | | ClampToDayTime(ref layer.timeSpan_start); |
| 0 | 796 | | ClampToDayTime(ref layer.timeSpan_End); |
| | 797 | |
|
| | 798 | | // Fading |
| 0 | 799 | | RenderSepratedFloatFields("Fading", "In", ref layer.fadingInTime, "Out", ref layer.fadingOutTime); |
| | 800 | |
|
| | 801 | | // Tint |
| 0 | 802 | | RenderFloatFieldAsSlider("Tint", ref layer.tintPercentage, 0, 100); |
| | 803 | |
|
| 0 | 804 | | if (layer.layerType == LayerType.Cubemap) |
| | 805 | | { |
| 0 | 806 | | RenderCubemapLayer(layer); |
| | 807 | |
|
| 0 | 808 | | } |
| 0 | 809 | | else if (layer.layerType == LayerType.Planar) |
| | 810 | | { |
| 0 | 811 | | RenderPlanarLayer(layer); |
| | 812 | |
|
| 0 | 813 | | } |
| 0 | 814 | | else if (layer.layerType == LayerType.Radial) |
| | 815 | | { |
| 0 | 816 | | RenderPlanarLayer(layer, true); |
| 0 | 817 | | } |
| 0 | 818 | | else if (layer.layerType == LayerType.Satellite) |
| | 819 | | { |
| 0 | 820 | | RenderSatelliteLayer(layer); |
| 0 | 821 | | } |
| 0 | 822 | | else if (layer.layerType == LayerType.Particles) |
| | 823 | | { |
| 0 | 824 | | RenderParticleLayer(layer); |
| | 825 | | } |
| 0 | 826 | | } |
| | 827 | |
|
| | 828 | | void RenderCubemapLayer(TextureLayer layer) |
| | 829 | | { |
| | 830 | | // Cubemap |
| 0 | 831 | | RenderCubemapTexture("Cubemap", ref layer.cubemap); |
| | 832 | |
|
| | 833 | | // Gradient |
| 0 | 834 | | RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true); |
| | 835 | |
|
| 0 | 836 | | EditorGUILayout.Separator(); |
| | 837 | |
|
| | 838 | | // Movement Type |
| 0 | 839 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 840 | | EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 841 | | layer.movementTypeCubemap = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypeCubemap, GUILayout.Wid |
| 0 | 842 | | EditorGUILayout.EndHorizontal(); |
| | 843 | |
|
| 0 | 844 | | EditorGUILayout.Separator(); |
| | 845 | |
|
| | 846 | | // Rotation |
| 0 | 847 | | if (layer.movementTypeCubemap == MovementType.PointBased) |
| | 848 | | { |
| 0 | 849 | | RenderTransitioningVector3(layer.rotations_Vector3, "Rotation", "%", "Rot:", layer.timeSpan_start, layer |
| | 850 | |
|
| 0 | 851 | | } |
| | 852 | | else |
| | 853 | | { |
| 0 | 854 | | RenderVector3Field("Speed", ref layer.speed_Vector3); |
| | 855 | | } |
| 0 | 856 | | } |
| | 857 | |
|
| | 858 | | void RenderPlanarLayer(TextureLayer layer, bool isRadial = false) |
| | 859 | | { |
| | 860 | | // Texture |
| 0 | 861 | | RenderTexture("Texture", ref layer.texture); |
| | 862 | |
|
| | 863 | | // Row and Coloumns |
| 0 | 864 | | RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns); |
| | 865 | |
|
| | 866 | | // Anim Speed |
| 0 | 867 | | RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed); |
| | 868 | |
|
| | 869 | | // Normal Texture |
| 0 | 870 | | RenderTexture("Normal Map", ref layer.textureNormal); |
| | 871 | |
|
| | 872 | | // Normal Intensity |
| 0 | 873 | | RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1); |
| | 874 | |
|
| | 875 | | // Gradient |
| 0 | 876 | | RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true); |
| | 877 | |
|
| | 878 | | // Tiling |
| 0 | 879 | | RenderVector2Field("Tiling", ref layer.tiling); |
| | 880 | |
|
| | 881 | | // Movement Type |
| 0 | 882 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 883 | | EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 884 | | layer.movementTypePlanar_Radial = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypePlanar_Radial, G |
| 0 | 885 | | EditorGUILayout.EndHorizontal(); |
| | 886 | |
|
| 0 | 887 | | EditorGUI.indentLevel++; |
| 0 | 888 | | EditorGUILayout.Separator(); |
| | 889 | |
|
| 0 | 890 | | if (layer.movementTypePlanar_Radial == MovementType.Speed) |
| | 891 | | { |
| | 892 | | // Speed |
| 0 | 893 | | RenderVector2Field("Speed", ref layer.speed_Vector2); |
| 0 | 894 | | } |
| | 895 | | else |
| | 896 | | { |
| | 897 | | // Offset |
| 0 | 898 | | RenderTransitioningVector2(layer.offset, "Position", "%", "", layer.timeSpan_start, layer.timeSpan_End); |
| | 899 | | } |
| | 900 | |
|
| 0 | 901 | | EditorGUI.indentLevel--; |
| | 902 | |
|
| 0 | 903 | | EditorGUILayout.Space(15); |
| | 904 | |
|
| | 905 | | // Render Distance |
| 0 | 906 | | RenderTransitioningFloat(layer.renderDistance, "Render Distance", "", "", true, 0, 20, layer.timeSpan_start, |
| | 907 | |
|
| 0 | 908 | | EditorGUILayout.Space(15); |
| | 909 | |
|
| | 910 | | // Rotation |
| 0 | 911 | | if (!isRadial) |
| | 912 | | { |
| 0 | 913 | | RenderTransitioningFloat(layer.rotations_float, "Rotation", "", "", true, 0, 360, layer.timeSpan_start, |
| 0 | 914 | | EditorGUILayout.Separator(); |
| | 915 | | } |
| | 916 | |
|
| 0 | 917 | | RenderDistortionVariables(layer); |
| | 918 | |
|
| 0 | 919 | | EditorGUILayout.Space(10); |
| 0 | 920 | | } |
| | 921 | |
|
| | 922 | | void RenderSatelliteLayer(TextureLayer layer) |
| | 923 | | { |
| | 924 | | // Texture |
| 0 | 925 | | RenderTexture("Texture", ref layer.texture); |
| | 926 | |
|
| | 927 | | // Row and Coloumns |
| 0 | 928 | | RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns); |
| | 929 | |
|
| | 930 | | // Anim Speed |
| 0 | 931 | | RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed); |
| | 932 | |
|
| | 933 | | // Normal Texture |
| 0 | 934 | | RenderTexture("Normal Map", ref layer.textureNormal); |
| | 935 | |
|
| | 936 | | // Normal Intensity |
| 0 | 937 | | RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1); |
| | 938 | |
|
| | 939 | | // Gradient |
| 0 | 940 | | RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true); |
| | 941 | |
|
| 0 | 942 | | EditorGUILayout.Space(10); |
| 0 | 943 | | EditorGUILayout.Space(10); |
| | 944 | |
|
| 0 | 945 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 946 | | EditorGUILayout.LabelField("Movemnt Type", GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 947 | | layer.movementTypeSatellite = (MovementType)EditorGUILayout.EnumPopup(layer.movementTypeSatellite, GUILayout |
| 0 | 948 | | EditorGUILayout.EndHorizontal(); |
| | 949 | |
|
| 0 | 950 | | EditorGUI.indentLevel++; |
| 0 | 951 | | EditorGUILayout.Separator(); |
| | 952 | |
|
| 0 | 953 | | if (layer.movementTypeSatellite == MovementType.Speed) |
| | 954 | | { |
| | 955 | | // Speed |
| 0 | 956 | | RenderVector2Field("Speed", ref layer.speed_Vector2); |
| 0 | 957 | | } |
| | 958 | | else |
| | 959 | | { |
| | 960 | | // Offset |
| 0 | 961 | | RenderTransitioningVector2(layer.offset, "Position", "%", "", layer.timeSpan_start, layer.timeSpan_End); |
| | 962 | | } |
| | 963 | |
|
| 0 | 964 | | EditorGUI.indentLevel--; |
| 0 | 965 | | EditorGUILayout.Space(20); |
| | 966 | |
|
| | 967 | | // Rotation |
| 0 | 968 | | RenderTransitioningFloat(layer.rotations_float, "Rotation", "", "", true, 0, 360, layer.timeSpan_start, laye |
| | 969 | |
|
| 0 | 970 | | EditorGUILayout.Space(12); |
| | 971 | |
|
| | 972 | | // Size |
| 0 | 973 | | RenderTransitioningVector2(layer.satelliteWidthHeight, "Width & Height", "%", "", layer.timeSpan_start, laye |
| 0 | 974 | | } |
| | 975 | |
|
| | 976 | | void RenderParticleLayer(TextureLayer layer) |
| | 977 | | { |
| | 978 | | // Texture |
| 0 | 979 | | RenderTexture("Texture", ref layer.texture); |
| | 980 | |
|
| | 981 | | // Row and Coloumns |
| 0 | 982 | | RenderVector2Field("Rows and Columns", ref layer.flipbookRowsAndColumns); |
| | 983 | |
|
| | 984 | | // Anim Speed |
| 0 | 985 | | RenderFloatField("Anim Speed", ref layer.flipbookAnimSpeed); |
| | 986 | |
|
| | 987 | | // Normal Map |
| 0 | 988 | | RenderTexture("Normal Map", ref layer.textureNormal); |
| | 989 | |
|
| | 990 | | // Normal Intensity |
| 0 | 991 | | RenderFloatFieldAsSlider("Normal Intensity", ref layer.normalIntensity, 0, 1); |
| | 992 | |
|
| | 993 | | // Gradient |
| 0 | 994 | | RenderColorGradientField(layer.color, "color", layer.timeSpan_start, layer.timeSpan_End, true); |
| | 995 | |
|
| | 996 | | // Tiling |
| 0 | 997 | | RenderVector2Field("Tiling", ref layer.particleTiling); |
| | 998 | |
|
| | 999 | | // Offset |
| 0 | 1000 | | RenderVector2Field("Offset", ref layer.particlesOffset); |
| | 1001 | |
|
| | 1002 | | // Amount |
| 0 | 1003 | | RenderFloatField("Amount", ref layer.particlesAmount); |
| | 1004 | |
|
| | 1005 | | // Size |
| 0 | 1006 | | RenderSepratedFloatFields("Size", "Min", ref layer.particleMinSize, "Max", ref layer.particleMaxSize); |
| | 1007 | |
|
| | 1008 | | // Spread |
| 0 | 1009 | | RenderSepratedFloatFields("Spread", "Horizontal", ref layer.particlesHorizontalSpread, "Vertical", ref layer |
| | 1010 | |
|
| | 1011 | | // Fade |
| 0 | 1012 | | RenderSepratedFloatFields("Fade", "Min", ref layer.particleMinFade, "Max", ref layer.particleMaxFade); |
| | 1013 | |
|
| | 1014 | | // Particle Rotation |
| 0 | 1015 | | RenderTransitioningVector3(layer.particleRotation, "Rotation", "%", "value", layer.timeSpan_start, layer.tim |
| 0 | 1016 | | } |
| | 1017 | |
|
| | 1018 | | void RenderDistortionVariables(TextureLayer layer) |
| | 1019 | | { |
| 0 | 1020 | | layer.distortionExpanded = EditorGUILayout.Foldout(layer.distortionExpanded, "Distortion Values", true, Edit |
| | 1021 | |
|
| 0 | 1022 | | if (!layer.distortionExpanded) |
| | 1023 | | { |
| 0 | 1024 | | return; |
| | 1025 | | } |
| | 1026 | |
|
| 0 | 1027 | | EditorGUILayout.Space(10); |
| | 1028 | |
|
| 0 | 1029 | | EditorGUI.indentLevel++; |
| | 1030 | |
|
| | 1031 | | // Distortion Intensity |
| 0 | 1032 | | RenderTransitioningFloat(layer.distortIntensity, "Intensity", "%", "Value", false, 0, 1, layer.timeSpan_star |
| | 1033 | |
|
| 0 | 1034 | | EditorGUILayout.Space(10); |
| | 1035 | |
|
| | 1036 | | // Distortion Size |
| 0 | 1037 | | RenderTransitioningFloat(layer.distortSize, "Size", "%", "Value", false, 0, 1, layer.timeSpan_start, layer.t |
| | 1038 | |
|
| 0 | 1039 | | EditorGUILayout.Space(10); |
| | 1040 | |
|
| | 1041 | | // Distortion Speed |
| 0 | 1042 | | RenderTransitioningVector2(layer.distortSpeed, "Speed", "%", "Value", layer.timeSpan_start, layer.timeSpan_E |
| | 1043 | |
|
| 0 | 1044 | | EditorGUILayout.Space(10); |
| | 1045 | |
|
| | 1046 | | // Distortion Sharpness |
| 0 | 1047 | | RenderTransitioningVector2(layer.distortSharpness, "Sharpness", "%", "Value", layer.timeSpan_start, layer.ti |
| | 1048 | |
|
| 0 | 1049 | | EditorGUILayout.Space(10); |
| | 1050 | |
|
| 0 | 1051 | | EditorGUI.indentLevel--; |
| 0 | 1052 | | } |
| | 1053 | |
|
| | 1054 | | #endregion |
| | 1055 | |
|
| | 1056 | | #region Render simple Variables |
| | 1057 | |
|
| | 1058 | | void RenderSepratedFloatFields(string label, string label1, ref float value1, string label2, ref float value2) |
| | 1059 | | { |
| 0 | 1060 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1061 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1062 | | EditorGUILayout.LabelField(label1, GUILayout.Width(90), GUILayout.ExpandWidth(false)); |
| 0 | 1063 | | value1 = EditorGUILayout.FloatField("", value1, GUILayout.Width(90)); |
| 0 | 1064 | | EditorGUILayout.LabelField(label2, GUILayout.Width(90), GUILayout.ExpandWidth(false)); |
| 0 | 1065 | | value2 = EditorGUILayout.FloatField("", value2, GUILayout.Width(90)); |
| 0 | 1066 | | GUILayout.EndHorizontal(); |
| 0 | 1067 | | EditorGUILayout.Separator(); |
| 0 | 1068 | | } |
| | 1069 | |
|
| | 1070 | | void RenderFloatField(string label, ref float value) |
| | 1071 | | { |
| 0 | 1072 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1073 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1074 | | value = EditorGUILayout.FloatField(value, GUILayout.Width(90)); |
| 0 | 1075 | | EditorGUILayout.EndHorizontal(); |
| 0 | 1076 | | EditorGUILayout.Separator(); |
| 0 | 1077 | | } |
| | 1078 | |
|
| | 1079 | | void RenderFloatFieldAsSlider(string label, ref float value, float min, float max) |
| | 1080 | | { |
| 0 | 1081 | | EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1082 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1083 | | value = EditorGUILayout.Slider(value, min, max, GUILayout.Width(200)); |
| 0 | 1084 | | EditorGUILayout.EndHorizontal(); |
| 0 | 1085 | | EditorGUILayout.Separator(); |
| 0 | 1086 | | } |
| | 1087 | |
|
| | 1088 | | void RenderVector3Field(string label, ref Vector3 value) |
| | 1089 | | { |
| 0 | 1090 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1091 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1092 | | value = EditorGUILayout.Vector3Field("", value, GUILayout.Width(200), GUILayout.ExpandWidth(false)); |
| 0 | 1093 | | GUILayout.EndHorizontal(); |
| 0 | 1094 | | EditorGUILayout.Separator(); |
| 0 | 1095 | | } |
| | 1096 | |
|
| | 1097 | | void RenderVector2Field(string label, ref Vector2 value) |
| | 1098 | | { |
| 0 | 1099 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1100 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1101 | | value = EditorGUILayout.Vector2Field("", value, GUILayout.Width(200), GUILayout.ExpandWidth(false)); |
| 0 | 1102 | | GUILayout.EndHorizontal(); |
| 0 | 1103 | | EditorGUILayout.Separator(); |
| 0 | 1104 | | } |
| | 1105 | |
|
| | 1106 | | void RenderTexture(string label, ref Texture2D tex) |
| | 1107 | | { |
| 0 | 1108 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1109 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1110 | | tex = (Texture2D)EditorGUILayout.ObjectField(tex, typeof(Texture2D), false, GUILayout.Width(200)); |
| 0 | 1111 | | GUILayout.EndHorizontal(); |
| 0 | 1112 | | EditorGUILayout.Separator(); |
| 0 | 1113 | | } |
| | 1114 | |
|
| | 1115 | | void RenderCubemapTexture(string label, ref Cubemap tex) |
| | 1116 | | { |
| 0 | 1117 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1118 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1119 | | tex = (Cubemap)EditorGUILayout.ObjectField(tex, typeof(Cubemap), false, GUILayout.Width(200)); |
| 0 | 1120 | | GUILayout.EndHorizontal(); |
| 0 | 1121 | | EditorGUILayout.Separator(); |
| 0 | 1122 | | } |
| | 1123 | |
|
| | 1124 | | #endregion |
| | 1125 | |
|
| | 1126 | | #region Render Transitioning Variables |
| | 1127 | |
|
| | 1128 | | void RenderTransitioningVector3(List<TransitioningVector3> list, string label, string percentTxt, string valueTe |
| | 1129 | | { |
| 0 | 1130 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1131 | | EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| 0 | 1132 | | EditorGUILayout.BeginVertical(); |
| | 1133 | |
|
| 0 | 1134 | | if (list.Count == 0) |
| | 1135 | | { |
| 0 | 1136 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1137 | | { |
| 0 | 1138 | | Vector3 tLastPos = Vector3.zero; |
| 0 | 1139 | | if (list.Count != 0) |
| | 1140 | | { |
| 0 | 1141 | | tLastPos = list[list.Count - 1].value; |
| | 1142 | | } |
| 0 | 1143 | | list.Add(new TransitioningVector3(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100, |
| | 1144 | | } |
| | 1145 | | } |
| | 1146 | |
|
| 0 | 1147 | | for (int i = 0; i < list.Count; i++) |
| | 1148 | | { |
| 0 | 1149 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| | 1150 | |
|
| 0 | 1151 | | if (GUILayout.Button(">", GUILayout.ExpandWidth(false))) |
| | 1152 | | { |
| 0 | 1153 | | timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1 |
| | 1154 | | } |
| | 1155 | |
|
| | 1156 | | // Percentage |
| 0 | 1157 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 1158 | |
|
| 0 | 1159 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 1160 | |
|
| 0 | 1161 | | GUILayout.Space(10); |
| | 1162 | |
|
| 0 | 1163 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 1164 | |
|
| 0 | 1165 | | GUILayout.Space(10); |
| 0 | 1166 | | list[i].value = EditorGUILayout.Vector3Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi |
| | 1167 | |
|
| 0 | 1168 | | GUILayout.Space(20); |
| 0 | 1169 | | if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false))) |
| | 1170 | | { |
| 0 | 1171 | | list.RemoveAt(i); |
| | 1172 | | } |
| | 1173 | |
|
| 0 | 1174 | | if (i == (list.Count - 1)) |
| | 1175 | | { |
| 0 | 1176 | | GUILayout.Space(20); |
| 0 | 1177 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1178 | | { |
| 0 | 1179 | | Vector3 tLastPos = Vector3.zero; |
| 0 | 1180 | | if (list.Count != 0) |
| | 1181 | | { |
| 0 | 1182 | | tLastPos = list[list.Count - 1].value; |
| | 1183 | | } |
| 0 | 1184 | | list.Add(new TransitioningVector3(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * |
| | 1185 | | } |
| | 1186 | | } |
| | 1187 | |
|
| 0 | 1188 | | GUILayout.EndHorizontal(); |
| | 1189 | | } |
| | 1190 | |
|
| 0 | 1191 | | EditorGUILayout.EndVertical(); |
| 0 | 1192 | | GUILayout.EndHorizontal(); |
| | 1193 | |
|
| 0 | 1194 | | Rect lastRect = GUILayoutUtility.GetLastRect(); |
| 0 | 1195 | | lastRect.y -= 5; |
| 0 | 1196 | | lastRect.height += 10; |
| 0 | 1197 | | GUI.Box(lastRect, "", EditorStyles.helpBox); |
| 0 | 1198 | | } |
| | 1199 | |
|
| | 1200 | | void RenderTransitioningVector2(List<TransitioningVector2> list, string label, string percentTxt, string valueTe |
| | 1201 | | { |
| 0 | 1202 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1203 | | EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| 0 | 1204 | | EditorGUILayout.BeginVertical(); |
| | 1205 | |
|
| 0 | 1206 | | if (list.Count == 0) |
| | 1207 | | { |
| 0 | 1208 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1209 | | { |
| 0 | 1210 | | Vector2 tLastPos = Vector2.zero; |
| 0 | 1211 | | if (list.Count != 0) |
| | 1212 | | { |
| 0 | 1213 | | tLastPos = list[list.Count - 1].value; |
| | 1214 | | } |
| 0 | 1215 | | list.Add(new TransitioningVector2(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100, |
| | 1216 | | } |
| | 1217 | | } |
| | 1218 | |
|
| 0 | 1219 | | for (int i = 0; i < list.Count; i++) |
| | 1220 | | { |
| 0 | 1221 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| | 1222 | |
|
| 0 | 1223 | | if (GUILayout.Button(">", GUILayout.ExpandWidth(false))) |
| | 1224 | | { |
| 0 | 1225 | | timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1 |
| | 1226 | | } |
| | 1227 | |
|
| | 1228 | | // Percentage |
| 0 | 1229 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 1230 | |
|
| 0 | 1231 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 1232 | |
|
| 0 | 1233 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 1234 | |
|
| 0 | 1235 | | GUILayout.Space(10); |
| 0 | 1236 | | list[i].value = EditorGUILayout.Vector2Field("", list[i].value, GUILayout.Width(200), GUILayout.ExpandWi |
| | 1237 | |
|
| 0 | 1238 | | GUILayout.Space(20); |
| 0 | 1239 | | if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false))) |
| | 1240 | | { |
| 0 | 1241 | | list.RemoveAt(i); |
| | 1242 | | } |
| | 1243 | |
|
| 0 | 1244 | | if (i == (list.Count - 1)) |
| | 1245 | | { |
| 0 | 1246 | | GUILayout.Space(20); |
| 0 | 1247 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1248 | | { |
| 0 | 1249 | | Vector2 tLastPos = Vector2.zero; |
| 0 | 1250 | | if (list.Count != 0) |
| | 1251 | | { |
| 0 | 1252 | | tLastPos = list[list.Count - 1].value; |
| | 1253 | | } |
| 0 | 1254 | | list.Add(new TransitioningVector2(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * |
| | 1255 | | } |
| | 1256 | | } |
| | 1257 | |
|
| 0 | 1258 | | GUILayout.EndHorizontal(); |
| | 1259 | | } |
| | 1260 | |
|
| 0 | 1261 | | EditorGUILayout.EndVertical(); |
| 0 | 1262 | | GUILayout.EndHorizontal(); |
| | 1263 | |
|
| 0 | 1264 | | Rect lastRect = GUILayoutUtility.GetLastRect(); |
| 0 | 1265 | | lastRect.y -= 5; |
| 0 | 1266 | | lastRect.height += 10; |
| 0 | 1267 | | GUI.Box(lastRect, "", EditorStyles.helpBox); |
| 0 | 1268 | | } |
| | 1269 | |
|
| | 1270 | | void RenderTransitioningFloat(List<TransitioningFloat> list, string label, string percentTxt, string valueText, |
| | 1271 | | { |
| 0 | 1272 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1273 | | EditorGUILayout.LabelField(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| 0 | 1274 | | EditorGUILayout.BeginVertical(); |
| | 1275 | |
|
| 0 | 1276 | | if (list.Count == 0) |
| | 1277 | | { |
| 0 | 1278 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1279 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1280 | | { |
| 0 | 1281 | | float tLast = 0; |
| 0 | 1282 | | if (list.Count != 0) |
| | 1283 | | { |
| 0 | 1284 | | tLast = list[list.Count - 1].value; |
| | 1285 | | } |
| 0 | 1286 | | list.Add(new TransitioningFloat(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 100, t |
| | 1287 | | } |
| 0 | 1288 | | GUILayout.EndHorizontal(); |
| | 1289 | | } |
| | 1290 | |
|
| 0 | 1291 | | for (int i = 0; i < list.Count; i++) |
| | 1292 | | { |
| 0 | 1293 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| | 1294 | |
|
| 0 | 1295 | | GUILayout.Space(10); |
| 0 | 1296 | | if (GUILayout.Button(">", GUILayout.ExpandWidth(false))) |
| | 1297 | | { |
| 0 | 1298 | | timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1 |
| | 1299 | | } |
| 0 | 1300 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 1301 | |
|
| 0 | 1302 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 1303 | |
|
| 0 | 1304 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 1305 | |
|
| 0 | 1306 | | if (slider) |
| | 1307 | | { |
| 0 | 1308 | | list[i].value = EditorGUILayout.Slider(list[i].value, min, max, GUILayout.Width(200), GUILayout.Expa |
| 0 | 1309 | | } |
| | 1310 | | else |
| | 1311 | | { |
| 0 | 1312 | | list[i].value = EditorGUILayout.FloatField("", list[i].value, GUILayout.Width(200), GUILayout.Expand |
| | 1313 | | } |
| | 1314 | |
|
| | 1315 | |
|
| 0 | 1316 | | GUILayout.Space(20); |
| 0 | 1317 | | if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false))) |
| | 1318 | | { |
| 0 | 1319 | | list.RemoveAt(i); |
| | 1320 | | } |
| | 1321 | |
|
| 0 | 1322 | | if (i == (list.Count - 1)) |
| | 1323 | | { |
| 0 | 1324 | | GUILayout.Space(20); |
| 0 | 1325 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1326 | | { |
| 0 | 1327 | | float tLast = 0; |
| 0 | 1328 | | if (list.Count != 0) |
| | 1329 | | { |
| 0 | 1330 | | tLast = list[list.Count - 1].value; |
| | 1331 | | } |
| 0 | 1332 | | list.Add(new TransitioningFloat(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 10 |
| | 1333 | | } |
| | 1334 | | } |
| | 1335 | |
|
| 0 | 1336 | | GUILayout.EndHorizontal(); |
| | 1337 | | } |
| | 1338 | |
|
| 0 | 1339 | | EditorGUILayout.EndVertical(); |
| 0 | 1340 | | GUILayout.EndHorizontal(); |
| | 1341 | |
|
| 0 | 1342 | | Rect lastRect = GUILayoutUtility.GetLastRect(); |
| 0 | 1343 | | lastRect.y -= 5; |
| 0 | 1344 | | lastRect.height += 10; |
| 0 | 1345 | | GUI.Box(lastRect, "", EditorStyles.helpBox); |
| 0 | 1346 | | } |
| | 1347 | |
|
| | 1348 | | void RenderColorGradientField(Gradient color, string label = "color", float startTime = -1, float endTime = -1, |
| | 1349 | | { |
| 0 | 1350 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1351 | | EditorGUILayout.LabelField(label, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| | 1352 | |
|
| 0 | 1353 | | if (startTime != -1) |
| | 1354 | | { |
| 0 | 1355 | | EditorGUILayout.LabelField(startTime + "Hr", GUILayout.Width(65), GUILayout.ExpandWidth(false)); |
| | 1356 | | } |
| | 1357 | |
|
| 0 | 1358 | | color = EditorGUILayout.GradientField(new GUIContent(""), color, hdr, GUILayout.Width(250), GUILayout.Expand |
| | 1359 | |
|
| 0 | 1360 | | if (endTime != 1) |
| | 1361 | | { |
| 0 | 1362 | | EditorGUILayout.LabelField(endTime + "Hr", GUILayout.Width(65), GUILayout.ExpandWidth(false)); |
| | 1363 | | } |
| 0 | 1364 | | GUILayout.EndHorizontal(); |
| 0 | 1365 | | EditorGUILayout.Separator(); |
| 0 | 1366 | | } |
| | 1367 | |
|
| | 1368 | | void RenderTransitioningQuaternionAsVector3(List<TransitioningQuaternion> list, string label, string percentTxt, |
| | 1369 | | { |
| 0 | 1370 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1371 | | GUILayout.Label(label, GUILayout.Width(120), GUILayout.ExpandWidth(false)); |
| | 1372 | |
|
| 0 | 1373 | | GUILayout.BeginVertical(); |
| | 1374 | |
|
| 0 | 1375 | | if (list.Count == 0) |
| | 1376 | | { |
| 0 | 1377 | | GUILayout.BeginHorizontal(GUILayout.ExpandWidth(false)); |
| 0 | 1378 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1379 | | { |
| 0 | 1380 | | list.Add(new TransitioningQuaternion(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) * 1 |
| | 1381 | | } |
| 0 | 1382 | | GUILayout.EndHorizontal(); |
| | 1383 | | } |
| | 1384 | |
|
| 0 | 1385 | | for (int i = 0; i < list.Count; i++) |
| | 1386 | | { |
| 0 | 1387 | | GUILayout.BeginHorizontal(); |
| 0 | 1388 | | if (GUILayout.Button(">", GUILayout.ExpandWidth(false))) |
| | 1389 | | { |
| 0 | 1390 | | timeOfTheDay = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, list[i].percentage / 1 |
| | 1391 | | } |
| | 1392 | |
|
| 0 | 1393 | | GUILayout.Label(percentTxt, GUILayout.ExpandWidth(false)); |
| | 1394 | |
|
| 0 | 1395 | | RenderPercentagePart(layerStartTime, layerEndTime, ref list[i].percentage); |
| | 1396 | |
|
| 0 | 1397 | | GUILayout.Space(10); |
| | 1398 | |
|
| 0 | 1399 | | GUILayout.Label(valueText, GUILayout.ExpandWidth(false)); |
| | 1400 | |
|
| | 1401 | | // Convert Quaternion to Vector3 |
| 0 | 1402 | | list[i].value = Quaternion.Euler(EditorGUILayout.Vector3Field("", list[i].value.eulerAngles, GUILayout.E |
| | 1403 | |
|
| 0 | 1404 | | if (GUILayout.Button("Capture", GUILayout.Width(100), GUILayout.ExpandWidth(false))) |
| | 1405 | | { |
| 0 | 1406 | | selectedConfiguration.directionalLightLayer.lightDirection[i].percentage = GetNormalizedLayerCurrent |
| 0 | 1407 | | selectedConfiguration.directionalLightLayer.lightDirection[i].value = GetCurrentRotation(); |
| 0 | 1408 | | break; |
| | 1409 | | } |
| | 1410 | |
|
| 0 | 1411 | | if (GUILayout.Button("Remove", GUILayout.Width(100), GUILayout.ExpandWidth(false))) |
| | 1412 | | { |
| 0 | 1413 | | list.RemoveAt(i); |
| 0 | 1414 | | break; |
| | 1415 | | } |
| | 1416 | |
|
| 0 | 1417 | | if (i == (list.Count - 1)) |
| | 1418 | | { |
| 0 | 1419 | | GUILayout.Space(20); |
| 0 | 1420 | | if (GUILayout.Button("+", GUILayout.Width(20), GUILayout.ExpandWidth(false))) |
| | 1421 | | { |
| 0 | 1422 | | list.Add(new TransitioningQuaternion(GetNormalizedLayerCurrentTime(layerStartTime, layerEndTime) |
| | 1423 | | } |
| | 1424 | | } |
| | 1425 | |
|
| 0 | 1426 | | GUILayout.EndHorizontal(); |
| | 1427 | | } |
| 0 | 1428 | | GUILayout.EndVertical(); |
| 0 | 1429 | | GUILayout.EndHorizontal(); |
| | 1430 | |
|
| 0 | 1431 | | Rect lastRect = GUILayoutUtility.GetLastRect(); |
| 0 | 1432 | | lastRect.y -= 5; |
| 0 | 1433 | | lastRect.height += 10; |
| 0 | 1434 | | GUI.Box(lastRect, "", EditorStyles.helpBox); |
| 0 | 1435 | | } |
| | 1436 | |
|
| | 1437 | | void RenderPercentagePart(float layerStartTime, float layerEndTime, ref float percentage) |
| | 1438 | | { |
| 0 | 1439 | | GUILayout.Label(layerStartTime + "Hr", GUILayout.Width(35), GUILayout.ExpandWidth(false)); |
| | 1440 | |
|
| 0 | 1441 | | GUILayout.BeginVertical(percentagePartStyle, GUILayout.ExpandWidth(false), GUILayout.Width(150)); |
| 0 | 1442 | | float time = GetDayTimeForLayerNormalizedTime(layerStartTime, layerEndTime, percentage / 100); |
| 0 | 1443 | | GUILayout.Label(time.ToString("f2") + " Hr", GUILayout.ExpandWidth(false)); |
| 0 | 1444 | | percentage = EditorGUILayout.Slider(percentage, 0, 100, GUILayout.Width(150), GUILayout.ExpandWidth(false)); |
| 0 | 1445 | | GUILayout.EndVertical(); |
| | 1446 | |
|
| 0 | 1447 | | GUILayout.Label(layerEndTime + "Hr", GUILayout.Width(35), GUILayout.ExpandWidth(false)); |
| 0 | 1448 | | } |
| | 1449 | |
|
| | 1450 | | #endregion |
| | 1451 | |
|
| | 1452 | | private void ApplyOnMaterial() |
| | 1453 | | { |
| 0 | 1454 | | EnsureDependencies(); |
| 0 | 1455 | | selectedConfiguration.ApplyOnMaterial(selectedMat, timeOfTheDay, GetNormalizedDayTime(), matLayer.numberOfSl |
| | 1456 | |
|
| | 1457 | | // If in play mode, call avatar color from skybox controller class |
| 0 | 1458 | | if (Application.isPlaying && SkyboxController.i != null) |
| | 1459 | | { |
| 0 | 1460 | | SkyboxController.i.ApplyAvatarColor(GetNormalizedDayTime()); |
| | 1461 | | } |
| 0 | 1462 | | } |
| | 1463 | |
|
| | 1464 | | private float GetNormalizedDayTime() |
| | 1465 | | { |
| | 1466 | | float tTime = 0; |
| 0 | 1467 | | tTime = timeOfTheDay / 24; |
| 0 | 1468 | | tTime = Mathf.Clamp(tTime, 0, 1); |
| 0 | 1469 | | return tTime; |
| | 1470 | | } |
| | 1471 | |
|
| | 1472 | | private float GetNormalizedLayerCurrentTime(float startTime, float endTime) |
| | 1473 | | { |
| 0 | 1474 | | float editedEndTime = endTime; |
| 0 | 1475 | | float editedDayTime = timeOfTheDay; |
| 0 | 1476 | | if (endTime < startTime) |
| | 1477 | | { |
| 0 | 1478 | | editedEndTime = 24 + endTime; |
| 0 | 1479 | | if (timeOfTheDay < startTime) |
| | 1480 | | { |
| 0 | 1481 | | editedDayTime = 24 + timeOfTheDay; |
| | 1482 | | } |
| | 1483 | | } |
| 0 | 1484 | | return Mathf.InverseLerp(startTime, editedEndTime, editedDayTime); |
| | 1485 | | } |
| | 1486 | |
|
| | 1487 | | private float GetDayTimeForLayerNormalizedTime(float startTime, float endTime, float normalizeTime) |
| | 1488 | | { |
| 0 | 1489 | | float editedEndTime = endTime; |
| 0 | 1490 | | if (endTime < startTime) |
| | 1491 | | { |
| 0 | 1492 | | editedEndTime = 24 + endTime; |
| | 1493 | | } |
| 0 | 1494 | | float time = Mathf.Lerp(startTime, editedEndTime, normalizeTime); |
| | 1495 | |
|
| 0 | 1496 | | if (time > 24) |
| | 1497 | | { |
| 0 | 1498 | | time -= 24; |
| | 1499 | | } |
| | 1500 | |
|
| 0 | 1501 | | return time; |
| | 1502 | | } |
| | 1503 | |
|
| 0 | 1504 | | private void ClampToDayTime(ref float value) { value = Mathf.Clamp(value, 0, 24); } |
| | 1505 | | } |
| | 1506 | |
|
| | 1507 | | } |