Monday, July 6, 2015

Unity Extension Method Tutorial

Check out the code below the videos



In this Unity3D tutorial we learn about extension methods. They're super useful for adding functionality to Unity classes we can't normally edit. We will make a new function for the Vector3 class called toVector2()

Google+ Community: https://plus.google.com/communities/108584850180626452949
Twitter: https://twitter.com/Devination3D
Facebook: https://www.facebook.com/unity3Dtutorialsbydevin

Support Further Tutorial Development
Comments?
Check out the videos above to hear the explanation and see the code in action
/*/
* Script by Devin Curry
* www.Devination.com
* www.youtube.com/user/curryboy001
* Please like and subscribe if you found my tutorials helpful :D
* Google+ Community: https://plus.google.com/communities/108584850180626452949
* Twitter: https://twitter.com/Devination3D
* Facebook Page: https://www.facebook.com/unity3Dtutorialsbydevin
/*/
using UnityEngine;
using System.Collections;

public static class ExtensionMethods
{
 public static Vector2 toVector2(this Vector3 vec3)
 {
  return new Vector2(vec3.x, vec3.y);
 }
}