Exemplo n.º 1
0
        private static void _ProcessUpdateBundleList(string bundleName, BundleImportData selectData, FilterHandler filter)
        {
            BundleData data = BundleDataManager.GetBundleData(bundleName);

            if (data == null)
            {
                return;
            }

            for (int i = 0; i < data.includs.Count; ++i)
            {
                if (filter == null || filter(data.includs[i]))
                {
                    _AddToDict(data.name, m_bundleDict);
                    continue;
                }
                if (!selectData.Publish)
                {
                    continue;
                }
                string[] dep = AssetDepend.GetDependenciesCache(data.includs[i]);
                for (int k = 0; k < dep.Length; ++k)
                {
                    if (!filter(dep[k]))
                    {
                        continue;
                    }
                    if (!BundleDataManager.CheckPathInBundle(dep[k]))
                    {
                        _AddToDict(data.name, m_bundleDict);
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void CreateBundles()
        {
            _PreProcessSpecialBundle();

            List <string> list = m_dataControl.GetPublishPackagePath();

            for (int i = 0; i < list.Count; ++i)
            {
                string name = Path.GetFileName(list[i]);
                if (EditorUtility.DisplayCancelableProgressBar("Create Bundle", name, (i * 1.0f) / list.Count))
                {
                    Debug.LogWarning("[BundleAdapter] CreateBundles Stop.");
                    break;
                }
                string[] dep = AssetDepend.GetDependenciesCache(list[i]);
                for (int j = 0; j < dep.Length; ++j)
                {
                    if (string.IsNullOrEmpty(dep[j]))
                    {
                        continue;
                    }
                    _ProcessSpecialResource(dep[j]);
                    BundleImportData data = m_dataControl.GetPathSelectData(dep[j]);
                    if (data != null && !data.SkipData)
                    {
                        _AddPathToBundleByPathConfig(data, dep[j]);
                    }
                }
            }
            EditorUtility.ClearProgressBar();

            BMDataAccessor.SaveData();
            AssetDatabase.SaveAssets();
        }
Exemplo n.º 3
0
        private static void _ProcessDependBundleList()
        {
            bool loop = true;

            while (loop)
            {
                loop = false;
                List <string> list = new List <string>(m_bundleDict.Keys);
                for (int i = 0; i < list.Count; ++i)
                {
                    bool isProcess = false;

                    if (!m_bundleDict.TryGetValue(list[i], out isProcess))
                    {
                        continue;
                    }
                    if (isProcess)
                    {
                        continue;
                    }

                    m_bundleDict[list[i]] = true;
                    loop = true;

                    BundleData data = BundleDataManager.GetBundleData(list[i]);
                    if (data == null)
                    {
                        continue;
                    }
                    for (int j = 0; j < data.includs.Count; ++j)
                    {
                        string[] dep = AssetDepend.GetDependenciesCache(data.includs[j]);
                        for (int k = 0; k < dep.Length; ++k)
                        {
                            string bundleName = BundleDataManager.GetPathBundleName(dep[k]);
                            if (!string.IsNullOrEmpty(bundleName))
                            {
                                _AddToDict(bundleName, m_bundleDict);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static long CalcPathFileSize(string path, BundleType type)
        {
            path = PathConfig.FormatAssetPath(path);
            path = PathConfig.NormalizePathSplash(path);

            long ret = 0;

            if (m_pathFileSize.TryGetValue(path, out ret))
            {
                return(ret);
            }

            UnityEngine.Object[] objs = null;

            switch (type)
            {
            case BundleType.Texture:
                objs = AssetDatabase.LoadAllAssetsAtPath(path);
                for (int i = 0; i < objs.Length; ++i)
                {
                    if (objs[i] is Texture)
                    {
#pragma warning disable 0618
                        ret += Profiler.GetRuntimeMemorySize(objs[i]);
#pragma warning restore 0618
                    }
                }
                ret /= 4;

                break;

            case BundleType.Material:
                string[] deps = AssetDepend.GetDependenciesCache(path);
                for (int i = 0; i < deps.Length; ++i)
                {
                    if (PathConfig.IsTexture(deps[i]))
                    {
                        BundleImportData data = m_dataControl.GetPathSelectData(deps[i]);
                        if (data == null || data.SkipData)
                        {
                            ret += EditorCommon.CalculateTextureSizeBytes(deps[i]) / 4;
                        }
                    }
                }
                ret += 512;
                break;

            case BundleType.FBX:
            case BundleType.Controller:
            case BundleType.Animation:
                objs = AssetDatabase.LoadAllAssetsAtPath(path);
                List <UnityEngine.Object> list = new List <Object>();
                BuildHelper.FilterObjectByType(objs, list, type, path);
                for (int i = 0; i < list.Count; ++i)
                {
#pragma warning disable 0618
                    ret += Profiler.GetRuntimeMemorySize(list[i]);
#pragma warning restore 0618
                }
                ret /= 6;
                break;

            default:
                FileInfo fileInfo = new FileInfo(path);
                ret = fileInfo.Length;
                break;
            }

            if (objs != null)
            {
                _ProcessClear();
            }

            for (int i = 0; objs != null && i < objs.Length; ++i)
            {
                if ((!(objs[i] is GameObject)) && (!(objs[i] is Component)))
                {
                    Resources.UnloadAsset(objs[i]);
                }
            }

            m_pathFileSize.Add(path, ret);
            return(ret);
        }