Newtonsoft.Json可在Unity Editor中工作,但不能在移动设备上工作 [英] Newtonsoft.Json works in Unity Editor but not on mobile devices

查看:583
本文介绍了Newtonsoft.Json可在Unity Editor中工作,但不能在移动设备上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Unity中按类别编写问答游戏.类别是通过返回JSON文本的PHP脚本获得的, *当我在UnityEditor中使用此解决方案时,它可以正常工作,但是当我在移动设备上安装.apk时,反序列化将无法工作* .

I am programming a game of questions and answers by categories in Unity. The categories are obtained through a PHP script that returns a JSON text,* when I use this solution in the UnityEditor it works correctly, but when I install the .apk on my mobile device, deserialization does not work*.

与mysql数据库和PHP脚本的连接正常工作,因为在我登录之前,它工作正常

The connection to the mysql database and the PHP scripts work correctly because before I log in and it works fine

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"
    }
]

然后我将该字符串转换为类别列表

then I convert this string to a List of Categories

lsSubCategorias = JsonConvert.DeserializeObject<List<Categoria>>(json, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });

我已经在代码中放置了踪迹,它就在它停止的那一行上.

I've put traces in the code and it's right on that line where it stops.

我使用NuGet安装了Newtonsoft.Json,它出现在参考文献中.

I Installed the Newtonsoft.Json using the NuGet and it appears in the references.

我还只处理了一个类别对象而不是列表,但是它也不起作用. 这不是可视化问题,因为我已经创建了类别对象并使用它们创建了按钮.

I've also dealt with only one category object instead of a list, but it doesn't work either. And it is not a visualization problem because I have created category objects and created buttons with them.

问题是它可以在Unity Editor中运行,但不能在我的android设备上运行

The problem is that it works in Unity Editor but it doesn't work on my android device

我的手机有以下错误:

类型错误:System.PlatformNotSupportedException ToString Error(): Error.ToString()

Type ERROR: System.PlatformNotSupportedException ToString Error(): Error.ToString()

推荐答案

我使用NuGet安装了Newtonsoft.Json,它出现在参考文献中.

I Installed the Newtonsoft.Json using the NuGet and it appears in the references.

Unity3d il2cpp目标(例如移动设备)不支持NuGet的

Newtonsoft.Json.使用资产商店中的Newtonsoft.Json分支,例如

Newtonsoft.Json from NuGet is not supported in Unity3d il2cpp targets, like mobile devices. Use a Newtonsoft.Json fork from the asset store, like this one.

这篇关于Newtonsoft.Json可在Unity Editor中工作,但不能在移动设备上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