Dragging over multiple UI elements within a gridlayout.

Hi there, I’m trying to remake a game I made in Android Studio, and was wondering if someone could clear something up for me.
In my game there are several tiles in a gridlayout, and as the user drags(mobile app) over them multiple tiles get selected (kinda like Ruzzle if you’ve played that game). In my Java solution I added a listener to the grid itself and had no listeners on the tiles. I used x,y cooordinates of the grid to determine which position was being dragged over and stored an array of Tiles in the gridclass to alter the appearance of the tiles being selected / deselected. My question is if this would be a good solution in Unity, or would a solution where I implement touchlisteners on each Tile be better (Creating a prefab with a Tile script added to it)?

I’d appreciate any thoughts on this, thank you.

@Hallers

Hi there, IMO this is a bit of problem with Unity UI; basically, you start a click on button or image, and then continue dragging, you end up not creating new presses until after you release button/touch then start a new one.

Getting multiple items along path of drag won’t work very well using default UI approach which is click,hold and release - over one UI item.

You could actually use something like you said you already used in Java:

Create some sort of script that checks button presses, using IPointerDownHandler, IPointerUpHandler and such.

Store state that you are now pressing button.

Start moving pointer, then do raycasts if pressing button, using UI system raycast features (EventSystem.RaycastAll).

Check if you hit objects you want to hit, if so, collect them and process them as you wish.