// <comment> // This function will be call when the target is found // </comment> private void OnTrackingFound() { // <comment> // sentence is a string that the detected phrase // </comment> string sentence = ""; StateManager stateManager = TrackerManager.Instance.GetStateManager(); // <comment> // this will get the words detected in the image // </comment> IEnumerable <WordResult> wordResults = stateManager.GetWordManager().GetActiveWordResults(); foreach (WordResult wordResult in wordResults) { Score++; // <comment> // append the detected words to "sentence" object // </comment> Word word = wordResult.Word; sentence += word.StringValue + " "; Debug.Log(sentence); } // <comment> // using the Trasnlator to translate the sentence from english to target language // </comment> string language = GameObject.Find("Language/Dropdown/Label").GetComponent <Text>().text; if (language == "Spanish") { language = "es"; } else if (language == "French") { language = "fr"; } else if (language == "Greek") { language = "el"; } sentence = Translator.TranslateGoogleApisSimple(sentence, "en", language); // <comment> // add the translated phrase to the textbox // </comment> GameObject.Find("ScoreCanvas/Score/Text").GetComponent <Text>().text = "Score: " + Score; GameObject.Find("Canvas/spanishText/Text").GetComponent <Text> ().text = sentence; Renderer[] rendererComponents = GetComponentsInChildren <Renderer>(true); Collider[] colliderComponents = GetComponentsInChildren <Collider>(true); // Enable rendering: foreach (Renderer component in rendererComponents) { component.enabled = true; } // Enable colliders: foreach (Collider component in colliderComponents) { component.enabled = true; } Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found"); }