【发布时间】:2016-05-24 04:57:54
【问题描述】:
我正在 Unity 上开发 iOS 应用程序,但遇到了问题。 对于数据存储,我使用 JSON,在 Unity 中我使用 Newtonsoft.Json(我从官方网站下载 dll 文件并添加到 .Net 2.0 的 Unity 项目版本)。
当我在 Mac 上的 Unity 中启动场景时一切正常,但是当我为 iPhone 构建项目并在 iPhone XCode 上启动场景时输出此日志(并且元素不会添加到下拉菜单)。
在来自 json 文件的场景中,我得到了我的元素列表并添加到下拉列表中。
public Dropdown anions;
public Dropdown cations;
StreamReader reader;
string json;
SolubilityTable solubility;
public void Start() { //When I start Scene
reader = new StreamReader (Application.dataPath + "/Data/solubilityTable.json");
json = reader.ReadToEnd ();
solubility = JsonConvert.DeserializeObject<SolubilityTable>(json);
anions.AddOptions (solubility.anions);
cations.AddOptions (solubility.cations);
}
日志:
MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.ComponentModel.TypeConverter'.
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
at System.ComponentModel.TypeDescriptor.GetConverter (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetTypeConverter (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Utilities.ConvertUtils.GetConverter (System.Type t) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CanConvertToString (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe (System.Type type) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <filename unknown>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <filename unknown>:0
at Solubility.Start () [0x00000] in <filename unknown>:0
(Filename: currently not available on il2cpp Line: -1)
【问题讨论】:
-
你收到的Json是什么样的?你能把收到的Json文件贴在这里吗?