unity 2D 游戏背景无线循环简单使用

注意的地方:

贴图格式(Texture type): Texture

wrap Mode::Clamp

using UnityEngine;
using System.Collections;
public class BG : MonoBehaviour {
 public float BGSpeed;//设置背景速度
 private Material BGMaterial;
 // Use this for initialization
 void Start () 
 {
  //this.BGMaterial = renderer.material;//找到当前的材质
    this.BGMateral = GetComponent().material;
 }  
 // Update is called once per frame
 void Update ()
 { 
 //材质循环
  this.BGMaterial.mainTextureOffset = new Vector2(BGSpeed*Time.time,0);
 }
}

你可能感兴趣的:(简单使用)