【发布时间】:2016-06-04 03:16:33
【问题描述】:
我有以下类,它是可序列化的,并且只有字符串作为字段:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[System.Serializable]
public class Cabeza
{
string id, urlOBJ, urlTextura, pathOBJbajado, pathTexturaBajada;
public string Id { get; set; }
public string UrlOBJ { get; set; }
public string UrlTextura { get; set; }
public string PathOBJbajado { get; set; }
public string PathTexturaBajada { get; set; }
public Cabeza (string nuevoId)
{
Id = nuevoId;
UrlOBJ = nuevoId +".obj";
UrlTextura = nuevoId + ".png";
}
}
据我所知,应该可以从中获取 JSON...但是,JsonUtility.ToJson() 仅返回 { }。这怎么可能?我错过了什么?
【问题讨论】:
-
我认为它正在序列化您的字段,这些字段没有值,因此不会出现在序列化结果中。
-
你能显示你调用
ToJson(...)的代码吗? -
@Maarten UrlOBJ ad UrlTextura 应该有值。