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 GridView 设置行背景
经常有这样的需求,你的功能图标要像一个个物品,摆放在书架上,像这样: 我的思路比较简单,重载GridView,在他绘制子视图前,先把背景绘制完成 1 2 3 4 5 6 7 8 9 10 11 12 ...
- Cstyle的UEFI导读:第18.0篇 NVRAM的工作原理(上)
虽有句话说的好,实用的东西记在脑子里.没有的记在笔记本上. 可是如今的信息量越来越大,并且随着时间的推移记忆力会越来越不可靠,所以仅仅好把近期工作之余看的一些东西记录下来,避免被迅速忘记.这里 ...
- php 总结
1.安装完apache之后 2.有一个目录 htdocs 下面就是根目录了 3.测试一下,新建一个index.html 写入 it works .输入localhost 看是否显示 it works ...
- urlconnection用法(转)
1.获取ip地址 package demo.net; import java.net.InetAddress; import java.net.UnknownHostException; /* * 获 ...
- DIV------使用 <div> 元素的网页布局
<!DOCTYPE html> <html> <head> <style type="text/css"> div#containe ...
- MySQL日志概述
为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/SJQ. http://www.cnblogs.com/shijiaqi1066/p/3859866.html ...
- 11.3 morning
noip模拟题day1 总览(Overview) 题目名称 取模 等比数列 回文串 程序名 mod sequence palindromes 输入文件名 mod.in sequence.in pa ...
- OSI七层模型理解
物理层功能1,为数据端设备提供传送数据的通路 功能2,传输数据 接口.传输介质.信号的传输.网络设备 有线介质:双绞线(普通的网线),光纤. 无线介质:无线电.微波.激光.红外线. 例如手机.电视接收 ...
- Java-Android 之输入提示框
Android的文本提示框有两种方式: main.xml文件 <?xml version="1.0" encoding="utf-8"?> < ...
- aliyun云服务器硬件性能测试
1.所购买阿里云服务器信息 2.dd命令测试 3.