我正在 Unity 中按类别编写问答游戏。类别是通过返回 JSON 文本的 PHP 脚本获得的,* 当我在 UnityEditor 中使用此解决方案时,它可以正常工作,但是当我在移动设备上安装 .apk 时,反序列化不起作用*。
与 mysql 数据库和 PHP 脚本的连接工作正常,因为在我登录之前它工作正常
string json = [
{ "id_cat":"1",
"nombre_cat":"DAM",
"id_cat_padre":"0"
},
{ "id_cat":"4",
"nombre_cat":"ASIR",
"id_cat_padre":"0"
},
{ "id_cat":"5",
"nombre_cat":"DAW",
"id_cat_padre":"0"
}
]
然后我将此字符串转换为类别列表
lsSubCategorias = JsonConvert.DeserializeObject<List<Categoria>>(json, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
我已经在代码中添加了痕迹,它就在它停止的那一行。
我使用 NuGet 安装了 Newtonsoft.Json,它出现在参考资料中。
我也只处理了一个类别对象而不是列表,但它也不起作用。这不是一个可视化问题,因为我已经创建了类别对象并使用它们创建了按钮。
问题是它在 Unity 编辑器中工作,但在我的 android 设备上不起作用
我的手机出现以下错误:
类型错误:System.PlatformNotSupportedException ToString 错误():Error.ToString()