- Home /
How does renderer.material instances work?
If i understand the documentation correctly, sharedMaterial is the default. By using renderer.material, a new instance of sharedMaterial is created that will only affect the object that called the code. If i make a change to sharedMaterial on another object with the same material, it will no longer affect the first one as that has its own instance now. I may be mistaken here but assuming i am right, can anyone explain the following behavior: I use renderer.material on awake of a function to gradually fade in my GO. Another script calls renderer.material on awake so i can animate the GO. They both run at the same time and it works well, but i do not understand why that works. I believed that the script to last call awake would change the instance to one it can reference and the one that first called it would now be pointing towards a material no longer associated with the GO so only the last called scrips affect (either animate or fade) would work. It works so maybe i should not complain, but i clearly misunderstand whats going on so clarification would be great! Thanks in advance.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090638im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
how do i create material instances without errors 4 Answers
Material doesn't have a color property '_Color' 4 Answers
Replacing sharedMaterials by an existing Material C# 1 Answer
When generating prefab, i cant load images from either resource or assetbundle 2 Answers
Why does reading MeshRenderer.material change MeshRenderer.sharedMaterial? 1 Answer