For my current project I created a new TextMeshProUGUI extension class that does some extra stuff in regards to resizing itself and calculating some text size-related things.
Could have made it a second script that attached to the same GameObject as the TMProUGUI object, didn’t want to. Wanted a single object, so I extended TextMeshProUGUI
Unnecessary Explanation as to why/what I changed. Was about to delete it, thought I’d leave it in case anyone cares.
I have two places where I needed ‘deeper’ access to TMPro.
I wanted to override the .text property so that when text was set, I could act on that. Could have made my own property, but I wanted this to be a drop-in replacement for TextMeshProUGUI. If I had to make my own new property, lots of other code that updates TextMeshProUGUI.text would have needed to be changed. The property in TMP_Text.cs is “public string text” - I need it to be “public virtual string text”.
Second, I do some custom calculations related to the auto sizing, and that requires me to manually reset
m_recursiveCount, which is set as private, with no public/virtual methods to reset it’s value. So I need that to be protected int m_recursiveCount instead of private.
TL/DR for those who didn’t care to read the unnecessary spoiler text above: I needed to tweak stuff in TMP_Text.cs for my inherited class to work.
So I went in and updated the TMP_Text.cs file and made those changes. And everything works great. However, every time close and restart unity, the TMP_Text.cs file is “restored”, overwriting the changes I’ve made, and I need to re-edit it again.
How can I edit that file so that the changes stay? Either for just this project, or for any project I work on from this computer. They don’t break anything for future software I write (where I may forget about those changes) - it just makes those two properties/variables accessible to classes that inherit from TMP_Text.