using System.Collections;
using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBehaviour { //滚动速度 public float HorSpeed = 1.0f; public float VerSpeed = 1.0f; //Offset偏移量 //水平滚动Offset.y public float HorMin = 1.0f; public float HorMax = 2.0f; //垂直滚动Offset.x public float VerMin = 1.0f; public float VerMax = 2.0f; //渲染器 MeshRenderer MeshR ; private void Awake() { //获得渲染器 MeshR = GetComponent<MeshRenderer>(); } private void Update() { Vector2 Offset = new Vector2( (MeshR.material.mainTextureOffset.x > HorMax) ? HorMin : MeshR.material.mainTextureOffset.x + Time.deltaTime * HorSpeed, (MeshR.material.mainTextureOffset.y > VerMax) ? VerMin : MeshR.material.mainTextureOffset.y + Time.deltaTime * VerSpeed ); MeshR.material.mainTextureOffset = Offset; } }