LayaSkyboxProceduralShaderGUI.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Unity C# reference source
  2. // Copyright (c) Unity Technologies. For terms of use, see
  3. // https://unity3d.com/legal/licenses/Unity_Reference_Only_License
  4. using System;
  5. using UnityEditor;
  6. using UnityEngine;
  7. class LayaSkyboxProceduralShaderGUI : ShaderGUI
  8. {
  9. private enum SunDiskMode
  10. {
  11. None,
  12. Simple,
  13. HighQuality
  14. }
  15. public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)
  16. {
  17. materialEditor.SetDefaultGUIWidths();
  18. MaterialProperty sunDiskModeProp = FindProperty("sunDisk", props);
  19. SunDiskMode sunDiskMode = (SunDiskMode)sunDiskModeProp.floatValue;
  20. for (var i = 0; i < props.Length; i++)
  21. {
  22. if ((props[i].flags & (MaterialProperty.PropFlags.HideInInspector | MaterialProperty.PropFlags.PerRendererData)) != 0)
  23. continue;
  24. //sunSizeConvergence is only used with the HighQuality sun disk.
  25. if ((props[i].name == "sunSizeConvergence") && (sunDiskMode != SunDiskMode.HighQuality))
  26. continue;
  27. float h = materialEditor.GetPropertyHeight(props[i], props[i].displayName);
  28. Rect r = EditorGUILayout.GetControlRect(true, h, EditorStyles.layerMaskField);
  29. materialEditor.ShaderProperty(r, props[i], props[i].displayName);
  30. }
  31. }
  32. }