public override IEnumerator CheckVersion()
        {
            var progressDelta = 1 / 5f;

            m_ShowTipCoroutine = GameCore.Instance.StartCoroutine(ShowCheckTip());

            //1 先检查本地版本信息,执行相关清理操作
            m_CoroutineWorkflow.AddLast("CheckLocalVersionInfo", CheckLocalVersionInfo);
            LoadingUI.Instance.SetLoadingBarProgressDelta(progressDelta);

            //2 检查远程配置信息
            m_CoroutineWorkflow.AddLast("CheckRemoteConfig", CheckRemoteConfig);
            LoadingUI.Instance.SetLoadingBarProgressDelta(progressDelta);

            //3 加载远程配置信息
            m_CoroutineWorkflow.AddLast("LoadRemoteControlConfig", LoadRemoteControlConfig);
            LoadingUI.Instance.SetLoadingBarProgressDelta(progressDelta);

            //4 检查Apk下载
            m_CoroutineWorkflow.AddLast("CheckProgramVersion", CheckProgramVersion);
            LoadingUI.Instance.SetLoadingBarProgressDelta(progressDelta);

            //5 检查资源版本
            m_CoroutineWorkflow.AddLast("CheckResourceVersion", CheckResourceVersion);
            LoadingUI.Instance.SetLoadingBarProgressDelta(progressDelta);

            yield return(GameCore.Instance.StartCoroutine(m_CoroutineWorkflow.ExecuteTasksAsync()));

            GameCore.Instance.StopCoroutine(m_ShowTipCoroutine);
            FileSystemUtility.ClearDirectory(UGCoreConfig.GetExternalDownloadFolder() + "/Patches");
            FileSystemUtility.ClearDirectory(UGCoreConfig.GetExternalDownloadFolder() + "/Apk");
            LoadingUI.Instance.SetLoadingBarProgressDelta(0.04f);
        }
Esempio n. 2
0
    private static void PackScripts()
    {
        var scriptsPath = Directory.GetParent(Application.dataPath) + "/obj/Release/";

        FileSystemUtility.ClearDirectory(scriptsPath);

        var path    = Application.dataPath + "/Editor/AssetBundleBuilder/Config/BuildScripts.bat";
        var process = System.Diagnostics.Process.Start(path);

        process.WaitForExit();

        var dllPath = scriptsPath + "Assembly-CSharp.dll";

        File.Move(dllPath, Application.dataPath + "/Resources/Assembly-CSharp.bytes");

        AssetDatabase.Refresh();
        Object[] objs = new Object[1];
        objs[0] = AssetDatabase.LoadMainAssetAtPath("Assets/Resources/Assembly-CSharp.bytes");
        string[] assetsName = new string[] { "Assets/Resources/RuntimeScripts" };
        BuildAssetBundle(objs, assetsName, Path.GetDirectoryName(Application.dataPath) + ExportDir + "/RuntimeScripts.pkg");

        File.Delete(Application.dataPath + "/Resources/Assembly-CSharp.bytes");
        File.Delete(Application.dataPath + "/Resources/Assembly-CSharp.bytes.meta");
        AssetDatabase.Refresh();

        //打apk

        /* var directoryInfo = new DirectoryInfo(Application.dataPath).Parent;
         * String bundleVersion = PlayerSettings.bundleVersion;
         * String unionName = "union";
         * String unionApkName = "zsby_" + unionName + "_" + bundleVersion + "_" + ".apk";
         * var targetApkName = directoryInfo + "/apk/" + unionApkName;
         *
         * if (!Directory.Exists(Path.GetDirectoryName(targetApkName)))
         * {
         *   Directory.CreateDirectory(Path.GetDirectoryName(targetApkName));
         * }
         *
         * string[] levels = { "Assets/LaunchScene/LaunchScene.unity" };
         * BuildPipeline.BuildPlayer(levels, targetApkName, BuildTarget.Android, BuildOptions.None);*/
    }
Esempio n. 3
0
        protected void SaveVersionInfo(string programVersion, string resourceVersion, bool needClearResources = true)
        {
            GameRuntimeInfo.ProgramVersion  = programVersion;
            GameRuntimeInfo.ResourceVersion = resourceVersion;

            var programData  = Encoding.UTF8.GetBytes(programVersion);
            var resourceData = Encoding.UTF8.GetBytes(resourceVersion);

            var data = new byte[programData.Length + resourceData.Length + 1];

            for (int i = 0; i < programData.Length; i++)
            {
                data[i] = programData[i];
            }
            data[programData.Length] = 0;
            for (int i = 0; i < resourceData.Length; i++)
            {
                data[programData.Length + i + 1] = resourceData[i];
            }

            var versionFileDir  = UGCoreConfig.GetExternalConfigFolder();
            var versionFilePath = Path.Combine(versionFileDir, "Version.config");

            if (!Directory.Exists(versionFileDir))
            {
                Directory.CreateDirectory(versionFileDir);
            }
            StreamWriter sw = new StreamWriter(new FileStream(versionFilePath, FileMode.Create));

            sw.Write(Convert.ToBase64String(data));
            sw.Flush();
            sw.Close();

            if (needClearResources)
            {
                FileSystemUtility.ClearDirectory(UGCoreConfig.GetExternalResourceFolder());
            }
        }