Render object by color

Is this feasible? I get an error, is it possible to render an object visible by detecting the color of two other objects? Thanks.

 function Update () {
    
    if 
    (GameObject.Find("Sphere1").renderer.material.Color.grey == true) 
    (GameObject.Find("Sphere2").renderer.material.Color.grey == true);
    {
    GameObject.Find("Cylinder1").renderer.enabled;
    }
    }

Yes, it is possible. But the way you’re doing it is very inefficient. GameObject.Find isn’t cheap. You should store references to all those objects, assign them from the inspector. Like:

var sphere1 : GameObject;
var sphere2 : GameObject;   // if you're gonna have many, consider store them in a regular array
var cylinder1 : GameObject;

function Update()
{
   if (sphere1.renderer.material.color == Color.grey && sphere2.renderer.material.color == Color.grey)
      cylinder1.renderer.enabled = false;
}

Consider doing this in a function, and call it when you really need to, instead of doing it each frame in Update.

[Code not tested]

// This will disable/enable the `renderer` of `goToChangeState` (based on the `enable` parameter), if the color on all the gameObjects in `goArr` is `color`
function ChangeGoRendererState (goArr : GameObject[], goToChangeState : GameObject, color : Color, enable : boolean)
{
	for(var i = 0; i < goArr.Length; i++)
	{
		var r = goArr*.renderer;*
  •   	if (r == null) {*
    
  •   		continue;*
    

_ print (goArr*.name + " doesn’t have a renderer component attached");_
_
}_
_
if (r.material.color != color) {_
_
return;_
_
}_
_
}_
_
var renderer = goToChangeState.renderer;_
_
if (renderer == null)_
_
{_
_
print (goToChangeState.name + " doesn’t have a renderer component attached");_
_
return;_
_
}_
_
renderer.enabled = enable;_
_
}_
if you still insist on your code:
function Update ()
_
{_
if (GameObject.Find(“Sphere1”).renderer.material.color == Color.grey &&
GameObject.Find(“Sphere2”).renderer.material.color == Color.grey) {
GameObject.Find(“Cylinder1”).renderer.enabled = false;
_
}_
_
}*_
You should watch out for nulls - Make sure the objects have the renderer component.