public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { // WriteJson is never called when value == null. Instead Json.NET calls writer.WriteNull() directly. var metadata = new GameObjectMetadata((UnityEngine.Object)value); serializer.Serialize(writer, metadata); }
public static GameObjectMetadata LoadMetadata(this XElement xml) { if (xml.Name.LocalName != MetadataNode) { throw new ArgumentException("Load Metadata: xml is not a GameObjectMetadata."); } return(GameObjectMetadata.FromXml(xml)); }
public bool AddOrModify(GameObjectMetadata metadata) { if (_collection.FirstOrDefault(or => or.Equals(metadata)) is GameObjectMetadata existing) { bool modified = false; if (existing.Name != metadata.Name) { existing.Name = metadata.Name; modified = true; } if (existing.Keywords.SequenceEqual(metadata.Keywords)) { existing.UpdateKeywords(metadata.Keywords); modified = true; } return(modified); } else { _collection.Add(metadata); return(true); } }
public bool Remove(GameObjectMetadata metadata) { return(_collection.Remove(metadata)); }