From 0946e743baa30d72fc0e48e1c5ca26fef64b753c Mon Sep 17 00:00:00 2001 From: zhangshanxue Date: Fri, 27 Aug 2021 16:44:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=A6=86=E7=9B=96=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=8C=85=E6=97=B6=E6=B8=85=E9=99=A4=E7=BC=93=E5=AD=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/GameInit/GameStart.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Assets/Scripts/GameInit/GameStart.cs b/Assets/Scripts/GameInit/GameStart.cs index 2f68f47bdc..957680e0ed 100644 --- a/Assets/Scripts/GameInit/GameStart.cs +++ b/Assets/Scripts/GameInit/GameStart.cs @@ -14,6 +14,9 @@ public class GameStart : MonoBehaviour private AssetBundle bundle; void Start() { + // 判断是否是覆盖安装了包,是就清除缓存 + ClearCach(); + // 开始启动游戏 if (Application.isEditor && AppConst.bundleMode && AppConst.isUpdate) { if (!System.IO.Directory.Exists(Util.AppContentPath())) @@ -46,6 +49,29 @@ public class GameStart : MonoBehaviour } } } + //请本地缓存 + void ClearCach() + { + int localCode = PlayerPrefs.GetInt("SDKVersionCode", -1); + int code = localCode; + if (AppConst.isSDK) + { + code = AndroidDeviceInfo.Instance.GetVersionCode(); + } +#if !UNITY_EDITOR + if (code != localCode) + { + string RootPath = AppConst.PersistentDataPath; + string path = RootPath.Substring(0, RootPath.Length - 1); + if (Directory.Exists(path)) + { + Directory.Delete(path, true); + } + Directory.CreateDirectory(path); + PlayerPrefs.SetInt("SDKVersionCode", code); + } +#endif + } void playSplash() {