static void Text() { var objects = VRTK_SharedMethods.FindEvenInactiveComponentsInValidScenes <Text>(false); foreach (var obj in objects) { Debug.Log(obj.name, obj); } }
static void DoLocaliseText() { var local = new HashSet <string>(); foreach (var line in File.ReadAllLines(@"D:\Unity Projects\VR-Empathy\Assets\StreamingAssets\Languages\English.txt")) { local.Add(line.Split('=')[0]); } var objects = VRTK_SharedMethods.FindEvenInactiveComponentsInValidScenes <Text>(false); foreach (var obj in objects) { if (!local.Contains(obj.gameObject.name)) { continue; } var textLocal = obj.GetComponent <LeanLocalizedText>(); if (!textLocal) { textLocal = ObjectFactory.AddComponent <LeanLocalizedText>(obj.gameObject); } textLocal.FallbackText = obj.text; textLocal.TranslationName = obj.gameObject.name; } var objects2 = VRTK_SharedMethods.FindEvenInactiveComponentsInValidScenes <TextMeshProUGUI>(false); foreach (var obj in objects2) { if (!local.Contains(obj.gameObject.name)) { continue; } var textLocal = obj.GetComponent <LeanLocalizedTextMeshProUGUI>(); if (!textLocal) { textLocal = ObjectFactory.AddComponent <LeanLocalizedTextMeshProUGUI>(obj.gameObject); } textLocal.FallbackText = obj.text; textLocal.TranslationName = obj.gameObject.name; } }
static void TextToCSV() { var lines = new List <string>(); var objects = VRTK_SharedMethods.FindEvenInactiveComponentsInValidScenes <Text>(false); foreach (var obj in objects) { if (obj.gameObject.name == "UITextFront" || obj.gameObject.name == "UITextReverse" || obj.gameObject.name.EndsWith(".") || string.IsNullOrWhiteSpace(obj.text) || (obj.gameObject.name == "FromText" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) || (obj.gameObject.name == "FromTime" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) || (obj.gameObject.name == "Text" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) || (obj.gameObject.name == "Tag" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) ) { continue; } lines.Add(obj.gameObject.name + "=" + obj.text.Replace("\r", "").Replace("\n", "\\n")); } var objects2 = VRTK_SharedMethods.FindEvenInactiveComponentsInValidScenes <TextMeshProUGUI>(false); foreach (var obj in objects2) { if (obj.gameObject.name == "UITextFront" || obj.gameObject.name == "UITextReverse" || obj.gameObject.name.EndsWith(".") || string.IsNullOrWhiteSpace(obj.text) || (obj.gameObject.name == "FromText" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) || (obj.gameObject.name == "FromTime" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) || (obj.gameObject.name == "Text" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) || (obj.gameObject.name == "Tag" && obj.GetComponentsInParent <ScreenMessage>(true)?.Length > 0) ) { continue; } lines.Add(obj.gameObject.name + "=" + obj.text.Replace("\r", "").Replace("\n", "\\n")); } File.WriteAllLines("D:\\" + SceneManager.GetActiveScene().name + ".txt", lines); }