Configuring the web request
Unity has made creating and sending a basic GET request extremely simple for us (wonderful, since this topic can be hard to understand at first). Let’s put together the pieces of our request by updating WebRequestManager.cs to match the following code, which adds our URL as a string variable, instantiates a UnityWebRequest instance, and sends it on its way to bring us back our weather data:
using UnityEngine;
// 1
using UnityEngine.Networking;
using System.Collections;
public class WebRequestManager : MonoBehaviour, IManager
{
// 2
private string _url = "https://api.open-meteo.com/v1/forecast
?latitude=40.71&longitude=-74.01¤t_weather=true";
private string _state;
public string State { //… No changes needed… }
public void Initialize()
{
_state = "Web Request Manager initialized..";
Debug.Log(_state);
//3
FetchData();
}
void...