XDracam / unity-corelibrary

Collection of classes and extension methods that make life with Unity3D more comfortable
MIT License
15 stars 3 forks source link

Is<>, As<> and All<> on Collisions #6

Closed Eregerog closed 5 years ago

Eregerog commented 5 years ago

It's faster than writing collision.gameObject.As<>(), and I don't think it would lead to confusion

XDracam commented 5 years ago

You can still collision.transform.As<T>() if I'm not mistaken

I will consider this for the next update

Eregerog commented 5 years ago

Indeed, but it's more code to write and can get quite messy in an if statement, where you just want to check if you collided with an object with a specific script

XDracam commented 5 years ago

Bonus: I made these three work on every Component as well as any Collision to allow more expressive code in the future.