Why when I do
obj.gameObject is there no TextMesh of textMesh? For a given GameObject how do I access it’s text mesh component - and why is this different to the way I access its other components?!
Why when I do
obj.gameObject is there no TextMesh of textMesh? For a given GameObject how do I access it’s text mesh component - and why is this different to the way I access its other components?!
Look up GetComponent.
All of the dot-renderer, dot-rigidbody’s … are shortcuts for things like player.GetComponent()
. TestMesh just happens to have no shortcut, so you have to use the long/real way.
For the reasons: it makes sense to provide shortcuts only for common components, so auto-complete doesn’t get all cluttered. And once you start using scripts, you have to learn GetComponent, anyway. And, they are called 3DTexts in the drop down. That’s a nice descriptive name, but since it starts with a number, the component was renamed TextMesh. So most people would try to type player.3D...
and wouldn’t find dot-textMesh even if it did exist.