通用物体旋转脚本

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);
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,458评论 0 10
  • 人的心很小,能分出来的位置很有限,如果她的身边有了关系好的人,那么以前高中的朋友,就会渐渐地被她从心里无意识地赶出去
    b7e9c7e1657a阅读 291评论 0 0
  • 看到这张图片的第一眼,就特别喜欢。 然后想起很久以前去四川,刚下车就看到满田的麦穗,心里欢喜的不得了,同样因为麦穗...
    青蓝0601阅读 228评论 1 1