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