32 lines
838 B
C#
32 lines
838 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class SlotPathDeleter : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private GridManager TargetCarveGrid;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
Invoke(nameof(LateStart), 0.1f);
|
||
|
}
|
||
|
|
||
|
private void LateStart()
|
||
|
{
|
||
|
MeshCollider[] targets = TargetCarveGrid.SpawnedSlots.Select(x=>x.GetComponentInChildren<MeshCollider>()).ToArray();
|
||
|
|
||
|
BoxCollider[] colliders = GetComponentsInChildren<BoxCollider>();
|
||
|
for (int i = 0; i < colliders.Length; i++)
|
||
|
{
|
||
|
for (int j = 0; j < targets.Length; j++)
|
||
|
{
|
||
|
if (colliders[i].bounds.Intersects(targets[j].bounds))
|
||
|
{
|
||
|
Destroy(targets[j].gameObject);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|