Exemple #1
0
    async Task Start()
    {
        JsManager.Instance.Startup();

        //初始化FairyGUI
        GRoot.inst.SetContentScaleFactor(1280, 720, UIContentScaler.ScreenMatchMode.MatchWidthOrHeight);
        UIPackage.unloadBundleByFGUI = false;

        //加载FairyGUI Package
        ResourceManager.init();

        //Test
        UINoticeWin notice = UINoticeWin.Inst;

        notice.ShowOneButton("test test", () =>
        {
            notice.Hide();
        });
        await notice.WaitForResponse();

        // 开始更新
        var launchPage = launchPageGO.GetComponent <LaunchPage>();

        if (launchPage != null)
        {
            await launchPage.CheckUpdate();
        }
    }
Exemple #2
0
    IEnumerator Start()
    {
        LoggerHelper.Instance.Startup();
        JsManager.Instance.Startup();

        //初始化FairyGUI
        GRoot.inst.SetContentScaleFactor(1280, 720, UIContentScaler.ScreenMatchMode.MatchWidthOrHeight);
        UIPackage.unloadBundleByFGUI = false;

        NTexture.CustomDestroyMethod = (Texture t) =>
        {
            Addressables.Release(t);
            Logger.Log(".... release addressable: " + t.name);
        };

        UIObjectFactory.SetPackageItemExtension(LaunchPage.URL, typeof(LaunchPage));
        UIObjectFactory.SetPackageItemExtension(UINoticeWin.URL, typeof(UINoticeWin));

        //加载FairyGUI Package
        AsyncOperationHandle <TextAsset> handle = Addressables.LoadAssetAsync <TextAsset>(fairy_package);

        yield return(handle);

        TextAsset pkgAsset = handle.Result;

        UIPackage.AddPackage(
            pkgAsset.bytes,
            "game",
            async(string name, string extension, Type type, PackageItem ite) => {
            Logger.Log($"{name}, {extension}, {type.ToString()}, {ite.ToString()}");

            if (type == typeof(Texture))
            {
                Texture t = await Addressables.LoadAssetAsync <Texture>(name + extension).Task;
                ite.owner.SetItemAsset(ite, t, DestroyMethod.Custom);
            }
        });
        Addressables.Release(handle);

        //加载更新界面
        launchPage = LaunchPage.CreateInstance();
        launchPage.Show();

        //Test
        UINoticeWin notice = UINoticeWin.CreateInstance();

        notice.ShowOneButton("test test", () => {
            notice.Hide();
        });
        yield return(notice.WaitForResponse());


        // 开始更新
        if (launchPage != null)
        {
            StartCoroutine(launchPage.CheckUpdate());
        }
        yield break;
    }
Exemple #3
0
    async Task Start()
    {
        LoggerHelper.Instance.Startup();
        JsManager.Instance.Startup();

        //初始化FairyGUI
        GRoot.inst.SetContentScaleFactor(1280, 720, UIContentScaler.ScreenMatchMode.MatchWidthOrHeight);
        UIPackage.unloadBundleByFGUI = false;


        UIObjectFactory.SetPackageItemExtension(LaunchPage.URL, typeof(LaunchPage));
        UIObjectFactory.SetPackageItemExtension(UINoticeWin.URL, typeof(UINoticeWin));

        //加载FairyGUI Package
        ResourceManager.init();
        await ResourceManager.LoadFairyGUIPackage("common_fui.bytes", "common");

        await ResourceManager.LoadFairyGUIPackage("launch_fui.bytes", "launch");


        //加载更新界面
        launchPage = LaunchPage.CreateInstance();
        launchPage.Show();

        //Test
        UINoticeWin notice = UINoticeWin.CreateInstance();

        notice.ShowOneButton("test test", () => {
            notice.Hide();
        });
        await notice.WaitForResponse();


        // 开始更新
        if (launchPage != null)
        {
            await launchPage.CheckUpdate();
        }
    }
