示例#1
0
        public static void BuildBundles()
        {
            BundleBuildHelper.PushAssetDependencies();

            BuildSingleBundle(BundleName.BN_SCRIPT, null);

            BundleData shader = BundleDataManager.GetBundleData(BundleName.BN_SHADER);

            for (int i = 0; shader != null && i < shader.children.Count; ++i)
            {
                BundleData  shaderChild = BundleDataManager.GetBundleData(shader.children[i]);
                BundleState childState  = BundleDataManager.GetBundleState(shader.children[i]);
                bool        result      = BundleBuildHelper.BuildShaderBundle(shaderChild, childState);
                if (!result)
                {
                    Debug.LogErrorFormat("[BundleAdapter] BuildShaderBundle {0} Failed.", shader.children[i]);
                }
            }

            List <BundleImportData> dataList = m_dataControl.DataList;

            for (int i = 0; i < dataList.Count; ++i)
            {
                BundleImportData data       = dataList[i];
                string           parentName = BundleDataManager.GetIndexBundleName(i);
                BuildSingleBundle(parentName, data);
            }

            BundleBuildHelper.PopAssetDependencies();

            BundleExport.ExportBundleMainfestToOutput();

            AssetDatabase.SaveAssets();
        }
示例#2
0
        private static void BuildSingleBundle(string name, BundleImportData data)
        {
            BundleData bundle = BundleDataManager.GetBundleData(name);

            if (bundle == null)
            {
                return;
            }
            for (int i = 0; i < bundle.children.Count; ++i)
            {
                BundleData  child      = BundleDataManager.GetBundleData(bundle.children[i]);
                BundleState childState = BundleDataManager.GetBundleState(bundle.children[i]);
                if (child == null || child.includs.Count == 0 || childState == null)
                {
                    continue;
                }
                if (m_buildAll && !m_bundleDict.ContainsKey(child.name))
                {
                    continue;
                }

                bool result = BundleBuildHelper.BuildSingleBundle(child, childState, data == null ? false : data.PushDependice);
                if (!result)
                {
                    Debug.LogErrorFormat("[BundleAdapter] BuildSingleBundle {0} Failed.", child.name);
                }
            }
        }
示例#3
0
        private static void _BuildSingleBundle(string name, BundleImportData data)
        {
            BundleData bundle = BundleDataManager.GetBundleData(name);

            if (bundle == null)
            {
                return;
            }
            for (int i = 0; i < bundle.children.Count; ++i)
            {
                BundleData  child      = BundleDataManager.GetBundleData(bundle.children[i]);
                BundleState childState = BundleDataManager.GetBundleState(bundle.children[i]);
                if (child == null || child.includs.Count == 0 || childState == null)
                {
                    continue;
                }
                if (m_useFilter && !m_bundleDict.ContainsKey(child.name))
                {
                    continue;
                }

                BuildHelper.BuildSingleBundle(child, childState, data.PushDependice);
            }
        }
示例#4
0
        public static void ExportBundleDictToOutput()
        {
            EditorTool.CreateDirectory(BuildConfig.InterpretedOutputPath);

            BundleDataControl dataControl    = BundleDataControl.Instance;
            BundleMainfest    bundleMainfest = new BundleMainfest();

            BundleData[] bundleData = BundleDataAccessor.Datas.ToArray();

            Dictionary <string, string> dict = new Dictionary <string, string>();

            for (int i = 0; i < bundleData.Length; ++i)
            {
                for (int j = 0; j < bundleData[i].includs.Count; ++j)
                {
                    string path = bundleData[i].includs[j];
                    if (string.IsNullOrEmpty(path))
                    {
                        continue;
                    }

                    if (!dict.ContainsKey(path))
                    {
                        dict.Add(path, bundleData[i].name);
                    }
                    else
                    {
                        Debug.LogWarningFormat("[BundleExport] Path to bundle name have same path {0} : {1} _ {2}", path, bundleData[i].name, dict[path]);
                    }

                    BundleImportData data = dataControl.GetPathImportData(path);
                    if (data == null || !data.Publish || !path.StartsWith("Assets", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    string bundlePath = path; // format path to load path!!!
                    bundleMainfest.AddPathToBundle(bundlePath, bundleData[i].name);
                }
            }

            for (int i = 0; i < bundleData.Length; ++i)
            {
                for (int j = 0; j < bundleData[i].includs.Count; ++j)
                {
                    string[] dep = AssetDepot.GetDependenciesCache(bundleData[i].includs[j]);
                    for (int k = 0; k < dep.Length; ++k)
                    {
                        if (EditorPath.IsScript(dep[k]) || EditorPath.IsShader(dep[k]))
                        {
                            continue;
                        }

                        string bundleName = null;
                        dict.TryGetValue(EditorPath.NormalizePathSplash(dep[k]), out bundleName);
                        if (string.IsNullOrEmpty(bundleName) || bundleName == bundleData[i].name)
                        {
                            continue;
                        }

                        BundleState childBuildState = BundleDataManager.GetBundleState(bundleName);
                        if (childBuildState.loadState == BundleLoadState.Preload || childBuildState.size == -1)
                        {
                            continue;
                        }

                        bundleMainfest.AddBundleDepend(bundleData[i].name, bundleName);
                    }
                }
            }

            List <BundleState> stateList = new List <BundleState>(BundleDataAccessor.States);

            bundleMainfest.AddBundleState(stateList);

            bundleMainfest.SaveBytes(BuildConfig.BundleMainfestOutputPath);

            AssetDatabase.ImportAsset(BuildConfig.BundleMainfestOutputPath, ImportAssetOptions.ForceSynchronousImport);
        }