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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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;
        }