public static string ToJson(this glTF_VRM_Firstperson self) { var f = new JsonFormatter(); VRMSerializer.Serialize_vrm_firstPerson(f, self); return(f.ToString()); }
public static glTF_VRM_Firstperson Deserialize_vrm_firstPerson(ListTreeNode <JsonValue> parsed) { var value = new glTF_VRM_Firstperson(); foreach (var kv in parsed.ObjectItems()) { var key = kv.Key.GetString(); if (key == "firstPersonBone") { value.firstPersonBone = kv.Value.GetInt32(); continue; } if (key == "firstPersonBoneOffset") { value.firstPersonBoneOffset = Deserialize_vrm_firstPerson_firstPersonBoneOffset(kv.Value); continue; } if (key == "meshAnnotations") { value.meshAnnotations = Deserialize_vrm_firstPerson_meshAnnotations(kv.Value); continue; } if (key == "lookAtTypeName") { value.lookAtTypeName = kv.Value.GetString(); continue; } if (key == "lookAtHorizontalInner") { value.lookAtHorizontalInner = Deserialize_vrm_firstPerson_lookAtHorizontalInner(kv.Value); continue; } if (key == "lookAtHorizontalOuter") { value.lookAtHorizontalOuter = Deserialize_vrm_firstPerson_lookAtHorizontalOuter(kv.Value); continue; } if (key == "lookAtVerticalDown") { value.lookAtVerticalDown = Deserialize_vrm_firstPerson_lookAtVerticalDown(kv.Value); continue; } if (key == "lookAtVerticalUp") { value.lookAtVerticalUp = Deserialize_vrm_firstPerson_lookAtVerticalUp(kv.Value); continue; } } return(value); }
public static void Serialize_vrm_firstPerson(JsonFormatter f, glTF_VRM_Firstperson value) { f.BeginMap(); if (value.firstPersonBone >= 0) { f.Key("firstPersonBone"); f.Value(value.firstPersonBone); } if (value.firstPersonBoneOffset != null) { f.Key("firstPersonBoneOffset"); Serialize_vrm_firstPerson_firstPersonBoneOffset(f, value.firstPersonBoneOffset); } if (value.meshAnnotations != null && value.meshAnnotations.Count >= 0) { f.Key("meshAnnotations"); Serialize_vrm_firstPerson_meshAnnotations(f, value.meshAnnotations); } if (!string.IsNullOrEmpty(value.lookAtTypeName)) { f.Key("lookAtTypeName"); f.Value(value.lookAtTypeName); } if (value.lookAtHorizontalInner != null) { f.Key("lookAtHorizontalInner"); Serialize_vrm_firstPerson_lookAtHorizontalInner(f, value.lookAtHorizontalInner); } if (value.lookAtHorizontalOuter != null) { f.Key("lookAtHorizontalOuter"); Serialize_vrm_firstPerson_lookAtHorizontalOuter(f, value.lookAtHorizontalOuter); } if (value.lookAtVerticalDown != null) { f.Key("lookAtVerticalDown"); Serialize_vrm_firstPerson_lookAtVerticalDown(f, value.lookAtVerticalDown); } if (value.lookAtVerticalUp != null) { f.Key("lookAtVerticalUp"); Serialize_vrm_firstPerson_lookAtVerticalUp(f, value.lookAtVerticalUp); } f.EndMap(); }
public void FirstPersonTest() { var model = new glTF_VRM_Firstperson(); var json = model.ToJson(); Assert.AreEqual( @"{""firstPersonBoneOffset"":{""x"":0,""y"":0,""z"":0},""meshAnnotations"":[],""lookAtTypeName"":""Bone"",""lookAtHorizontalInner"":{""xRange"":90,""yRange"":10},""lookAtHorizontalOuter"":{""xRange"":90,""yRange"":10},""lookAtVerticalDown"":{""xRange"":90,""yRange"":10},""lookAtVerticalUp"":{""xRange"":90,""yRange"":10}}", json); Debug.Log(json); }
public void FirstPersonTest() { var model = new glTF_VRM_Firstperson(); var json = model.ToJson(); Assert.AreEqual( @"{""firstPersonBone"":-1,""firstPersonBoneOffset"":{""x"":0,""y"":0,""z"":0},""meshAnnotations"":[],""lookAtTypeName"":""Bone"",""lookAtHorizontalInner"":{""xRange"":90,""yRange"":10},""lookAtHorizontalOuter"":{""xRange"":90,""yRange"":10},""lookAtVerticalDown"":{""xRange"":90,""yRange"":10},""lookAtVerticalUp"":{""xRange"":90,""yRange"":10}}", json); Debug.Log(json); var c = new JsonSchemaValidationContext("") { EnableDiagnosisForNotRequiredFields = true, }; var json2 = JsonSchema.FromType <glTF_VRM_Firstperson>().Serialize(model, c); Assert.AreEqual( @"{""firstPersonBone"":-1,""firstPersonBoneOffset"":{""x"":0,""y"":0,""z"":0},""meshAnnotations"":[],""lookAtTypeName"":""Bone"",""lookAtHorizontalInner"":{""xRange"":90,""yRange"":10},""lookAtHorizontalOuter"":{""xRange"":90,""yRange"":10},""lookAtVerticalDown"":{""xRange"":90,""yRange"":10},""lookAtVerticalUp"":{""xRange"":90,""yRange"":10}}", json2); }