FindGameObjectWithTag, FindWithTag
2023. 8. 24.

https://discussions.unity.com/t/difference-between-gameobject-findgameobjectwithtag-tag-tag-and-gameobject-findwithtag-tag-tag/68305

 

difference between GameObject.FindGameObjectWithTag(Tag tag) and GameObject.FindWithTag(Tag tag)

i’ve been wondering what the difference between these 2 is. I’ve seen them both appear and they seem to do exactly the same. The best explaination i could come up with is that the code got rewritten and they didn’t remove the old function. Also there

discussions.unity.com

FindWithTag와 FindGameObjectWithTag가 다른가에 대해 찾아보았다. 둘 다 매개변수로 string tag를 받는다.

 

깃허브에 들어가 GameObject를 확인해보니 FindWithTag는 FindGameObjectWithTag를 리턴하므로 tag를 리턴한다.

FindGameObjectWithTag가 어떻게 동작하는지 내부코드는 공개되어있지 않아서 자세한 것은 알 수 없지만 둘이 똑같이 동작하는 것 같다.

 

GameObject에서 확인해보았다.

-FindWithTag는 FindGameObjectWithTag를 리턴한다

 

https://github.com/Unity-Technologies/UnityCsReference/blob/master/Runtime/Export/Scripting/GameObject.bindings.cs

 

myoskin