- Home /
UI Text - changing material instance
I have two UI Text instances, each one with a material attached to it. I would like to change a material's property for a shader like:
[into a script attached to UI Text]
this.gameObject.GetComponent<Text>().material.SetFloat ("myValue", 0.5f);
This works but unfortunately it sets the float variable for ALL the UI Text instances. I would like to change it only for one UI Text instance. How can I achieve this?
Answer by gjf · Feb 06, 2015 at 01:00 PM
if you're using the same material for all of them then it will - you need to ensure that the one you are changing has a unique material and set that accordingly.
Any way to spawn a new instance of the material (with the shader attached) and assign it to one UI Text instance?
Your answer
Follow this Question
Related Questions
Glowing text effect 0 Answers
Part of text with different material 1 Answer
Line break UI Text field 1 Answer
How to have fonts affected by lightning? 2 Answers