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