OnTriggerEnter2D unity code example

Example 1: unity oncollisionenter2d

void OnCollisionEnter2D(Collision2D col)
    {
		//This method will run when your 2D game object
      	//collides with something

      	Debug.Log("Collided");
    }

Example 2: ontriggerenter2d

void OnTriggerEnter2D(Collider2D col)
{
	Debug.Log(gameObject.name + " Collided");
}

Example 3: ontriggerenter2d

void OnTriggerEnter2D (Collider2D other) //Make sure to put this out of Voids
     {
         if (other.gameObject.tag == "Object") 
         {
             Debug.Log ("Collided");
         }

Example 4: ontriggerenter2d

void OnTriggerEnter2D(Collider2D col)
    {
        Debug.Log(col.gameObject.name + " : " + gameObject.name + " : " + Time.time);
        spriteMove = -0.1f;
    }