FancyScrollView control updated to add an event when the page is changed / Selected
Thanks to @ChongHann (Hann Chong) for the fix Resolves #157release
parent
adb09d3481
commit
b4a2e81aae
|
@ -4,7 +4,6 @@ namespace UnityEngine.UI.Extensions.Examples
|
|||
{
|
||||
public class Example01ScrollView : FancyScrollView<Example01CellDto>
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
ScrollPositionController scrollPositionController;
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace UnityEngine.UI.Extensions.Examples
|
|||
new void Awake()
|
||||
{
|
||||
scrollPositionController.OnUpdatePosition.AddListener(UpdatePosition);
|
||||
// Add OnItemSelected event listener
|
||||
scrollPositionController.OnItemSelected.AddListener(CellSelected);
|
||||
|
||||
SetContext(new Example02ScrollViewContext { OnPressedCell = OnPressedCell });
|
||||
base.Awake();
|
||||
}
|
||||
|
@ -27,5 +30,13 @@ namespace UnityEngine.UI.Extensions.Examples
|
|||
context.SelectedIndex = cell.DataIndex;
|
||||
UpdateContents();
|
||||
}
|
||||
|
||||
// An event triggered when a cell is selected.
|
||||
void CellSelected(int cellIndex)
|
||||
{
|
||||
// Update context.SelectedIndex and call UpdateContents for updating cell's content.
|
||||
context.SelectedIndex = cellIndex;
|
||||
UpdateContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@ namespace UnityEngine.UI.Extensions.Examples
|
|||
new void Awake()
|
||||
{
|
||||
scrollPositionController.OnUpdatePosition.AddListener(UpdatePosition);
|
||||
|
||||
// Add OnItemSelected event listener
|
||||
scrollPositionController.OnItemSelected.AddListener(CellSelected);
|
||||
|
||||
SetContext(new Example03ScrollViewContext { OnPressedCell = OnPressedCell });
|
||||
base.Awake();
|
||||
}
|
||||
|
@ -28,5 +32,12 @@ namespace UnityEngine.UI.Extensions.Examples
|
|||
UpdateContents();
|
||||
}
|
||||
|
||||
// An event triggered when a cell is selected.
|
||||
void CellSelected(int cellIndex)
|
||||
{
|
||||
// Update context.SelectedIndex and call UpdateContents for updating cell's content.
|
||||
context.SelectedIndex = cellIndex;
|
||||
UpdateContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue