'how to make simple pagination unity
how to make simple pagination
I am using grid layout for showing all number page.
page 1 offset = 0
page 2 until end offset += 10
I had a problem making pagination function for move to every page.
void DrawButton()
{
int n = jsnData.JmlPro[0].JmlProduct;
float asi = n / 10;
float pages = Mathf.Ceil(n / 10f);
int ofs = 0;
for (int i = 1; i <= pages; i++)
{
int offset = ofs;
GameObject goButton = (GameObject)Instantiate(prefabButton);
goButton.transform.SetParent(ParentPanel, false);
Button tempButton = goButton.GetComponent<Button>();
int tempInt = i;
tempButton.transform.GetChild(0).GetComponent<TMPro.TMP_Text>().text = tempInt.ToString();
if (i == 1)
{
tempButton.onClick.AddListener(() => ButtonClicked(offset));
}
else if (i > 1)
{
#if clicked number 2 until end offset will be +10. offset is paramater for ButtonClicked
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
