I'm starting with C# and having trouble writing a method that accepts both Vector2 and Vector3 arguments in C#.
Generic methods looked like the way to go, but I can't make it work just yet. Here's what I tried:
static void GetNoisePosition<T>(ref T position, float offset, float scale) where T : IEquatable<T>
{
position += position.GetType().one * (offset + 0.1f);
position *= scale;
}
I dont really want to have 2 versions of GetNoisePosition, each taking a vector type, as I dont want to duplicate the logic, and it'd be hard to create another method that would share some of this logic.
So, the issue is that I want to call the one
method on the class of type T, but it's telling me that I can't.
Can I get access to the class via the position
instance and call one on it?