使用RawImage更改UV实现循环播放画面

需要实现的是波形图

 

需要先更改波形图片设置 Wrap Mode为Repeat模式

 

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class offectuv : MonoBehaviour {


    float x ;
    public float speed=0.01f;
    public RawImage myRaw;
    void Start ()
    {
        x = myRaw.uvRect.x;
    }
    // Update is called once per frame
    void Update()
    {
        if (x <= -1f)
        {
            x = 0;
            x = x - speed;
        }
        else
        {
            x = x - speed;
        }
        myRaw.uvRect = new Rect(x, 0, 1, 1);
    }
}

 

posted @ 2021-09-18 12:04  昭1122  阅读(233)  评论(0编辑  收藏  举报