Exemple #4
0
    public async Task CheckUpdate()
    {
        var start = DateTime.Now;

        gTextField.text = "正在检查资源更新...";

        await Addressables.InitializeAsync().Task;

        var a        = Addressables.RuntimePath;
        var catalogs = await Addressables.CheckForCatalogUpdates(false).Task;

        Log.Debug(LogGroups.UI, string.Format("CheckIfNeededUpdate use {0}ms", (DateTime.Now - start).Milliseconds));
        Log.Debug(LogGroups.UI, $"catalog count: {catalogs.Count} === check status: {catalogs}");

        if (catalogs != null && catalogs.Count > 0)
        {
            gTextField.text   = "正在更新资源...";
            gProgress.visible = true;
            gProgress.value   = 0;

            start = DateTime.Now;
            var locators = await Addressables.UpdateCatalogs(catalogs, false).Task;

            Log.Debug(LogGroups.UI, $"locator count: {locators.Count}");

            foreach (var v in locators)
            {
                var size = await Addressables.GetDownloadSizeAsync(v.Keys).Task;

                Log.Debug(LogGroups.UI, $"download size:{size}");

                if (size > 0)
                {
                    UINoticeWin notice = UINoticeWin.Inst;
                    notice.ShowOneButton($"本次更新大小:{size}", () => {
                        notice.Hide();
                    });

                    //等待确定
                    await notice.WaitForResponse();

                    var downloadHandle = Addressables.DownloadDependenciesAsync(v.Keys, Addressables.MergeMode.Union);
                    while (!downloadHandle.IsDone)
                    {
                        float percentage = downloadHandle.PercentComplete;
                        Log.Debug(LogGroups.UI, $"download pregress: {percentage}");
                        gProgress.value = percentage * 100;
                    }
                    Addressables.Release(downloadHandle);
                }
            }

            Log.Debug(LogGroups.UI, string.Format("UpdateFinish use {0}ms", (DateTime.Now - start).Milliseconds));
            UpdateFinish();

            Addressables.Release(locators);

            Addressables.Release(catalogs);
        }
        StartGame();
    }
Exemple #5
0
    public IEnumerator CheckUpdate()
    {
        var start = DateTime.Now;

        gTextField.text = "正在检查资源更新...";

        var initHandle = Addressables.InitializeAsync();

        yield return(initHandle);

        var a           = Addressables.RuntimePath;
        var checkHandle = Addressables.CheckForCatalogUpdates(false);

        yield return(checkHandle);

        Logger.Log(string.Format("CheckIfNeededUpdate use {0}ms", (DateTime.Now - start).Milliseconds));
        Logger.Log($"catalog count: {checkHandle.Result.Count} === check status: {checkHandle.Status}");
        if (checkHandle.Status == AsyncOperationStatus.Succeeded)
        {
            List <string> catalogs = checkHandle.Result;
            if (catalogs != null && catalogs.Count > 0)
            {
                gTextField.text   = "正在更新资源...";
                gProgress.visible = true;
                gProgress.value   = 0;

                start = DateTime.Now;
                AsyncOperationHandle <List <IResourceLocator> > updateHandle = Addressables.UpdateCatalogs(catalogs, false);
                yield return(updateHandle);

                var locators = updateHandle.Result;
                Logger.Log($"locator count: {locators.Count}");

                foreach (var v in locators)
                {
                    List <object> keys = new List <object>();
                    keys.AddRange(v.Keys);

                    var sizeHandle = Addressables.GetDownloadSizeAsync(keys);
                    yield return(sizeHandle);

                    long size = sizeHandle.Result;
                    Logger.Log($"download size:{size}");

                    if (size > 0)
                    {
                        UINoticeWin notice = UINoticeWin.CreateInstance();
                        notice.ShowOneButton($"本次更新大小:{size}", () => {
                            notice.Hide();
                        });
                        yield return(notice.WaitForResponse());

                        var downloadHandle = Addressables.DownloadDependenciesAsync(keys, Addressables.MergeMode.Union);
                        while (!downloadHandle.IsDone)
                        {
                            float percentage = downloadHandle.PercentComplete;
                            Logger.Log($"download pregress: {percentage}");
                            gProgress.value = percentage * 100;

                            yield return(null);
                        }
                        Addressables.Release(downloadHandle);
                    }
                }

                Logger.Log(string.Format("UpdateFinish use {0}ms", (DateTime.Now - start).Milliseconds));
                yield return(UpdateFinish());

                Addressables.Release(updateHandle);
            }

            Addressables.Release(checkHandle);
        }

        yield return(StartGame());
    }