2020-05-09 13:31:21 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using ResUpdate;
|
2021-06-16 10:44:12 +08:00
|
|
|
|
using UnityEngine.Networking;
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
namespace GameLogic
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 热更新面板
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UpdatePanel : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提示文字
|
|
|
|
|
/// </summary>
|
|
|
|
|
[SerializeField]
|
|
|
|
|
Text tipsText;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 进度条
|
|
|
|
|
/// </summary>
|
|
|
|
|
[SerializeField]
|
|
|
|
|
SliderCtrl slider;
|
|
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
|
UpdateMsgBox msgBox;
|
|
|
|
|
|
2021-05-31 21:36:05 +08:00
|
|
|
|
AssetBundle bundle;
|
2020-05-09 13:31:21 +08:00
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
msgBox.gameObject.SetActive(false);
|
|
|
|
|
//StartCoroutine(GetGameConfig());
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-16 17:29:17 +08:00
|
|
|
|
public IEnumerator LoadFromStream(Action<Sprite> act)
|
2021-05-31 19:19:57 +08:00
|
|
|
|
{
|
2021-07-09 11:56:53 +08:00
|
|
|
|
XDebug.Log.l(Application.streamingAssetsPath + "/Res/PackConfig.txt");
|
2021-06-16 17:29:17 +08:00
|
|
|
|
UnityWebRequest uwr = UnityWebRequest.Get(Application.streamingAssetsPath + "/Res/PackConfig.txt");
|
|
|
|
|
yield return uwr.SendWebRequest();
|
|
|
|
|
if (uwr.isNetworkError || uwr.isHttpError)
|
2021-06-11 08:58:15 +08:00
|
|
|
|
{
|
2021-07-09 11:56:53 +08:00
|
|
|
|
XDebug.Log.l(uwr.error);
|
2021-06-16 10:44:12 +08:00
|
|
|
|
if (act != null)
|
|
|
|
|
{
|
|
|
|
|
act(null);
|
|
|
|
|
}
|
2021-06-11 08:58:15 +08:00
|
|
|
|
}
|
2021-06-16 10:44:12 +08:00
|
|
|
|
else
|
2021-05-31 19:19:57 +08:00
|
|
|
|
{
|
2021-06-16 17:29:17 +08:00
|
|
|
|
Hashtable table = MiniJSON.jsonDecode(uwr.downloadHandler.text) as Hashtable;
|
|
|
|
|
string bgName = table["UpdatePanelBG"] as string;
|
|
|
|
|
|
|
|
|
|
UnityWebRequest www = UnityWebRequestTexture.GetTexture(Application.streamingAssetsPath + "/Res/" + bgName + ".png");
|
|
|
|
|
yield return www.SendWebRequest();
|
|
|
|
|
if (www.isNetworkError || www.isHttpError)
|
2021-05-31 21:36:05 +08:00
|
|
|
|
{
|
2021-07-09 11:56:53 +08:00
|
|
|
|
XDebug.Log.l(www.error);
|
2021-06-16 17:29:17 +08:00
|
|
|
|
if (act != null)
|
|
|
|
|
{
|
|
|
|
|
act(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-07-09 11:56:53 +08:00
|
|
|
|
XDebug.Log.l("load success");
|
2021-06-16 17:29:17 +08:00
|
|
|
|
Texture2D tex = ((DownloadHandlerTexture)www.downloadHandler).texture;
|
|
|
|
|
Sprite sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0));
|
|
|
|
|
if (act != null)
|
|
|
|
|
{
|
|
|
|
|
act(sp);
|
|
|
|
|
}
|
2021-06-11 02:36:08 +08:00
|
|
|
|
}
|
2021-06-16 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
2021-06-30 19:50:47 +08:00
|
|
|
|
GameObject go = this.transform.Find("Canvas/LoadingScreen").gameObject;
|
2021-06-16 18:23:30 +08:00
|
|
|
|
go.SetActive(false);
|
2021-06-30 19:50:47 +08:00
|
|
|
|
GameObject go2 = this.transform.Find("Canvas/HighLayer").gameObject;
|
|
|
|
|
go2.SetActive(false);
|
2021-06-16 17:29:17 +08:00
|
|
|
|
Image img = this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent<Image>();
|
|
|
|
|
img.color = new Color(1f, 1f, 1f, 0f);
|
|
|
|
|
StartCoroutine(LoadFromStream((Sprite sp) =>
|
2021-06-16 10:44:12 +08:00
|
|
|
|
{
|
2021-06-16 17:29:17 +08:00
|
|
|
|
if (sp != null)
|
2021-06-11 02:36:08 +08:00
|
|
|
|
{
|
2021-06-16 17:29:17 +08:00
|
|
|
|
img.sprite = sp;
|
|
|
|
|
}
|
|
|
|
|
img.color = new Color(1f, 1f, 1f, 1f);
|
2021-06-16 18:23:30 +08:00
|
|
|
|
go.SetActive(true);
|
2021-06-30 19:50:47 +08:00
|
|
|
|
go2.SetActive(true);
|
2021-06-16 17:29:17 +08:00
|
|
|
|
}));
|
2021-05-31 19:19:57 +08:00
|
|
|
|
}
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
string updatePanelBg = ConfigManager.Instance.GetConfigInfo("Setting.UPDATE_PANEL_BG.value");
|
|
|
|
|
if (updatePanelBg != null)
|
|
|
|
|
{
|
2021-05-31 21:36:05 +08:00
|
|
|
|
if (bundle != null) bundle.Unload(true);
|
|
|
|
|
bundle = null;
|
2021-05-31 19:19:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
|
|
|
{
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CANEL), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM_CLOSE), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
if (result == 1)
|
|
|
|
|
Application.Quit();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// void Start()
|
|
|
|
|
// {
|
|
|
|
|
//#if UNITY_EDITOR
|
|
|
|
|
//#elif UNITY_ANDROID
|
|
|
|
|
// Debug.LogError("UpdatePanel HideSplash Init SDKManager::::");
|
|
|
|
|
// using (AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
|
|
|
|
// {
|
|
|
|
|
// using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))
|
|
|
|
|
// {
|
|
|
|
|
// jo.Call("HideSplash");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//#elif UNITY_IPHONE || UNITY_IOS
|
|
|
|
|
|
|
|
|
|
//#endif
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
IEnumerator GetGameConfig()
|
|
|
|
|
{
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
var jsonData = UpdateManager.Instance.PostServerInfo();
|
|
|
|
|
WWW www = new WWW(AppConst.Download_apk_Url, Encoding.UTF8.GetBytes(jsonData));
|
|
|
|
|
yield return www;
|
|
|
|
|
if (string.IsNullOrEmpty(www.error))
|
|
|
|
|
{
|
|
|
|
|
OnGetGameConfig(www.text);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError(www.url+" "+www.error);
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS_FAILED), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
StartCoroutine(GetGameConfig());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
www.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CheckAndConvert<T>(Hashtable tab,string parameterName,object targetValue)
|
|
|
|
|
{
|
|
|
|
|
if(tab.Contains(parameterName))
|
|
|
|
|
{
|
|
|
|
|
var parStr= tab[parameterName] as string;
|
|
|
|
|
if(typeof(T) ==typeof(int))
|
|
|
|
|
{
|
|
|
|
|
int intValue=0;
|
|
|
|
|
if (int.TryParse(parStr, out intValue))
|
|
|
|
|
{
|
|
|
|
|
targetValue= intValue;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(typeof(T) ==typeof(bool))
|
|
|
|
|
{
|
|
|
|
|
if (parStr.ToLower() == "true" || parStr=="1")
|
|
|
|
|
{
|
|
|
|
|
targetValue = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (typeof(T) == typeof(string))
|
|
|
|
|
{
|
|
|
|
|
if (parStr!=null)
|
|
|
|
|
{
|
|
|
|
|
targetValue = parStr;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnGetGameConfig(string config)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(config))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Util.LogError("gameConfig::"+config);
|
|
|
|
|
var data = MiniJSON.jsonDecode(config) as Hashtable;
|
|
|
|
|
if(data==null || data.Contains("error"))
|
|
|
|
|
{
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS_ERROR), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
StartCoroutine(GetGameConfig());
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (AppConst.isUpdate)
|
|
|
|
|
{
|
|
|
|
|
BeginUpdateGame();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OnUpdateFinish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新游戏
|
|
|
|
|
/// </summary>
|
|
|
|
|
void BeginUpdateGame()
|
|
|
|
|
{
|
|
|
|
|
GameUpdateManager.Instance.BeginUpdate(OnGameUpdateStateChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新平台
|
|
|
|
|
/// </summary>
|
|
|
|
|
void BeginUpdatePlatform()
|
|
|
|
|
{
|
|
|
|
|
UpdateManager.Instance.UpdateResources(OnResourcesUpdateStateChanged);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 游戏状态改变
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="isFinish"></param>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
void OnGameUpdateStateChanged(bool isFinish, GameUpdateState state, object param)
|
|
|
|
|
{
|
|
|
|
|
//Debug.LogFormat("OnGameUpdateStateChanged=======>IsFinish:{0},State:{1}", isFinish, state.ToString());
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case GameUpdateState.DownLoadGameConfigs:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_VERSION_INFO);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.DownLoadGameConfigsFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_GAME_SETTINGS_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdateGame();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.NeedUpdateApp:
|
|
|
|
|
// msgBox.Show();
|
|
|
|
|
GameUpdateManager.Instance.UpdateApp();
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.DownLoadAPKProgress:
|
|
|
|
|
OnGameUpdateProgress(param as DownLoadProgress);
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.DownLoadAPKFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNlOAD_FILE_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
GameUpdateManager.Instance.UpdateAPK(true);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case GameUpdateState.Success:
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 资源更新状态改变
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="isFinish"></param>
|
|
|
|
|
/// <param name="state"></param>
|
|
|
|
|
/// <param name="param"></param>
|
|
|
|
|
void OnResourcesUpdateStateChanged(bool isFinish, ResourcesUpdateState state, object param)
|
|
|
|
|
{
|
|
|
|
|
//Debug.LogFormat("OnResourcesUpdateStateChanged=======>IsFinish:{0},State:{1}", isFinish, state.ToString());
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ResourcesUpdateState.GetGameConfigs:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_RESOURCES_SETTINGS);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.GetGameConfigsFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_RESOURCES_VERSION_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadVersionFiles:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CHECK_RESOURCES_FILE);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadVersionFilesFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.GET_RESOURCES_SETTINGS_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadFromNoWifi:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
slider.SetValue(0f);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
float size = 1f * (long)(param as object[])[0] / 1024 / 1024;
|
|
|
|
|
Action startDownAction = (param as object[])[1] as Action;
|
2021-01-26 17:08:39 +08:00
|
|
|
|
string msg = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.NOT_WIFI_CONFIRM), size);
|
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM), msg, (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
startDownAction();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.DownLoadWithWifi:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
slider.SetValue(0f);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
float size2 = 1f * (long)(param as object[])[0] / 1024 / 1024;
|
|
|
|
|
Action startDownAction2 = (param as object[])[1] as Action;
|
2021-01-26 17:08:39 +08:00
|
|
|
|
string msg2 = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.WIFI_CONFIRM), size2);
|
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.CONFIRM), msg2, (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
startDownAction2();
|
2020-08-22 15:31:14 +08:00
|
|
|
|
// 打点 - 开始更新
|
|
|
|
|
SDK.SdkCustomEvent.CustomEvent("Load-updates");
|
2020-05-09 13:31:21 +08:00
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.UpdateResourcesProgress:
|
|
|
|
|
OnResUpdateProgress(param as ResUpdateProgress);
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.UpdateResourcesFailed:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RETRY), SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNlOAD_RESOURCES_FILE_FAILED_CONFIRM_WIFI), (result) =>
|
2020-05-09 13:31:21 +08:00
|
|
|
|
{
|
|
|
|
|
BeginUpdatePlatform();
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.Success:
|
|
|
|
|
string version = (string)param;
|
|
|
|
|
VersionManager.Instance.SaveVersion(version);
|
|
|
|
|
OnUpdateFinish();
|
2020-08-22 15:31:14 +08:00
|
|
|
|
// 打点 - 更新完成
|
|
|
|
|
SDK.SdkCustomEvent.CustomEvent("End-loading");
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
case ResourcesUpdateState.OldPackageNeedChange:
|
2021-01-26 17:08:39 +08:00
|
|
|
|
msgBox.Show(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNLOAD_NEWEST_APP));
|
2020-05-09 13:31:21 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 游戏更新进度
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="progress"></param>
|
|
|
|
|
void OnGameUpdateProgress(DownLoadProgress progress)
|
|
|
|
|
{
|
|
|
|
|
slider.UpdateValue(progress.Progress);
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNLOAD_PROGRESS_RATE), progress.SizeMB.ToString("f2"), progress.TotalSizeMB.ToString("f2"),progress.LoadSpeed.ToString("f2"));
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 资源更新进度
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="progress"></param>
|
|
|
|
|
void OnResUpdateProgress(ResUpdateProgress progress)
|
|
|
|
|
{
|
|
|
|
|
slider.UpdateValue(progress.Progress);
|
2021-03-07 20:48:05 +08:00
|
|
|
|
tipsText.text = string.Format(SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.DOWNLOAD_PROGRESS), progress.SizeMB.ToString("f2"), progress.TotalSizeMB.ToString("f2"), (progress.SizeMB/progress.TotalSizeMB)*100);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新结束
|
|
|
|
|
/// </summary>
|
|
|
|
|
void OnUpdateFinish() {
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.UPDATE_COMPLETE);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
slider.SetValue(1f);
|
|
|
|
|
StartCoroutine(LoadGlobalRes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator LoadGlobalRes() {
|
2021-01-26 17:08:39 +08:00
|
|
|
|
tipsText.text = SLanguageMoreLanguageMgr.Instance.GetLanguageChValBykey(more_language.RELOAD_RESOURCES);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
slider.SetValue(0f);
|
|
|
|
|
GlobalResLoader loader = new GlobalResLoader();
|
|
|
|
|
loader.LoadGlobalRes(null);
|
|
|
|
|
while (!loader.IsLoadFinish) {
|
|
|
|
|
slider.UpdateValue(loader.Progress);
|
|
|
|
|
yield return 1;
|
|
|
|
|
}
|
|
|
|
|
slider.SetValue(1f);
|
|
|
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
|
|
yield return UpdateFinish();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator UpdateFinish() {
|
|
|
|
|
yield return new WaitForSeconds(0.2f);
|
2021-06-16 10:44:12 +08:00
|
|
|
|
App.Instance.StartUp();
|
|
|
|
|
yield return new WaitForSeconds(1f);
|
2020-05-09 13:31:21 +08:00
|
|
|
|
DestroyImmediate(this.gameObject);
|
|
|
|
|
UpdateManager.Instance.UnLoadUpdateAsset();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|