Skip to content

Instantly share code, notes, and snippets.

@asus4
Created April 6, 2015 05:12
Show Gist options
  • Save asus4/bbd946ac82be9021a6e1 to your computer and use it in GitHub Desktop.
Save asus4/bbd946ac82be9021a6e1 to your computer and use it in GitHub Desktop.
Linq for Unity Vector3.
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