Ejemplo n.º 1
0
    public void OpenPopup(PopupType popupType, BasePopupData data /*,bool isSingleOnScreen = false*/)
    {
        _canvas = GameObject.FindGameObjectWithTag("MainCanvas").GetComponent <Canvas>();
        PopupData popupData = _popupDataList.popupDataList.Find(x => x.popupType == popupType);

        if (popupData == null)
        {
            Debug.LogError("PopupManager:OpenPopup The popup " + popupType.ToString() + "you are trying to open doesn`t exist.");
            return;
        }

        // if (isSingleOnScreen)
        //{
        //   CloseAllMenus();
        //}
        //ifatuTODO - check if this is needed or corect
        //Destroy(_currentMenu);
        //_currentMenu = null;
        _currentPopup = Instantiate(popupData.popupPrefab, transform.position, Quaternion.identity);
        _currentPopup.Init(data);
        _currentPopup.transform.SetParent(_canvas.transform, false);

        //   _currentMenu.transform.position = new Vector3(0, 0, 0);
        // _currentMenu.transform.localScale = new Vector3(1, 1, 1);
        _popupStack.Add(_currentPopup);
    }