10183人加入学习
(109人评价)
UGUI整体解决方案-基础篇(Unity 2019.1.0f2)

2019-06-01

价格 免费

private RawImage rimag;

private float offsetX;

private float offsetY;   //增量

rimage.uvRect = new Rect();

offsetY = 1/0.4f

 

 

[展开全文]
public class RawImageAni : MonoBehaviour {

    private RawImage _rawImage;
    private float _offsetX;
    private float _offsetY;
	// Use this for initialization
	void Start () {
        _rawImage = GetComponent<RawImage>();
        _offsetX = 1 / 4.0f;
        _offsetY = 1 / 2.0f;
        StartCoroutine(Ani());
	}

    private IEnumerator Ani()
    {
        float x = 0;
        float y = 0;
        while (true) {
            y += _offsetY;
            while (true) {
                x += _offsetX;
                _rawImage.uvRect = new Rect(x, y, _rawImage.uvRect.height,_rawImage.uvRect.width);
                yield return new WaitForSeconds(0.3f);
            }
        }
    }
	// Update is called once per frame
	void Update () {
		
	}
}

 

[展开全文]

授课教师

课程特色

视频(61)
下载资料(1)