Reading data from the web
Much data and authentication is now available via web communications. In this recipe, we’ll create a simple Unity project using a C# script class to retrieve a small sample JSON text file from the web.
Figure 10.16: The JSON data downloaded from the web
Getting ready
The example of the web-published text file for this recipe can be found at the following URL (thanks to filesamples.com for publishing a range of test files on their website): https://filesamples.com/samples/code/json/sample1.json
However, you can replace this web address with any URL that returns a text file of some kind.
How to do it...
To read data from the web, perform the following steps:
- Create a new Unity 2D project.
- Load the TextMeshPro essentials resources, by choosing the menu Window | TextMeshPro | Import TMP Essential Resources.
- In the Hierarchy panel, add a Text TMP GameObject to the scene by choosing the menu GameObject...