Search Unity

TextMesh Pro How to create a new class dependent on TextMeshProUGUI with new variables (example in description)

Discussion in 'UGUI & TextMesh Pro' started by Olexi4ik, Mar 7, 2023.

  1. Olexi4ik

    Olexi4ik

    Joined:
    Jan 24, 2023
    Posts:
    4
    Code (CSharp):
    1. using TMPro;
    2. using UnityEngine;
    3.  
    4. public class NewText : TextMeshProUGUI
    5. {
    6.     [SerializeField]
    7.     private string Index;
    8. }
    The code works, but the Index variable does not appear in the Inspector

     
  2. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Because , theres most likely, a custom editor at play. Not 100% sure, but generally this can be a cause.
     
  3. Olexi4ik

    Olexi4ik

    Joined:
    Jan 24, 2023
    Posts:
    4
    Sorry, didn't mean to create a poll
     
  4. Olexi4ik

    Olexi4ik

    Joined:
    Jan 24, 2023
    Posts:
    4
    Is it impossible to do?
     
  5. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    no, but , i would first just check to see if indeed there is some form of custom editor at play. You should be able to locate it, if it is the case, rather easily.

    Actually, i just did, and it doesnt seem there is a custom editor...

    Strange indeed. I am investigating further, will post back if i locate anything.
     
  6. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    So, if you put unity into debug mode, the variable is indeed there, the class in inheriting correctly, but yea. oddly, serializing it, does not reveal it. Im actually not sure on this one mate, most often, this is case of custom editors only showing what they have been told to show... but in this case, i dont see any editor source. Hopefully someone comes along that does know the ins and outs of this particular component.

    I do note that there is a few scriptable objects involved in the construct of the component. I'll have a look in there too. Actually, im really thinking that the TMP_Settings has a large role in this.
     
    Last edited: Mar 7, 2023
  7. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Aight, so after a bit of digging, i have a bit of insight, but no fix.

    It seems that all the fields you are seeing on the TMP component, are actually from within the TMP_Settings SO. The problem is, its a package cached library, and it rebuilds it self if you attempt to modify it at all. But from all i can seee, those varialbes are indeed coming from within that SO.

    I Will be watching this thread as someone smarter than I is sure to have a little more to offer towards a solution.

    Lets ask @Kurt-Dekker to weigh in on this.
     
  8. Olexi4ik

    Olexi4ik

    Joined:
    Jan 24, 2023
    Posts:
    4
  9. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    I don't have TMPRo handy and I dunno about custom editors but I think there might be some custom property drawers going on, perhaps something in that is hiding your field?

    Also check if perhaps the field appears is under one of the folds.