Dragging multiple objects onto a script

I’ve seen a lot of tutorials out there saying that in order to access the script of another object, you should drag that object onto the script.

For example:

If Object A has Script A and you want to call a function from Script A using Script B, you have to drag object A onto script B.

But what if I want to make a keyboard controller script which could end up controlling dozens of objects?

Does that mean I would have to drag dozens of objects onto the keyboard controller script?

Is there an easier way?

Another Example:
Just say I had 100 unique objects. I want to be able to delete any of those objects by selecting it with the mouse then hitting “D” on the keyboard. I would either have to attach the keyboard script to each unique object or attach each unique object to the keyboard script. Is there no way I can just find out what the active object is and delete it without there being any explicit connection between the keyboard script and the object?


The decoupling between scripts can be done using events. The documentation can be found here: UnityEvents