using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; public class TRANS : MonoBehaviour { public static string This(string txt) { int ind = System.Array.IndexOf(_T.TRANS, txt); string t = _T.TRANS[ind + _G.L]; return t; } // This() lit _T a l'aveugle et lance si la cle n'y est pas. Version tolerante, pour les libelles // construits a partir d'un nom de bouton (T_Grey, T_Stainless...) : on retombe sur le nom nu. public static string Safe(string txt) { if (string.IsNullOrEmpty(txt)) return ""; if (System.Array.IndexOf(_T.TRANS, txt) < 0) return txt.StartsWith("T_") ? txt[2..] : txt; return This(txt); } public static void go() { trans("txt", ""); trans("txt_pro", "pro"); trans("CT2", ""); trans("txt", ""); trans("CT1", ""); trans("CTP1", "pro"); trans("CTP2", "pro"); } public static void trans(string Tag, string P){ //print("P==="+P+" tag==="+Tag); GameObject[] gos; gos = GameObject.FindGameObjectsWithTag(Tag); int ind = 1; foreach (GameObject go in gos) { if (go.name != "") { ind = System.Array.IndexOf(_T.TRANS, go.name); if(P=="pro")go.gameObject.GetComponent().text = _T.TRANS[ind + _G.L]; else go.gameObject.GetComponent().text = _T.TRANS[ind + _G.L]; } } } }