本文由 @EGWriket出品,转载请注明出处。 http://blog.csdn.net/egwriket
环境
软件:untiy5.0.2f1 插件:NGUI3.6.7
步骤
1.UI及资源放置
1.UI 需要一个PopupList的控件,NGUI→Open,直接从Prefab Toolbar拖一个出来就好了 2.把视频放在Project面板中的Resources文件夹(不一定要叫这个名,要用Resources.Load方法加载的话就用这个名),以图片为例
2.代码及绑定
using UnityEngine;
using System.Collections;
using System.IO;
using System.Collections.Generic;
public class PanelManager : MonoBehaviour {
public UIPanel panel;
public UIPopupList popListPicture;
string path=
"Evaluation/swallow/Picture(到文件夹为止)";
public void SelectBirdPictureFile()
{
if (Directory.Exists(path))
{
DirectoryInfo direction =
new DirectoryInfo(path);
FileInfo[] files = direction.GetFiles(
"*", SearchOption.AllDirectories);
for (
int i =
0; i < files.Length; i++)
{
if (files[i].Name.EndsWith(
".meta"))
{
continue;
}
Debug.Log(
"Name:" + files[i].Name);
popListPicture.items.Add(files[i].Name);
}
}
}
}
1.Hierarchy面板选中UIRoot(可选其他),把代码绑定 2.Hierarchy面板选中Texture,拖入脚本中的未定义的控件变量PopList绑定 3.Hierarchy面板选中PopulList,选择On Value Change 6把UIRoot拖进Notify,method选择PanelManager/SelectBirdPictureFile
3.运行
感觉项目做不完了……
转载请注明原文地址: https://ju.6miu.com/read-970764.html