Ejemplo n.º 1
0
        public int AddAssetBundleName(string name, string[] depends, string md5, int fileSize, long buildTime, out AssetDataPackage package)
        {
            package = null;

            if (string.IsNullOrEmpty(name))
            {
                return(-1);
            }

            string key  = null;
            string path = null;

            GetPackageKeyFromABName(name, out key, out path);

            if (string.IsNullOrEmpty(key))
            {
                return(-1);
            }

            package = GetAssetDataPackage(key);

            if (package == null)
            {
                package = new AssetDataPackage(key, path, System.DateTime.Now.Ticks);
                m_AllAssetDataPackages.Add(package);
                Log.i("#Create Config Group:" + key);
            }

            return(package.AddAssetBundleName(name, depends, md5, fileSize, buildTime));
        }
Ejemplo n.º 2
0
        //检测当前版本是否是新装版本,如果安装了新版本,则需要对比内外部资源
        //使用默认assetpackage的创建时间来
        private bool CheckIsNewInstall()
        {
            string defaultPackage = PlayerPrefs.GetString(INNER_RES_PACKAGE, "");

            bool isNewPackage = false;

            if (string.IsNullOrEmpty(defaultPackage))
            {
                //重来没装过,或者卸载过,那么此时一定是新装版本
                isNewPackage = true;
            }
            else
            {
                int buildTime = PlayerPrefs.GetInt(INNER_RES_BUILDTIME);

                AssetDataPackage package = AssetDataTable.S.GetAssetDataPackage(defaultPackage);
                if (package == null)
                {
                    //新包连这个package都没了,那么一定重新装过
                    isNewPackage = true;
                }
                else
                {
                    int pBuildTime = (int)package.buildTime;
                    int offset     = pBuildTime - buildTime;

                    if (offset < -1 || offset > 1)
                    {
                        isNewPackage = true;
                    }
                }
            }

            return(isNewPackage);
        }
Ejemplo n.º 3
0
        public void LoadPackageFromFile(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            object data = SerializeHelper.DeserializeBinary(FileMgr.S.OpenReadStream(path));

            if (data == null)
            {
                Log.e("Failed Deserialize AssetDataTable:" + path);
                return;
            }

            AssetDataPackage.SerializeData sd = data as AssetDataPackage.SerializeData;

            if (sd == null)
            {
                Log.e("Failed Load AssetDataTable:" + path);
                return;
            }

            //string parentFolder = PathHelper.GetFolderPath(path);

            AssetDataPackage package = BuildAssetDataPackage(sd, path);

            string key = package.key;


            for (int i = m_AllAssetDataPackages.Count - 1; i >= 0; --i)
            {
                if (m_AllAssetDataPackages[i].key.Equals(key))
                {
                    var oldConfig = m_AllAssetDataPackages[i];

                    if (oldConfig.buildTime > package.buildTime)
                    {
                        return;
                    }
                    else
                    {
                        m_AllAssetDataPackages.RemoveAt(i);
                        break;
                    }
                }
            }

            m_AllAssetDataPackages.Add(package);
        }
Ejemplo n.º 4
0
        public void SwitchLanguage(string key)
        {
            m_ActiveAssetDataPackages.Clear();

            string languageKey = string.Format("[{0}]", key);

            for (int i = m_AllAssetDataPackages.Count - 1; i >= 0; --i)
            {
                AssetDataPackage group = m_AllAssetDataPackages[i];

                if (!group.key.Contains("i18res"))
                {
                    m_ActiveAssetDataPackages.Add(group);
                }
                else if (group.key.Contains(languageKey))
                {
                    m_ActiveAssetDataPackages.Add(group);
                }
            }
            Log.i("AssetDataTable Switch 2 Language:" + key);
        }
Ejemplo n.º 5
0
        public void ModifyAssetDataTable(AssetDataTable table)
        {
            RecordCell       cell    = null;
            AssetDataPackage package = null;

            for (int i = 0; i < m_UpdateRecordList.Count; ++i)
            {
                cell = m_UpdateRecordList[i];
                ABUnit unit = table.GetABUnit(cell.name);
                if (unit == null)
                {
                    table.AddAssetBundleName(cell.name, null, cell.md5, 1, cell.buildTime, out package);
                    continue;
                }
                else
                {
                    unit.buildTime = cell.buildTime;
                    unit.md5       = cell.md5;
                    unit.fileSize  = cell.fileSize;
                }
            }
        }