Hey!
Thanks again for STM, been a user for a wee bit (we even talked before!) and it has worked wonders for me. I unfortunately come to you today with a problem.
Context
I have a simple screen with some text in it:
This looks great, however when I want to localize the text, things get hairy. Here is the code I use to localize my text:
using UnityEngine; using I2.Loc; [RequireComponent(typeof(SuperTextMesh))] public class VSScreenTextHelper : MonoBehaviour { public string LocalizationString; private SuperTextMesh textMesh; void Awake () { textMesh = GetComponent<SuperTextMesh>(); textMesh.Text = LocalizationManager.GetTermTranslation(LocalizationString); } }
Pretty simple, yeah? This script is attached to the GameObject that has the STM component on it, which is a UI object (it has a RectTransform). The code puts in a new string inside STM's Text property and sends it on its way. Yet, as you might have already realized, problems arise.
Problem
When setting Text on an STM instance via code on a UI object, STM loses its alignment until any property is triggered in the inspector. Below is a gif of the process.
What I've tried
I tried a couple things before coming on these here forums to ask for help:
- Messing with the parent's layout options
- Using content size fitters
- Triggering Rebuild() after changing the text
- Toggling options via code, and then Rebuild()ing
I would love to dive into STM's codebase to figure it out but unfortunately with a big deadline looming above my head it's impossible for me to do so. I hope I provided enough information for you to be able to have at least a vague idea of what's going on.
Thanks for any help you can provide!