private static string convertWorldTileGridArrayToJSON(WorldTileMap world) { WorldJSONWrapper jsonWrapper = new WorldJSONWrapper(); GameObject[,] gridArray = world.grid; int width = (int)world.width; int height = (int)world.height; TileListJSONWrapper <TileJSONWrapper> tileList = new TileListJSONWrapper <TileJSONWrapper>(); tileList.list = new List <TileJSONWrapper>(); for (var i = 0; i < width; ++i) { for (var j = 0; j < height; ++j) { GridTile tileComponent = gridArray[i, j].GetComponent <GridTile>(); Debug.Log(tileComponent.currentTileType); TileJSONWrapper tileWrapper = new TileJSONWrapper(tileComponent.currentTileType, i, j); tileList.list.Add(tileWrapper); } } jsonWrapper.width = width; jsonWrapper.height = height; jsonWrapper.tileList = tileList.list; return(JsonUtility.ToJson(jsonWrapper)); }
private static WorldJSONWrapper wrapMapFromJSON(string json, WorldTileMap worldMap) { WorldJSONWrapper newMapWrapper = (WorldJSONWrapper)JsonUtility.FromJson(json, System.Type.GetType("WorldJsonUtility").GetNestedType("WorldJSONWrapper")); return(newMapWrapper); }