UnityTypeConverter
A custom JSON converter used by the Button Attribute to serialize the following Unity types:
Vector2, Vector2Int, Vector3, Vector3Int, Vector4, Color, Rect, RectInt, Bounds, BoundsInt
- Inheritance:
object -> JsonConverter -> UnityTypeConverter
- Namespace:
EditorAttributes.Editor.Utility
- Assembly:
EditorAttributes.Editor.asmdef
Syntax:
public class UnityTypeConverter : JsonConverter
Methods
CanConvert(Type)
Determines whether this instance can convert the specified object type.
Declaration:
public override bool CanConvert(Type objectType)
- Parameters:
TypeobjectType: The object type
Returns: bool: true if this instance can convert the specified object type; otherwise, false
Overrides:
JsonConverter.CanConvert(Type)
ReadJson(JsonReader, Type, object?, JsonSerializer)
Reads the JSON representation of the object.
Declaration:
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
- Parameters:
JsonReaderreader: The JSON reader to read fromTypeobjectType: The object typeobject?existingValue: The existing value of object being readTypeserializer: The calling serializer
Returns: object?: The object value
Overrides:
JsonConverter.ReadJson(JsonReader, Type, object?, JsonSerializer)
WriteJson(JsonWriter, object?, JsonSerializer)
Writes the JSON representation of the object.
Declaration:
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
- Parameters:
JsonWriterwriter: Writes the JSON representation of the objectobject?value: The valueJsonSerializerserializer: The calling serializer
Overrides:
JsonConverter.WriteJson(JsonWriter, object?, JsonSerializer)