public void TreeModelControllerTestListSimplePasses()
    {
        // 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.ListForeachNode((n) =>
        {
            string c = "[";
            foreach (var item in n.childs)
            {
                c += item + ",";
            }
            c += "]";
            Debug.Log(n.Id + " " + c + "  Path: " + n.relativeRootPath);
            return(true);
        });
    }
Ejemplo n.º 2
0
 void UpdateChooseFileData(TreeModelController <FileData> data)
 {
     data.ListForeachNode((n) =>
     {
         if (settingData.packageOnePaths.Contains(n.relativeRootPath))
         {
             n.isChoose = true;
         }
         return(true);
     });
 }
Ejemplo n.º 3
0
 void DrawFileDirectoryGUI()
 {
     if (fileData == null)
     {
         string[] paths = PathUtils.GetDirectoryFilePath(assetPath);
         fileData = EditorDrawFileDirectory.GetFileDirectoryInfo(paths);
         UpdateChooseFileData(fileData);
     }
     GUILayout.Label("选择打成一个包的目录:");
     pos0 = GUILayout.BeginScrollView(pos0, "box");
     EditorDrawFileDirectory.DrawFileDirectory(fileData, ShowFileDirectoryType.OnlyDirectory, null, null, true, PakagOneChooseCallBack);
     GUILayout.EndScrollView();
 }
Ejemplo n.º 4
0
    int CreateUpdatePack(string oldData, string newData)
    {
        string updateZipDir = UpdatePackageController.localDirPath;
        string zipFileName  = UpdateAssetsConst.UpdatePackageFileName;

        Dictionary <string, string> olderDic = GetMD5FileData(oldData);
        Dictionary <string, string> newDic   = GetMD5FileData(newData);

        Dictionary <string, string> resDic = new Dictionary <string, string>();
        Dictionary <string, string> paths  = AssetBundleBuildUtils.GetPathFileData(Application.streamingAssetsPath + "/PathFile.txt");

        foreach (string key in newDic.Keys)
        {
            if (!olderDic.ContainsKey(key))
            {
                resDic.Add(key, paths[key]);
            }
        }
        int num = resDic.Count;

        if (num <= 0)
        {
            return(num);
        }
        string fileData = "";

        foreach (string s in resDic.Keys)
        {
            fileData += s + "," + resDic[s] + "&";
        }
        FileUtils.CreateTextFile(updateZipDir + "/UpdatePathFile.txt", fileData);


        List <string> zipPaths = new List <string>();

        foreach (string s in resDic.Values)
        {
            zipPaths.Add(Application.streamingAssetsPath + "/" + s);
        }
        zipPaths.Add(updateZipDir + "/UpdatePathFile.txt");
        zipPaths.Add(updateZipDir + "/AssetBundleInfo.txt");

        string zipPath = updateZipDir + "/" + zipFileName + ".zip";

        ZipUtils.ZipManyFilesOrDictorys(zipPaths, zipPath, null);
        FileUtils.DeleteFile(updateZipDir + "/UpdatePathFile.txt");


        return(num);
    }
Ejemplo n.º 5
0
    private static bool HaveChildDirectory(TreeModelController <FileData> control, FileData data)
    {
        bool isHave = false;

        control.SearchChilds(data, (node) =>
        {
            if (node.isDirectory)
            {
                isHave = true;
                return(false);
            }
            return(true);
        });
        return(isHave);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 获取文件目录信息
    /// </summary>
    /// <param name="assetPath">资源文件夹路径</param>
    /// <param name="isAllOpen">是否展开所有目录</param>
    /// <param name="iconName">当为空字符时使用文件夹目录图标,不为空时强制使用此图标</param>
    /// <returns></returns>
    public static TreeModelController <FileData> GetFileDirectoryInfo(string[] paths, bool isAllOpen = false, string iconName = "", CallBack <FileData> initParamsCallBack = null)
    {
        TreeModelController <FileData> control = new TreeModelController <FileData>();

        control.AddPathsToCreateNode(paths);
        control.ListForeachNode((node) =>
        {
            node.isSelected = isAllOpen;
            node.content    = GetPathGUIContent(node.relativeRootPath, iconName);
            if (initParamsCallBack != null)
            {
                initParamsCallBack(node);
            }
            return(true);
        });

        return(control);
    }
Ejemplo n.º 7
0
    /// <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);
        });
    }
Ejemplo n.º 8
0
    static void DrawGUIData(TreeModelController <FileData> control, FileData data, ShowFileDirectoryType direType = ShowFileDirectoryType.ShowAllFile, CallBack <FileData> selectCallback = null, bool isShowChoose = false, CallBack <FileData> chooseCallBack = null)
    {
        GUIStyle style = "Label";

        style.richText = true;
        Rect rt = GUILayoutUtility.GetRect(data.content, style);

        if (data == selectData)
        {
            EditorGUI.DrawRect(rt, Color.gray);
        }
        rt.x += (24 * data.Deep);

        if (data.isDirectory)
        {
            Rect rt1 = new Rect(rt.x - 12, rt.y, 20, rt.height);
            if (direType == ShowFileDirectoryType.OnlyDirectory)
            {
                if (HaveChildDirectory(control, data))
                {
                    data.isSelected = EditorGUI.Foldout(rt1, data.isSelected, "");
                }
            }
            else
            {
                data.isSelected = EditorGUI.Foldout(rt1, data.isSelected, "");
            }
        }
        if (isShowChoose)
        {
            // rt.x += 20;
            Rect rt1 = new Rect(rt.x - 13, rt.y, 20, rt.height);
            if (data.isDirectory)
            {
                if (direType == ShowFileDirectoryType.OnlyDirectory)
                {
                    if (HaveChildDirectory(control, data))
                    {
                        rt1.x -= 13;
                    }
                }
                else
                {
                    rt1.x -= 13;
                }
            }
            bool oldChoose = data.isChoose;
            data.isChoose = EditorGUI.ToggleLeft(rt1, "", data.isChoose);
            if (data.isChoose != oldChoose)
            {
                if (chooseCallBack != null)
                {
                    chooseCallBack(data);
                }
            }
        }
        if (GUI.Button(rt, data.content, style))
        {
            //  data.isSelected = !data.isSelected;
            selectData = data;
            if (selectCallback != null)
            {
                selectCallback(data);
            }
        }
    }
Ejemplo n.º 9
0
    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);
            }
        }
    }