2
我想用Newtonsoft.Json序列化整個GameObject。 當我序列化對象與JsonConvert它拋出一個錯誤:Unity 5 GameObject序列化
NotSupportedException: rigidbody property has been deprecated
UnityEngine.GameObject.get_rigidbody() (at C:/buildslave/unity/build/Runtime/Export/UnityEngineGameObject_Deprecated.cs:23)
(wrapper dynamic-method) UnityEngine.GameObject.Getrigidbody (object) <IL 0x00006, 0x00073>
Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue (object) (at Assets/JsonDotNet/Source/Serialization/DynamicValueProvider.cs:104)
Rethrow as JsonSerializationException: Error getting value from 'rigidbody' on 'UnityEngine.GameObject'.
Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue (System.Object target) (at Assets/JsonDotNet/Source/Serialization/DynamicValueProvider.cs:108)
Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContract collectionValueContract) (at Assets/JsonDotNet/Source/Serialization/JsonSerializerInternalWriter.cs:338)
這是爲什麼發生?
有問題,在這裏:
public object GetValue(object target)
{
try
{
if (_getter == null)
_getter = DynamicReflectionDelegateFactory.Instance.CreateGet<object>(_memberInfo);
return _getter(target);
}
catch (Exception ex)
{
throw new JsonSerializationException("Error getting value from '{0}' on '{1}'.".FormatWith(CultureInfo.InvariantCulture, _memberInfo.Name, target.GetType()), ex);
}
}
這是DynamicValueProvider.cs
問題在於增加的部分。 – metalowy