Changing the color of hundreds of objects in a performant way

Hello! For my game I want an effect where all the environment assets (1000+ objects) all have a unique color that gradually changes as the game is played. (One starts red that gradually turns yellow while another starts green that gradually turns purple that gradually turns yellow etc. forever)

I had a script that just made a new material instance for each object and managed them to cycle through colors, and it looked great! The downside? 4000+ Batches and very rough performance even on a good machine.

Is there a way to achieve this effect in a performant way without thousands of batches? Any help or pointers appreciated!

Are all 1000 object visible at the same time? Try calculating color every frame but changing color of material only if object is visible to the player.
You should also probably reduce number of monobehaviours (if each object has its own script) by creating one color manager with array of renderers). Running Update() in 1000 scripts can also cause performance loss i think.

You could use RSUV. That’s made to allow setting per-renderer values without breaking batching.

Could you just lerp between colors in Shader Graph? That shouldn’t break batching.

Hey, there’s a whole thread on the topic: