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()

Twitter: https://twitter.com/Devination3D

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
* Twitter: https://twitter.com/Devination3D
/*/
using UnityEngine;
using System.Collections;

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