Search Unity

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

Discussion in 'UGUI & TextMesh Pro' started by WavyRancheros, Jul 9, 2019.

  1. WavyRancheros

    WavyRancheros

    Joined:
    Feb 5, 2013
    Posts:
    176
    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:
    176
    Am I really the only one who wants that?
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    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:
    176
    Thanks for the reply. An IText interface would be even better.
     
  5. alexarbuznikov

    alexarbuznikov

    Joined:
    Jan 31, 2020
    Posts:
    1
    I'm plus one on this.
    I'm also really surprised that no one still asked this before..

    First of all TMP is great! And thank you for your hard work!

    But I'm really disappointed that all TextMeshProUGUI classes are not derived from the Unity.UI classes. Though they are supposed to be...
    Such design buries any flexibility on the project. You have to decide which implementation to use at the beginning. You tie yourself and the team on that decision. And you can not change it later without a real pain... You have to go through the whole code and replace it in each place where it references any text variable or change callbacks. If the the project is heavy UI'ed than it's a real problem.
    UI is the most changable part of any software, and I would put it in the top priority to make a flexible and extensible system rather than the one that is full of features...
    The only way right now is to reinvent the wheels and make custom editor scripts and abstractions here and there...

    Anyway, no offenses, the work that is done with TMP is outstanding! Thank you for your hard work and attention to us )
     
  6. WryMim

    WryMim

    Joined:
    Mar 16, 2019
    Posts:
    69
    They still haven't done it...
    What should I do now? I want to make a script for my library. Display client version. Should I write separate scripts for Unity UI and TextMeshPro ? Isn't it funny to you?
    As usual, Unity solutions and logic = nothing in common