unity3d 幻灯片效果实现
上一篇使用的是静态方式进行的加载,采用的数据结构为 数组
该篇文章则是使用动态加载的方式实现:
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 幻灯片效果实现的更多相关文章
- Codrops 教程:实现内容倾斜的 3D 幻灯片效果
今天给大家分享的优秀教程来自 Codrops 网站,实现一个内容倾斜的 3D 幻灯片效果.我们平常见到的都是那种水平或者垂直滚动的效果,这个倾斜的内容滑动效果相信会让你眼前一亮.因为使用了 CSS 3 ...
- 【jquery】幻灯片效果
闲着无聊,用Jquery写了一个幻灯片效果. 我这人喜欢造轮子,除了jquery这种有强大开发团队的框架级别JS,其实的一些小程序都是尽量自己写. 一是因为怕出问题了没人问,二是自己写的改起来也方便. ...
- bxSlider 在网页里添加幻灯片效果
幻灯片效果在网页上很常见,本文介绍用 bxSlider 轻松实现的方法. bxSlider是什么 bxSlider 是用 JQuery 和 CSS 实现网页中幻灯片效果的工具.可在 http://bx ...
- css+js 控制幻灯片效果
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 使用CSS实现一个简单的幻灯片效果
方法一: 简单的CSS代码实现幻灯片效果 方法二: 使用CSS3 Animation来制作幻灯片 方法一: 简单的CSS代码实现幻灯片效果 话不多说,直接上代码 <!DOCTYPE html&g ...
- javascript - 图片的幻灯片效果
javascript 代码: <script type="text/javascript"> function select_play() { var select_p ...
- 纯css实现幻灯片效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- 一个很好的幻灯片效果的jquery插件--kinMaxShow
在做一些网站时,或多或少的要给网站做幻灯片效果,以前每次做这个效果,都是现成带网上找,找到的很多很杂,而且用完后就不会再理会更加不会去总结代码. 无意中找到了kinMaxShow这个插件,机会满足了我 ...
- jquery特效 幻灯片效果
jquery特效 幻灯片效果,效果图如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Cont ...
随机推荐
- shell从函数文件里调用函数
碰到一个shell中函数调用的小问题,记录一下. shell中函数有三种调用方式,一种是在文件前面定义函数,然后在以下直接调用:一种是通过加载shell,在shell中直接调用:第三种是将函数写入文件 ...
- Node.js异步处理CPU密集型任务
Node.js异步处理CPU密集型任务 Node.js擅长数据密集型实时(data-intensive real-time)交互的应用场景.然而数据密集型实时应用程序并非仅仅有I/O密集型任务,当碰到 ...
- HUNNU--湖师大--11407--It Is Cold
[F] It Is Cold Dr. Ziad Najem is known as the godfather of the ACPC. When the regional contest was ...
- etrace 跟踪程序函数动态执行流程
https://github.com/elcritch/etrace 窗口1: 监控窗口,执行监控程序,显示监控结果 [root@monitor example]# pwd /root/etrace- ...
- [转] Spring Boot and React hot loader
When I develop web applications, I love using React. I'm also a Spring and groovy addict. Those two ...
- Java使用poi对Execl简单_读_操作
public class ReadExecl { // private final String XLSX = ".xlsx"; // 2007以上版本 // private fi ...
- RecyclerView实例-实现可下拉刷新上拉加载更多并可切换线性流和瀑布流模式(1)
摘要 最近项目有个列表页需要实现线性列表和瀑布流展示的切换,首先我想到的就是上 [RecyclerView],他本身已经很好的提供了三种布局方式,只是简单做个切换应该是很简单的事情,如果要用Recyc ...
- SQL SERVER 存储过程基础
一.注释 -- 单行注释,从这到本行结束为注释,类似C++,c#中// /* … */ 多行注释,类似C++,C#中/* … */ 二.变量 (int, smallint, tinyint, deci ...
- 绘图quartz之阴影
//设置矩形的阴影 并在后边加一个圆 不带阴影 步骤: CGContextRef context = UIGraphicsGetCurrentContext(); ...
- 关于SQL配置管理器的服务无法启动的解决办法!
由于各种问题的因素,导致SQL服务无法启动,然后去事件查看器里看了下,有两个关于SQL 的错误.分别是实例中master.mdf和master.ldf的文件系统拒绝访问! 为了赶作业,带着焦急的心情去 ...