/// <summary> /// 绘制文件目录GUI /// </summary> /// <param name="control">文件信息</param> /// <param name="direType">显示文件夹或全部目录</param> /// <param name="selectCallback">选择一个文件回调</param> /// <param name="isShowChoose">是否打开勾选文件</param> /// <param name="chooseCallBack">勾选文件回调</param> public static void DrawFileDirectory(TreeModelController <FileData> control, ShowFileDirectoryType direType = ShowFileDirectoryType.ShowAllFile, string[] showEndsWith = null, CallBack <FileData> selectCallback = null, bool isShowChoose = false, CallBack <FileData> chooseCallBack = null) { GUI.enabled = true; EditorGUIUtility.SetIconSize(Vector2.one * 16); control.TreeForeachNode((data) => { if (direType == ShowFileDirectoryType.OnlyDirectory) { if (data.isDirectory) { DrawGUIData(control, data, direType, selectCallback, isShowChoose, chooseCallBack); if (!data.isSelected) { return(false); } } } else { if (data.isDirectory && !data.isSelected) { DrawGUIData(control, data, direType, selectCallback, isShowChoose, chooseCallBack); return(false); } if (showEndsWith != null) { if (!data.isDirectory) { if (OtherUtils.ArrayContains(showEndsWith, Path.GetExtension(data.relativeRootPath))) { DrawGUIData(control, data, direType, selectCallback, isShowChoose, chooseCallBack); } return(true); } } DrawGUIData(control, data, direType, selectCallback, isShowChoose, chooseCallBack); } return(true); }); }
void SetPreLoadFileGUI() { GUILayout.Space(7); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Refresh", GUILayout.Width(60))) { preLoadFileData = null; return; } GUILayout.EndHorizontal(); GUILayout.Space(5); if (preLoadFileData == null) { string[] paths = PathUtils.GetDirectoryFilePath(AssetBundlesOutputPath); preLoadFileData = EditorDrawFileDirectory.GetFileDirectoryInfo(paths, true); //paths = PathUtils.RemovePathWithEnds(paths, new string[] { ".meta" }); UpdatePreLoadFileData(preLoadFileData); tempAllFilePath = PathUtils.GetDirectoryFilePath(AssetBundlesOutputPath); } GUILayout.Label("选择预加载文件:"); pos1 = GUILayout.BeginScrollView(pos1, "box"); EditorDrawFileDirectory.DrawFileDirectory(preLoadFileData, ShowFileDirectoryType.ShowAllFile, new string[] { ".assetbundle" }, null, true, PreLoadChooseCallBack); GUILayout.EndScrollView(); GUILayout.Space(8); GUILayout.Label("选中的文件路径:"); pos4 = GUILayout.BeginScrollView(pos4, "box"); foreach (string p in settingData.preLoadResPaths) { GUILayout.BeginHorizontal("box"); if (!OtherUtils.ArrayContains(tempAllFilePath, p)) { GUI.color = Color.red; } GUILayout.Label("预加载路径:" + p); if (GUI.color == Color.red) { GUILayout.FlexibleSpace(); GUILayout.Label("文件不存在"); } GUI.color = oldGUIColor; GUILayout.EndHorizontal(); GUILayout.Space(4); } GUILayout.EndScrollView(); GUILayout.Space(10); if (GUILayout.Button("移除不存在预加载文件路径")) { List <string> tList = new List <string>(); foreach (string p in settingData.preLoadResPaths) { if (!OtherUtils.ArrayContains(tempAllFilePath, p)) { tList.Add(p); } } foreach (string p in tList) { settingData.preLoadResPaths.Remove(p); } } }