1.首先创建UI RawImage
2.图片设置
3.效果
4.代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FilmMove : MonoBehaviour
{
//速度
public float m_speedmove;
private RawImage m_RawImage;
// Use this for initialization
void Start () {
m_RawImage = this.GetComponent<RawImage>();
}
// Update is called once per frame
void Update () {
float s =this.m_speedmove * Time.deltaTime;
Rect r =this.m_RawImage.uvRect;
//改变x或y,来改变图片的移动方向
r.y += s;
this.m_RawImage.uvRect = r;
}
//上下交替实现无缝连接
// public float m_MoveSpeed = 1;
// // Start is called before the first frame update
// void Start()
// {
//
// }
//
// // Update is called once per frame
// void Update()
// {
// transform.Translate(0,m_MoveSpeed*Time.deltaTime*100,0);
// if (transform.position.y >= 2880)
// {
// transform.localPosition=new Vector3(0,-1915,0);
// }
// }
}