Danil Dzer
Ученик
(159),
на голосовании
3 года назад
Почему ошибка Assets\Scripts\Activator.cs(18,59): error CS0103: The name 'normal' does not exist in the current context И Assets\Scripts\Activator.cs(29,56): error CS0103: The name 'normal' does not exist in the current context
Вот код
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Activator : MonoBehaviour { public GameObject[] firstGroup; public GameObject[] secondGroup; public Activator button; public Material transparent;
И
Assets\Scripts\Activator.cs(29,56): error CS0103: The name 'normal' does not exist in the current context
Вот код
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Activator : MonoBehaviour
{
public GameObject[] firstGroup;
public GameObject[] secondGroup;
public Activator button;
public Material transparent;
private void OnTriggerEnter(Collider other)
{
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;
}
}
}