is it possible destroy different objects on mouseClick with only one script?

I'm creating this game inspired from the famous game "Mystery Case Files". If you don't know the game, it's simply a game where there are items given in a side of panel and you'll have to find all the items before the time runs out.

In my current progress, i can destroy the game object once its clicked using this code attached to a game object that i want to destroy.

function OnMouseOver() {
    if(Input.GetMouseButtonDown(0)) {
    CheckScript.showCheck = true; //just displaying a GUItexture once clicked

now since there are tons of objects in my game, can i minimize the usage of this script? is it possible to destroy different object using only this script?

oh and also each time I destroy a game object there is also a GUITexture(which is the name of the object) that i need to destroy, i can do it using that script, but is it possible also to use a script that will destroy a specific GUITexture?

I am thinking of a varible where the game object and the GUITexture will be put in there. But it seems i can't do it xD hehehe kinda beginner here :3

Thanks in advance ^^,BlockquoteBlockquote

You can drag this script to every object that you want to destroy.

Put the GUITexture/GUIText inside the object (Making the object parent of the texture/text), then when you destroy, it will be destroyed too.


To get the texture inside the gameObject as child, you need to do a "foreach" like this:

 function Start(){
   children = GetComponentsInChildren (GUITexture);

   for (var child : GUITexture in children) {
      Debug.Log(child);  // returns myGUITextuyre (UnityEngine.GUITexture)

this is an example, put this where you have to.