Begin and End Drag not working properly on iOS, but works on Android.

I’m having a bug with the Begin Drag and End Drag event triggers on iOS that isn’t happening on Android, and I’ve failed to find a answer for it. I’m using Unity 2020.3.3.

My screen is split into 2 portions, the bottom portion is a menu with a scroll rect containing a list of UI objects that you can scroll through, and the top is just a normal screen where you can drag and interact with an object (drag to rotate, tap to do something, etc).

The Scroll rect has a raycast blocker than prevents the touch raycasts from through through it and interacting with the object behind it. The scroll rect is only enabled when you tap on certain places on the object, which opens the menu.

The reason why I put the Begin and End drag events on the menu portion is because I don’t want the interaction to immediately switch over to interacting with object as soon as the finger moves above the scroll rect. Vise versa, I don’t want the interaction to switch over to the list if the user starts in the normal portion of the screen and moves their touch into the menu.

I’ve added touch events to the scroll rect like this.

8737122--1183047--upload_2023-1-17_11-35-38.png

Each event is has a method attached that just sets a bool. The bool, if true, disables the ability to interact with the object. The idea is that if I drag in the menu portion of the screen, while the menu is enabled, it would block interaction with the object even if I drag my finger onto the top portion of the screen, and will do so until let go. Begin Drag sets the bool to true, and End Drag sets the bool to false.

This is working exactly as intended on Android. But on iOS it doesn’t. As soon as the menu is enabled, the interaction is blocked for the top portion of the screen until I start and end a drag on the bottom portion of the screen first.

Since there isn’t a unity remote for iOS that I’m aware of, I’m not sure what the cause is. Any help would be appreciated. Or if there is a better way of doing what I’m trying to do.

Try using log viewer to bring up Debug messages. Add them throughout your code. This will also spit out errors if you have any that are appearing on iOS.

Just to double check, everything is working in editor as well, correct?

Everything works in editor and Android. Working find in editor through Unity Remote and works fine when built to android.

Unity Remote is just the editor streamed to the device and input from the device streamed back to the editor for processing. Unity Remote is available via the app store though. “Unity Remote 5”.
It isn’t always reliable to test things with since it is just the editor running.

As Brathnann suggested use Debug messages. Or as Kurt usually says when in doubt print it out.

Either remove the EventTrigger and replace it with this DragHandler component

public class DragHandler : MonoBehaviour, IBeginDragHandler, IEndDragHandler
{
    public void OnBeginDrag(PointerEventData eventData)
    {
        Debug.Log("OnBeginDrag");
    }
 
    public void OnEndDrag(PointerEventData eventData)
    {
        Debug.Log("OnEndDrag");
    }
}

or create a debug component and serialize it in the EventTrigger DragStart and DragEnd.

public class DebugComponent : MonoBehaviour
{
    public void Log(string message) => Debug.Log(message, this);
}

Also I don’t know if your scroll rect is actually visible, but make sure you give the draggable area a visible color. That way you know the layout isn’t screwing anything up.
Build&Run for iOS and either observe the xcode log or use an in-app console that displays all the debug logs.

also note on EventTrigger component:

Update: So the bug seemed to have resolved itself after rebuilding for IOS. Maybe something got screwed up while ebuilding. There was some XCode updates recently and maybe something wasn’t set up right. Feature is now working as intended on both OSes. Thank you all for the help. I’ll update again if the bug resurfaces.