0
\$\begingroup\$

I have a large dial which can be rotated by touch. I have a circular crosshairs at the top to show which number is selected. I have had to turnoff the Raycast Target on the crosshairs because it was stopping the dial rotation when the when the finger touch was moving over it.

My problen now is that when the desired number is selected in the crosshairs I want to be able to tap the crosshairs to go to that level. Is it possible to detect the tap on the crosshairs?

Here is the code I have attached to the dial for rotation.The crosshairs is the very next GameObject in the hierarchy.

public void OnDrag(PointerEventData eventData)
{
    //CHECK IF CAN DRAG
    if (!_canDrag)
    {
       return;
    }
    transform.rotation = finalRotation;
\$\endgroup\$
2
  • \$\begingroup\$ Maybe start by not disabling functionality that you need? Try showing us how you were doing your touch rotation, and we may be able to help you find ways to modify the behaviour so it doesn't require hiding the crosshairs from the touch input system. \$\endgroup\$
    – DMGregory
    Aug 16, 2019 at 22:19
  • \$\begingroup\$ Have you tried forwarding the drag control from the crosshairs to this script? It's difficult to offer a full solution when we can see only so little of your code & scene setup — we don't know how the _canDrag or finalRotation variables are assigned, for example. \$\endgroup\$
    – DMGregory
    Aug 16, 2019 at 23:22

1 Answer 1

1
\$\begingroup\$

You can reference the Image crosshair and on start you can disable the raycast so it does not interfere with the dial as you mentioned.

Image crosshair
void Start()
{
    crosshair = GetComponent<Image>();
    crosshair.raycastTarget = false;
}

then after your desired number is selected set the image raycast back to true for the crosshair so it can be selectable again.

crosshair.raycastTarget = true;
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .