Created
July 23, 2015 15:21
-
-
Save v21/5ac91135387b03a4cb8d to your computer and use it in GitHub Desktop.
VectorExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public static class VectorExtensions { | |
public static Vector2 xy(this Vector3 vector) | |
{ | |
return new Vector2(vector.x, vector.y); | |
} | |
public static Vector2 yz(this Vector3 vector) | |
{ | |
return new Vector2(vector.y, vector.z); | |
} | |
public static Vector2 xz(this Vector3 vector) | |
{ | |
return new Vector2(vector.x, vector.z); | |
} | |
public static Vector3 zyx(this Vector3 vector) | |
{ | |
return new Vector3(vector.z, vector.y, vector.x); | |
} | |
public static Vector2 zy(this Vector3 vector) | |
{ | |
return new Vector2(vector.z, vector.y); | |
} | |
public static Vector3 x0y(this Vector2 vector) | |
{ | |
return new Vector3(vector.x, 0, vector.y); | |
} | |
public static Vector3 xy0(this Vector2 vector) | |
{ | |
return new Vector3(vector.x, vector.y, 0); | |
} | |
public static Vector3 ChangeX(this Vector3 vector, float x) | |
{ | |
return new Vector3(x, vector.y, vector.z); | |
} | |
public static Vector3 ChangeY(this Vector3 vector, float y) | |
{ | |
return new Vector3(vector.x, y, vector.z); | |
} | |
public static Vector3 ChangeZ(this Vector3 vector, float z) | |
{ | |
return new Vector3(vector.x, vector.y, z); | |
} | |
public static Vector2 ComponentwiseMultiply(this Vector2 vector, Vector2 multiplicand) | |
{ | |
return new Vector2(vector.x * multiplicand.x, vector.y * multiplicand.y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment