0
\$\begingroup\$

In the update method I'm using unity's touch, as you can see in the code.

void Update()
{
    //Input.GetTouch(i).phase == TouchPhase.Began
    if (Input.touchCount > 0)
    {
        for (int i = 0; i < Input.touchCount; i++)
        {
            if (Input.GetTouch(i).phase == TouchPhase.Began)
            {
                x = Input.GetTouch(i).position.x;
                y = Input.GetTouch(i).position.y;
            }
        }
    }
}

The problem is that it tells me the following error: "error CS0019: Operator '==' can not be applied to operands of type 'TouchPhase' and 'TouchPhase'" I find it strange that I have this error, when one can see this if in the documentation of unity in c #

\$\endgroup\$
  • \$\begingroup\$ Is it possible that you have another TouchPhase enum defined in your project that the compiler thinks you're trying to use here? Try something like Debug.Log(typeof(foo).AssemblyQualifiedName); to print out the full details of the type of the phase you're getting from Input vs the enum, to compare where the two qualified names might differ. If they're identical, then this might be a big or corruption you can fix by reinstalling Unity/VS or nuking & re-building your solution files. \$\endgroup\$ – DMGregory Jun 6 '19 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.