Changing material of an object VS Changing the color property of the material which is more efficient ?

using a script which holds an array of 5-6 materials and then using this script to change the material of a particular object


using a script to just hold 5-6 color values then changing the objects>materials> color value

which is more efficient ?
[Making a casual game for mobile devices - so it should run on a device that’s even 2/3 years old]

This is actually a pretty interesting question. Initially I would have said that you want as few materials as possible (and that still is the case), however in your case accessing renderer.material to change the colour per-renderer actually creates a new material behind the scenes - so if this was going to be used on multiple objects then having a list of pre-created materials and setting those to the renderer’s sharedMaterial would probably be more efficient.