Fixed public GoToScreen call to only raise events internally (not multiple)

pull/413/head
Simon (darkside) Jackson 2020-09-28 18:12:35 +01:00
parent 56391827d6
commit 263368ba8d
3 changed files with 10 additions and 7 deletions

View File

@ -238,7 +238,7 @@ namespace UnityEngine.UI.Extensions
if (JumpOnEnable || !RestartOnEnable) if (JumpOnEnable || !RestartOnEnable)
SetScrollContainerPosition(); SetScrollContainerPosition();
if (RestartOnEnable) if (RestartOnEnable)
GoToScreen(StartingScreen); GoToScreen(StartingScreen, true);
} }
/// <summary> /// <summary>

View File

@ -357,7 +357,7 @@ namespace UnityEngine.UI.Extensions
/// *Note, this is based on a 0 starting index - 0 to x /// *Note, this is based on a 0 starting index - 0 to x
/// </summary> /// </summary>
/// <param name="screenIndex">0 starting index of page to jump to</param> /// <param name="screenIndex">0 starting index of page to jump to</param>
public void GoToScreen(int screenIndex) public void GoToScreen(int screenIndex, bool local = false)
{ {
if (screenIndex <= _screens - 1 && screenIndex >= 0) if (screenIndex <= _screens - 1 && screenIndex >= 0)
{ {
@ -366,7 +366,7 @@ namespace UnityEngine.UI.Extensions
_lerp = true; _lerp = true;
CurrentPage = screenIndex; CurrentPage = screenIndex;
GetPositionforPage(_currentPage, ref _lerp_target); GetPositionforPage(_currentPage, ref _lerp_target);
ScreenChange(); if(local) ScreenChange();
} }
} }
@ -623,7 +623,7 @@ namespace UnityEngine.UI.Extensions
/// </summary> /// </summary>
public void ChangePage(int page) public void ChangePage(int page)
{ {
GoToScreen(page); GoToScreen(page, true);
} }
public void OnPointerClick(PointerEventData eventData) public void OnPointerClick(PointerEventData eventData)

View File

@ -228,10 +228,13 @@ namespace UnityEngine.UI.Extensions
{ {
InitialiseChildObjectsFromScene(); InitialiseChildObjectsFromScene();
DistributePages(); DistributePages();
if (MaskArea) UpdateVisible(); if (MaskArea)
UpdateVisible();
if (JumpOnEnable || !RestartOnEnable) SetScrollContainerPosition(); if (JumpOnEnable || !RestartOnEnable)
if(RestartOnEnable) GoToScreen(StartingScreen); SetScrollContainerPosition();
if (RestartOnEnable)
GoToScreen(StartingScreen, true);
} }
/// <summary> /// <summary>