detect Gameobject which is created from c#

hi all

I am not creating GameObject ( Empty object) from UNITY editor instead i am creating new GameObject from C#. I am loading spritesheet and its subimages to these objects. How to detect these objects at runtime ?

I am not able to find which sprite I have clicked. I used RaycastHit2D but its only help if I have a gameobject in editor ( I mean if I have created through Editor). It is not detecting objects which I have created through c# ( as mentioned above).

When I run ( Game mode) I can see newly created sprite and its name since I have added name to object from c#

It sort of depends on how youre creating them, are you just instantiating them as a prefab or are you building a new gameobject from scratch?

make sure it has a collider on there, or you wont be able to detect it with a raycast.