O'Reilly logo

Unity 5.x Cookbook by Chico Queiroz, Matt Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading game data from a text file map

Rather than, for every level of a game, having to create and place every GameObject on the screen by hand, a better approach can be to create the text files of rows, and columns of characters, where each character corresponds to the type of GameObject that is to be created in the corresponding location. In this recipe, we'll use a text file and set of prefab sprites to display a graphical version of a text-data file for a screen from the classic game called NetHack.

Loading game data from a text file map

Getting ready

In the 1362_10_08 folder, we have provided the following two files for this recipe:

  • level1.txt (a text file, representing a level)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required