예제 #1
0
 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}.");
         }
     }
 }
예제 #2
0
 private Offset(Vector2 value, OffsetReference reference, bool isReference)
 {
     this.Value       = value;
     this.Reference   = reference;
     this.IsReference = isReference;
 }
예제 #3
0
 public Offset(OffsetReference reference) : this(Vector2.Zero, reference, true)
 {
 }