- Home /
Most optimal way of changing all textures on scene
I'm looking for the best way of changing the texture of all the gameobjects on scene. I need a way that affects the performance as little as possible. One of the possibilities I've considered is to attach a script to all those objects that are texturized and then somehow call a function that affects all those objects that had this script attached. However, I'm not sure how to do so, thus if some of you knows, I'd appreciate any advice. I'd also appreciate it if you could propose more optimal ways to achieve the same result. Thanks for your time.
If you are a frequent user of StackOverFlow, I've raised the same question there.
Answer by robertbu · Aug 15, 2013 at 12:28 AM
Since you are using C#, a nice way to communicate the change to all the scripts is to use Events and Delegates. Here is a video tutorial on the subject:
http://www.youtube.com/watch?v=N2zdwKIsXJs
As for the actual change itself, efficiency will depend on your game setup. The best setups use use a texture atlas and change the textures by directly changing the uv in the mesh. This allows different objects with different textures (but all other material settings the same), to be drawn in a single draw call. But even for a single object, changing the uvs has benefits. This type of change of textures can be difficult to do without third-party tools. A couple of links:
http://answers.unity3d.com/questions/14578/whats-the-best-way-to-reduce-draw-calls.html
http://docs.unity3d.com/Documentation/Manual/DrawCallBatching.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613112159im_/https://answers.unity.com/themes/thub/images/avi.jpg)