Vector4 and Color messing up with method overloading

Hello,

it’s very hot here, and I can’t seem to understand if my issue has a solution or not.

I have a method which accepts a parameter of type Color:

void SomeMethod(Color color) {...}

Now the problem is that I really really need to overload that method, so that it can alternatively accept a Vector4 parameter instead and do different things:

void SomeMethod(Vector4 vector) {...}

Now that’s where things get bad, since Unity’s Color type can be implicitly converted to Vector4 and viceversa, so the compiler doesn’t know which one to choose. Anyone knows if there’s some tricky solution to this issue, while still being able to overload?

Thanks

EDIT ------------------------

tswalk showed me that it SHOULD work, so I made other tests and realized the issue is still related to overloads and implicit casting, but happens only when there are optional parameters involved. Posted an updated question here

did you try casting the type to the overloaded method to see if it would get the right signature?

public void testMethod(Color color)
{
Debug.Log(“color method”);
}

public void testMethod(Vector4 _vector)
{
Debug.Log(“vector method”);
}

Vector4 test = new Vector4(0, 0, 0, 0);
Color cTest = Color.black;

testMethod((Vector4)test);
testMethod((Color)cTest);
testMethod(test);
testMethod(cTest);

In both sets of examples above, the correct method is called for me… so, not sure why the signature isn’t working for you.