在游戏中新建一个bg1,调整camera到合适的位置
再复制一个bg2放到bg1的上方,位置根据图片的像素决定,因为pixels pre unit是100,所以例如图片的高是852像素,换算到unity里就算8.52,所以bg2的y设为8.52


最后写一个脚本用来控制bg移动
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BgLoop : MonoBehaviour
{
public static float moveSpeed = 2f;
// Update is called once per frame
void Update ()
{
this.transform.Translate (Vector3.down * moveSpeed * Time.deltaTime);
Vector3 postion = this.transform.position;
if (postion.y <= -8.52f) {
this.transform.position = new Vector3 (postion.x, postion.y + 8.52f * 2, postion.z);
}
}
}
将脚本挂在bg1和bg2上就ok了!
效果如下:



请问你试过速度快的情况下,bg1移动到bg2后面的时候,瞬间有缝隙的问题么?请问怎么解决?