¿Cómo mostrar el valor de la devolución del rendimiento?
Frecuentes
Visto 169 veces
1
How to display value from yield return ?
Este es mi código:
public void getTypeRoomb1(string buildingNUM){
StartCoroutine(getjsonroomtype1(buildingNUM));
}
public IEnumerator getjsonroomtype1(string buildingNUM){
WWW request = new WWW(mainurl+"json_typeroom.php?building="+buildingNUM+"");
yield return request;
if (request.error == null || request.error == "")
{
var N = JSON.Parse(request.text);
if(N["type"].Count < 1){
notFoundText = "Not found";
}else{
yield return N; // Value return this line.
}
}else
{
Debug.Log("WWW error: " + request.error);
}
}
I locate line to return value.How do I display value ?
Suggest me plaese!
2 Respuestas
1
You have to save the "returning value" somewhere else, like get a reference to an other object and provide it with the value.
Coroutines in Unity can't return anything.
Respondido el 25 de Septiembre de 13 a las 11:09
1
You could pass the yielded values through a dedicated method:
static IEnumerable LogValues(IEnumerable enumerable)
{
foreach (var value in enumerable)
{
Debug.Log(value.ToString());
yield return value;
}
}
// ..
// Keep getjsonroomtype1 untouched
// ..
public void getTypeRoomb1(string buildingNUM)
{
StartCoroutine(LogValues(getjsonroomtype1(buildingNUM)));
}
Respondido el 25 de Septiembre de 13 a las 11:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c# unity3d or haz tu propia pregunta.
What do you mean exactly by DISPLAY? - meilke
Soy parcial a la lambda return method. - Jerdak