Exemplo n.º 1
0
    //通过每个节点的数据生成子节点
    private AssetViewItem CreateTree(string guid, ref int elementCount, int _depth, Stack <string> stack)
    {
        if (stack.Contains(guid))
        {
            return(null);
        }

        stack.Push(guid);
        if (needUpdateState && !updatedAssetSet.Contains(guid))
        {
            data.UpdateAssetState(guid);
            updatedAssetSet.Add(guid);
        }
        ++elementCount;
        var referenceData = data.assetDict[guid];
        var root          = new AssetViewItem {
            id = elementCount, displayName = referenceData.name, data = referenceData, depth = _depth
        };
        var childGuids = isDepend ? referenceData.dependencies : referenceData.references;

        foreach (var childGuid in childGuids)
        {
            var child = CreateTree(childGuid, ref elementCount, _depth + 1, stack);
            if (child != null)
            {
                root.AddChild(child);
            }
        }

        stack.Pop();
        return(root);
    }
    //通过每个节点的数据生成子节点
    private AssetViewItem CreateTree(string guid, ref int elementCount, int _depth)
    {
        if (needUpdateState && !updatedAssetSet.Contains(guid))
        {
            data.UpdateAssetState(guid);
            updatedAssetSet.Add(guid);
        }

        ++elementCount;
        var referenceData = data.assetDict[guid];
        var root          = new AssetViewItem {
            id = elementCount, displayName = referenceData.name, data = referenceData, depth = _depth
        };
        var childGuids = isDependency ? referenceData.dependencies : referenceData.references;

        foreach (var childGuid in childGuids)
        {
            root.AddChild(CreateTree(childGuid, ref elementCount, _depth + 1));
        }

        return(root);
    }