Here link text it says that: “This function automatically instantiates the materials and makes them unique to this renderer. It is your responsibility to destroy the materials when the game object is being destroyed”
Since i am using this function in an update function I need to how many times the material gets instantiated.
is it only once?
It is not advised to run code in Update() if posible not to. Use your code at start, and call those two lines when you need to (either through a looping coroutine, or InvokeRepeating(), even FixedUpdate() is a better alternative to Update() in most situations)
Either way. I think you are misunderstanding the documentation.
The line you are refering to tells us, that even though multiple objects share the same basic material, they can be changed individually.
I.e. Four cubes with the same material. They will have their own individual material/shader when the game runs. When we change the color, offset, or scale, we don’t change it for all objects with the same material. We only change it for a single object.
yes, it is only once. Once per renderer your access the material field on. Once a renderer has it’s own material instance that instance is not replaced by a new instance on subsequent accesses to material field.
To my best knowledge.
Cheers.