private void ThrowWarnings(TranslationScript ts) { if (ts._translation.Count < enumList.Length) { Debug.LogWarning(new Exception(ts.gameObject.transform.parent.name + " is missing a language")); } foreach (var translation in ts._translation) { if (String.IsNullOrEmpty(translation.translation)) { Debug.LogWarning(new Exception(ts.transform.parent.gameObject.name + " is missing a translation")); } } }
/// <summary> /// Look for all the existing TMP objects and then start the assigning process for the prefabs.Then loop through /// them all and try and get the component Translation script if it doesn't /// have one already it will add it. /// </summary> /// <param name="list"></param> private void InsertComponent(TextMeshProUGUI[] list) { Undo.RecordObjects(list, "Assign Translation Objects"); foreach (var item in list) { GameObject temp = item.gameObject; if (!temp.TryGetComponent(out TranslationScript ts)) { TranslationScript tempClass = temp.AddComponent <TranslationScript>(); tempClass._translation = new List <TranslationObject>(); for (int i = 0; i < ls.LanguageNumber(); i++) { tempClass._translation.Add(new TranslationObject("", (LanguageScript.Languages)i)); } Debug.Log(temp.name + " got added"); } PrefabUtility.RecordPrefabInstancePropertyModifications(item); } }