美文网首页
通用物体旋转脚本

通用物体旋转脚本

作者: 小黑Unity_齐xc | 来源:发表于2018-09-03 12:18 被阅读10次
using UnityEngine;
using System.Collections;

/// <summary>
/// Simple class to scroll the UVs across a model
/// </summary>
public class UVScroller : MonoBehaviour 
{
    [Tooltip("Speed to scroll in the X direction")]
    public float xSpeed = 1.0f;//
    [Tooltip("Speed to scroll in the Y direction")]
    public float ySpeed = 0.0f;

    private float x = 0.0f;
    private float y = 0.0f;
    private Material material;

    void Start()
    {
        material = GetComponent<Renderer>().material;
    }

    void Update () 
    {
        // update our uv offset values
        x = Mathf.Repeat(x + Time.deltaTime * xSpeed, 1.0f);
        y = Mathf.Repeat(y + Time.deltaTime * ySpeed, 1.0f);

        // set the offset on the material
        material.mainTextureOffset = new Vector2(x,y);
    }
}

相关文章

网友评论

      本文标题:通用物体旋转脚本

      本文链接:https://www.haomeiwen.com/subject/viubwftx.html