Пример #1
0
        /// <summary>
        /// Initializes the toast system.
        /// </summary>
        private void InitSystem()
        {
            SetCanvas(null);

            if (m_CurrentAnimator == null)
            {
                m_CurrentAnimator = PrefabManager.InstantiateGameObject(PrefabManager.ResourcePrefabs.toast, transform).GetComponent <ToastAnimator>();
            }

            m_ToastQueue = new Queue <KeyValuePair <Toast, Canvas> >();
        }
Пример #2
0
        protected internal static bool OnToastCompleted(Toast toast, ToastAnimator toastAnimator)
        {
            var isCustomToast = toast == null || toast.IsCustomToast();
            var finalize      = isCustomToast || Instance.m_ToastQueue.Count <= 0;

            //Force Destory Custom Toasts
            if (toastAnimator != null && !toastAnimator.CanDestroyToast && isCustomToast)
            {
                toastAnimator.CanDestroyToast = true;
            }

            Instance.m_CurrentToast = null;
            Instance.StartQueue();

            return(finalize);
        }
Пример #3
0
        private KeyValuePair <string, ToastAnimator> InstantiateAnimator_Internal(string assetPath, PrefabAddress defaultAdress, Transform parent)
        {
            if (string.IsNullOrEmpty(assetPath))
            {
                assetPath = defaultAdress != null ? defaultAdress.Name : null;
            }

            ToastAnimator currentAnimator = null;

            _AnimatorsCache.TryGetValue(assetPath, out currentAnimator);
            if (currentAnimator == null)
            {
                var Instance = PrefabManager.InstantiateGameObject(assetPath, transform);
                if (Instance == null)
                {
                    Instance = PrefabManager.InstantiateGameObject(defaultAdress != null ? defaultAdress.Name : null, transform);
                }

                currentAnimator = Instance.GetComponent <ToastAnimator>();

                if (!string.IsNullOrEmpty(assetPath))
                {
                    _AnimatorsCache[assetPath] = currentAnimator;
                }
            }

            if (currentAnimator != null)
            {
                currentAnimator.transform.SetParent(parent);
                currentAnimator.transform.localScale    = Vector3.one;
                currentAnimator.transform.localRotation = Quaternion.identity;
                currentAnimator.transform.SetAsLastSibling();
            }

            return(new KeyValuePair <string, ToastAnimator>(assetPath, currentAnimator));
        }