using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using UnityEngine.Video; public class Main:MonoBehaviour {
private FileInfo[] files;
public GameObject explain;
public GameObject homePage;
public GameObject allBtn;
public GameObject showPic;
public List<string> list = new List<string>();
private int currentStep = 0;
private int totalStep;
public GameObject nextBtn;
public GameObject prevBtn;
public GameObject backBtn;
public string standName;
public VideoPlayer video;
private string AndroidDirectory = "/storage/emulated/0/Android/";//安卓路径
private string WindowsDirectory = System.Environment.CurrentDirectory + "/资源/";//Windows路径
private string filePath;
void Start() {
explain.SetActive(false);
explain.GetComponent<Image>().raycastTarget = false; if(Directory.Exists(WindowsDirectory)) {
filePath = WindowsDirectory;
} else if(Directory.Exists(AndroidDirectory)) {
filePath = AndroidDirectory + "资源";
} else {
return;
}
for(int i = 0;i < allBtn.transform.childCount;i++) {
GameObject obj = allBtn.transform.GetChild(i).gameObject;
EventTriggerListener.Get(obj).onClick = onClick;
} string homePath = filePath + "/" + standName + ".png";
LoaderPic.LoadByIo(homePath,homePage);
video.url = filePath + "/" + standName + ".mp4"; string explainPath = filePath + "/" + standName + "弹框.png";
LoaderPic.LoadByIo(explainPath,explain);
EventTriggerListener.Get(nextBtn).onClick = onNext;
EventTriggerListener.Get(prevBtn).onClick = onPrev;
EventTriggerListener.Get(backBtn).onClick = onBack;
} public Text txt;
void onClick(GameObject sender) {
string getPaths = filePath + "/图片" + sender.name;
if(Directory.Exists(getPaths)) {//判断这个路径是否存在
DirectoryInfo direction = new DirectoryInfo(getPaths);
files = direction.GetFiles("*",SearchOption.AllDirectories);
}
list.Clear();
for(int i = 0;i < files.Length;i++) {
if(files[i].Name.EndsWith(".meta")) {
continue;
}
list.Add(files[i].ToString());
}
totalStep = list.Count;
showPic.SetActive(true);
explain.SetActive(true);
txt.text = "====" + list[currentStep].ToString();
LoaderPic.LoadByIo(list[currentStep],showPic);
} void onNext(GameObject sender) {
currentStep++;
if(currentStep >= totalStep) {
currentStep = 0;
}
LoaderPic.LoadByIo(list[currentStep],showPic);
}
void onPrev(GameObject sender) {
if(currentStep <= 0) {
currentStep = totalStep;
}
currentStep--;
LoaderPic.LoadByIo(list[currentStep],showPic);
}
void onBack(GameObject sender) {
showPic.SetActive(false);
explain.SetActive(false);
list.Clear();
} IEnumerator GetTexture(Image showPic, string url) {
UnityWebRequest uwr = UnityWebRequest.Get(url);
DownloadHandlerTexture downloadTexture = new DownloadHandlerTexture(true);
uwr.downloadHandler = downloadTexture;
yield return uwr.SendWebRequest();
if(uwr.isNetworkError || uwr.isHttpError) {
print(uwr.error);
} else {
Texture2D t = downloadTexture.texture;
showPic.sprite = Sprite.Create(t,new Rect(0,0,t.width,t.height),Vector2.one);
}
}
}

