void RecursivelyFindLabels(GameObject search, bool checkChildren) { if (search != null) { TranslatedText translation1 = search.GetComponent <TranslatedText>(); if ((translation1 != null) && (IsTranslating(translation1) == false)) { labels1.Add(translation1); } TranslatedTextMesh translation2 = search.GetComponent <TranslatedTextMesh>(); if ((translation2 != null) && (IsTranslating(translation2) == false)) { labels2.Add(translation2); } TranslatedTextMeshPro translation3 = search.GetComponent <TranslatedTextMeshPro>(); if ((translation3 != null) && (IsTranslating(translation3) == false)) { labels3.Add(translation3); } // Look for children if ((checkChildren == true) && (search.transform.childCount > 0)) { Transform child; for (int index = 0; index < search.transform.childCount; ++index) { child = search.transform.GetChild(index); RecursivelyFindLabels(child.gameObject, checkChildren); } } } }
void RecursivelyFindOldTexts(GameObject search, bool checkChildren) { if (search != null) { // Fill in the list //Dropdown dropDown = search.GetComponent<Dropdown>(); //if(dropDown != null) //{ // oldDropdowns.Add(dropDown); //} //InputField input = search.GetComponent<InputField>(); //if(input != null) //{ // oldInputs.Add(input); //} TranslatedText translation = search.GetComponent <TranslatedText>(); if (translation != null) { oldTranslations.Add(translation); } else { Text text = search.GetComponent <Text>(); if (text != null) { oldTextsWithoutTranslations.Add(text); } } // Look for children if ((checkChildren == true) && (search.transform.childCount > 0)) { Transform child; for (int index = 0; index < search.transform.childCount; ++index) { child = search.transform.GetChild(index); RecursivelyFindOldTexts(child.gameObject, checkChildren); } } } }
private void ReplaceOldTranslationWithNew(TranslatedText source) { // Setup variables GameObject parentObject = source.gameObject; Text sourceLabel = source.Label; string translationKey = source.TranslationKey; string fontKey = source.FontKey; // Destroy the old component DestroyImmediate(source); // Replace the label component ReplaceOldTextWithNew(sourceLabel); // Add the new text component TranslatedTextMeshPro newTranslation = parentObject.AddComponent <TranslatedTextMeshPro>(); TextMeshProResizer newResizer = parentObject.AddComponent <TextMeshProResizer>(); // Copy the old translation properties into the new one newTranslation.TranslationKey = translationKey; newTranslation.FontKey = fontKey; }