效果如上
将图片 WarpMode 格式设置为 Repeat后 通过代码控制 图片的uvRect就能实现
代码如下
public class Test : MonoBehaviour {
public RawImage image;
public float imgefill = 0;
public float nowtime = 0;
public float delay = 0.1f;
public float a = -1f;
public void Update()
{
if (nowtime+ delay < Time.time)
{
imgefill+=a;
if(imgefill>1){
imgefill = 0;
}
if(imgefill<-1){
imgefill = 0;
}
image.uvRect =new Rect(imgefill,0,1,1);
nowtime = Time.time;
}
}
}