private IEnumerator FillBar() { // When the bar starts to fill, reset the timer. m_Timer = 0f; // The amount of time it takes to fill is either the duration set in the inspector, or the duration of the radial. float fillTime = m_SelectionRadial != null ? m_SelectionRadial.SelectionDuration : m_Duration; // Until the timer is greater than the fill time... while (m_Timer < fillTime) { // ... add to the timer the difference between frames. m_Timer += Time.deltaTime; // Set the value of the slider or the UV based on the normalised time. SetSliderValue(m_Timer / fillTime); // Wait until next frame. yield return(null); // If the user is still looking at the bar, go on to the next iteration of the loop. if (m_GazeOver) { continue; } // If the user is no longer looking at the bar, reset the timer and bar and leave the function. m_Timer = 0f; SetSliderValue(0f); yield break; } // If the loop has finished the bar is now full. m_BarFilled = true; if (gameObject.name == "Jury") { api.SendText(); } else { api.StartNativeRecognition(); } // Play the clip for when the bar is filled. // If anything has subscribed to OnBarFilled call it now. if (OnBarFilled != null) { OnBarFilled(); } m_Audio.clip = m_OnFilledClip; m_Audio.Play(); // If the bar should be disabled once it is filled, do so now. //if (m_DisableOnBarFill) //enabled = false; }
//Comprobamos cada 2 segundos si estamos apuntando al botón NextImage, o PreviousImage, en caso de hacerlo cambiamos la imagen void ExecuteAfterTime() { //Inicializamos las variables necesarias para hacer el raycasting int sum; RaycastHit hit; Vector3 pos = cam.transform.position; //lanzamos un rayo desde la cámara hacia delante y si golpeamos algún objeto con un el rayo nos devuelve true if (Physics.Raycast(pos, cam.transform.forward, out hit, 10000)) { //Si el nombre del objeto golpeado es NextImage o PreviousImage, entonces cambiamos el contenido de los vectores images y texts if (hit.transform.name == "NextImage") { sum = 2; actual_pos += sum; if (actual_pos >= images.Count && (actual_pos % 2) == 0) { actual_pos = 0; } else if (actual_pos >= images.Count && (actual_pos % 2) != 0) { actual_pos = 1; } image.GetComponent <SpriteRenderer>().sprite = images[actual_pos]; text.GetComponent <Text>().text = texts[actual_pos]; } else if (hit.transform.name == "PreviousImage") { sum = 2; actual_pos -= sum; if (actual_pos < 0 && (actual_pos % 2) == 0) { actual_pos = 2; } else if (actual_pos < 0 && (actual_pos % 2) != 0) { actual_pos = 3; } image.GetComponent <SpriteRenderer>().sprite = images[actual_pos]; text.GetComponent <Text>().text = texts[actual_pos]; } //Según cuál sea el cuadro y el autor cambiamos el contexto del dialogflow switch (actual_pos) { case 0: ai_module.SendText("Goya"); ai_module.SendText("Garrotazos"); break; case 1: ai_module.SendText("Velazquez"); ai_module.SendText("Meninas"); break; case 2: ai_module.SendText("Goya"); ai_module.SendText("Fusilamientos"); break; case 3: ai_module.SendText("Velazquez"); ai_module.SendText("Breda"); break; } } }