上一篇使用的是静态方式进行的加载,采用的数据结构为 数组

该篇文章则是使用动态加载的方式实现:

this.objsOfRouses = Resources.LoadAll("images",typeof(Texture));

该方法会安排图片在文件在顺序进行加载。

如图:

加载顺序如下:

using UnityEngine;

using System.Collections;

public class imageAnimation : MonoBehaviour {
//
private Object[] objsOfRouses;

private Texture2D[] texturesLoaded;

private Material materialOfPanel;

private int frameCounter =0;

public float delayTime =0.5f;

private float currentTime=0.0f;
private float endTime =0.0f;

public GameObject dongWu;
void Awake()
{
//get the material of this panel
this.materialOfPanel = this.renderer.material;

}

// Use this for initialization
void Start () 
{
//set the starting time
currentTime =Time.time;//0.0s
//get images form the Resourse floder
//the return value is object
this.objsOfRouses = Resources.LoadAll("images",typeof(Texture));
int theLength =objsOfRouses.Length;

//put the images into material arrary 
texturesLoaded =new Texture2D[theLength];
for (int i=0; i<theLength; i++)
{
this.texturesLoaded[i] =(Texture2D)this.objsOfRouses[i];
Debug.Log("the image'name is -->"+this.texturesLoaded[i].name);
}
}
 
// Update is called once per frame
void Update () {
 
changePic();

}

//
void changePic(){
endTime = Time.time;
float timeOffset = endTime - currentTime;
if (timeOffset>0.3){
if (this.frameCounter<this.objsOfRouses.Length){
this.materialOfPanel.mainTexture = texturesLoaded[frameCounter];
++frameCounter;
}else{
frameCounter=0;
this.materialOfPanel.mainTexture = texturesLoaded[frameCounter];
}
//when changge one image,get the new time
currentTime =Time.time;
}

}

}

最后效果如下:

unity3d 幻灯片效果实现的更多相关文章

  1. Codrops 教程:实现内容倾斜的 3D 幻灯片效果

    今天给大家分享的优秀教程来自 Codrops 网站,实现一个内容倾斜的 3D 幻灯片效果.我们平常见到的都是那种水平或者垂直滚动的效果,这个倾斜的内容滑动效果相信会让你眼前一亮.因为使用了 CSS 3 ...

  2. 【jquery】幻灯片效果

    闲着无聊,用Jquery写了一个幻灯片效果. 我这人喜欢造轮子,除了jquery这种有强大开发团队的框架级别JS,其实的一些小程序都是尽量自己写. 一是因为怕出问题了没人问,二是自己写的改起来也方便. ...

  3. bxSlider 在网页里添加幻灯片效果

    幻灯片效果在网页上很常见,本文介绍用 bxSlider 轻松实现的方法. bxSlider是什么 bxSlider 是用 JQuery 和 CSS 实现网页中幻灯片效果的工具.可在 http://bx ...

  4. css+js 控制幻灯片效果

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  5. 使用CSS实现一个简单的幻灯片效果

    方法一: 简单的CSS代码实现幻灯片效果 方法二: 使用CSS3 Animation来制作幻灯片 方法一: 简单的CSS代码实现幻灯片效果 话不多说,直接上代码 <!DOCTYPE html&g ...

  6. javascript - 图片的幻灯片效果

    javascript 代码: <script type="text/javascript"> function select_play() { var select_p ...

  7. 纯css实现幻灯片效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...

  8. 一个很好的幻灯片效果的jquery插件--kinMaxShow

    在做一些网站时,或多或少的要给网站做幻灯片效果,以前每次做这个效果,都是现成带网上找,找到的很多很杂,而且用完后就不会再理会更加不会去总结代码. 无意中找到了kinMaxShow这个插件,机会满足了我 ...

  9. jquery特效 幻灯片效果

    jquery特效 幻灯片效果,效果图如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Cont ...

随机推荐

  1. Linux内核之mmc子系统-sdio

    现在的Linux内核中,mmc不仅是一个驱动,而是一个子系统.这里通过分析Linux3.2.0内核,结合TI的arm335x平台及omap_hsmmcd host分析下mmc子系统,重点关注sdio及 ...

  2. 安装在ubuntu12.04上安装gcc4.8

    因为gcc4.8支持最新的c++11标准,所有开始c++11标准系列学习前,请按照gcc4.8,方便边学习边写代码练习. 安装编译好的gcc4.8 sudo add-apt-repository pp ...

  3. 粗谈pcap_next_ex()

      pcap_next_ex(pcap_t* p,struct pcap_pkthdr** pkt_header,const u_char** pkt_data) 功能: 从interface或离线记 ...

  4. Objective-C--Runtime机制

    个人理解: 简单来说,Objective-C runtime是一个实现Objective-C语言的C库.对象可以用C语言中的结构体表示,而方法(methods)可以用C函数实现.事实上,他们 差不多也 ...

  5. 在Eclipse中显示空格(space)和制表符(tab)

    显示空格(space)和制表符(tab)设置: Window->Preferences->General->Editors->Text Editors->Show whi ...

  6. rabbitmq 消息持久化

    rabbitmq 消息持久化 2016-02-18 11:19 224人阅读 评论(0) 收藏 举报  分类: 综合(15)  版权声明:本文为博主原创文章,未经博主允许不得转载. 二: 任务分发 & ...

  7. WCF系列学习5天速成

    看到一篇比较好的基础wcf学习博客,分享给大家:http://www.cnblogs.com/huangxincheng/archive/2011/10/23/2221845.html

  8. 非常不错的ASP操作数据库类,支持多数据库MSSQL,ACCESS,ORACLE,MYSQL等

    可同时操作多个不同类型的数据库. 完全不用考虑数据类型的差别,再也不用想字符型字段加不加单引号. 调用非常简单,对数据库的主要操作一般只需要一行代码. 支持mssql事务回滚. 可自动生成和输出sql ...

  9. Netbeans IDE配置

  10. 可以打开mdb文件的小软件

    下载地址: http://dl-sh-ocn-1.pchome.net/09/rh/DatabaseBrowser.zip