CalendarTexture.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using UnityEngine;
  3. public class CalendarTexture : MonoBehaviour
  4. {
  5. public void Start()
  6. {
  7. this.Init();
  8. }
  9. public virtual void Init()
  10. {
  11. if (this.Year == 0)
  12. {
  13. this.Year = 2017;
  14. }
  15. DateTime now = DateTime.Now;
  16. if (now.Year != this.Year)
  17. {
  18. this.SetFrontPage();
  19. }
  20. else
  21. {
  22. this.SetPage(now.Month);
  23. }
  24. }
  25. public void SetFrontPage()
  26. {
  27. if (this.TargetMaterial == null || this.FrontPage == null)
  28. {
  29. return;
  30. }
  31. this.TargetMaterial.mainTexture = this.FrontPage;
  32. }
  33. public void SetPage(int month)
  34. {
  35. if (1 > month || month > 12 || this.TargetMaterial == null)
  36. {
  37. return;
  38. }
  39. Texture[] array = new Texture[]
  40. {
  41. this.January,
  42. this.February,
  43. this.March,
  44. this.April,
  45. this.May,
  46. this.June,
  47. this.July,
  48. this.August,
  49. this.September,
  50. this.October,
  51. this.November,
  52. this.December
  53. };
  54. if (array[month - 1] == null)
  55. {
  56. return;
  57. }
  58. this.TargetMaterial.mainTexture = array[month - 1];
  59. }
  60. public int Year;
  61. public Material TargetMaterial;
  62. public Texture FrontPage;
  63. public Texture January;
  64. public Texture February;
  65. public Texture March;
  66. public Texture April;
  67. public Texture May;
  68. public Texture June;
  69. public Texture July;
  70. public Texture August;
  71. public Texture September;
  72. public Texture October;
  73. public Texture November;
  74. public Texture December;
  75. }