Пример #1
0
 /// <summary>
 /// Go to a new page as root (clearing history)
 /// </sumary>
 public void GoToRoot(UIPage newRoot)
 {
     if (history.currentPage.page != newRoot)
     {
         history.GoToRoot(newRoot);
     }
     // Else we're already there
 }
Пример #2
0
    // Start is called before the first frame update
    void Awake()
    {
        header.onBackClicked.AddListener(OnBack);
        header.onMenuClicked.AddListener(OnMenu);
        header.onSaveClicked.AddListener(OnSave);

        foreach (var pat in pages)
        {
            pat.page.gameObject.SetActive(false);
            if (pat.button != null)
            {
                pat.button.onClick.AddListener(() => GoToRoot(pat.page));
                pat.button.SetCurrent(false);
            }
        }

        // Start the page navigation history
        history = new PageHistory();
        history.onPageEntered += onHistoryPageEntered;
        history.onLeavingPage += onHistoryLeavingPage;

        // Go to the home page
        history.GoToRoot(pages[0].page);
    }