Someone told me that this:
Is better than this:
Is that true? Thanks.
asked Jan 01, 2012 at 04:44 PM
CompareTag compiles to fewer CIL instructions than the direct comparison, for sure: it probably results in a single call to the CompareTag internal function, while the other alternative will need a call to the tag getter function (to get the tag string) and another call to the string comparison function, all of this in CIL (the interpreted language used in .NET applications). Since the tag string must be returned by the getter function, space must be allocated, what takes extra time. Anyway, the difference probably is very small, but may become significant if a lot of CompareTags is used in Update or OnCollision/TriggerStay, and/or the target machine is a mobile device.
answered Jan 01, 2012 at 05:19 PM