/// <summary> /// 刷新内容其实是刷新是否有新内容这个事情。 /// </summary> private void RefreshContent() { var version = _versionResult.Read(); if (version == null) { return; } var billboard = version.billboard_6_2; if (billboard == null) { ShowSavedBillboard(); return; } var timestamp = PrefsUtil.GetLong(BillboardTimestampKey, 0); if (timestamp < billboard.timestamp) { // 更新公告栏的内容。 PrefsUtil.SetString(BillboardContentKey, billboard.content); PrefsUtil.SetLong(BillboardTimestampKey, billboard.timestamp); PrefsUtil.Flush(); } // 显示公告栏。 ShowSavedBillboard(); }
protected override void DoHandle(VersionResult versionResult) { _versionResult.Write(versionResult, Time.time); // 如果成功获取VersionResult数据,则保存Launcher大图。 if (versionResult.result != ResultCode.OK) { return; } // version >= 6.4.0 不再处理SplashScreen的广告位。 // 保存游戏界面背景。 var inGameConfig = versionResult.in_game_config; if (inGameConfig != null) { PrefsUtil.SetString(BgConstant.GameBgKey, inGameConfig.game_bg); PrefsUtil.SetString(BgConstant.GameBgUrlKey, inGameConfig.game_bg_url); PrefsUtil.Flush(); } // 保存公告。 var billboard = versionResult.billboard_6_2; if (billboard != null) { PrefsUtil.SetString(BillboardPanel.BillboardContentKey, billboard.content); PrefsUtil.SetLong(BillboardPanel.BillboardTimestampKey, billboard.timestamp); PrefsUtil.Flush(); } }
public static void SaveAuthCode(string authCode) { if (string.IsNullOrEmpty(authCode)) { PrefsUtil.DeleteKey(WechatAuthCode); } else { PrefsUtil.SetString(WechatAuthCode, authCode); } PrefsUtil.Flush(); }
public static void SaveOpenId(string openId) { if (string.IsNullOrEmpty(openId)) { PrefsUtil.DeleteKey(WechatOpenId); } else { PrefsUtil.SetString(WechatOpenId, openId); } PrefsUtil.Flush(); }
public void Confirm() { var saleChannel = SaleChannel.text; PrefsUtil.SetString(TestLoginRecord.TestSaleChannel, saleChannel); var product = Product.text; PrefsUtil.SetString(TestLoginRecord.TestProduct, product); int clientVersion = 0; if (int.TryParse(ClientVersion.text, out clientVersion)) { PrefsUtil.SetInt(TestLoginRecord.TestClientVersion, clientVersion); } else { GetDialogManager().ShowToast("ClientVersion不对", 2); return; } int platform = 0; if (int.TryParse(Platform.text, out platform)) { PrefsUtil.SetInt(TestLoginRecord.TestPlatform, platform); } else { GetDialogManager().ShowToast("Platform 不对", 2); return; } var lastUsername = LastVisitorUsername.text; LoginRecord.LastVisitorUsername = lastUsername; var lastVisitorId = LasVisitorId.text; LoginRecord.LastVisitorId = lastVisitorId; PrefsUtil.Flush(); _isSetTestClientVersion.Write(true, Time.time); Hide(); }
public void Confirm() { var ip = Ip.text; int port = 0; if (int.TryParse(Port.text, out port)) { PrefsUtil.SetString(TestLoginRecord.PServerTestLoginIp, ip); PrefsUtil.SetInt(TestLoginRecord.PServerTestLoginPort, port); PrefsUtil.Flush(); _isSetTestLogin.Write(true, Time.time); Hide(); } else { GetDialogManager().ShowToast("端口不对", 2); } }
/// <summary> /// 将host和port保存到PlayerPrefs中。 /// </summary> /// <param name="host"></param> /// <param name="port"></param> private void SavePIP(string host, int port) { PrefsUtil.SetString(LastHostKey, host); PrefsUtil.SetInt(LastPortKey, port); PrefsUtil.Flush(); }
private IEnumerator DownloadResource() { var pip = _context.GetPIPLogic(); if (pip.IsTest()) { SetDownloadResourceResult(DownloadResourceResult.Ok, ""); yield break; } var data = pip.GetPIPData(); if (data == null) { SetDownloadResourceResult(DownloadResourceResult.Error, string.Format( "获取下载资源失败,请重新登陆\n【错误码{0}】)", NetworkStateErrorCode.DownloadResourcesFailCode)); yield break; } if (data.Assets != null && data.Assets.Length > 0) { var downloadAssetBundleInfo = new DownloadAssetBundleInfo(); downloadAssetBundleInfo.LoadType = DownloadAssetBundleInfo.DownloadType.Download; downloadAssetBundleInfo.TotalCount = data.Assets.Length; downloadAssetBundleInfo.CompleteCount = 0; foreach (var asset in data.Assets) { if (asset == null) { continue; } //已下载过相同版本 if (GetLastAssetVersion(asset.Asset) != null && GetLastAssetVersion(asset.Asset).Version == asset.Version) { continue; } _downloadAssetBundleInfo.Write(downloadAssetBundleInfo, Time.time); var req = UnityWebRequest.GetAssetBundle(asset.Url, (uint)asset.Version, (uint)0); req.SendWebRequest(); while (!req.isDone) { yield return(null); } if (req.isNetworkError || req.isHttpError) { MyLog.ErrorWithFrame(name, asset.Url + " download fail "); SetDownloadResourceResult(DownloadResourceResult.Error, string.Format( "下载资源失败,请重新登陆\n【错误码{0}】)", NetworkStateErrorCode.DownloadResourcesFailCode)); yield break; } try { var assetJson = JsonUtility.ToJson(asset); PrefsUtil.SetString(asset.Asset, assetJson); PrefsUtil.Flush(); downloadAssetBundleInfo.CompleteCount++; //只卸载没有被cache的临时的assetbundle if (!HasCached(asset.Asset)) { var assetBundle = DownloadHandlerAssetBundle.GetContent(req); if (assetBundle) { assetBundle.Unload(false); } } } catch (Exception e) { MyLog.ErrorWithFrame(name, asset.Url + " download fail with error :" + e); continue; } } } yield return(null); _downloadAssetBundleInfo.ClearAndInvalidate(Time.time); SetDownloadResourceResult(DownloadResourceResult.Ok, ""); MyLog.InfoWithFrame(name, " download all resource succ >>>>>>>>>>>>>>>>> UnloadAllAssetBundles >>>>>>>>>>>"); }
public void OnGUI() { if (GUILayout.Button("清空登陆类型")) { PrefsUtil.SetInt(LoginRecord.LoginTypeKey, LoginRecord.NoLogin); PrefsUtil.Flush(); } if (GUILayout.Button("清空DeviceId和Username")) { PrefsUtil.SetString(LoginRecord.VisitorIdKey, ""); PrefsUtil.SetString(LoginRecord.VisitorUsernameKey, ""); PrefsUtil.Flush(); } if (GUILayout.Button("清空公告")) { PrefsUtil.SetString(BillboardPanel.BillboardContentKey, ""); PrefsUtil.SetLong(BillboardPanel.BillboardTimestampKey, 0); PrefsUtil.Flush(); } if (GUILayout.Button("清空选牌类型引导")) { PrefsUtil.SetBool(PrefsKeys.HasGuideSelectPoker, false); PrefsUtil.Flush(); } if (GUILayout.Button(("清空记录选牌的方式"))) { PrefsUtil.DeleteKey(PrefsKeys.XuanDanZhangKey); PrefsUtil.DeleteKey(PrefsKeys.HasGuideSelectPoker); PrefsUtil.Flush(); } if (GUILayout.Button("清空更新记录")) { PrefsUtil.DeleteKey(LoginRecord.DontUpdateDateKey); PrefsUtil.Flush(); } _content = EditorGUILayout.TextField("版本号", _content); if (GUILayout.Button("清空初始化Cache记录")) { PrefsUtil.SetString("InitAssetKey", _content);; var key = PrefsKeys.AssetBundleInitializedKey + _content; PrefsUtil.DeleteKey(key); PrefsUtil.Flush(); } if (GUILayout.Button("清空所有记录的更新的AssetBundle记录")) { //路径 var fullPath = Application.streamingAssetsPath; //获取指定路径下面的所有资源文件 if (Directory.Exists(fullPath)) { var direction = new DirectoryInfo(fullPath); var files = direction.GetFiles("*", SearchOption.AllDirectories); Debug.Log(files.Length); for (var i = 0; i < files.Length; i++) { if (files[i].Name.EndsWith(".meta") || files[i].Name.EndsWith(".manifest")) { continue; } PrefsUtil.DeleteKey(files[i].Name); PrefsUtil.Flush(); Debug.Log("已清空:" + files[i].Name); } } } }