How to detect a click on an object without attaching a script to that gameobject

I want all my code in one script and that script will be attached to the player gameobject
How to detect a click on an object without attaching a script to that gameobject

You only have to make a raycast using Camera.ScreenPointToRay as the ray and check what object your raycast hit. No need to attach a script to that object (but it does need a collider on it).