Created
April 6, 2015 05:12
-
-
Save asus4/bbd946ac82be9021a6e1 to your computer and use it in GitHub Desktop.
Linq for Unity Vector3.
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.Generic; | |
using System.Linq; | |
namespace AppKit.Extension | |
{ | |
public static class Vector3Extension | |
{ | |
public static Vector3 Average(this IEnumerable<Vector3> source) | |
{ | |
int length = source.Count(); | |
Vector3 all = Vector3.zero; | |
foreach(Vector3 v in source) | |
{ | |
all += v; | |
} | |
return all / length; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment