[Unity] 文件夹图像资源的读取
来源:互联网 发布:网络视频赌博骗局 编辑:程序博客网 时间:2024/05/15 23:45
注意文件以及文件夹必须寄宿在Resources目录下,才能顺利调用Resources.Load()和Resources.loadAll()这两个函数得到所需要的图像文件。
public class GUITest : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
private Texture2D texSingle;
private Texture2D[] texAll;
void OnGUI()
{
if (GUI.Button(new Rect(0,10,100,50),"加载一张贴图"))
{
if (texSingle==null)
{
texSingle = Resources.Load("single/0") as Texture2D; //这里不需要加后缀
}
}
if (GUI.Button(new Rect(0,130,100,50),"加载一组贴图"))
{
if (texAll==null)
{
var textures = Resources.LoadAll("textures");
int countAll=textures.Length;
texAll=new Texture2D[countAll];
for (int i = 0; i < countAll; i++)
{
texAll[i] = textures[i] as Texture2D;
}
}
}
//绘制贴图
if (texSingle!=null)
{
GUI.DrawTexture(new Rect(110,10,80,80),texSingle,ScaleMode.ScaleToFit,true,0);
}
if (texAll!=null)
{
int countOfAll = texAll.Length;
for (int i = 0; i < countOfAll; i++)
{
GUI.DrawTexture(new Rect(110+i*80,130,80,80),texAll[i],ScaleMode.ScaleToFit,true,0);
}
}
}
}
- [Unity] 文件夹图像资源的读取
- unity默认资源的文件夹
- Matlab读取文件夹下的图像文件名
- 读取raw 文件夹下的资源
- 读取raw 文件夹下的资源
- MATLAB读取文件夹及其所有子文件夹内的图像
- C++图像批处理:读取文件夹中全部图像的方法
- Unity读取本地图片资源
- Unity读取本地图片资源
- Unity读取本地图片资源
- MATLAB批量读取一个文件夹里的图像
- Python如何读取指定文件夹下的所有图像
- MATLAB中读取文件夹中多组图像的方法
- android 读取assets文件夹下的文件资源
- 读取assert文件夹中的文件夹资源
- matlab读取2级文件夹,并把图像保存到指定的文件夹
- Android 读取资源文件(assets 文件夹 或res文件夹 )下面的文件
- Unity特殊的文件夹
- cocos2d-x封神榜(1) -- 【研发思路及感想】
- 编译错误:configure: error: newly created file is older than distributed files!
- YII 路径总结
- 陌陌:蛋疼,移动社交真心不好做!
- dom4j xpath 语法
- [Unity] 文件夹图像资源的读取
- Win8页面之间传值练习
- Eclipse中修改包名或类名
- SD销售凭证改号码段
- 异步下载图片
- 查看solaris系统的版本和位数
- ubuntu64位使用jd-gui的若干问题
- 金蝶K/3产品性能稳定性优化指导手册
- [转]QWidget QMainWindow QDialog的区别和相互转换