Esempio n. 1
0
        /// <summary>
        /// Adds toast to the list.
        /// </summary>
        /// <param name="parent">Parent transform.</param>
        /// <param name="text">Text.</param>
        /// <param name="tokenId">Token ID for translation.</param>
        /// <param name="tokenArguments">Token arguments.</param>
        /// <param name="duration">Duration.</param>
        private static void AddToast(
            Transform parent
            , string text
            , R.sections.Toasts.strings tokenId
            , object[]                  tokenArguments
            , float duration
            )
        {
            DebugEx.VerboseFormat("Toast.AddToast(parent = {0}, text = {1}, tokenId = {2}, tokenArguments = {3}, duration = {4})"
                                  , parent
                                  , text
                                  , tokenId
                                  , tokenArguments
                                  , duration);

            #region Toast GameObject
            GameObject toast = new GameObject("Toast");
            Utils.InitUIObject(toast, parent);

            //===========================================================================
            // RectTransform Component
            //===========================================================================
            #region RectTransform Component
            RectTransform toastTransform = toast.AddComponent <RectTransform>();
            Utils.AlignRectTransformStretchStretch(toastTransform, 20f, 20f, 20f, 20f);
            #endregion

            //===========================================================================
            // ToastScript Component
            //===========================================================================
            #region ToastScript Component
            ToastScript toastScript = toast.AddComponent <ToastScript>();

            toastScript.text           = text;
            toastScript.tokenId        = tokenId;
            toastScript.tokenArguments = tokenArguments;
            toastScript.duration       = duration;
            #endregion
            #endregion

            sToasts.Add(toastScript);

            if (sToasts.Count == 1)
            {
                ShowNextToast();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handler for toast destroy event.
        /// </summary>
        /// <param name="toast">Toast script.</param>
        public static void ToastDestroyed(ToastScript toast)
        {
            int index = mToasts.IndexOf(toast);

            if (index >= 0)
            {
                mToasts.RemoveAt(index);

                if (index == 0 && mToasts.Count > 0)
                {
                    ShowNextToast();
                }
            }
            else
            {
                Debug.LogError("Unexpected behaviour for toast destroyed handler");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Handler for toast destroy event.
        /// </summary>
        /// <param name="toast">Toast script.</param>
        public static void ToastDestroyed(ToastScript toast)
        {
            DebugEx.VerboseFormat("Toast.ToastDestroyed(toast = {0})", toast);

            int index = sToasts.IndexOf(toast);

            if (index >= 0)
            {
                sToasts.RemoveAt(index);

                if (index == 0 && sToasts.Count > 0)
                {
                    ShowNextToast();
                }
            }
            else
            {
                DebugEx.Fatal("Unexpected behaviour in Toast.ToastDestroyed()");
            }
        }