if (this.CompareTag("Cube") && other.CompareTag("Cube"))
{
foreach(Activator button in FindObjectOfType<Activator>()) // тут пишет ошибку
{
button.canPuch = false;
}
error CS1579: foreach statement cannot operate on variables of type 'Activator' because 'Activator' does not contain a public instance definition for 'GetEnumerator'
public class Activator : MonoBehaviour
{
public GameObject[] firstGroup;
public GameObject[] secondGroup;
public Activator button;
public Material normal;
public Material transparent;
public bool canPuch;
private void OnTriggerEnter(Collider other)
{
if (canPuch)
{
if (other.CompareTag("Cube") || other.CompareTag("Player"))
{
foreach (GameObject first in firstGroup)
{
first.GetComponent<Renderer>().material = normal;
first.GetComponent<Collider>().isTrigger = false;
}
foreach (GameObject second in secondGroup)
{
second.GetComponent<Renderer>().material = transparent;
second.GetComponent<Collider>().isTrigger = true;
}
GetComponent<Renderer>().material = transparent;
button.GetComponent<Renderer>().material = normal;
button.canPuch = true;
}
}
}
}