unity转微信小游戏,隐藏后台时,把数据存储到缓存里。但会报错:
plugin.js:93 JsonException: Can't add a value here
at LitJson.JsonWriter.DoValidation (LitJson.Condition cond) [0x00000] in <00000000000000000000000000000000>:0
(env: Windows,mg,1.06.2402040; lib: 3.2.5)
代码如下:
WX.OnHide((res) => {
WX.SetStorageSync("key", "data");
});
我也遇到了同样的问题,改成WX.StorageSetStringSync("token", token)就可以了,可能WX.SetStorageSync的第二个参数只能传对象