12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System;
- using UnityEngine;
- public class CalendarTexture : MonoBehaviour
- {
- public void Start()
- {
- this.Init();
- }
- public virtual void Init()
- {
- if (this.Year == 0)
- {
- this.Year = 2017;
- }
- DateTime now = DateTime.Now;
- if (now.Year != this.Year)
- {
- this.SetFrontPage();
- }
- else
- {
- this.SetPage(now.Month);
- }
- }
- public void SetFrontPage()
- {
- if (this.TargetMaterial == null || this.FrontPage == null)
- {
- return;
- }
- this.TargetMaterial.mainTexture = this.FrontPage;
- }
- public void SetPage(int month)
- {
- if (1 > month || month > 12 || this.TargetMaterial == null)
- {
- return;
- }
- Texture[] array = new Texture[]
- {
- this.January,
- this.February,
- this.March,
- this.April,
- this.May,
- this.June,
- this.July,
- this.August,
- this.September,
- this.October,
- this.November,
- this.December
- };
- if (array[month - 1] == null)
- {
- return;
- }
- this.TargetMaterial.mainTexture = array[month - 1];
- }
- public int Year;
- public Material TargetMaterial;
- public Texture FrontPage;
- public Texture January;
- public Texture February;
- public Texture March;
- public Texture April;
- public Texture May;
- public Texture June;
- public Texture July;
- public Texture August;
- public Texture September;
- public Texture October;
- public Texture November;
- public Texture December;
- }
|