Changing the scale of UITextInstance via the .textScale property causes it to redraw the whole text string, which I'm trying to avoid due to performance problems.
So, I'm changing the .localScale of the UITextInstance object. But, if the text instance redraws itself while the .localScale is not (1, 1, z), the child text sprites have a broken .localScale due to the operation of parenting them to the UITextInstance transform.
My solution was to change UIText.updateText so that it resets the text instance transform to (1, 1, z), redraws the text instance, and then restores the original text instance transform.
I didn't check this into my branch because I have a lot of other changes (mostly hacks to try and get stuff to work / lack of understand of how UIToolkit works on my part), but here is the updated code from UIText.cs:
public void updateText( UITextInstance textInstance )
{
// if our textInstance has a localScale of anything other than (1, 1, z), the child sprites generated here will have a weird local scale as well.
// so, lets reset our text instance to (1, 1, z) and then restore the previous local scale after drawText
Vector3 originalScale = textInstance.localScale;
bool scaleChanged = false;
if (originalScale.x != 1f || originalScale.y != 1f) {
textInstance.localScale = new Vector3(1f, 1f, originalScale.z);
scaleChanged = true;
}
// kill the current text then draw some new text
drawText( textInstance, textInstance.xPos, textInstance.yPos, textInstance.textScale, textInstance.depth, textInstance.colors, textInstance.alignMode, textInstance.verticalAlignMode );
// now restore the originalScale scale
if (scaleChanged) {
textInstance.localScale = originalScale;
}
}
Then you can tween with the Vector3 version of .scaleTo and worry less about performance of this operation.
Changing the scale of UITextInstance via the .textScale property causes it to redraw the whole text string, which I'm trying to avoid due to performance problems.
So, I'm changing the .localScale of the UITextInstance object. But, if the text instance redraws itself while the .localScale is not (1, 1, z), the child text sprites have a broken .localScale due to the operation of parenting them to the UITextInstance transform.
My solution was to change UIText.updateText so that it resets the text instance transform to (1, 1, z), redraws the text instance, and then restores the original text instance transform.
I didn't check this into my branch because I have a lot of other changes (mostly hacks to try and get stuff to work / lack of understand of how UIToolkit works on my part), but here is the updated code from UIText.cs:
Then you can tween with the Vector3 version of .scaleTo and worry less about performance of this operation.