unity Android路径的相关部分代码
2024-10-21 15:27:50
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
public class ClientTools:MonoBehaviour {
// Start is called before the first frame update
public GameObject obj;
public Text text;
private FileInfo[] floders;
private string AndroidDirectory = "/storage/emulated/0/Android/";//安卓路径
private string WindowsDirectory = System.Environment.CurrentDirectory + "/资源/";//Windows路径
private string filePath;
/// <summary>
/// /storage/emulated/0/ Android 外置内存根目录
/// Application.persistentDataPath; 来检测Android 外置内存根目录的方法
/// </summary>
void Start() {
EventTriggerListener.Get(obj).onClick = onClick;
} private void onClick(GameObject sender) {
ClientUDP.instance.Send("123123");
if(Directory.Exists(WindowsDirectory)) {
filePath = WindowsDirectory;
} else if(Directory.Exists(AndroidDirectory)) {
filePath = WindowsDirectory;
} else {
return;
} DirectoryInfo direction = new DirectoryInfo(filePath);
floders = direction.GetFiles("*.jpg",SearchOption.TopDirectoryOnly);
// text.text += floders.Length.ToString() + "_____****";
if(floders.Length > 0) {
LoaderPic.LoadByIo(floders[0].ToString(),obj);
} }
}
最新文章
- AlloyTeam2015前端大会都说了啥
- 【代码笔记】iOS-iCarouselDemo
- POJ 1258 Agri-Net(最小生成树 Prim+Kruskal)
- Linux中source是什么指令?
- Android开发笔记:eclipse导入java项目
- 【Linux学习】 写一个简单的Makefile编译源码获取当前系统时间
- asp.net 备份和恢复数据库
- DLL Export 报错
- js跨浏览器事件对象、事件处理程序
- TCP的阻塞和重传
- 设计模式 ( 十六 ) 观察者模式Observer(对象行为型)
- 极路由器刷机安装ss插件最新教程
- vue的增删改查
- Servlet案例3:验证码功能
- heapy() :python自带的堆排序
- HDU 1425 sort C语言实现快速排序
- SQL优化之索引分析
- p2 入门
- 分享基于Sails.js和React.js的全栈聊天室
- JAVA card 应用开发(一) 创建第一个APPLET