EditorUtils.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.Rendering;
  4. namespace UnityEditor.Rendering.Universal.Internal
  5. {
  6. /// <summary>
  7. /// Contains a database of built-in resource GUIds. These are used to load built-in resource files.
  8. /// </summary>
  9. public static class ResourceGuid
  10. {
  11. /// <summary>
  12. /// GUId for the <c>ScriptableRendererFeature</c> template file.
  13. /// </summary>
  14. public static readonly string rendererTemplate = "51493ed8d97d3c24b94c6cffe834630b";
  15. }
  16. }
  17. namespace UnityEditor.Rendering.Universal
  18. {
  19. static class EditorUtils
  20. {
  21. // Each group is separate in the menu by a menu bar
  22. public const int lwrpAssetCreateMenuPriorityGroup1 = CoreUtils.assetCreateMenuPriority1;
  23. public const int lwrpAssetCreateMenuPriorityGroup2 = CoreUtils.assetCreateMenuPriority1 + 50;
  24. public const int lwrpAssetCreateMenuPriorityGroup3 = lwrpAssetCreateMenuPriorityGroup2 + 50;
  25. internal class Styles
  26. {
  27. //Measurements
  28. public static float defaultLineSpace = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  29. public static float defaultIndentWidth = 12;
  30. }
  31. public static void DrawCascadeSplitGUI<T>(ref SerializedProperty shadowCascadeSplit)
  32. {
  33. float[] cascadePartitionSizes = null;
  34. Type type = typeof(T);
  35. if (type == typeof(float))
  36. {
  37. cascadePartitionSizes = new float[] { shadowCascadeSplit.floatValue };
  38. }
  39. else if (type == typeof(Vector3))
  40. {
  41. Vector3 splits = shadowCascadeSplit.vector3Value;
  42. cascadePartitionSizes = new float[]
  43. {
  44. Mathf.Clamp(splits[0], 0.0f, 1.0f),
  45. Mathf.Clamp(splits[1] - splits[0], 0.0f, 1.0f),
  46. Mathf.Clamp(splits[2] - splits[1], 0.0f, 1.0f)
  47. };
  48. }
  49. if (cascadePartitionSizes != null)
  50. {
  51. EditorGUI.BeginChangeCheck();
  52. ShadowCascadeSplitGUI.HandleCascadeSliderGUI(ref cascadePartitionSizes);
  53. if (EditorGUI.EndChangeCheck())
  54. {
  55. if (type == typeof(float))
  56. shadowCascadeSplit.floatValue = cascadePartitionSizes[0];
  57. else
  58. {
  59. Vector3 updatedValue = new Vector3();
  60. updatedValue[0] = cascadePartitionSizes[0];
  61. updatedValue[1] = updatedValue[0] + cascadePartitionSizes[1];
  62. updatedValue[2] = updatedValue[1] + cascadePartitionSizes[2];
  63. shadowCascadeSplit.vector3Value = updatedValue;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }