public void TreeModelControllerTreeTestSimplePasses() { // Use the Assert class to test conditions. string[] paths = PathUtils.GetDirectoryFilePath("Assets/Resources"); paths = PathUtils.RemovePathWithEnds(paths, new string[] { ".meta" }); TreeModelController <TreeNodeBase> control = new TreeModelController <TreeNodeBase>(); foreach (var i in paths) { TreeNodeBase node = control.GetNewNode(i); control.AddNode(node); } control.TreeForeachNode((n) => { Debug.Log(n.Id + " Path: " + n.relativeRootPath); return(true); }); }
/// <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); }); }