using UnityEngine; using System.Collections; /// <summary> /// 2d背景循环滚动 /// </summary> public class Test : MonoBehaviour { public float xScrollSpeed=0.1f; public float yScrollSpeed=0f; void Update() { float offsetX = Time.time * xScrollSpeed; float offsetY = Time.time * yScrollSpeed; renderer.material.SetTextureOffset("_MainTex", new Vector2(offsetX, offsetY)); } }
时间: 2024-10-12 11:49:25