public static string ToJsonString(Gesture g) { int[][] values = ArrayUnroll(g.LUT); GestureJsonString gestString = new GestureJsonString { X = new float[g.Points.Length], Y = new float[g.Points.Length], StrokeID = new int[g.Points.Length], intX = new int[g.Points.Length], intY = new int[g.Points.Length], gestureClass = g.gestureClass, pointLength = g.Points.Length, //LUT = g.LUT LUTdimension = values[0], LUTflat = values[1] }; for (int i = 0; i < g.Points.Length; i++) { gestString.X[i] = g.Points[i].X; gestString.Y[i] = g.Points[i].Y; gestString.StrokeID[i] = g.Points[i].StrokeID; gestString.intX[i] = g.Points[i].intX; gestString.intY[i] = g.Points[i].intY; } string jstring = JsonUtility.ToJson(gestString); return(jstring); }
public static Gesture LoadGestureJson(string strJson) { GestureJsonString gj = JsonUtility.FromJson <GestureJsonString>(strJson); Point[] pointArr = new Point[gj.pointLength]; for (int i = 0; i < pointArr.Length; i++) { Point p = new Point(0, 0, 0) { X = gj.X[i], Y = gj.Y[i], StrokeID = gj.StrokeID[i], intX = gj.intX[i], intY = gj.intY[i] }; pointArr[i] = p; } Gesture loadedGesture = new Gesture(); loadedGesture.gestureClass = gj.gestureClass; loadedGesture.Points = pointArr; loadedGesture.LUT = ArrayRollup(gj.LUTdimension, gj.LUTflat); //loadedGesture.LUT = gj.LUT; return(loadedGesture); }