public void DeserializeComponentTypes(JsonHelperReader json, GameObject go) { json.ReadPropertyName("componentTypes"); json.Read(); // Drop StartArray while (json.TokenType != JsonToken.EndArray) { Type componentType = json.ReadObject <Type>(); if (go.GetComponent(componentType) == null) { go.AddComponent(componentType); } } json.Read(); // Drop EndArray }
public virtual void Deserialize(JsonHelperReader json, object obj, string prop) { MemberInfo info; if (!_MemberMap.TryGetValue(prop, out info)) { // Forcibly throw here - can't parse the following data anymore throw new JsonReaderException("Invalid property " + prop + "!"); } object value = json.ReadObject(info.GetValueType()); if (obj == null) { // Just drop the value. return; } ReflectionHelper.SetValue(info, obj, value); }