GetComponent and Interfaces and warnings

So I have this IInteractable that I tag some of my monobehaviours with.
The player has a trigger box attached to the front of them, and I have this little method running.

void OnTriggerEnter(Collider _col)
{
    if (_col.GetComponent(typeof(IInteractable)))
    {
        interactObject = _col.GetComponent(typeof(IInteractable)) as IInteractable;      
    }
}

and then later in an update I call :

interactObject.Action()

to get the whole thing working.

Anyway, I’m having a problem, more of an annoyance really.
Every time the trigger box touches anything in the game, I get this warning:

GetComponent requires that the requested component ‘IInteractable’ is inherited or implemented by ‘objectName’.

And literally everything the trigger box touches gives this warning. The floor, the walls, the player themselves. This makes the console rather bothersome to use, even if I turn collapse on. Anyone have any ideas on how to make it not generate hundreds of warnings?

I will say, I found a solution that works, but requires a little more set up than I’d like. Just putting the box on the player on it’s own layer, say PlayerInteract, and then every object that you can interact with in the game on it’s own layer, Interactable. And then making it so PlayerInteract touches no layers except Interactable. This works, but I’m trying to see if I can just change the if statement to something else so I can avoid having to check layers all the time.

So it does work.
It just throws a lot of warnings. Like a lot a lot. I’m just trying to see if I can get the warnings to go away.
It expects that everything it touches to have implemented IInteractable in some shape, way or form.
What’s odd, to me at least, is that if it’s not an interface, it doesn’t throw that warning. Unity is totally cool with doing a GetComponent<> as a check, and failing without throwing a warning. Interfaces still work, but they seem to behave differently.

I had the same problem. The GetComponent works well, but throws warnings. Here’s my solution a custom GetComponent method:

def GetComponent[of T(class)](gameobj as GameObject) as T:
		comps = gameobj.GetComponents(Component)
		for comp in comps:
			if comp as T != null:
				return comp as T
		return null