I am trying to extend Vector3 which is a Unity3D feature. It does not have a less than operator, so I am trying to create one. However, When I write the extension method for it, my IDE tells me "Identifier expected, 'this' is a keyword".
How can I write an extension method using operators? This is my attempt, which unexpectedly did not work:
using UnityEngine;
using System.Collections;
public static class Vector3Extensions
{
public static bool operator <(this Vector3 vector3, Vector3 other)
{
if (vector3.x < other.x)
{
return true;
}
else if (vector3.x > other.x)
{
return false;
}
else if (vector3.y < other.y)
{
return true;
}
else if (vector3.y > other.y)
{
return false;
}
else if (vector3.z < other.z)
{
return true;
}
return false;
}
}