Hi there
There is a ListView example here: Unity - Manual: Creating your first runtime UI
But I was wondering if anyone knows how to populate a ScrollView dynamically and also drag and dropping from these into another UI. I havent found anything yet.
Any tips would be appreciated.
Thanks
Hi,
ScrollView is populated calling ScrollView.Add(…).
E.g: ScrollView.Add(new Button());
@alexandred_unity
Cool, I managed to add to to the scrollview. Guess one of the reasons to have a working example is to not ask these sort of questions but I was wondering how to drag a scrollview element into another area of the screen.
That’ll kind of help me get part of my ui complete.
Thanks
Also, is it possible to drag a scrollview element outside of its container so it interacts with a regular 3d world element in the scene?
When I run this:
void OnMouseMoveEvent (MouseMoveEvent mouseEvent)
{
m_IsDragging = true;
SetPosition(GetMousePositionNew(mouseEvent.mousePosition));
}
public void StartDrag ()
{
m_IsDragging = true;
BringToFront();
}
public void SetPosition(Vector2 pos)
{
style.left = pos.x;
style.top = pos.y;
}
I can only drag a scrollview element as far as its container. I wonder if I should try some logic where I feed some math where a negative style.left value can be used?
Thanks