25 lines
622 B
C#
25 lines
622 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
|
|
public class JsonLoader
|
|
{
|
|
public static IEnumerator LoadJSON(string jsonURL, OnLoadCompleted onLoadCompleted)
|
|
{
|
|
UnityWebRequest www = UnityWebRequest.Get(jsonURL);
|
|
yield return www.SendWebRequest();
|
|
|
|
if (www.result == UnityWebRequest.Result.ConnectionError)
|
|
{
|
|
Debug.LogError(www.error);
|
|
}
|
|
else
|
|
{
|
|
onLoadCompleted?.Invoke(www.downloadHandler.text);
|
|
}
|
|
}
|
|
}
|
|
|
|
public delegate void OnLoadCompleted(string jsonString);
|