I have a script that connects to the database and retrieve data. The GetData function is called by other script. is there a way that I can return the data back to the caller?
public IEnumerator GetData(){
using (UnityWebRequest wwww = UnityWebRequest.Get("http://localhost/BMS/LoadGame.php")) {
yield return wwww.SendWebRequest();
if (wwww.isNetworkError || wwww.isHttpError){
Debug.Log(wwww.error);
} else {
Debug.Log(wwww.downloadHandler.text);
//How to return the result to the caller?
}
}
}
The method that I know is to call another function in other script to pass the data, but this is a lot more troublesome. Is there any direct way that I can return the data to the caller? Thanks!
↧