Mark's Favorite Unity C# Extensions

For those of you using C# in your Unity projects (and at this point you really should be) extension methods allow you to add methods to existing types without having to create your own subtypes or change the original type in any way. They are very useful part of C#, something that is fairly unique to the language, and something you should be using to make your life easier! There are many in depth explanations of extension methods just a quick Google search away, but here are a few things to remember: All extension methods must be placed inside of a static class (I like to call mine Extensions) The extension method must also be static The first parameter to the method is preceded by the this keyword. The type of this parameter will be the type to which we are adding our extension method. Contrived Example What? You want » read more