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() {