Search Unity

TextObject as base class for Text, TextMesh, TextMeshPro...

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by WavyRancheros, Jul 9, 2019.

  1. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    75
    Hi,

    not sure where to post this. I'd like to see all Text components (Text Mesh, UI.Text, TextMeshPro, etc...) share a common base class TextObject that has a text Property. That way I'd be able to write my code completely independent from whatever the hell I put into the scene.

    I received code from a project where the developer used Text Mesh and UI.Text, and I have to change everything to TextMeshPro due to a coding guideline. And I'm thinking: why the hell do I even have to change CODE when I'm replacing a simple Text component in my prefabs? It would be so simple:

    TextObject myText = GetComponent<TextObject>();
    myText.text = "Enter Text Here.";

    and then I wouldn't have to worry about any future code-breaking changes.

    Best regards,
    Wavy
     
  2. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    75
    Am I really the only one who wants that?
     
  3. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,175
    Similar requests have been made before and I certainly understand the desire / convenience for this.

    Since these components inherit from other classes which adds complications and interface like iText would be a better alternative.

    Unfortunately and although the TMP components are still on active development, UI.Text is on maintenance and given the many features I still want to add to TMP and my limited bandwidth, it is unlikely that we'll get to this in the near term.

    P.S. I wanted to reply since I never replied to your first post. Please know that although I do not reply to every post, I do read all of them so keep suggestions / feedback coming.
     
  4. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    75
    Thanks for the reply. An IText interface would be even better.