[Unity3D]C#切换plane上的图片

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 
 5 public class Test : MonoBehaviour
 6 {
 7     public Texture[] InputPNG;
 8     private int pngIndex;
 9     // Start is called before the first frame update
10     void Start()
11     {
12         pngIndex = 0;
13         this.GetComponent<Renderer>().material.mainTexture = InputPNG[0];
14         InvokeRepeating("ChangePng", 0.03f, 0.03f);
15     }
16 
17     // Update is called once per frame
18     void Update()
19     {
20 
21     }
22     private void ChangePng()
23     {
24         if (pngIndex == InputPNG.Length - 1)
25         {
26             //CancelInvoke();
27             pngIndex = 0;
28         }
29         else
30         {
31             this.GetComponent<Renderer>().material.mainTexture = InputPNG[pngIndex];
32             pngIndex++;
33         }
34     }
35 }

 

posted @ 2021-07-09 15:45  锤子猫  阅读(375)  评论(2编辑  收藏  举报