//------------------------------------------------------------------------- /// <summary> /// Coroutine to run the text display flow. /// </summary> /// <param name="aRMessages">Data of the thread texts (time + key)</param> /// <returns></returns> private IEnumerator ShowText(ARMessages aRMessages) { threadAnimation.SetActive(true); int currentAnimationIndex = threadAnimation.transform.GetSiblingIndex(); for (int i = 0; i < aRMessages.localizationSeries. localizationTexts.Length; i++) { // Perform the delay. yield return(new WaitForSeconds(aRMessages.localizationSeries.localizationTexts[i].delayTime)); // Generate the text frame. GameObject text = Instantiate (threadTextTemplate, threadTextParent); // Call the right text. text.GetComponentInChildren <Text>().text = displayTextAsked(aRMessages.localizationSeries.localizationTexts[i].key); //// Move the animation down. //threadAnimation.transform. // SetSiblingIndex(++currentAnimationIndex); } threadAnimation.SetActive(false); }
//------------------------------------------------------------------------- /// <summary> /// Ask for displaying texts on the UI thread. /// </summary> /// <param name="aRMessages">Time and text keys sent to the UI part.</param> private void AskThreadDisplay(ARMessages aRMessages) { threadMessagePassAsked(aRMessages); }
//------------------------------------------------------------------------- /// <summary> /// Display the thread text. Use the coroutine to set up the waiting period. /// </summary> public void DisplayThreadText(ARMessages aRMessages) { _currentCoroutine = StartCoroutine(ShowText(aRMessages)); }