- Home /
Replace texture without touching materials?
Is there any way to replace a texture with another texture, without touching any specific materials?
I want to replace a texture with a higher-resolution version of itself at runtime, and then have any and all materials that use that texture, at any time, use the higher-resolution version, without having to do anything to keep track of which materials are using the texture in question.
Why don't you just use mipmaps? That's kind of the inbuilt way of doing exactly that.
I am using mipmaps. I want to only selectively load the largest mipmaps into memory, though.
Answer by kromenak · Oct 16, 2011 at 09:22 AM
I believe that materials are shared amongst all the objects that are using them - so if you have several renderers in a scene using the same material, they are really all sharing the same material instance. You can access this through renderer.sharedMaterial.
So I would expect that replacing the texture in a sharedMaterial would change the texture for all objects using that material. However, the documentation does mention that changing the properties of a sharedMaterial will change the actual asset as opposed to an individual instance.
What about renderers for things I've not instantiated yet? I'd want them, when instantiated, to use the correct (newly loaded) texture.