using UnityEngine; using Newtonsoft.Json; /* GesturePointOffset 每一个定位点相对于上一个定位点的偏移量 */ public class GesturePointOffset { public float distance { set; get; } = 0f; // 两个点之间的距离 public float angle { set; get; } = 0f;// 两个点之间的角度 public GesturePointOffset(float distance, float angle) { this.distance = distance; this.angle = angle; } public string ExportToJson() { string json = JsonConvert.SerializeObject(this); return json; } public void ImportFromJson(string json) { var deserializedObject = JsonConvert.DeserializeObject(json); if (deserializedObject != null) { // 手动将反序列化后的对象的属性值复制到当前实例 this.distance = deserializedObject.distance; this.angle = deserializedObject.angle; } } }