so i have this class
using UnityEngine;
using System.Collections;
public class StaticCoroutine : MonoBehaviour {
static public StaticCoroutine instance;
void Awake ()
{
instance = this;
}
IEnumerator Perform(IEnumerator coroutine)
{
yield return StartCoroutine(coroutine);
}
static public void DoCoroutine(IEnumerator coroutine){
instance.StartCoroutine(instance.Perform(coroutine));
}
public static void getFile(string path)
{
StaticCoroutine.DoCoroutine(DoGetFile(path));
}
static IEnumerator DoGetFile(string path)
{
var www = new WWW(path);
yield return www;
string result = www.text;
Debug.Log(result);
}
}
when i call this code from other script using
StaticCoroutine.getFile(url);
it works and the console show the result, but how if i want to use the result in other script and store it in variable…
something like if i’m doing in other normal method…
return result;
and will end like this
string variableResult = StaticCoroutine.getFile(url);