I’m implementing a simple list of tags in a scroll view, however, I fetch those tags from a rest API that works with pagination.
So I need to know when the user has reached the bottom of the current list of fetched tags to fetch the next page.
This is my current code, but I don’t know how to make the method UserIsAtTheBottomOfScrollView
[CustomEditor(typeof(ObjectTags))]
public class ObjectTagsEditor : Editor
{
...
private void OnEnable()
{
tagsProperty = serializedObject.FindProperty("tags");
}
public override void OnInspectorGUI()
{
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Height(300));
List<string> allTags = GetTags().Where(tag => TagContainsText(tag, searchTagText) && !IsTagAlredyPresent(tag)).ToList();
foreach (string tag in allTags)
{
if (GUILayout.Button(tag))
{
AddTagIfNotPresent(tag);
}
}
EditorGUILayout.EndScrollView();
if (UserIsAtTheBottomOfScrollView())
{
FetchNextPage();
}
}
private bool UserIsAtTheBottomOfScrollView()
{
// how do I know when the user is at the bottom of the scroll view?
}
...
}