Exemplo n.º 1
0
    /// <summary>
    /// 计算packageNode工作线程函数
    /// </summary>
    /// <param name="data"></param>
    private static void GeneratePackageNodeWorckFunc(System.Object data)
    {
        AssetPackageListNode node = (AssetPackageListNode)data;

        if (null == node)
        {
            return;
        }
        GeneratePackageNode(node.nodeType, node.paths, ref node.resultTable, node.ignorePackageNameStr);
        node.isDone = true;
    }
Exemplo n.º 2
0
    /// <summary>
    /// 分发需要计算PackageNode的路径到各个线程
    /// </summary>
    /// <param name="allPath"></param>
    /// <param name="ThreadCount"></param>
    /// <returns></returns>
    private static List <AssetPackageListNode> DispatchPackageNode(PackageNodeType packageType, List <string> allPath, string ignorePackageNameStr, int ThreadCount)
    {
        if (null == allPath)
        {
            return(null);
        }
        if (allPath.Count <= 0)
        {
            return(null);
        }

        List <AssetPackageListNode> reslut = new List <AssetPackageListNode>();
        //根据每个线程处理的最少数目,来分配需要多少个线程,最多只有ThreadCount个线程
        int realyThreadCount = Mathf.Clamp(allPath.Count / MinThreadProcessCout, 1, ThreadCount);

        int clipCount = allPath.Count / realyThreadCount;
        //遇到有余数的,待会直接分配到最后一根线程
        int Remainder = allPath.Count - (realyThreadCount * clipCount);

        List <string>[] clipArray = new List <string> [realyThreadCount];


        for (int i = 0; i < realyThreadCount; i++)
        {
            AssetPackageListNode node = new AssetPackageListNode();
            node.isDone = false;
            for (int j = i * clipCount; j < (i + 1) * clipCount; j++)
            {
                node.paths.Add(allPath[j]);
            }
            node.ignorePackageNameStr = ignorePackageNameStr;
            node.nodeType             = packageType;
            reslut.Add(node);
        }

        //余下的分配给最后一根线程
        for (int j = 0; j < Remainder; j++)
        {
            reslut[realyThreadCount - 1].paths.Add(allPath[realyThreadCount * clipCount + j]);
        }

        foreach (AssetPackageListNode node in reslut)
        {
            AssetBundleManager.PushWork(GeneratePackageNodeWorckFunc, node);
        }
        return(reslut);
    }
Exemplo n.º 3
0
 private static bool IsPackageNodeFinish(AssetPackageListNode nod)
 {
     return(null == nod || nod.isDone);
 }