- Home /
How to change the color of the TextMeshPro GUI component?
Hi there,
I'm writing a script that can be used to fade in TextMeshPro (asset) text.
However I'm not able to access the color of the TextMeshProUGUI component in my script:
Here is my inspector with the TextMeshProUGUI component:
What can I do to make this work? Am I even able to change the color of the TextMeshProUGUI component? Thanks in advance!
Answer by csommer828 · Oct 13, 2018 at 08:24 PM
Remember to use TMPro class:
using TMPro;
Assign your tmp object variable using TextMeshProUGUI:
private TextMeshProUGUI tmpObj;
Set the color with a new Color32:
tmpObj.color = new Color32(50, 50, 50, 255);
you need to set the tags, otherwise setting color does nothing...
see here http://digitalnativestudios.com/textmeshpro/docs/ScriptReference/TextMeshPro-color.html
Your answer
Welcome to Unity Answers
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Initialising List array for use in a custom Editor 1 Answer
Flip over an object (smooth transition) 3 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer