Detect if UI Image is in a trigger

Hello,

I was making my game, but i ran into this problem… I dont know how to detect two UI images, if one is in the trigger of the other image. Can somebody tell me exactly how can i do it?

Dear @username, For detecting the trigger on UI gameObject, You need to do the following:-

  1. Attach colliders2D to both of the game Object and make sure that one of them is triggered check.

  2. Attach Rigidbody2D to them.

  3. Assign Tag one gameObject i.e. “Mytag”

  4. Attach the script to other UI gameObject having this code :-

      void OnTriggerEnter2D(Collider2D other)
        {
           if(other.gameObject.tag=="Mytag")
            {
                 //Do whatever you want to do
              }
        }