示例#1
0
    public void Pause()
    {
        if (GameManager.Instance.gameState == GameState.Playing)
        {
            SoundsManager.Instance.PlaySound(SoundsManager.Instance.buttonSubmit);
            //Pause
            GameManager.Instance.gameState = GameState.Pause;
            Time.timeScale = 0;
            pauseMenu.gameObject.SetActive(true);

            pauseMenu.GetComponent <RectTransform> ().DOAnchorPos(onScreenPosition, menuAnimationDuration).SetEase(menuEase).OnComplete(() =>
            {
                currentMenu = pauseMenu.GetComponent <MenuComponent> ();
                eventSystem.SetSelectedGameObject(null);
                eventSystem.SetSelectedGameObject(pauseMenu.GetComponent <MenuComponent> ().selectable);
            }).SetUpdate(true);
        }

        else if (GameManager.Instance.gameState == GameState.Pause)
        {
            SoundsManager.Instance.PlaySound(SoundsManager.Instance.buttonCancel);
            //Unpause
            pauseMenu.GetComponent <RectTransform> ().DOAnchorPos(offScreenPosition, menuAnimationDuration).SetEase(menuEase).OnComplete(() =>
            {
                eventSystem.SetSelectedGameObject(null);
                pauseMenu.gameObject.SetActive(false);
                Time.timeScale = 1;
                currentMenu    = null;
                GameManager.Instance.gameState = GameState.Playing;
            }).SetUpdate(true);
        }
    }
示例#2
0
 public void ShowInstantMenu(MenuComponent menu)
 {
     menu.gameObject.SetActive(true);
     menu.GetComponent <RectTransform> ().anchoredPosition = onScreenPosition;
     currentMenu = menu;
 }