SwitchAd.cs 478 B

123456789101112131415161718192021222324252627
  1. using UnityEngine;
  2. using System.Collections;
  3. public class SwitchAd : MonoBehaviour
  4. {
  5. public MeshRenderer Renderer;
  6. public Material[] Materials;
  7. private static int id = 0;
  8. private static void Next()
  9. {
  10. id++;
  11. if (id>5)
  12. {
  13. id = 0;
  14. }
  15. }
  16. // Use this for initialization
  17. private void OnEnable()
  18. {
  19. Renderer.sharedMaterial = Materials[id];
  20. Next();
  21. // Debug.Log("change");
  22. }
  23. }