MaterialOps.cs 832 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. namespace SoftMasking.Extensions {
  3. public static class MaterialOps {
  4. public static bool SupportsSoftMask(this Material mat) {
  5. return mat.HasProperty("_SoftMask");
  6. }
  7. public static bool HasDefaultUIShader(this Material mat) {
  8. return mat.shader == Canvas.GetDefaultCanvasMaterial().shader;
  9. }
  10. #if UNITY_5_4_OR_NEWER
  11. public static bool HasDefaultETC1UIShader(this Material mat) {
  12. return mat.shader == Canvas.GetETC1SupportedCanvasMaterial().shader;
  13. }
  14. #endif
  15. public static void EnableKeyword(this Material mat, string keyword, bool enabled) {
  16. if (enabled)
  17. mat.EnableKeyword(keyword);
  18. else
  19. mat.DisableKeyword(keyword);
  20. }
  21. }
  22. }