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()).ToArray(); BoxCollider[] colliders = GetComponentsInChildren(); 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); } } } } }