private static MonoBehaviour SetupForStringLocalization(TextMeshProUGUI target) { //Avoid adding the component multiple times if (target.GetComponent <LocalizeStringEvent>() != null) { return(null); } var comp = Undo.AddComponent(target.gameObject, typeof(LocalizeStringEvent)) as LocalizeStringEvent; var setStringMethod = target.GetType().GetProperty("text").GetSetMethod(); var methodDelegate = System.Delegate.CreateDelegate(typeof(UnityAction <string>), target, setStringMethod) as UnityAction <string>; Events.UnityEventTools.AddPersistentListener(comp.OnUpdateString, methodDelegate); const int kMatchThreshold = 5; var foundKey = LocalizationEditorSettings.FindSimilarKey(target.text); if (foundKey.collection != null && foundKey.matchDistance < kMatchThreshold) { comp.StringReference.TableEntryReference = foundKey.entry.Id; comp.StringReference.TableReference = foundKey.collection.TableCollectionNameReference; } return(null); }