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);
}
}
}

最新文章

  1. 基于华清远见STM32f051的 IIC从模式实现方法
  2. matlab初学之plot颜色和线型
  3. 【软件工程】用map 实现把英语文本文件词和个数打印出来
  4. Tomcat6环境JBPM4.4报错:java.lang.ClassNotFoundException: de.odysseus.el.util.SimpleResolver
  5. Android ListView异步加载数据
  6. 我的MYSQL学习心得 mysql的权限管理
  7. python Redis
  8. Oracle\PLSQL Developer报“动态执行表不可访问,本会话的自动统计被禁止”的解决方案
  9. 一道变态的js题
  10. netty 入门二 (传输bytebuf 或者pojo)
  11. css控制file控件透明 漂浮
  12. 大名鼎鼎的红黑树,你get了么?2-3树 绝对平衡 右旋转 左旋转 颜色反转
  13. C#线程安全使用(二)
  14. k8s基本对象及架构
  15. 201771010134杨其菊《面向对象程序设计(java)》第十三周学习总结
  16. python 安装scrapy need vistual c++ 14.0 的正面解法
  17. selenium使用location定位元素坐标偏差
  18. 项目Alpha冲刺--4/10
  19. 在vue项目中使用sass
  20. 安全测试5_服务端的安全漏洞(SQL注入、命令注入、文件操作类)

热门文章

  1. .Net Core IIS部署以及问题总结
  2. js根据某个字段进行分组
  3. Postgresql 除法保留小数位
  4. Net6 Core Api(.net6)发布到IIS注意事项及显示HTTP 错误500.19解决方法
  5. 免费ASP空间
  6. linux常用操作指令记录
  7. 问题记录——mysql服务忘记root密码后加skip-grant-tables 跳过权限认证参数启动报错处理
  8. Centos7 安装mysql 5.7 教程
  9. 只会Jquery,后端程序员如何学会前端(webpack,react,babel,es5,es6)
  10. DRF过滤Filtering