示例#1
0
        public static void Save(MainGrid grid)
        {
            GroundPointBuilder[] points = grid.Points.Select(item => new GroundPointBuilder(item)).ToArray();
            GroundEdgeBuilder[]  edges  = grid.Edges.Select(item => new GroundEdgeBuilder(item)).ToArray();
            GroundLoader         loader = new GroundLoader(points, edges);
            string asJson = JsonUtility.ToJson(loader);

            PlayerPrefs.SetString(SaveFilePath, asJson);
            PlayerPrefs.Save();
        }
示例#2
0
        public static MainGrid Load(string json)
        {
            GroundLoader gridLoader = JsonUtility.FromJson <GroundLoader>(json);

            return(new MainGrid(gridLoader.Points, gridLoader.Edges));
        }