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. [专题总结]Gridea快速免费搭建个人博客

    介绍 或许你很想把你所知道的问题写出来,或许你文思泉涌,想给大家分享.我相信,你一定能写好博客,只要坚持,就可以了. 或许大家会不理解,为什么不用大平台的博客呢?或许你稍微了解就会知道,现在的博客平台 ...

  2. LeetCode算法训练-回溯 491.递增子序列 46.全排列 47.全排列 II

    欢迎关注个人公众号:爱喝可可牛奶 LeetCode算法训练-回溯 491.递增子序列 46.全排列 47.全排列 II LeetCode 491. 递增子序列 分析 找出并返回所有数组中不同的递增子序 ...

  3. Oracle & MSSql 数据库表映射方法(dblink or other)

    一.Oracle 1.在旧库创建公共链接 命名为 bidblink create public database link bidblink connect to c##v26_xxxx IDENTI ...

  4. IntelliJ IDEA 程序运行的控制台乱码

    参考:https://blog.csdn.net/zp357252539/article/details/124614007 上方导航栏"Run→Edit Configurations-&q ...

  5. 在orangepi 3 lts使用high speed timer

    概述 在allwin H6的用户手册上可以发现全志H6芯片支持普通计时器和高速计时器. 普通计时器可以处理低频定时任务,其时钟源包括LOSC和OSC,前者频率为32768Hz,后者为24MHz. 高数 ...

  6. FPGA MIG调试bug(一)

    目标器件:复旦微FPGA:JFM7K325T8FCBGA676(对标Xilinx Kintex-7系的XC7K325T) 工程背景:板载4片DDR(AllianceMemory_DDR3L_8G_AS ...

  7. vite 运行或打包出现内存溢出的解决方案

    在使用vite运行或打包时出现了内存耗尽的报错 vite VUE npm run build 报错 npm ERR! code ELIFECYCLE npm ERR! errno 134 内存溢出 n ...

  8. 【个人笔记】CentOS 修改 SSH 端口, 禁止 ROOT 远程登陆

    1. 修改 SSH 端口号, 禁止 ROOT 用户远程登录 # 使用ROOT用户或者其他有权限的用户登录 # 首先新建一个普通用户,避免禁用 ROOT 用户远程登陆后自己也无法登陆, 已有用户可以跳过 ...

  9. Linux系统安全:SNAT和DNAT的实现

    一.SNAT1.SNAT实验目的公司内有2台机器,但是只有一个公网ip,利用SNAT技术实现2台私网地址都可以访问公网. 2.SNAT实验环境准备①三台服务器:PC1客户端.PC2网关.PC3服务端. ...

  10. Linux系统Shell脚本第一章:Shell脚本基础及时间同步

    目录 一.Shell脚本基础 1.Shell作用 2.什么是Shell脚本及处理逻辑 3.shell脚本基本格式 4. shell脚本执行方式 5.实操演示 二.Shell脚本中的变量 1.变量的作用 ...