You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.0 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. namespace TMPro
  4. {
  5. public enum ColorMode
  6. {
  7. Single,
  8. HorizontalGradient,
  9. VerticalGradient,
  10. FourCornersGradient
  11. }
  12. [System.Serializable]
  13. public class TMP_ColorGradient : ScriptableObject
  14. {
  15. public ColorMode colorMode = ColorMode.FourCornersGradient;
  16. public Color topLeft;
  17. public Color topRight;
  18. public Color bottomLeft;
  19. public Color bottomRight;
  20. const ColorMode k_DefaultColorMode = ColorMode.FourCornersGradient;
  21. static readonly Color k_DefaultColor = Color.white;
  22. /// <summary>
  23. /// Default Constructor which sets each of the colors as white.
  24. /// </summary>
  25. public TMP_ColorGradient()
  26. {
  27. colorMode = k_DefaultColorMode;
  28. topLeft = k_DefaultColor;
  29. topRight = k_DefaultColor;
  30. bottomLeft = k_DefaultColor;
  31. bottomRight = k_DefaultColor;
  32. }
  33. /// <summary>
  34. /// Constructor allowing to set the default color of the Color Gradient.
  35. /// </summary>
  36. /// <param name="color"></param>
  37. public TMP_ColorGradient(Color color)
  38. {
  39. colorMode = k_DefaultColorMode;
  40. topLeft = color;
  41. topRight = color;
  42. bottomLeft = color;
  43. bottomRight = color;
  44. }
  45. /// <summary>
  46. /// The vertex colors at the corners of the characters.
  47. /// </summary>
  48. /// <param name="color0">Top left color.</param>
  49. /// <param name="color1">Top right color.</param>
  50. /// <param name="color2">Bottom left color.</param>
  51. /// <param name="color3">Bottom right color.</param>
  52. public TMP_ColorGradient(Color color0, Color color1, Color color2, Color color3)
  53. {
  54. colorMode = k_DefaultColorMode;
  55. this.topLeft = color0;
  56. this.topRight = color1;
  57. this.bottomLeft = color2;
  58. this.bottomRight = color3;
  59. }
  60. }
  61. }