Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using UnityEditor.Rendering.Universal.ShaderGraph;
  2. using UnityEngine;
  3. using UnityEngine.Rendering;
  4. using static Unity.Rendering.Universal.ShaderUtils;
  5. namespace UnityEditor
  6. {
  7. // Used for ShaderGraph Lit shaders
  8. class SixWayGUI : ShaderGraphLitGUI
  9. {
  10. private MaterialProperty useColorAbsorption;
  11. /// <summary>
  12. /// Container for the text and tooltips used to display the shader.
  13. /// </summary>
  14. protected class SixWayStyles
  15. {
  16. // Categories
  17. /// <summary>
  18. /// The text and tooltip for the surface options GUI.
  19. /// </summary>
  20. public static readonly GUIContent UseColorAbsorptionText =
  21. EditorGUIUtility.TrTextContent("Use Color Absorption", "When enabled, the lightmaps are used to simulate color absorption whose strength can be tuned with the Absorption Strength parameter.");
  22. }
  23. // collect properties from the material properties
  24. public override void FindProperties(MaterialProperty[] properties)
  25. {
  26. base.FindProperties(properties);
  27. useColorAbsorption = FindProperty(UniversalSixWaySubTarget.SixWayProperties.UseColorAbsorption, properties, false);
  28. }
  29. public override void DrawSurfaceOptions(Material material)
  30. {
  31. base.DrawSurfaceOptions(material);
  32. if(useColorAbsorption != null)
  33. materialEditor.ShaderProperty(useColorAbsorption, SixWayStyles.UseColorAbsorptionText);
  34. }
  35. public static void UpdateSixWayKeywords(Material material)
  36. {
  37. bool useColorAbsorptionValue = false;
  38. if (material.HasProperty(UniversalSixWaySubTarget.SixWayProperties.UseColorAbsorption))
  39. useColorAbsorptionValue = material.GetFloat(UniversalSixWaySubTarget.SixWayProperties.UseColorAbsorption) > 0.0f;
  40. CoreUtils.SetKeyword(material, "_SIX_WAY_COLOR_ABSORPTION", useColorAbsorptionValue);
  41. }
  42. public override void ValidateMaterial(Material material)
  43. {
  44. base.ValidateMaterial(material);
  45. UpdateSixWayKeywords(material);
  46. }
  47. }
  48. } // namespace UnityEditor