public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(new Matrix4x4()); } var obj = BacktraceJObject.Load(reader); return(new Matrix4x4 { m00 = (float)obj["m00"], m01 = (float)obj["m01"], m02 = (float)obj["m02"], m03 = (float)obj["m03"], m20 = (float)obj["m20"], m21 = (float)obj["m21"], m22 = (float)obj["m22"], m23 = (float)obj["m23"], m30 = (float)obj["m30"], m31 = (float)obj["m31"], m32 = (float)obj["m32"], m33 = (float)obj["m33"] }); }
private static Vector2 PopulateVector2(JsonReader reader) { var result = new Vector2(); if (reader.TokenType != JsonToken.Null) { var jo = BacktraceJObject.Load(reader); result.x = jo["x"].Value <float>(); result.y = jo["y"].Value <float>(); } return(result); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = BacktraceJObject.Load(reader); var result = new Resolution { height = (int)obj["height"], width = (int)obj["width"], refreshRate = (int)obj["refreshRate"] }; return(result); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(new Color()); } var obj = BacktraceJObject.Load(reader); if (objectType == typeof(Color32)) { return(new Color32((byte)obj["r"], (byte)obj["g"], (byte)obj["b"], (byte)obj["a"])); } return(new Color((float)obj["r"], (float)obj["g"], (float)obj["b"], (float)obj["a"])); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(null); } var result = new List <T>(); var obj = BacktraceJObject.Load(reader); for (var i = 0; i < obj.Count; i++) { result.Add(BacktraceDataConverter.DeserializeObject <T>(obj[i].ToString())); } return(result); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var obj = BacktraceJObject.Load(reader); var props = obj.Properties().ToList(); var result = new Quaternion(); if (props.Any(p => p.Name == "w")) { result.w = (float)obj["w"]; } if (props.Any(p => p.Name == "x")) { result.x = (float)obj["x"]; } if (props.Any(p => p.Name == "y")) { result.y = (float)obj["y"]; } if (props.Any(p => p.Name == "z")) { result.z = (float)obj["z"]; } if (props.Any(p => p.Name == "eulerAngles")) { var eulerVecObj = obj["eulerAngles"]; var eulerVec = new Vector3(); eulerVec.x = (float)eulerVecObj["x"]; eulerVec.y = (float)eulerVecObj["y"]; eulerVec.z = (float)eulerVecObj["z"]; result.eulerAngles = eulerVec; } return(result); }