private static bool BuildCurrentDirectoryToAssetBundleTemp(List <string> allChildDependences, string exportPath, string assetPath)
    {
        var tempPath        = EditorFileUtility.GetPath(assetPath);
        var assetBundleName = Path.GetFileName(Path.GetDirectoryName(assetPath));

        var assetBundlePath = exportPath + "/temp/" + tempPath + "/" + assetBundleName + ".pkg";

        if (HasBuildAssetBundleMapTemp.Contains(assetBundlePath))
        {
            return(true);
        }
        EditorFileUtility.CreateParentDirecotry(assetBundlePath);

        //收集和自己同一个目录下的资源(不包括子目录)
        var           currentDir         = Path.GetDirectoryName(assetPath);
        List <string> readyToBuildAssets = new List <string>();

        foreach (var dependence in allChildDependences)
        {
            if (Path.GetDirectoryName(dependence) == currentDir)
            {
                readyToBuildAssets.Add(dependence);
            }
        }

        List <Object> objects    = new List <Object>();
        List <string> assetNames = new List <string>();

        foreach (var asset in readyToBuildAssets)
        {
            objects.Add(AssetDatabase.LoadMainAssetAtPath(asset));
            assetNames.Add(asset);
        }

        BuildAssetBundleWithoutCollectDependencies(objects.ToArray(), assetNames.ToArray(), assetBundlePath);
        HasBuildAssetBundleMapTemp.Add(assetBundlePath);
        return(true);
    }
    private static void BuildCurrentDirectoryToAssetBundle(string exportPath, AssetInfo asset)
    {
        //判断是不是已经生成正常的AssetBundle
        var tempPath        = EditorFileUtility.GetPath(asset.Path);
        var assetBundleName = Path.GetFileName(Path.GetDirectoryName(asset.Path));
        var assetBundlePath = exportPath + "/" + tempPath + "/" + assetBundleName + ".pkg";

        if (HasBuildAssetBundleMap.Contains(assetBundlePath))
        {
            return;
        }
        EditorFileUtility.CreateParentDirecotry(assetBundlePath);

        //收集和自己同一个目录下的资源(不包括子目录)
        var currentDir = Path.GetDirectoryName(asset.Path);
        List <AssetInfo> readyToBuildAssets = new List <AssetInfo>();

        foreach (var gameAsset in GameAssets)
        {
            if (Path.GetDirectoryName(gameAsset.Value.Path) == currentDir)
            {
                readyToBuildAssets.Add(gameAsset.Value);
            }
        }

        //收集asset的所有依赖,如果依赖是同一个assetBundle下的跳过
        List <string> allChildDependences = new List <string>();

        foreach (var gameAsset in readyToBuildAssets)
        {
            foreach (var dependence in gameAsset.ChildDependences)
            {
                if (Path.GetDirectoryName(dependence) != currentDir)
                {
                    allChildDependences.Add(dependence);
                }
            }
        }

        //删除临时目录的AssetBundle
        EditorFileUtility.DeleteDirectory(exportPath + "/temp");
        HasBuildAssetBundleMapTemp.Clear();

        BuildPipeline.PushAssetDependencies();

        foreach (var dependence in allChildDependences)
        {
            if (BuildAllFileToAssetBundleTemp(allChildDependences, exportPath, dependence))
            {
                continue;
            }

            if (BuildSingleFileToAssetBundleTemp(exportPath, dependence))
            {
                continue;
            }

            BuildCurrentDirectoryToAssetBundleTemp(allChildDependences, exportPath, dependence);
        }

        List <Object> objects    = new List <Object>();
        List <string> assetNames = new List <string>();

        foreach (var buildAsset in readyToBuildAssets)
        {
            objects.Add(AssetDatabase.LoadMainAssetAtPath(buildAsset.Path));
            assetNames.Add(buildAsset.Path);
        }

        BuildPipeline.PushAssetDependencies();
        BuildAssetBundle(objects.ToArray(), assetNames.ToArray(), assetBundlePath);
        BuildPipeline.PopAssetDependencies();

        BuildPipeline.PopAssetDependencies();

        //配置asset的Assetbundle路径
        foreach (var buildAsset in readyToBuildAssets)
        {
            buildAsset.AssetBundlePath = tempPath + "/" + assetBundleName + ".pkg";
        }
        HasBuildAssetBundleMap.Add(assetBundlePath);
    }