Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit d69b378

Browse files
committed
Added new public method to PaginationManager, to faciliate adding or removing toggles at runtime.
1 parent d62607e commit d69b378

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Runtime/Scripts/Utilities/PaginationManager.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
/// Credit Brogan King (@BroganKing)
33
/// Original Sourced from - https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/issues/158/pagination-script
44

@@ -44,7 +44,16 @@ protected override void Start()
4444
scrollSnap.OnSelectionPageChangedEvent.AddListener(SetToggleGraphics);
4545
scrollSnap.OnSelectionChangeEndEvent.AddListener(OnPageChangeEnd);
4646

47-
// add selectables to list
47+
ResetPaginationChildren();
48+
}
49+
50+
/// <summary>
51+
/// Remake the internal list of child toggles (m_PaginationChildren).
52+
/// Used after adding/removing a toggle.
53+
/// </summary>
54+
public void ResetPaginationChildren()
55+
{
56+
// add selectables to list
4857
m_PaginationChildren = GetComponentsInChildren<Toggle>().ToList<Toggle>();
4958
for (int i = 0; i < m_PaginationChildren.Count; i++)
5059
{
@@ -61,7 +70,6 @@ protected override void Start()
6170
Debug.LogWarning("Uneven pagination icon to page count");
6271
}
6372

64-
6573
/// <summary>
6674
/// Calling from other scripts if you need to change screens programmatically
6775
/// </summary>
@@ -128,4 +136,4 @@ private void OnPageChangeEnd(int pageNo)
128136
isAClick = false;
129137
}
130138
}
131-
}
139+
}

0 commit comments

Comments
 (0)