void OnTriggerExit(Collider other)... Заранее Спасибо!
Вот Скрипт:
Синтаксис:
Используется csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PreviewObject : MonoBehaviour
{
public List<Collider> col = new List<Collider>();
public objectsorts sort;
public Material green;
public Material red;
public bool IsBuildable;
public bool IsDetail;
public bool second;
public PreviewObject childcol;
public Transform graphics;
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer == 9)
col.Add(other);
if (other.gameObject.layer == 10)
col.Add(other);
}
public void OnTriggerExit(Collider other)
{
if (other.gameObject.layer == 9)
col.Remove(other);
if (other.gameObject.layer == 10)
col.Remove(other);
}
void Update()
{
if (!second)
changecolor();
}
public void changecolor()
{
if (sort == objectsorts.foundation)
{
if (col.Count == 0)
{
IsDetail = true;
IsBuildable = true;
}
else
{
IsDetail = false;
IsBuildable = false;
}
}
else
{
if (col.Count == 0 && childcol.col.Count > 0)
{
IsDetail = true;
IsBuildable = true;
}
else
{
IsDetail = false;
IsBuildable = false;
}
}
if (IsBuildable)
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = green;
}
}
else
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = red;
}
}
if (IsDetail)
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = green;
}
}
else
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = red;
}
}
}
}
public enum objectsorts
{
normal,
foundation,
floor
}
using System.Collections.Generic;
using UnityEngine;
public class PreviewObject : MonoBehaviour
{
public List<Collider> col = new List<Collider>();
public objectsorts sort;
public Material green;
public Material red;
public bool IsBuildable;
public bool IsDetail;
public bool second;
public PreviewObject childcol;
public Transform graphics;
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer == 9)
col.Add(other);
if (other.gameObject.layer == 10)
col.Add(other);
}
public void OnTriggerExit(Collider other)
{
if (other.gameObject.layer == 9)
col.Remove(other);
if (other.gameObject.layer == 10)
col.Remove(other);
}
void Update()
{
if (!second)
changecolor();
}
public void changecolor()
{
if (sort == objectsorts.foundation)
{
if (col.Count == 0)
{
IsDetail = true;
IsBuildable = true;
}
else
{
IsDetail = false;
IsBuildable = false;
}
}
else
{
if (col.Count == 0 && childcol.col.Count > 0)
{
IsDetail = true;
IsBuildable = true;
}
else
{
IsDetail = false;
IsBuildable = false;
}
}
if (IsBuildable)
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = green;
}
}
else
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = red;
}
}
if (IsDetail)
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = green;
}
}
else
{
foreach (Transform child in graphics)
{
child.GetComponent<Renderer>().material = red;
}
}
}
}
public enum objectsorts
{
normal,
foundation,
floor
}