public override Offset ReadJson(JsonReader reader, Type objectType, Offset existingValue, bool hasExistingValue, JsonSerializer serializer) { try { OffsetReference value = serializer.Deserialize <OffsetReference>(reader); return(new Offset(value)); } catch { try { Vector2 value = serializer.Deserialize <Vector2>(reader); return(new Offset(value)); } catch (JsonSerializationException exception) { throw new JsonReaderException($"Error converting value \"{reader.Value}\" to one of type '{typeof(Vector2)}' or '{typeof(OffsetReference)}'. Path '{exception.Path}', line {exception.LineNumber}, position {exception.LinePosition}."); } } }
private Offset(Vector2 value, OffsetReference reference, bool isReference) { this.Value = value; this.Reference = reference; this.IsReference = isReference; }
public Offset(OffsetReference reference) : this(Vector2.Zero, reference, true) { }