2017-08-02 17:21:45 +08:00
|
|
|
|
namespace UnityEngine.UI.Extensions.Examples
|
|
|
|
|
{
|
|
|
|
|
public class UpdateScrollSnap : MonoBehaviour
|
|
|
|
|
{
|
2017-05-06 00:14:03 +08:00
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public UnityEngine.UI.Extensions.HorizontalScrollSnap HSS;
|
|
|
|
|
public UnityEngine.UI.Extensions.VerticalScrollSnap VSS;
|
|
|
|
|
public GameObject HorizontalPagePrefab;
|
|
|
|
|
public GameObject VerticalPagePrefab;
|
|
|
|
|
public UnityEngine.UI.InputField JumpPage;
|
2017-05-06 00:14:03 +08:00
|
|
|
|
|
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public void AddButton()
|
2017-05-06 00:14:03 +08:00
|
|
|
|
{
|
2017-08-02 17:21:45 +08:00
|
|
|
|
if (HSS)
|
|
|
|
|
{
|
|
|
|
|
var newHSSPage = GameObject.Instantiate(HorizontalPagePrefab);
|
|
|
|
|
HSS.AddChild(newHSSPage);
|
|
|
|
|
}
|
|
|
|
|
if (VSS)
|
|
|
|
|
{
|
|
|
|
|
var newVSSPage = GameObject.Instantiate(VerticalPagePrefab);
|
|
|
|
|
VSS.AddChild(newVSSPage);
|
|
|
|
|
}
|
2017-05-06 00:14:03 +08:00
|
|
|
|
}
|
2017-08-02 17:21:45 +08:00
|
|
|
|
|
|
|
|
|
public void RemoveButton()
|
2017-05-06 00:14:03 +08:00
|
|
|
|
{
|
2017-08-02 17:21:45 +08:00
|
|
|
|
GameObject removed, removed2;
|
|
|
|
|
if (HSS)
|
|
|
|
|
{
|
|
|
|
|
HSS.RemoveChild(HSS.CurrentPage, out removed);
|
|
|
|
|
removed.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
if (VSS)
|
|
|
|
|
{
|
|
|
|
|
VSS.RemoveChild(VSS.CurrentPage, out removed2);
|
|
|
|
|
removed2.SetActive(false);
|
|
|
|
|
}
|
2017-05-06 00:14:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public void JumpToPage()
|
2017-05-06 00:14:03 +08:00
|
|
|
|
{
|
2017-08-02 17:21:45 +08:00
|
|
|
|
int jumpPage = int.Parse(JumpPage.text);
|
|
|
|
|
if (HSS)
|
|
|
|
|
{
|
|
|
|
|
HSS.GoToScreen(jumpPage);
|
|
|
|
|
}
|
|
|
|
|
if (VSS)
|
|
|
|
|
{
|
|
|
|
|
VSS.GoToScreen(jumpPage);
|
|
|
|
|
}
|
2017-05-06 00:14:03 +08:00
|
|
|
|
}
|
2017-08-02 17:21:45 +08:00
|
|
|
|
|
|
|
|
|
public void SelectionStartChange()
|
2017-05-06 00:14:03 +08:00
|
|
|
|
{
|
2017-08-02 17:21:45 +08:00
|
|
|
|
Debug.Log("Scroll Snap change started");
|
2017-05-06 00:14:03 +08:00
|
|
|
|
}
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public void SelectionEndChange()
|
2017-05-06 00:14:03 +08:00
|
|
|
|
{
|
2017-08-02 17:21:45 +08:00
|
|
|
|
Debug.Log("Scroll Snap change finished");
|
2017-05-06 00:14:03 +08:00
|
|
|
|
}
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public void PageChange(int page)
|
2017-05-06 00:14:03 +08:00
|
|
|
|
{
|
2017-08-02 17:21:45 +08:00
|
|
|
|
Debug.Log(string.Format("Scroll Snap page changed to {0}", page));
|
2017-05-06 00:14:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public void RemoveAll()
|
|
|
|
|
{
|
|
|
|
|
GameObject[] children;
|
|
|
|
|
HSS.RemoveAllChildren(out children);
|
|
|
|
|
VSS.RemoveAllChildren(out children);
|
|
|
|
|
}
|
2017-07-30 20:13:29 +08:00
|
|
|
|
|
2017-08-02 17:21:45 +08:00
|
|
|
|
public void JumpToSelectedToggle(int page)
|
|
|
|
|
{
|
|
|
|
|
HSS.GoToScreen(page);
|
|
|
|
|
}
|
2017-07-30 20:13:29 +08:00
|
|
|
|
}
|
2017-08-02 17:21:45 +08:00
|
|
|
|
}
|