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 ...
随机推荐
- Android 仿PhotoShop调色板应用(四) 不同区域颜色选择的颜色生成响应
版权声明:本文为博主原创文章,未经博主允许不得转载. Android 仿PhotoShop调色板应用(四) 不同区域颜色选择的颜色生成响应 上一篇讲过了主体界面的绘制,这里讲解调色板应用中的另外一 ...
- android 19 activity纵横屏切换的数据保存与恢复
Bundle类:竖屏的activity换到横屏的activity的时候,会把竖屏的activity杀掉横屏的activity创建,竖屏的activity会有一些计算结果,可以用数据存起来,存到内存里面 ...
- Sysstat LINUX工具包址
http://sebastien.godard.pagesperso-orange.fr/
- 如何设计一个简单的C++ ORM
2016/11/15 "没有好的接口,用C++读写数据库和写图形界面一样痛苦" 阅读这篇文章前,你最好知道什么是 Object Relation Mapping (ORM) 阅读这 ...
- 一致性哈希(Consistent Hash)
http://blog.csdn.net/cywosp/article/details/23397179/ http://www.codeproject.com/Articles/56138/Cons ...
- 偶遇问题 - - JavaScript 取消链接默认行为问题
今天在测试<JavaScript DOM编程艺术(第2版)>中第69页代码时,遇到了问题.本来预期效果应该是点击链接后不跳转当前页面,而是另外弹出有个窗口.但结果却是页面跳转了.代码如下图 ...
- LayoutInflater类详解
http://www.cnblogs.com/top5/archive/2012/05/04/2482328.html 在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于 ...
- Uri、UriMatcher、ContentUris详解
http://blog.csdn.net/feng88724/article/details/6331396 1.Uri 通用资源标志符(Universal Resource Identifier, ...
- Android Studio下添加引用jar文件和so文件
博客: 安卓之家 微博: 追风917 CSDN: 蒋朋的家 简书: 追风917 博客园: 追风917 安卓开发中我们常会遇到jar文件和so文件的引用,下面介绍下在as下如何添加使用,这里以百度地图s ...
- SQL SERVER字符集的研究(中英文字符集,varchar,nvarchar).
一. 试验归类测试SQL: drop table a )) insert into a values('a') insert into a values(N'a') insert into a val ...