ShaderConfig.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using UnityEngine;
  2. namespace FairyGUI
  3. {
  4. /// <summary>
  5. ///
  6. /// </summary>
  7. public static class ShaderConfig
  8. {
  9. /// <summary>
  10. ///
  11. /// </summary>
  12. /// <param name="name"></param>
  13. /// <returns></returns>
  14. public delegate Shader GetFunction(string name);
  15. /// <summary>
  16. ///
  17. /// </summary>
  18. public static GetFunction Get = Shader.Find;
  19. /// <summary>
  20. ///
  21. /// </summary>
  22. public static string imageShader = "FairyGUI/Image";
  23. /// <summary>
  24. ///
  25. /// </summary>
  26. public static string textShader = "FairyGUI/Text";
  27. /// <summary>
  28. ///
  29. /// </summary>
  30. public static string bmFontShader = "FairyGUI/BMFont";
  31. /// <summary>
  32. ///
  33. /// </summary>
  34. public static string TMPFontShader = "FairyGUI/TMP";
  35. public static int ID_ClipBox;
  36. public static int ID_ClipSoftness;
  37. public static int ID_AlphaTex;
  38. public static int ID_StencilComp;
  39. public static int ID_Stencil;
  40. public static int ID_StencilOp;
  41. public static int ID_StencilReadMask;
  42. public static int ID_ColorMask;
  43. public static int ID_ColorMatrix;
  44. public static int ID_ColorOffset;
  45. public static int ID_BlendSrcFactor;
  46. public static int ID_BlendDstFactor;
  47. public static int ID_ColorOption;
  48. public static int ID_Stencil2;
  49. static ShaderConfig()
  50. {
  51. ID_ClipBox = Shader.PropertyToID("_ClipBox");
  52. ID_ClipSoftness = Shader.PropertyToID("_ClipSoftness");
  53. ID_AlphaTex = Shader.PropertyToID("_AlphaTex");
  54. ID_StencilComp = Shader.PropertyToID("_StencilComp");
  55. ID_Stencil = Shader.PropertyToID("_Stencil");
  56. ID_StencilOp = Shader.PropertyToID("_StencilOp");
  57. ID_StencilReadMask = Shader.PropertyToID("_StencilReadMask");
  58. ID_ColorMask = Shader.PropertyToID("_ColorMask");
  59. ID_ColorMatrix = Shader.PropertyToID("_ColorMatrix");
  60. ID_ColorOffset = Shader.PropertyToID("_ColorOffset");
  61. ID_BlendSrcFactor = Shader.PropertyToID("_BlendSrcFactor");
  62. ID_BlendDstFactor = Shader.PropertyToID("_BlendDstFactor");
  63. ID_ColorOption = Shader.PropertyToID("_ColorOption");
  64. ID_Stencil2 = Shader.PropertyToID("_StencilRef");
  65. }
  66. /// <summary>
  67. ///
  68. /// </summary>
  69. /// <param name="name"></param>
  70. /// <returns></returns>
  71. public static Shader GetShader(string name)
  72. {
  73. Shader shader = Get(name);
  74. if (shader == null)
  75. {
  76. Debug.LogWarning("FairyGUI: shader not found: " + name);
  77. shader = Shader.Find("UI/Default");
  78. }
  79. shader.hideFlags = DisplayObject.hideFlags;
  80. return shader;
  81. }
  82. }
  83. }