unity Android 可后台替换图片的更多相关文章

  1. android+nutz后台如何上传和下载图片

    android+nutz后台如何上传和下载图片  发布于 588天前  作者 yummy222  428 次浏览  复制  上一个帖子  下一个帖子  标签: 无 最近在做一个基于android的ap ...

  2. Android中后台的劳动者“服务”

    前言 作为四大组件之一的Service,想必不少开发者都是了解的,那具体熟悉吗?是不是对Service中的每个知识点是否了解,它与Activity的关系又是什么样的,我们所理解的后台服务跟Servic ...

  3. android + php 后台开发

    android+php 安卓与服务器的数据交互 在我们进行android开发的时候,避免不了的要进行登录注册,个人信息获取,数据交互等等这一系列的操作.这样就需要进行android端与服务器端进行数据 ...

  4. dedecms织梦系统后台验证码图片不显示的解决方法

    网站迁移后,dedecms织梦系统后台验证码图片不显示的解决方法通用解决方案-取消后台验证码功能因为没有验证码,不能进后台,所以修改php文件源代码:方法一:打开dede/login.php 找到如下 ...

  5. Android中后台线程如何与UI线程交互

    我想关于这个话题已经有很多前辈讨论过了.今天算是一次学习总结吧. 在android的设计思想中,为了确保用户顺滑的操作体验.一些耗时的任务不能够在UI线程中运行,像访问网络就属于这类任务.因此我们必须 ...

  6. [Unity] Android插件

    1> 编写eclipse android代码. 2> 把unity下class.jar拷入eclipse libs目录下, 工程中右键build path, add to build pa ...

  7. Android之拨号界面图片风格,无信息默认显示界面修改

    Android之拨号界面图片风格,无信息默认显示界面修改 点开Dialer app,出现拨号,联系人,收藏三个选项卡,也就是三个Fragment,在三个界面都没有信息的时候会显示一个时钟,联系人,收藏 ...

  8. Android 加载大图片到内存

    本文演示android中图片加载到内存 首先设计界面: 代码如下: <LinearLayout xmlns:android="http://schemas.android.com/ap ...

  9. Android ImageView显示本地图片

    Android ImageView 显示本地图片 布局文件 <?xml version="1.0" encoding="utf-8"?> <R ...

  10. [转]Android 超高仿微信图片选择器 图片该这么加载

    快速加载本地图片缩略图的方法: 原文地址:Android 超高仿微信图片选择器 图片该这么加载 其示例代码下载: 仿微信图片选择器 ImageLoader

随机推荐

  1. PostgreSQL 实现快速删除一个用户

    一.具体方法 一般情况下直接执行 drop role xxx; 就可以把这个用户删除.但是很多时候会因为用户有依赖而报错. 二.权限依赖 postgres=# create role test wit ...

  2. redis(14)主从复制

    Redis主从复制 主机数据更新后根据配置和策略, 自动同步到备机的 master/slaver 机制,Master 以写为主,Slave 以读为主,主从复制节点间数据是全量的. 作用: 读写分离,性 ...

  3. linux系统安装MySQL服务,详细图文教程

    注:linux系统在安装操作系统时,如果选择了开发工具和兼容库后,一般默认都会安装MySQL服务的部分程序包.如果我们要自定义的安装全新的MySQL服务,就必须先把这些已经安装的程序包都卸载掉.否则, ...

  4. No.2.2

    空间转换(使用transform属性实现元素在空间的位移.旋转.缩放等效果) 空间:是从坐标轴角度定义的.x.y.和 z三条坐标轴构成了一个立体空间,z轴位置与视线方向相同. 空间转换也叫3D转换(属 ...

  5. java学习日记20230227-java学习方法/转义字符/注释

    Java学习方法 学习java基本原理和基本语法 快速入门(基本程序 CRUD) 研究技术的注意事项,使用细节,使用规范,如何优化 JAVA转义字符 \t : 一个制表位,实现对齐的功能 \n:换行符 ...

  6. 这个博客几乎包括了Makefile中的所有 $ 符号解释

    来源:https://blog.csdn.net/dlf1769/article/details/78997967 Makefile中的$@, $^, $< , $?, $%, $+, $* h ...

  7. N63050 第十周运维作业

    十九.VPN服务 1.firewalld和最新技术nft实现防火墙功能(65分钟) 2.open-v-p-n介绍和环境准备(48分钟) 3.open-v-p-n实现CA证书(45分钟) 4.open- ...

  8. SDN实验环境安装

  9. CodeGym自学笔记03——变量、数据类型

    变量 变量是用来存储数据的特殊实体. 1.在 Java 语言中,所有数据都存储在变量中. 2.最接近的比喻就好比是一个盒子. 3.在 Java 语言中,每个变量都有三个重要的属性:类型.名称和值. - ...

  10. 关于el-popover的箭头颜色

    因为会从四个方向不定弹出 所以需要写入4个方向: 注意弹出框是动态插入body中的,需写入根部样式中 如果有多个地方用到且颜色都不一样,可以用类名区分,elm提供了 然后把前面的 .el-popper ...