How can I spawn a game object/prefab on my mouse pointer while only hovering over a specific area?

I’m a total beginner in Unity and C#.

I’m creating a simple game in 2D with sprites. To be brief, I would like to spawn a game object or prefab with a left mouse click but only when the mouse pointer is hovering over a certain area in the scene. I then need the spawned object to be held and dragged along with the mouse pointer until the left mouse button is released.

I’ve created a script that let’s me click on and drag an object around the scene but I would like to spawn the object first and then be able to keep holding the left mouse button and drag it to a new location and then release to drop the item into a new spot. Does this make sense?

Any suggestions on tutorials or videos I could take a look at?

I’m also not sure if I’m posting in the right place (total noob).

Thanks in advance.

Hello Donovan.

If you are new, and dont know where to start with this, i recommend you to read manuals / watch tutorials about this things and watch this tutorials:

After this, you should be able to know how to do what you want!

Good luck!