Hey there folks.
I just noticed something pretty weird about Unity. There are 2 ways to find an GameObject by Tag. FindWithTag and FindGameObjectWithTag. I was asking myself what the differences could be so I checked the documentation. But there was the first weird thing I noticed. Only FindWithTag has a documentation entry. FindGameObjectWithTag doesn’t. Then I got really curious about that and jumped to declaration to see if I can spot differences there. And yes I did.
Thats the snippet I get when jumping to declaration:
[WrapperlessIcall]
[MethodImpl (MethodImplOptions.InternalCall)]
public static extern GameObject FindGameObjectWithTag (string tag);
public static GameObject FindWithTag (string tag)
{
return GameObject.FindGameObjectWithTag (tag);
}
And it turned out that FindWithTag simply calls FindGameObjectWithTag. Which I assume is some native/c++ way to find the object as it uses the extern keyword.
My question is why Unity has 2 methods for doing the same thing. And one of the methods is just calling the other and returning the result. So they are the same. Why not only have FindGameObjectWithTag? And remove FindWithTag?
Any speculations or definite answers on that?