- Home /
Problem is not reproducible or outdated
operator && cannot be applied to operands of type bool and method group
else if (touch.phase == TouchPhase.Ended && quit.HitTest)
{
Anim.Play("fgfffhfffthjjbczsd");
}
This code works on javascript, but on c sharp i get. "Operator && cannot be applied to operands of type bool and method group."
Fyi:quit is a GUI texture
Im a noob so i dont know what i did incorrectly.
is HitTest
a function? if so, AND it returns a bool
, then add ()
after HitTest
to denote the return value...
No, because HitTest requires parameters Vector3 and Camera. I did what you suggested before but i still get an error that HitTest does not take zero arguments
so, HitTest
is a function (a method to talk properly), gjf is not mistake, you need to pass both parameters to HitTest
, it probably are Input.mousePosition
and Camera.main
. so try
touch.phase == TouchPhase.Ended && quit.HitTest(Input.mousePosition, Camera.main)
Answer by ETurns · Aug 12, 2016 at 08:12 AM
HitTest is a function and therefore requires an open and closing parentheses. The HitTest function also requires at minimum a Vector3 for an argument. So your code would look like this.
else if (touch.phase == TouchPhase.Ended && quit.HitTest(myVector3))
{
Anim.Play("MyAnim");
}
You can find more information about the HitTest() function here: https://docs.unity3d.com/ScriptReference/GUIElement.HitTest.html