Reputation: 45
So, I am making an android app about some locations in my city. In my UI I have background, title, description and a selector tab, that should be dragged out and dragged back down whenever user wants it to. Here is an example: https://i.sstatic.net/FfgK8.jpg
The problem is - I don't really know how to make an event that checks when the object is being dragged in +Y or -Y axis and dragg's it to the fingers position. Any suggestions?
Upvotes: 0
Views: 234
Reputation: 74
You can add event trigger to UI panel 1. UI panel, add component -> Event -> Event Trigger 2. Add new event type Drag and add the function on it
public void onDragPanel()
{
if (!_isDrag)
{
_isDrag = true;
if (Input.GetAxis("Mouse Y") > 0 )
//Move up
else if (Input.GetAxis("Mouse Y") < 0 )
//Move down
}
}
and for the up/down movement, you can use animation with two animation states or you can use UITWEEN from asset store. https://assetstore.unity.com/packages/tools/animation/ui-tween-38583
Let me know if you have any further queries.
Upvotes: 1