Texture2D collides in a gameObject??

Good day! Just want to ask if there is such a thing like this? Like detecting when a texture2D collides with a gameObject. This stuff is for dragging a texture2D in a gameObject, then an event will happen after this.

function OnCollisionEnter(){
   if (!collider.isTrigger)//this should detect whether the texture2D was triggered
    {
       Destroy(gameObject);//if true, the gameObject that was collided by the texture2D will be destroyed
    }
}

A million thanks to those who will answer. thanks :slight_smile:

First, you can’t just have a texture 2D in your scene. It has to either be textured onto a game object or a GUITexture or displayed in GUI 2.0. So you can’t test to see if a game object overlaps with a Texture2D.

And supposing you did put the texture on some sort of object, there isn’t any inherent way of hit testing an object against a texture. You could probably write your own of varying degrees of complexity depending on what you want it to do. The simplest example. This just tests to see if the pivot of your game object takes up the same screen space as a guiTexture.

@RequireComponent( GUITexture);
function HitTest(gO : GameObject) : Boolean {
    var pos : Vector3 = Camera.main.WorldToScreenPoint( gO.transform.position );
    //convert the game object's position to screen space.
    return guiTexture.HitTest( pos);
    //does it overlap our guiTexture?
}