mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
更新Demo
更新Demo
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
using TEngine;
|
||||
|
||||
namespace GameMain
|
||||
{
|
||||
#pragma warning disable CS0649
|
||||
public class LoadStyle : MonoBehaviour
|
||||
{
|
||||
public Button _btn_ignore;
|
||||
public Button _btn_update;
|
||||
public Button _btn_package;
|
||||
|
||||
public Text _label_ignore;
|
||||
public Text _label_update;
|
||||
public Text _label_package;
|
||||
private Dictionary<StyleEnum, Dictionary<BtnEnum, StyleItem>> loadConfig;
|
||||
|
||||
private const string ConfigPath = "RawBytes/UIStyle/Style.json";
|
||||
|
||||
public enum StyleEnum
|
||||
{
|
||||
Style_Default = 0,//默认
|
||||
Style_QuitApp = 1,//退出应用
|
||||
Style_RestartApp = 2,//重启应用
|
||||
Style_Retry = 3,//重试
|
||||
Style_StartUpdate_Notice = 4,//提示更新
|
||||
Style_DownLoadApk = 5,//下载底包
|
||||
Style_Clear = 6,//修复客户端
|
||||
Style_DownZip = 7,//继续下载压缩包
|
||||
}
|
||||
|
||||
public enum BtnEnum
|
||||
{
|
||||
BtnOK = 0, //确定按钮
|
||||
BtnIgnore = 1,//取消按钮
|
||||
BtnOther = 2, //其他按钮
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单个按钮的样式
|
||||
/// </summary>
|
||||
private class StyleItem
|
||||
{
|
||||
public Alignment Align;//对其方式
|
||||
public bool Show;//是否隐藏
|
||||
public string Desc;//按钮描述
|
||||
}
|
||||
/// <summary>
|
||||
/// 对齐方式
|
||||
/// </summary>
|
||||
private enum Alignment
|
||||
{
|
||||
Left = 0,
|
||||
Middle = 1,
|
||||
Right = 2
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
//设置按钮的默认描述
|
||||
_label_ignore.text = LoadText.Instance.Label_Btn_Ignore;
|
||||
_label_update.text = LoadText.Instance.Label_Btn_Update;
|
||||
_label_package.text = LoadText.Instance.Label_Btn_Package;
|
||||
|
||||
InitConfig();
|
||||
}
|
||||
|
||||
private void InitConfig()
|
||||
{
|
||||
// string url = AssetUtility.Config.GetConfigAsset(ConfigPath);
|
||||
// if (!String.IsNullOrEmpty(url))
|
||||
// {
|
||||
// string finalPath = SetFilePath(url);
|
||||
// InitConfigDic(finalPath);
|
||||
// }
|
||||
}
|
||||
|
||||
#region 初始化配置文件
|
||||
private string SetFilePath(string path)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (path.StartsWith(Application.persistentDataPath))
|
||||
path = $"file://{path}";
|
||||
#elif UNITY_IOS
|
||||
if (path.StartsWith(Application.persistentDataPath)||path.StartsWith(Application.streamingAssetsPath))
|
||||
path = $"file://{path}";
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
private void InitConfigDic(string path)
|
||||
{
|
||||
UnityWebRequest www = UnityWebRequest.Get(path);
|
||||
UnityWebRequestAsyncOperation request = www.SendWebRequest();
|
||||
while (!request.isDone)
|
||||
{
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(www.downloadHandler.text))
|
||||
{
|
||||
loadConfig = JsonConvert.DeserializeObject<Dictionary<StyleEnum, Dictionary<BtnEnum, StyleItem>>>(www.downloadHandler.text);
|
||||
}
|
||||
www.Dispose();
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 设置样式
|
||||
/// </summary>
|
||||
/// <param name="type">样式对应的id</param>
|
||||
public void SetStyle(StyleEnum type)
|
||||
{
|
||||
if (type == StyleEnum.Style_Default)
|
||||
return;
|
||||
|
||||
if (loadConfig == null)
|
||||
{
|
||||
Log.Error("LoadConfig is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var style = loadConfig[type];
|
||||
if (style == null)
|
||||
{
|
||||
Log.Error($"LoadConfig, Can not find type:{type},please check it");
|
||||
return;
|
||||
}
|
||||
SetButtonStyle(style);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮的描述,是否隐藏
|
||||
/// </summary>
|
||||
private void SetButtonStyle(Dictionary<BtnEnum, StyleItem> list)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
switch (item.Key)
|
||||
{
|
||||
case BtnEnum.BtnOK:
|
||||
_label_update.text = item.Value.Desc;
|
||||
_btn_update.gameObject.SetActive(item.Value.Show);
|
||||
SetButtonPos(item.Value.Align, _btn_update.transform);
|
||||
break;
|
||||
case BtnEnum.BtnIgnore:
|
||||
_label_ignore.text = item.Value.Desc;
|
||||
_btn_ignore.gameObject.SetActive(item.Value.Show);
|
||||
SetButtonPos(item.Value.Align, _btn_ignore.transform);
|
||||
break;
|
||||
case BtnEnum.BtnOther:
|
||||
_label_package.text = item.Value.Desc;
|
||||
_btn_package.gameObject.SetActive(item.Value.Show);
|
||||
SetButtonPos(item.Value.Align, _btn_package.transform);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置按钮位置
|
||||
/// </summary>
|
||||
private void SetButtonPos(Alignment align, Transform item)
|
||||
{
|
||||
switch (align)
|
||||
{
|
||||
case Alignment.Left:
|
||||
item.SetSiblingIndex(0);
|
||||
break;
|
||||
case Alignment.Middle:
|
||||
item.SetSiblingIndex(1);
|
||||
break;
|
||||
case Alignment.Right:
|
||||
item.SetSiblingIndex(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c56a1db52fd64134881893a68f6e1371
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,140 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameMain
|
||||
{
|
||||
public class TextMode
|
||||
{
|
||||
public string Label_Load_Progress = "正在下载资源文件,请耐心等待\n当前下载速度:{0}/s 资源文件大小:{1}";
|
||||
public string Label_Load_FirstUnpack = "首次进入游戏,正在初始化游戏资源...(此过程不消耗网络流量)";
|
||||
public string Label_Load_Unpacking = "正在更新本地资源版本,请耐心等待...(此过程不消耗网络流量)";
|
||||
public string Label_Load_Checking = "检测更新设置{0}...";
|
||||
public string Label_Load_Checked = "最新版本检测完成";
|
||||
public string Label_Load_Package = "当前使用的版本过低,请下载安装最新版本";
|
||||
public string Label_Load_Plantform = "当前使用的版本过低,请前往应用商店安装最新版本";
|
||||
public string Label_Load_Notice = "检测到可选资源更新,更新包大小<color=#BA3026>{0}</color>,\n推荐完成更新提升游戏体验";
|
||||
public string Label_Load_Force = "检测到版本更新,取消更新将导致无法进入游戏";
|
||||
|
||||
public string Label_Load_Force_WIFI =
|
||||
"检测到有新的游戏内容需要更新,\n更新包大小<color=#BA3026>{0}</color>, \n取消更新将导致无法进入游戏,您当前已为<color=#BA3026>wifi网络</color>,请开始更新";
|
||||
|
||||
public string Label_Load_Force_NO_WIFI =
|
||||
"检测到有新的游戏内容需要更新,\n更新包大小<color=#BA3026>{0}</color>, \n取消更新将导致无法进入游戏,请开始更新";
|
||||
|
||||
public string Label_Load_Error = "更新参数错误{0},请点击确定重新启动游戏";
|
||||
public string Label_Load_FirstEntrerGame_Error = "首次进入游戏资源异常";
|
||||
public string Label_Load_UnpackComplete = "正在加载最新资源文件...(此过程不消耗网络流量)";
|
||||
public string Label_Load_UnPackError = "资源解压失败,请点击确定重新启动游戏";
|
||||
public string Label_Load_Load_Progress = "正在载入...{0}%";
|
||||
public string Label_Load_Download_Progress = "正在下载...{0}%";
|
||||
public string Label_Load_Load_Complete = "载入完成";
|
||||
public string Label_Load_Init = "初始化...";
|
||||
public string Label_Net_UnReachable = "当前网络不可用,请检查本地网络设置后点击确认进行重试";
|
||||
public string Label_Net_ReachableViaCarrierDataNetwork = "当前是移动网络,是否继续下载";
|
||||
public string Label_Net_Error = "网络异常,请重试";
|
||||
public string Label_Net_Changed = "网络切换,正在尝试重连,{0}次";
|
||||
public string Label_Data_Empty = "数据异常";
|
||||
public string Label_Memory_Low = "初始化资源加载失败,请检查本地内存是否充足";
|
||||
public string Label_Memory_Low_Load = "内存是否充足,无法更新";
|
||||
public string Label_Memory_UnZip_Low = "内存不足,无法解压";
|
||||
public string Label_App_id = "APPVer {0}"; //"游戏版本号:{0}";
|
||||
public string Label_Res_id = "ResVer {0}"; //"资源版本号:{0}";
|
||||
public string Label_Clear_Comfirm = "是否清理本地资源?(清理完成后会关闭游戏且重新下载最新资源)";
|
||||
public string Label_RestartApp = "本次更新需要重启应用,请点击确定重新启动游戏";
|
||||
public string Label_DownLoadFailed = "网络太慢,是否继续下载";
|
||||
public string Label_ClearConfig = "清除环境配置,需要重启应用";
|
||||
public string Label_RegionInfoIllegal = "区服信息为空";
|
||||
public string Label_RemoteUrlisNull = "热更地址为空";
|
||||
public string Label_FirstPackageNotFound = "首包资源加载失败";
|
||||
public string Label_RequestReginInfo = "正在请求区服信息{0}次";
|
||||
public string Label_RequestTimeOut = "请求区服信息超时,是否重试?";
|
||||
public string Label_Region_ArgumentError = "参数错误";
|
||||
public string Label_Region_IndexOutOfRange = "索引越界";
|
||||
public string Label_Region_NonConfigApplication = "未配置此应用";
|
||||
public string Label_Region_SystemError = "系统异常";
|
||||
|
||||
public string Label_PreventionOfAddiction = "著作人权:XX市TEngine有限公司 软著登记号:2022SR0000000\n抵制不良游戏,拒绝盗版游戏。注意自我保护,谨防受骗上当。适度游戏益脑," +
|
||||
"沉迷游戏伤身。合理安排时间,享受健康生活。";
|
||||
|
||||
public string Label_Btn_Update = "确定";
|
||||
public string Label_Btn_Ignore = "取消";
|
||||
public string Label_Btn_Package = "更新";
|
||||
|
||||
public string Label_Dlc_ConfigVerificateStage = "配置校验中...";
|
||||
public string Label_Dlc_ConfigLoadingStage = "下载配置中...";
|
||||
public string Label_Dlc_AssetsLoading = "下载资源中...";
|
||||
public string Label_Dlc_LoadingFinish = "下载结束";
|
||||
|
||||
public string Label_Dlc_Load_Force_WIFI =
|
||||
"检测到有新的游戏内容需要更新, 取消更新将导致无法进入游戏,您当前已为<color=#BA3026>wifi网络</color>,请开始更新";
|
||||
|
||||
public string Label_Dlc_Load_Force_NO_WIFI =
|
||||
"检测到有新的游戏内容需要更新, 取消更新将导致无法进入游戏,请开始更新";
|
||||
|
||||
public string Label_Had_Update = "检测到有版本更新...";
|
||||
public string Label_RequestVersionIng = "正在向服务器请求版本信息中...";
|
||||
public string Label_RequestVersionInfo = "正在向服务器请求版本信息{0}次";
|
||||
}
|
||||
|
||||
public class LoadText : TextMode
|
||||
{
|
||||
private static LoadText _instance;
|
||||
|
||||
public static LoadText Instance => _instance ??= new LoadText();
|
||||
|
||||
public void InitConfigData(TextAsset asset)
|
||||
{
|
||||
if (asset == null)
|
||||
return;
|
||||
|
||||
TextMode loadConfig = JsonUtility.FromJson<TextMode>(asset.text);
|
||||
if (loadConfig != null)
|
||||
{
|
||||
Label_Load_Progress = loadConfig.Label_Load_Progress;
|
||||
Label_Load_FirstUnpack = loadConfig.Label_Load_FirstUnpack;
|
||||
Label_Load_Unpacking = loadConfig.Label_Load_Unpacking;
|
||||
Label_Load_Checking = loadConfig.Label_Load_Checking;
|
||||
Label_Load_Checked = loadConfig.Label_Load_Checked;
|
||||
Label_Load_Package = loadConfig.Label_Load_Package;
|
||||
Label_Load_Plantform = loadConfig.Label_Load_Plantform;
|
||||
Label_Load_Notice = loadConfig.Label_Load_Notice;
|
||||
Label_Load_Force = loadConfig.Label_Load_Force;
|
||||
Label_Load_Force_WIFI = loadConfig.Label_Load_Force_WIFI;
|
||||
Label_Load_Force_NO_WIFI = loadConfig.Label_Load_Force_NO_WIFI;
|
||||
Label_Load_Error = loadConfig.Label_Load_Error;
|
||||
Label_Load_FirstEntrerGame_Error = loadConfig.Label_Load_FirstEntrerGame_Error;
|
||||
Label_Load_UnpackComplete = loadConfig.Label_Load_UnpackComplete;
|
||||
Label_Load_UnPackError = loadConfig.Label_Load_UnPackError;
|
||||
Label_Load_Load_Progress = loadConfig.Label_Load_Load_Progress;
|
||||
Label_Load_Download_Progress = loadConfig.Label_Load_Download_Progress;
|
||||
Label_Load_Init = loadConfig.Label_Load_Init;
|
||||
Label_Net_UnReachable = loadConfig.Label_Net_UnReachable;
|
||||
Label_Net_Error = loadConfig.Label_Net_Error;
|
||||
Label_Net_Changed = loadConfig.Label_Net_Changed;
|
||||
Label_Data_Empty = loadConfig.Label_Data_Empty;
|
||||
Label_Memory_Low = loadConfig.Label_Memory_Low;
|
||||
Label_Memory_Low_Load = loadConfig.Label_Memory_Low_Load;
|
||||
Label_Memory_UnZip_Low = loadConfig.Label_Memory_UnZip_Low;
|
||||
Label_App_id = loadConfig.Label_App_id;
|
||||
Label_Res_id = loadConfig.Label_Res_id;
|
||||
Label_Clear_Comfirm = loadConfig.Label_Clear_Comfirm;
|
||||
Label_RestartApp = loadConfig.Label_RestartApp;
|
||||
Label_DownLoadFailed = loadConfig.Label_DownLoadFailed;
|
||||
Label_ClearConfig = loadConfig.Label_ClearConfig;
|
||||
Label_PreventionOfAddiction = loadConfig.Label_PreventionOfAddiction;
|
||||
Label_RegionInfoIllegal = loadConfig.Label_RegionInfoIllegal;
|
||||
Label_RemoteUrlisNull = loadConfig.Label_RemoteUrlisNull;
|
||||
Label_FirstPackageNotFound = loadConfig.Label_FirstPackageNotFound;
|
||||
Label_RequestReginInfo = loadConfig.Label_RequestReginInfo;
|
||||
Label_Net_ReachableViaCarrierDataNetwork = loadConfig.Label_Net_ReachableViaCarrierDataNetwork;
|
||||
Label_RequestTimeOut = loadConfig.Label_RequestTimeOut;
|
||||
Label_Region_ArgumentError = loadConfig.Label_Region_ArgumentError;
|
||||
Label_Region_IndexOutOfRange = loadConfig.Label_Region_IndexOutOfRange;
|
||||
Label_Region_NonConfigApplication = loadConfig.Label_Region_NonConfigApplication;
|
||||
Label_Region_SystemError = loadConfig.Label_Region_SystemError;
|
||||
Label_Btn_Ignore = loadConfig.Label_Btn_Ignore;
|
||||
Label_Btn_Package = loadConfig.Label_Btn_Package;
|
||||
Label_Btn_Update = loadConfig.Label_Btn_Update;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26b25172848a83441b2cfadd771152ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace GameMain
|
||||
{
|
||||
public class LoadUpdateLogic
|
||||
{
|
||||
private static LoadUpdateLogic _instance;
|
||||
|
||||
public Action<int> DownloadCompleteAction = null;
|
||||
public Action<float> DownProgressAction = null;
|
||||
public Action<bool> UnpackedCompleteAction = null;
|
||||
public Action<float> UnpackedProgressAction = null;
|
||||
|
||||
public static LoadUpdateLogic Instance => _instance ??= new LoadUpdateLogic();
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c7fe9e5620ac5d4bae49fbd58746210
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TEngine;
|
||||
|
||||
namespace GameMain
|
||||
{
|
||||
public class UIDefine
|
||||
{
|
||||
public static readonly string UILoadUpdate = "UILoadUpdate";
|
||||
public static readonly string UILoadTip = "UILoadTip";
|
||||
}
|
||||
|
||||
public static class UILoadMgr
|
||||
{
|
||||
private static readonly Dictionary<string, System.Type> _uiMap = new Dictionary<string, System.Type>();
|
||||
|
||||
private static bool _isInit = false;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化。
|
||||
/// </summary>
|
||||
public static void Initialize()
|
||||
{
|
||||
if (_isInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_uiMap.Add(UIDefine.UILoadUpdate, typeof(UILoadUpdate));
|
||||
_uiMap.Add(UIDefine.UILoadTip, typeof(UILoadTip));
|
||||
GameModule.UI.ShowUI<UILoadUpdate>();
|
||||
_isInit = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show ui
|
||||
/// </summary>
|
||||
/// <param name="uiInfo">对应的ui</param>
|
||||
/// <param name="param">参数</param>
|
||||
public static void Show(string uiInfo, object param = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(uiInfo))
|
||||
return;
|
||||
|
||||
if (!_uiMap.ContainsKey(uiInfo))
|
||||
{
|
||||
Log.Error($"ui not exist: {uiInfo}");
|
||||
return;
|
||||
}
|
||||
|
||||
GameModule.UI.ShowUI(_uiMap[uiInfo], param);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏ui管理器。
|
||||
/// </summary>
|
||||
public static void HideAll()
|
||||
{
|
||||
GameModule.UI.CloseWindow<UILoadTip>();
|
||||
GameModule.UI.CloseWindow<UILoadUpdate>();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6381a0f5db6b61948a8fcb8176d8019b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,143 @@
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using TEngine;
|
||||
|
||||
namespace GameMain
|
||||
{
|
||||
public enum MessageShowType
|
||||
{
|
||||
None = 0,
|
||||
OneButton = 1,
|
||||
TwoButton = 2,
|
||||
ThreeButton = 3,
|
||||
}
|
||||
|
||||
[Window(UILayer.UI, fromResources: true, location: "AssetLoad/UILoadTip")]
|
||||
public class UILoadTip : UIWindow
|
||||
{
|
||||
public Action OnOk;
|
||||
public Action OnCancel;
|
||||
public MessageShowType ShowType = MessageShowType.None;
|
||||
|
||||
#region 脚本工具生成的代码
|
||||
private Button m_btnPackage;
|
||||
private Text m_textTittle;
|
||||
private Text m_textInfo;
|
||||
private Button m_btnIgnore;
|
||||
private Button m_btnUpdate;
|
||||
public override void ScriptGenerator()
|
||||
{
|
||||
m_btnPackage = FindChildComponent<Button>("BgImage/m_btnPackage");
|
||||
m_textTittle = FindChildComponent<Text>("BgImage/m_textTittle");
|
||||
m_textInfo = FindChildComponent<Text>("BgImage/m_textInfo");
|
||||
m_btnIgnore = FindChildComponent<Button>("BgImage/Group/m_btnIgnore");
|
||||
m_btnUpdate = FindChildComponent<Button>("BgImage/Group/m_btnUpdate");
|
||||
m_btnPackage.onClick.AddListener(OnClickPackageBtn);
|
||||
m_btnIgnore.onClick.AddListener(OnClickIgnoreBtn);
|
||||
m_btnUpdate.onClick.AddListener(OnClickUpdateBtn);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
|
||||
private void OnClickPackageBtn()
|
||||
{
|
||||
if (OnOk == null)
|
||||
{
|
||||
m_textInfo.text = "<color=#BA3026>该按钮不应该存在</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
OnOk();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickIgnoreBtn()
|
||||
{
|
||||
if (OnCancel == null)
|
||||
{
|
||||
m_textInfo.text = "<color=#BA3026>该按钮不应该存在</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
OnCancel();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickUpdateBtn()
|
||||
{
|
||||
if (OnOk == null)
|
||||
{
|
||||
m_textInfo.text = "<color=#BA3026>该按钮不应该存在</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
OnOk();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void OnRefresh()
|
||||
{
|
||||
base.OnRefresh();
|
||||
m_btnIgnore.gameObject.SetActive(false);
|
||||
m_btnPackage.gameObject.SetActive(false);
|
||||
m_btnUpdate.gameObject.SetActive(false);
|
||||
switch (ShowType)
|
||||
{
|
||||
case MessageShowType.OneButton:
|
||||
m_btnUpdate.gameObject.SetActive(true);
|
||||
break;
|
||||
case MessageShowType.TwoButton:
|
||||
m_btnUpdate.gameObject.SetActive(true);
|
||||
m_btnIgnore.gameObject.SetActive(true);
|
||||
break;
|
||||
case MessageShowType.ThreeButton:
|
||||
m_btnIgnore.gameObject.SetActive(true);
|
||||
m_btnPackage.gameObject.SetActive(true);
|
||||
m_btnUpdate.gameObject.SetActive(true);
|
||||
break;
|
||||
}
|
||||
|
||||
m_textInfo.text = UserData.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框,目前最多支持三个按钮
|
||||
/// </summary>
|
||||
/// <param name="desc">描述</param>
|
||||
/// <param name="showtype">类型(MessageShowType)</param>
|
||||
/// <param name="style">StyleEnum</param>
|
||||
/// <param name="onOk">点击事件</param>
|
||||
/// <param name="onCancel">取消事件</param>
|
||||
/// <param name="onPackage">更新事件</param>
|
||||
public static void ShowMessageBox(string desc, MessageShowType showtype = MessageShowType.OneButton,
|
||||
LoadStyle.StyleEnum style = LoadStyle.StyleEnum.Style_Default,
|
||||
Action onOk = null,
|
||||
Action onCancel = null,
|
||||
Action onPackage = null)
|
||||
{
|
||||
var operation = GameModule.UI.ShowUI<UILoadTip>(desc);
|
||||
if (operation == null || operation.Window == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ui = operation.Window as UILoadTip;
|
||||
ui.OnOk = onOk;
|
||||
ui.OnCancel = onCancel;
|
||||
ui.ShowType = showtype;
|
||||
ui.OnRefresh();
|
||||
|
||||
var loadStyleUI = ui.gameObject.GetComponent<LoadStyle>();
|
||||
if (loadStyleUI)
|
||||
{
|
||||
loadStyleUI.SetStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d32acf4f4a006a4986b0c39320a1a99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,134 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TEngine;
|
||||
using Version = TEngine.Version;
|
||||
|
||||
namespace GameMain
|
||||
{
|
||||
[Window(UILayer.UI, fromResources: true, location: "AssetLoad/UILoadUpdate",fullScreen:true)]
|
||||
public class UILoadUpdate : UIWindow
|
||||
{
|
||||
private Scrollbar m_scrollbarProgress;
|
||||
|
||||
#region 脚本工具生成的代码
|
||||
private Image m_imgBackGround;
|
||||
private Text m_textDesc;
|
||||
private Button m_btnClear;
|
||||
private Text m_textAppid;
|
||||
private Text m_textResid;
|
||||
public override void ScriptGenerator()
|
||||
{
|
||||
m_imgBackGround = FindChildComponent<Image>("m_imgBackGround");
|
||||
m_textDesc = FindChildComponent<Text>("m_textDesc");
|
||||
m_btnClear = FindChildComponent<Button>("TopNode/m_btnClear");
|
||||
m_textAppid = FindChildComponent<Text>("TopNode/m_textAppid");
|
||||
m_textResid = FindChildComponent<Text>("TopNode/m_textResid");
|
||||
m_scrollbarProgress = FindChildComponent<Scrollbar>("m_scrollbarProgress");
|
||||
m_btnClear.onClick.AddListener(OnClickClearBtn);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void OnCreate()
|
||||
{
|
||||
base.OnCreate();
|
||||
LoadUpdateLogic.Instance.DownloadCompleteAction += DownLoad_Complete_Action;
|
||||
LoadUpdateLogic.Instance.DownProgressAction += DownLoad_Progress_Action;
|
||||
LoadUpdateLogic.Instance.UnpackedCompleteAction += Unpacked_Complete_Action;
|
||||
LoadUpdateLogic.Instance.UnpackedProgressAction += Unpacked_Progress_Action;
|
||||
m_btnClear.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public override void RegisterEvent()
|
||||
{
|
||||
base.RegisterEvent();
|
||||
AddUIEvent(RuntimeId.ToRuntimeId("RefreshVersion"),RefreshVersion);
|
||||
}
|
||||
|
||||
public override void OnRefresh()
|
||||
{
|
||||
base.OnRefresh();
|
||||
}
|
||||
|
||||
#region 事件
|
||||
|
||||
private void OnClickClearBtn()
|
||||
{
|
||||
OnStop(null);
|
||||
UILoadTip.ShowMessageBox(LoadText.Instance.Label_Clear_Comfirm, MessageShowType.TwoButton,
|
||||
LoadStyle.StyleEnum.Style_Clear,
|
||||
() =>
|
||||
{
|
||||
GameModule.Resource.ClearSandbox();
|
||||
Application.Quit();
|
||||
}, () => { OnContinue(null); });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void RefreshVersion()
|
||||
{
|
||||
m_textAppid.text = string.Format(LoadText.Instance.Label_App_id, Version.GameVersion);
|
||||
m_textResid.text = string.Format(LoadText.Instance.Label_Res_id, GameModule.Resource.GetPackageVersion());
|
||||
}
|
||||
|
||||
public virtual void OnContinue(GameObject obj)
|
||||
{
|
||||
// LoadMgr.Instance.StartDownLoad();
|
||||
}
|
||||
|
||||
public virtual void OnStop(GameObject obj)
|
||||
{
|
||||
// LoadMgr.Instance.StopDownLoad();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度完成
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
protected virtual void DownLoad_Complete_Action(int type)
|
||||
{
|
||||
Log.Info("DownLoad_Complete");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度更新
|
||||
/// </summary>
|
||||
/// <param name="progress"></param>
|
||||
protected virtual void DownLoad_Progress_Action(float progress)
|
||||
{
|
||||
m_scrollbarProgress.gameObject.SetActive(true);
|
||||
|
||||
m_scrollbarProgress.size = progress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解压缩完成回调
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
protected virtual void Unpacked_Complete_Action(bool type)
|
||||
{
|
||||
m_scrollbarProgress.gameObject.SetActive(true);
|
||||
m_textDesc.text = LoadText.Instance.Label_Load_UnpackComplete;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解压缩进度更新
|
||||
/// </summary>
|
||||
/// <param name="progress"></param>
|
||||
protected virtual void Unpacked_Progress_Action(float progress)
|
||||
{
|
||||
m_scrollbarProgress.gameObject.SetActive(true);
|
||||
m_textDesc.text = LoadText.Instance.Label_Load_Unpacking;
|
||||
|
||||
m_scrollbarProgress.size = progress;
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
OnStop(null);
|
||||
LoadUpdateLogic.Instance.DownloadCompleteAction -= DownLoad_Complete_Action;
|
||||
LoadUpdateLogic.Instance.DownProgressAction -= DownLoad_Progress_Action;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0fad7cbc10b815488c9e6ebfeccb210
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user