public void HighlightWordGroup(WordGroupObject wordGroup) { foreach (WordText text in texts) { //Debug.Log(text.text); if (text.wordGroup == wordGroup && PageManagerRefScript.IsReadingAlong == 1.0f) { text.text.color = HighlightedColor; //Debug.Log(text.text.text); } else { text.text.color = NormalColor; } } }
public void AddText(WordGroupObject wordGroup) { //Debug.Log ("78THOUSAND"); string[] words = wordGroup.text.Split(' '); narrator = words [0]; for (int i = 0; i < words.Length; i++) { string word = words [i]; SentenceRow currentRow = rows [rowIndex]; WordText newText = currentRow.AddText(word); newText.text.color = NormalColor; //wordClone.GetComponent<Button> ().color.normalColor = Color.cyan; //To enforce the layout to rebuild, which makes the horizontal layoutgroup resize LayoutRebuilder.ForceRebuildLayoutImmediate(rt); float myWidth = rt.rect.width - layoutGroup.padding.horizontal; //We add a text, check if the width is fitting. if (currentRow.rt.rect.width + newText.rt.rect.width >= myWidth) { CreateRow(); currentRow.PopText(); rowIndex++; //Safety check in case of really long words if (newText.rt.rect.width < myWidth) { //go a word back i -= 1; } else { Debug.LogWarningFormat("The word {0} does not fit in the SentenceRowContainer! It will be skipped.", word); } } else { //We set the wordGroup of each textfield so we can highlight them alltogether newText.wordGroup = wordGroup; texts.Add(newText); } } }
private static SentenceObject GetSentence(string dataString) { SentenceObject so = new SentenceObject(); string[] lines = Regex.Split(dataString, "\\n"); //Debug.Log ("words.Length"+lines.Length); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } string[] words = Regex.Split(line, "\\t"); WordGroupObject obj = new WordGroupObject(); float.TryParse(words[0], out obj.time); //This is index 1 or 2 (dependend if the time is defined twice or not) obj.text = words[words.Length - 1]; so.wordGroups.Add(obj); //Debug.Log (line); } return(so); //return JsonUtility.FromJson<SentenceObject>(dataString); }
IEnumerator RunSequence(AudioObject obj) { //.Log(obj.clip); //if(audioIndex == 0)\ if (audioIndex == 0) { BackButton.GetComponent <Image>().enabled = false; } else { BackButton.GetComponent <Image>().enabled = true; } //if (audioIndex == 38) if (audioIndex == 38) { NextButton.GetComponent <Image>().enabled = false; } else { NextButton.GetComponent <Image>().enabled = true; } AudioObject currentAudio = currentPage.audioObjects[audioIndex]; Scenetext.GetComponent <Text>().text = currentAudio.name; //Scenetext.GetComponent<Text>().text = obj.clip.name; /*else * { * Debug.LogErrorFormat("Unable to read the audio from folder {0}. " + * "Please ensure an audio file is in the folder, and it's set to the assetbundle {1}.", obj.name, DataManager.currentStoryName); * } * * if (obj.sentence == null) * { * Debug.LogErrorFormat("Unable to read the text from folder {0}. " + * "Please ensure a text file is in the folder, and it's set to the assetbundle {1}.", obj.name, DataManager.currentStoryName); * yield break; * }*/ //float PreviousWordTime =0; /*foreach (WordGroupObject wordGroup in obj.sentence.wordGroups) * { * * * * if (wordGroup.text.Contains("///")) * {//Get The Narrator * * * * sentenceContainerCurrent += 1; * * if (sentenceContainer[sentenceContainerCurrent].GetComponentInParent<SpeechBubbleDelay>()) * { * sentenceContainer[sentenceContainerCurrent].GetComponentInParent<SpeechBubbleDelay>().Acvivate_SpeechBuggle(PreviousWordTime); * } * * } * else * { * PreviousWordTime = wordGroup.time; * sentenceContainer[sentenceContainerCurrent].AddText(wordGroup); * } * }*/ if (obj.clip != null) { audioSource.clip = obj.clip; audioSource.Play(); } //highlight the proper wordgroups int i = 0; WordGroupObject prevWordGroup = null; while (i < obj.sentence.wordGroups.Count) { WordGroupObject wordGroup = obj.sentence.wordGroups[i]; foreach (SentenceRowContainer Child in sentenceContainer) { if (Child != null) { Child.HighlightWordGroup(wordGroup); } } float waitTime = wordGroup.time; if (audioIndex == 13 && i == 0) { WordGroupObject wordGroupnext = obj.sentence.wordGroups[i + 1]; waitTime = wordGroupnext.time - wordGroup.time; } //We calculate it like this because the times given are actually absolute times, not times per word if (prevWordGroup != null && i > 1) { if (i == obj.sentence.wordGroups.Count - 1) { waitTime = obj.clip.length - wordGroup.time; } else { waitTime -= prevWordGroup.time; } } if (audioIndex == 37 && StoryManager.GetComponent <StoryManager>().pagesPerScene == 1) { waitTime = 4.0f; } i++; yield return(new WaitForSeconds(waitTime)); if (audioIndex == 36 && StoryManager.GetComponent <StoryManager>().pagesPerScene == 2) { Debug.Log(audioIndex + "///" + StoryManager.GetComponent <StoryManager>().pagesPerScene); NextButton.SetActive(true); BackButton.SetActive(true); isAutoChapterSkip = 0; } prevWordGroup = wordGroup; } //EffectedRow.HighlightWordGroup(null); //Debug.Log("PointReached"); //sentenceContainer.HighlightWordGroup(null); foreach (SentenceRowContainer Child in sentenceContainer) { if (Child != null) { Child.HighlightWordGroup(null); } } if (isAutoChapterSkip == 0) { //audioSource.clip = PageDone; //audioSource.Play (); } if (isAutoChapterSkip == 1 && audioIndex != 38) { GotoNext(); } }