This script doesn't seem to work for some reason. I've tried col.gameObject.SetActive(false); and that works totally fine. Why isn't the gameObjects changing colour please help!
private void OnMouseDown()
foreach (Collider col in colliders)
col.gameObject.GetComponent<SpriteRenderer>().material.color = Color.blue;
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
3 People are following this question.
What is color and what is material (in the context of gameobject)?
How to make 2D physics objects graphics?
Storing Renderer in a variable not working!
material color not changing
Colour showing up differently?