UnityWebRequestでjsonファイルをボディ付きのGETする
ちょっと(かなり)詰まったのでメモ。
Unityからjsonファイル諸々をGetする際に、UnityWebRequestを使ったり、wwwを使ったりして頑張る。
>|C#|
private IEnumerator GetTest{
UnityWebRequest request = UnityWebRequest.Get("ここにURL");//通信用意して
request.SetRequestHeader("Content-Type", "application/json"); //必要な ヘッダ設定して
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); // ボディ設定して
// リクエスト送信
yield return request.Send();
|