Created
March 24, 2022 10:35
-
-
Save karljj1/87a87442c0264a97d27156a05dae4ff5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using TMPro; | |
| using UnityEditor; | |
| using UnityEngine.Localization.PropertyVariants; | |
| using UnityEngine.Localization.PropertyVariants.TrackedObjects; | |
| using UnityEngine.Localization.PropertyVariants.TrackedProperties; | |
| public class AutoLinkTMP | |
| { | |
| [MenuItem("CONTEXT/TextMeshProUGUI/Localize (With Localized Properties)")] | |
| static void LocalizeTMProText(MenuCommand command) | |
| { | |
| var target = command.context as TextMeshProUGUI; | |
| var localizer = target.gameObject.GetComponent<GameObjectLocalizer>() ?? target.gameObject.AddComponent<GameObjectLocalizer>(); | |
| var trackedObject = localizer.GetTrackedObject<TrackedUGuiGraphic>(target, create: true); | |
| var trackedProp = trackedObject.AddTrackedProperty<LocalizedStringProperty>("m_text"); | |
| trackedProp.LocalizedString.SetReference("My Table", "My Entry"); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://forum.unity.com/threads/game-object-localizer-needs-a-way-to-add-text-property-to-assign-an-entry.1257438/#post-7990131