How would I change the colour of a prefab relative to the size of the character?

What I’m asking is how would I change the colour of an object relative to the size of the player?

What I’m trying to achieve is allowing the player to know whether what he is trying to “eat” is small enough to do so, however I’m having trouble determining whether something is of the right size.

I thought up a way to let the player know by having the enemy prefabs change in colour if the player’s size is large enough to consume it.

How would I achieve this?
The current player-growth-in-size script is as follows;

else if (other.tag == "Roach")
			transform.localScale += Vector3(.35,.35,.35);


Would I use a statement such as:
 if(other.transform.localScale.magnitude < transform.localScale.magnitude)


Your best bet would be to access the material and adjust the color values. Alternatively, you could just switch the materials once their scale is appropriately small. Either way works, but I’ve included a snippet of code for adjusting color values:

if(other.transform.localScale.magnitude < transform.localScale.magnitude)
	// Access the renderer attached to the enemy object,
	// then set the main color to a color of your preference.
	// You can also get more specific and toy with the ARGB values.
	renderer.material.color =;

Useful links: