Boundry destroy problem

I have a 2D asteroid game which spawn moving asteroids (spawn box) from left , right, above and below my main camera view. My original asteroids (objects) where place far away from my main camera and my spawn boxes so it wouldn’t come in at i time i didn’t give it. I made a boundary box around my main camera and my spawn box so it can destroy any asteroids (objects) that goes beyond that point. but it didn’t work. My problem is how can i make a boundary box using a box collider that destroy any objects that goes beyond it. WITHOUT destroying my original asteroids (objects). Here’s my boundary script :

using UnityEngine;
using System.Collections;
public class DestroyByBoundary : MonoBehaviour
{
void OnTriggerExit(Collider other)
{
Destroy(other.gameObject);
}
}

I will assume your “original asteroids” (hereafter called prefabs) are not moving around in your scene. If they are, stop moving your prefabs around at runtime because it doesn’t make sense. With the information given, the only way the prefabs would get destroyed would be if they enter and then exit the Boundry.

Consider disabling the prefab gameobject so it is inactive at runtime (no longer moving around, rendering, triggering stuff etc). When you instantiate a asteroid clone from an inactive prefab, active the clone with clone.gameObject.SetActive(true).

The most common way to work with prefabs is to make them assets and not have them hanging around in your scene. With that approach you won’t have to worry about the prefabs interacting with your game.