How to access IEnumerator variable from a different script? [c#]

I built a slightly modified version of the Server Side HighScore code (from the wiki) which fetches the user’s high score from the database based on his playerpref username.

So my IEnumerator looks like this:

	IEnumerator GetUserScore(string username)
	{
		Debug.Log ("Loading scores");
		string get_url = userScoreURL + "user=" + WWW.EscapeURL(username);
		Debug.Log (get_url);
		
		WWW hs_get = new WWW(get_url);
		yield return hs_get;
		
		if(hs_get.error != null)
		{
			print("There was an error getting your score: " + hs_get.error);
		}
		else
		{
			Debug.Log(username + " : " + hs_get.text); // used for testing
		}
		
	}

Since the IEnumerator isn’t public I decided to make a public method which starts the coroutine and can be called from the outside:

//method to call from outside
	public void GetUserScoreCoRoutine(string username)
	{
		StartCoroutine(GetUserScore(username));
	}

I’m accessing the IEnumerator from a different script through the CoRoutine like this:

public class DisplayUserScore : MonoBehaviour {

public HSController HSScript;

	void Start () {
		
		username = PlayerPrefs.GetString("Test");
		
		HSScript = GetComponent<HSController>();
		HSScript.GetUserScoreCoRoutine(username); 

void OnGUI(){

		GUI.Label (new Rect(50,50,200,50), "Personnal Global Score: ");
		// I WANT THE SCORE FROM DB TO APPEAR IN A GUI LABEL HERE		
	}	
	}

I know that fetching the score works because I can output it successfully in console from the original script. (so the PHP and DB are ok). But how can I access hs_get.text from my DisplayUserScore script? I’m not too familiar with IEnumerator so what I’m trying to do might not be actually doable.

Thanks for the help!

I also have same problem …did you find it working??

This topic is over 2 years old at this point, I know how frustrating it can be to see someone experiencing the same problem as you though no result - you would probably have better luck starting your own thread though.

That being said, there are numerous options to resolve this. First off would be a quick Google search which would have returned this link to Unity Answers (Can CoRoutines return a value? - Questions & Answers - Unity Discussions). Secondly, see the above link. It covers everything from simply adding a field and property to your class which you can access, or into adding Action Delegates and Lambda expression usage.