コード例 #1
0
 static void OnOkButtonClick(EditorControl c)
 {
     RecalcTreeNodes();
     CollectAllPaths();
     ResourceManageConfig.GetInstance().Save();
     s_root.ShutDown();
 }
コード例 #2
0
 static void OnEnable(EditorRoot root)
 {
     Debug.Log("OnEnable,窗口初始化?");
     ResourceManageConfig.GetInstance().Init();
     ResourceManageToolModel.GetInstance().Init();
     RebuildResourcesTreeView();
 }
コード例 #3
0
 public static ResourceManageConfig GetInstance()
 {
     if (s_instance == null)
     {
         s_instance = new ResourceManageConfig();
     }
     return(s_instance);
 }
コード例 #4
0
    static void OnDestroy(EditorRoot root)
    {
        ResourceManageToolModel.GetInstance().onResourceDBUpdate = null;
        ResourceManageToolModel.DestroyInstance();
        ResourceManageConfig.DestoryInstance();

        s_root = null;
    }
コード例 #5
0
 static bool CollectAllPathsTreeNodeVisitCallback(TreeViewNode n)
 {
     if ((bool)n.state.userParams[0].param)
     {
         string path = n.GetPathString();
         ResourceManageConfig.GetInstance().Paths.Add(path);
     }
     return(true);
 }
コード例 #6
0
    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);
        }
    }
コード例 #7
0
ファイル: U3DAssetDB.cs プロジェクト: Hengle/UnityEditor
    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);
    }
コード例 #8
0
    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;
            }
        }
    }
コード例 #9
0
 static void OnDestroy(EditorRoot root)
 {
     ResourceManageConfig.DestoryInstance();
 }
コード例 #10
0
 static void OnEnable(EditorRoot root)
 {
     ResourceManageConfig.GetInstance().Init();
     UpdateTreeView();
 }