码迷,mamicode.com
首页 > 其他好文 > 详细

u3d changeTexs

时间:2014-10-08 13:59:35      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   ar   for   sp   div   art   

using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class CTex : MonoBehaviour 
{
    public List<Texture2D> tx1;
    public int mfps;
    private float m_OldTime;
    private float m_DelTime;
    private int m_NowTex;
    // Use this for initialization
    void Start ()
    {
        m_DelTime = 1.0f / mfps;
        m_OldTime = Time.time;
        m_NowTex = 0;
       
    }
    
    // Update is called once per frame
    void Update ()
    {
        float NowTime = Time.time;
       // Debug.Log("Time.time:"+ NowTime);

        if (NowTime - m_OldTime >m_DelTime)
        {

            Debug.Log("NowTex:"+ m_NowTex);
            this.renderer.material.mainTexture = tx1[m_NowTex];
            m_NowTex++;
            m_OldTime = NowTime;

            if (m_NowTex >= tx1.Count)
                m_NowTex = 0;
        }

        
    }
}

list是要播放的图片序列,mfps是帧率,越大图片播放的越快,越小越慢

Time.time得到的是游戏开始运行到现在的运行时间长度,单位是秒

u3d changeTexs

标签:style   blog   color   io   ar   for   sp   div   art   

原文地址:http://www.cnblogs.com/dragon2012/p/4010713.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!