unity材质球贴图滚动


   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;
    }

}
 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM