static bool CreateAssetBundle(AssetBundleManageData data, AssetBundleData assetbundle, bool rebuild, bool dependency)
        {
            if (assetbundle.GetAllContents().Count <= 0)
            {
                return(false);
            }
            // add all path to list
            List <string> files = new List <string>();

            foreach (var path in assetbundle.GetAllContentsPath())
            {
                if (File.Exists(path))
                {
                    files.Add(path);
                }
            }
            // add special list asset for system
            BundleAssetList list     = null;
            string          listpath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(data)) + "/list/" + assetbundle.File + "/list.asset";   //Application.temporaryCachePath + "/" + "list.asset";

            if (!assetbundle.ForStreamedScene)
            {
                list        = CreateInstance <BundleAssetList>();
                list.Assets = files.Select(file => {
                    FileInfo info         = new FileInfo(file);
                    BundleAssetInfo asset = new BundleAssetInfo(info.Name);
                    return(asset);
                }).ToArray();

                var directory = System.IO.Path.GetDirectoryName(listpath).Substring("Assets".Length);
                System.IO.Directory.CreateDirectory(Application.dataPath + directory);
                AssetDatabase.CreateAsset(list, listpath);
                //files.Add(listpath);
                AssetBundleUtility.AssetList = list;
                // BundleAssetList.cs(not exist file "BundleAssetList.cs" with DLL)
                //string bundleAssetsListPath = "Assets/" + Path.GetDirectoryName(AssetBundleManager.SettingDataPath) + "/Scripts/BundleAssetList.cs";
                //files.Add(bundleAssetsListPath);
            }
            var targets = new BuildTarget[] { EditorUserBuildSettings.activeBuildTarget };

#if !DLL
            if (assetbundle.PlatformFolder && data.multiPlatform && 0 < data.targets.Count)
            {
                targets = data.targets.ToArray();
            }
#endif

            bool          ret          = false;
            List <string> platformList = new List <string>();
            foreach (BuildTarget target in targets)
            {
                var path = assetbundle.Path.Replace(AssetBundleManager.PlatformFolder, AssetBundleManager.GetPlatformFolder(Application.platform));
#if !DLL
                if (assetbundle.PlatformFolder)
                {
                    var platformFolder = AssetBundleManager.GetPlatformFolder(target);
                    if (platformList.Contains(platformFolder))
                    {
                        continue;
                    }
                    platformList.Add(platformFolder);
                    path = GetFullPath(assetbundle, target);
                }
#endif
                var dir       = Path.GetDirectoryName(path);
                var assetName = Path.GetFileName(path);
                if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);                    //AssetDatabase.CreateFolder(Path.GetDirectoryName(dir), Path.GetFileName(dir));
                }
                if (!string.IsNullOrEmpty(dir))
                {
                    dir = dir + "/";
                }

                if (!assetbundle.ForStreamedScene)
                {
                    if (!assetbundle.Separated)
                    {
                        Debug.Log(nestString + "Build " + assetbundle.File);

                        /*if( AssetBundleUtilityNew.CreateBundle(files.ToArray(), dir, assetName, (BuildAssetBundleOptions)assetbundle.Options, target, rebuild | assetbundle.Changed) )
                         * {
                         *      ret = true;
                         * }*/
                        //Hoavq change to new build system
                        AssetBundleBuild[] buildMap = new AssetBundleBuild[1];

                        /*buildMap[0].assetBundleName = assetName;
                         * Debug.Log("There're " + files.ToArray().Length + " file in " + assetName + " bundle. Created in " + dir);
                         * buildMap[0].assetNames = files.ToArray();*/

                        AddAssetBundleToBuildMap(buildMap, 0, data, assetbundle);
                        BuildPipeline.BuildAssetBundles(dir, buildMap, (BuildAssetBundleOptions)assetbundle.Options, target);
                    }
                }
            }
            assetbundle.Changed = false;
            return(ret);
        }
        IEnumerator LoadAssetBundle(AssetBundleContainer bundle, string url, int version, uint crc)
        {
            WWW www = null;

            if (0 <= version)
            {
                www = WWW.LoadFromCacheOrDownload(url, version, crc);
            }
            else
            {
                www = new WWW(url);
            }

            while (!www.isDone)
            {
                bundle.Progress = www.progress;
                yield return(9);
            }

            if (www.error != null)
            {
                Debug.LogError(string.Format("AssetBundleManager:\n\tload \"{0}\" error:{1}", url, www.error));
                bundle.Initialize(url, null, null);
                bundle.SetError(www.error);
            }
            else
            {
                BundleAssetInfo[] list = null;
                if (!www.assetBundle.isStreamedSceneAssetBundle)
                {
                    if (Application.HasProLicense())
                    {
#if UNITY_5
                        var request = www.assetBundle.LoadAssetAsync <BundleAssetList>("list");
#else
                        var request = www.assetBundle.LoadAsync("list", typeof(BundleAssetList));
#endif
                        yield return(request);

                        var bal = request.asset as BundleAssetList;
                        list = bal.Assets;
                    }
                    else
                    {
#if UNITY_5
                        var bal = www.assetBundle.LoadAsset <BundleAssetList>("list");
#else
                        var bal = www.assetBundle.Load("list", typeof(BundleAssetList)) as BundleAssetList;
#endif
                        list = bal.Assets;
                    }
                }
                else
                {
                    var paths = www.assetBundle.GetAllScenePaths();
                    list = new BundleAssetInfo[paths.Length];
                    for (int i = 0; i < paths.Length; ++i)
                    {
                        list[i] = new BundleAssetInfo(paths[i]);
                    }
                }
                if (list != null)
                {
                    bundle.Initialize(url, www.assetBundle, list);
                }
                else
                {
                    //Debug.LogWarning( "There is no BundleAssetList in " + www.url );
                    bundle.Initialize(url, www.assetBundle, null);
                }
            }
            if (www != null)
            {
                www.Dispose();
            }
        }
        static bool CreateAssetBundle(AssetBundleManageData data, AssetBundleData assetbundle, bool rebuild, bool dependency)
        {
            if (assetbundle.GetAllContents().Count <= 0)
            {
                return(false);
            }
            // add all path to list
            List <string> files = new List <string>();

            foreach (var path in assetbundle.GetAllContentsPath())
            {
                if (File.Exists(path))
                {
                    files.Add(path);
                }
            }
            // add special list asset for system
            BundleAssetList list     = null;
            string          listpath = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(data)) + "/list/" + assetbundle.File + "/list.asset";   //Application.temporaryCachePath + "/" + "list.asset";

            if (!assetbundle.ForStreamedScene)
            {
                list        = CreateInstance <BundleAssetList>();
                list.Assets = files.Select(file => {
                    FileInfo info         = new FileInfo(file);
                    BundleAssetInfo asset = new BundleAssetInfo(info.Name);
                    return(asset);
                }).ToArray();

                var directory = System.IO.Path.GetDirectoryName(listpath).Substring("Assets".Length);
                System.IO.Directory.CreateDirectory(Application.dataPath + directory);
                AssetDatabase.CreateAsset(list, listpath);
                //files.Add(listpath);
                AssetBundleUtility.AssetList = list;
                // BundleAssetList.cs(not exist file "BundleAssetList.cs" with DLL)
                //string bundleAssetsListPath = "Assets/" + Path.GetDirectoryName(AssetBundleManager.SettingDataPath) + "/Scripts/BundleAssetList.cs";
                //files.Add(bundleAssetsListPath);
            }
            var targets = new BuildTarget[] { EditorUserBuildSettings.activeBuildTarget };

#if !DLL
            if (assetbundle.PlatformFolder && data.multiPlatform && 0 < data.targets.Count)
            {
                targets = data.targets.ToArray();
            }
#endif

            bool          ret          = false;
            List <string> platformList = new List <string>();
            foreach (BuildTarget target in targets)
            {
                var path = assetbundle.Path.Replace(AssetBundleManager.PlatformFolder, AssetBundleManager.GetPlatformFolder(Application.platform));
#if !DLL
                if (assetbundle.PlatformFolder)
                {
                    var platformFolder = AssetBundleManager.GetPlatformFolder(target);
                    if (platformList.Contains(platformFolder))
                    {
                        continue;
                    }
                    platformList.Add(platformFolder);
                    path = GetFullPath(assetbundle, target);
                }
#endif
                var dir = Path.GetDirectoryName(path);
                if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);                    //AssetDatabase.CreateFolder(Path.GetDirectoryName(dir), Path.GetFileName(dir));
                }
                if (!string.IsNullOrEmpty(dir))
                {
                    dir = dir + "/";
                }

                if (!assetbundle.ForStreamedScene)
                {
                    if (!assetbundle.Separated)
                    {
                        Debug.Log(nestString + "Build " + assetbundle.File);
                        if (AssetBundleUtility.CreateBundle(files.ToArray(), path, (BuildAssetBundleOptions)assetbundle.Options, target, rebuild | assetbundle.Changed))
                        {
                            ret = true;
                        }
                    }
                    else
                    {
                        var infos = new BundleAssetInfo[] { new BundleAssetInfo("") };
                        list.Assets = infos;
                        AssetBundleUtility.AssetList = list;
                        foreach (var file in files)
                        {
                            infos[0].Name = file;
                            string name = Path.GetFileNameWithoutExtension(file) + ".unity3d";
                            Debug.Log(nestString + "Build " + name);
                            if (AssetBundleUtility.CreateBundle(file, dir + name, (BuildAssetBundleOptions)assetbundle.Options, target, rebuild | assetbundle.Changed))
                            {
                                ret = true;
                            }
                            BuildPipeline.PopAssetDependencies();
                            BuildPipeline.PushAssetDependencies();
                        }
                    }
                }
                else
                {
                    if (!assetbundle.Separated)
                    {
                        Debug.Log(nestString + "Build " + assetbundle.File);
                        if (AssetBundleUtility.CreateSceneBundle(files.ToArray(), path, (BuildAssetBundleOptions)assetbundle.Options, target, rebuild | assetbundle.Changed))
                        {
                            ret = true;
                        }
                    }
                    else
                    {
                        foreach (var file in files)
                        {
                            string name = Path.GetFileNameWithoutExtension(file) + ".unity3d";
                            Debug.Log(nestString + "Build " + name);
                            if (AssetBundleUtility.CreateSceneBundle(file, dir + name, (BuildAssetBundleOptions)assetbundle.Options, target, rebuild | assetbundle.Changed))
                            {
                                ret = true;
                            }
                            BuildPipeline.PopAssetDependencies();
                            BuildPipeline.PushAssetDependencies();
                        }
                    }
                }
            }
            assetbundle.Changed = false;
            //AssetDatabase.DeleteAsset(listpath);	Child assetbundle require list.asset of parent assetbundle.
            //AssetDatabase.Refresh();
            return(ret);
        }