Esempio n. 1
0
        void BuildiOS()
        {
            var oldTarget = EditorUserBuildSettings.activeBuildTarget;

            DirectoryEx.CreateDirectory(OutputDir);

            var app = BuildPlayer(GetIOSBuildTarget(), BuildOptions.None, "Assets/Level1.unity");

            var appDataDir  = Path.Combine(app, "Data");
            var assetbundle = BuildStreamedSceneAssetBundle(GetIOSBuildTarget(), "Assets/Level2.unity");

            if (!AssetBundlePatch.IsSupport(assetbundle))
            {
                Debug.LogError("AssetBundlePatch.IsSupport failed!!!!");
                return;
            }

            EditorUserBuildSettings.SwitchActiveBuildTarget(oldTarget);

            var diff = Path.Combine(OutputDir, Updater.Diff);
            var ret  = AssetBundlePatch.Diff(appDataDir, null, assetbundle, diff);

            if (!ret)
            {
                Debug.LogError("AssetBundlePatch.Diff failed!!!!");
                return;
            }

            // Real environment, you need to place this file on http server
            var diffZip = Path.Combine(appDataDir, "Raw");

            diffZip = Path.Combine(diffZip, Updater.DiffZip);

            ZipFile.CreateFromDirectory(new string[] { diff }, diffZip);

            var sb = new StringBuilder();

            sb.AppendLine(DateTime.Now.ToString());
            sb.AppendLine(string.Format("Assetbundle size:{0}", GetFileSizeString(assetbundle)));
            sb.AppendLine(string.Format("Diff size:{0}", GetFileSizeString(diff)));
            sb.AppendLine(string.Format("Diff zip size:{0}", GetFileSizeString(diffZip)));
            DebugInfo = sb.ToString();
        }
Esempio n. 2
0
        IEnumerator Start()
        {
            if (Application.platform != RuntimePlatform.Android && Application.platform != RuntimePlatform.IPhonePlayer)
            {
                yield break;
            }

            UpdateSucess = false;

            // Real environment, you need to download this file
            var diffZip = Path.Combine(Application.streamingAssetsPath, DiffZip);

            Debug.Log("DiffZip:" + diffZip);

            CurProgress = new UnzipProgress(diffZip, Application.persistentDataPath);
            yield return(StartCoroutine(ProcessProgress(CurProgress)));

            if (CurProgress.CurState != Progress.State.Succeed)
            {
                DebugMessage = "Unzip failed." + CurProgress.GetDebug();
                yield break;
            }

            var diff = Path.Combine(Application.persistentDataPath, Diff);

            Debug.Log("Diff:" + diff);

            var appDataDir = GetAppDataDir();

            Debug.Log("AppDataDir:" + appDataDir);

            var update = Path.Combine(Application.persistentDataPath, "update.asset");
            var ret    = AssetBundlePatch.Merge(appDataDir, null, update, diff);

            if (ret != AssetBundlePatchResult.Succeed)
            {
                DebugMessage = "Merge failed.";
                yield break;
            }

            AssetBundle.CreateFromFile(update);
            UpdateSucess = true;
        }