Пример #1
0
        public bool displayOrAddToast(string toastName, string toastText, float displayTime = 2f, bool addOnTop = true, string toastHeader = null, Sprite toastSprite = null)
        {
            IToast toastToDisplay = requestToast(toastName);

            if (toastToDisplay == null)
            {
                return(false);
            }
            //if the Toast is already showing we'll clone it
            if (toastToDisplay.IsShowing)
            {
                toastToDisplay = instantiateToast(toastToDisplay.modalObject);
            }
            toastToDisplay.modalObject.SetActive(true);
            toastToDisplay.ModifyModal(toastText);
            if (toastHeader != null)
            {
                toastToDisplay.setupHeader(toastHeader);
            }
            if (toastSprite != null)
            {
                toastToDisplay.ModifyModalImage(toastSprite);
            }
            if (addOnTop)
            {
                toastToDisplay.modalObject.transform.SetAsFirstSibling();
            }
            toastToDisplay.display();
            toastToDisplay.hide(displayTime);
            return(true);
        }
Пример #2
0
        public bool displayOrChangeToast(string toastName, string toastText, float displayTime = 2f, string toastHeader = null, Sprite toastSprite = null)
        {
            IToast toastToDisplay = requestToast(toastName);

            if (toastToDisplay == null)
            {
                return(false);
            }
            if (activeToast != null)
            {
                //check if this is a new Type of toast and if so hide the old type of toast
                if (activeToast != toastToDisplay)
                {
                    activeToast.hide();
                }
                toastToDisplay.modalObject.SetActive(true);
            }
            else
            {
                toastToDisplay.modalObject.SetActive(true);
            }

            activeToast = toastToDisplay;
            activeToast.ModifyModal(toastText);
            if (toastHeader != null)
            {
                activeToast.setupHeader(toastHeader);
            }
            if (toastSprite != null)
            {
                activeToast.ModifyModalImage(toastSprite);
            }
            activeToast.modalObject.transform.SetAsFirstSibling();
            activeToast.display();
            activeToast.hide(displayTime);
            return(true);
        }