Changing scene when all the object is destroyed

so here, let say i have 3 gameobject(cubes) with different names, i did use Destroy(gameObject) and its fine. but my problem is, im having a trouble making script that if i clicked the gameObject / Destroyed. it will change the scene/load level. any answer would be much appreciated.

Use GameObject.Find(“name1”) and GameObject.Find(“name2”) when you Destroy “name3”… If both return null, then you must load the scene/level.
Same goes for the other two cubes.

EDITED:

You can put a script on each cube that has the following in it:

public class DestroyDetection : MonoBehaviour
    {

       private static int objectsNeedToBeDestroyed = 0; 
       private static int objectsDestroyed = 0;
       
       void Start()
       {
          ++objectsNeedToBeDestroyed;
       }

       void OnDestroy() //will be called on destroying the object
       {
          if(++objectsDestroyed == objectsNeedToBeDestroyed)
          {
             Application.LoadLevel("YourLevelName");
          }
       }
    }

Note that this hasnt got an Update function that makes this optimal

Super Simple way…

var objectsCollider: Collider;

var objectsCount: int = 0;

function Update(){
    if(objectsCount >= 3){
        application.loadlevel("Blablabla");
    }
}
function OnColisionEnter(objectsCollider:Collider){
    objectsCount++
}

Another simple way of doing this is to keep the three cubes as a child of an EmptyGameObject and check against if the child count is zero or not.Simple…Like this

void Update()
{
  //If there are no child (which are the cubes) then change the scene
  if(transform.childCount<1)
  {
     Application.LoadLevel("YourLevelName");
  }
}