static void OnOkButtonClick(EditorControl c)
 {
     RecalcTreeNodes();
     CollectAllPaths();
     ResourceManageConfig.GetInstance().Save();
     s_root.ShutDown();
 }
 static void OnEnable(EditorRoot root)
 {
     Debug.Log("OnEnable,窗口初始化?");
     ResourceManageConfig.GetInstance().Init();
     ResourceManageToolModel.GetInstance().Init();
     RebuildResourcesTreeView();
 }
 static bool CollectAllPathsTreeNodeVisitCallback(TreeViewNode n)
 {
     if ((bool)n.state.userParams[0].param)
     {
         string path = n.GetPathString();
         ResourceManageConfig.GetInstance().Paths.Add(path);
     }
     return(true);
 }
    static void CollectAllPaths()
    {
        TreeViewCtrl treeView = s_root.FindControl("_MainTreeView") as TreeViewCtrl;

        if (treeView == null)
        {
            return;
        }

        ResourceManageConfig.GetInstance().Paths.Clear();

        foreach (var root in treeView.Roots)
        {
            TreeViewCtrl.PreorderTraverse(root, CollectAllPathsTreeNodeVisitCallback);
        }
    }
Exemplo n.º 5
0
    public bool IsPathContain(string path)
    {
        if (ResourceManageConfig.GetInstance().Paths.Count == 0)
        {
            //只有Assets下的资源可被包含
            if (path.IndexOf("Assets") == 0)
            {
                return(true);
            }
            return(false);
        }

        foreach (var p in ResourceManageConfig.GetInstance().Paths)
        {
            if (0 == path.IndexOf(p))
            {
                return(true);
            }
        }

        //此时当前路径不完全包含待扫描路径
        //如果当前路径为文件夹,则看其是否
        //在待扫描路径中出现
        if (ResourceManageToolUtility.PathIsFolder(path))
        {
            foreach (var p in ResourceManageConfig.GetInstance().Paths)
            {
                if (0 == p.IndexOf(path))
                {
                    return(true);
                }
            }
        }

        return(false);
    }
    static void AddAssetToResourceTreeView(string path)
    {
        TreeViewCtrl treeView = s_root.FindControl("_MainTreeView") as TreeViewCtrl;

        if (treeView == null)
        {
            return;
        }

        string totalPath = path;
        string currPath  = path;
        List <TreeViewNode> currLevelNodeList = treeView.Roots;
        TreeViewNode        parentNode        = null;
        int len = 0;

        while (currPath != "")
        {
            int i = currPath.IndexOf('/');
            if (i < 0)
            {
                i = currPath.Length;
            }
            len += i + 1;
            string pathNodeName     = currPath.Substring(0, i);
            string currNodeFullPath = totalPath.Substring(0, len - 1);
            if (i + 1 < currPath.Length)
            {
                currPath = currPath.Substring(i + 1);
            }
            else
            {
                currPath = "";
            }


            bool findNode = false;
            foreach (var treeNode in currLevelNodeList)
            {
                if (treeNode.name == pathNodeName)
                {
                    findNode          = true;
                    parentNode        = treeNode;
                    currLevelNodeList = treeNode.children;
                    break;
                }
            }

            if (!findNode)
            {
                TreeViewNode newNode = new TreeViewNode();
                newNode.name           = pathNodeName;
                newNode.image          = ResourceManageToolUtility.GetCachedIcon(path);
                newNode.state.IsExpand = true;
                TreeViewNodeUserParam userParam = new TreeViewNodeUserParam();

                bool toggleState = false;
                foreach (var p in ResourceManageConfig.GetInstance().Paths)
                {
                    if (p.Equals(currNodeFullPath))
                    {
                        toggleState = true;
                    }
                }
                userParam.param = toggleState;
                newNode.state.userParams.Add(userParam);

                if (parentNode == null)
                {//说明需要作为根节点插入树视图中
                    currLevelNodeList.Add(newNode);
                }
                else
                {
                    parentNode.Add(newNode);
                }
                parentNode        = newNode;
                currLevelNodeList = newNode.children;
            }
        }
    }
 static void OnEnable(EditorRoot root)
 {
     ResourceManageConfig.GetInstance().Init();
     UpdateTreeView();
 }