【覆盖安装包时清除缓存】
parent
7ca7e78761
commit
0946e743ba
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue