Center position after scale

I realise this is probably a really stupid question but its bugging me. I have created a 3d text that has a box collider on it so that I can check for mouse collision etc. Im trying to get the text to do a pulsing movement so just use a mathf.pingpong to change the x and y scale. The strange thing is it doesn’t scale from the centre… it scales from the top left point, which is odd behaviour since all other meshes scale from their centre. So what I’m trying to do is correct the amount it scaled to the right and down by moving it an equal amount up and left as it grows and vice versa as it shrinks.

Ive tried :

  • checking the size of the bounds of the collider after scaling compared to before hand and then reposition the text to half the difference.
  • using transform.transformpoint(

Any more ideas? Also could anyone explain why it decides not to scale?

Simply set the Anchor of the TextMesh component to “middle center” in the Inspector. Or, via script:

GetComponent(TextMesh).anchor = TextAnchor.MiddleCenter;