Exemplo n.º 1
0
        /// <summary>
        /// Show simple loading indicator and return loading id.
        /// </summary>
        /// <param name="timeOut">-1: forever loading</param>
        public int ShowSimple(float timeOut = -1, Action timeOutCallback = null)
        {
            if (mLoadingType != ELoadingType.Simple)
            {
                mListSimpleID.Clear();
            }
            mLoadingType = ELoadingType.Simple;

            if (mGameObject != null)
            {
                int loadingID = ++mCountSimple;
                mListSimpleID.Add(loadingID);

                _Show();

                if (timeOut > 0)
                {
                    string coroutineKey = typeof(MyUGUILoadingIndicator).Name + "_HideSimple" + loadingID;
                    MyCoroutiner.Start(coroutineKey, _DoHideSimple(loadingID, timeOut, timeOutCallback));
                }

                return(loadingID);
            }

            return(-1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Hide simple loading indicator by loading id.
        /// </summary>
        /// <param name="minLiveTime">minimum seconds have to show before hiding</param>
        public void HideSimple(int loadingID, float minLiveTime = 0)
        {
            if (mGameObject != null)
            {
                if (!mListSimpleID.Contains(loadingID))
                {
                    return;
                }

                string coroutineKey = typeof(MyUGUILoadingIndicator).Name + "_HideSimple" + loadingID;
                MyCoroutiner.Stop(coroutineKey);

                if (minLiveTime > 0)
                {
                    float displayedTime = Time.time - mStartingTime;
                    if (displayedTime < minLiveTime)
                    {
                        float delayTime = minLiveTime - displayedTime;
                        MyCoroutiner.Start(coroutineKey, _DoHideSimple(loadingID, delayTime));
                        return;
                    }
                }

                mListSimpleID.Remove(loadingID);
                mListSimpleID.ToString();
                if (mListSimpleID.Count == 0)
                {
                    _Hide();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Show tips loading indicator.
        /// </summary>
        /// <param name="isThreeDots">show three dots effect for description</param>
        /// <param name="timeOut">-1: forever loading</param>
        public void ShowTips(string tips, string description, bool isThreeDots, float timeOut = -1, Action timeOutCallback = null, Action cancelCallback = null)
        {
            if (mLoadingType != ELoadingType.Tips)
            {
                mListSimpleID.Clear();
            }
            mLoadingType = ELoadingType.Tips;

            if (mGameObject != null)
            {
                if (mTips != null)
                {
                    mTips.text = tips;
                }

                if (mDescription != null)
                {
                    mDescription.text = description;
                }

                _Show();

                if (isThreeDots && mDescription != null)
                {
                    string[] descriptions = new string[] { description + ".", description + "..", description + "..." };
                    MyCoroutiner.Start(_DoChangeDescription(descriptions, 0.2f));
                }

                if (timeOut > 0)
                {
                    string coroutineKey = typeof(MyUGUILoadingIndicator).Name + "_HideTips";
                    MyCoroutiner.Start(coroutineKey, _DoHideTips(timeOut, timeOutCallback));
                }
            }
        }
        /// <summary>
        /// OnPointerUp.
        /// </summary>
        void IPointerUpHandler.OnPointerUp(PointerEventData eventData)
        {
            mPointerEventDataPress = null;

            if (mOnEventPointerUp != null)
            {
                mOnEventPointerUp.Invoke(eventData);
            }

            if (mPressAnimationType == EAnimationType.Scale)
            {
                MyCoroutiner.Stop(DO_PRESS_SCALE_DOWN_ANIMATION + mId);
                MyCoroutiner.Start(DO_PRESS_SCALE_UP_ANIMATION + mId, _DoPressScaleUpAnimation(() =>
                {
                    mIsPressAnimationScaleCompleted = true;
                    if (mClickAnimationType == EAnimationType.None)
                    {
                        if (mOnEventPointerClick != null && mPointerEventDataClick != null)
                        {
                            mPointerEventDataClick.pointerPress = gameObject;
                            mOnEventPointerClick.Invoke(mPointerEventDataClick);
                            mPointerEventDataClick = null;
                        }
                    }
                }));
            }
        }
        /// <summary>
        /// Turn on fading.
        /// </summary>
        public void TurnOnFading()
        {
            string key = typeof(MyUGUISceneFading).Name + "_HandleFading";

            MyCoroutiner.Stop(key);
            MyCoroutiner.Start(key, _DoFading());
        }
        /// <summary>
        /// OnPointerDown.
        /// </summary>
        void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
        {
            mPointerEventDataPress          = eventData;
            mPointerEventDataClick          = null;
            mIsPressAnimationScaleCompleted = false;

            if (mOnEventPointerDown != null)
            {
                mOnEventPointerDown.Invoke(eventData);
            }

            if (mPressAnimationType == EAnimationType.Scale)
            {
                mId = MyLocalTime.CurrentUnixTime;
                MyCoroutiner.Start(DO_PRESS_SCALE_DOWN_ANIMATION + mId, _DoPressScaleDownAnimation());
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Hide loading indicator.
        /// </summary>
        /// <param name="minLiveTime">minimum seconds have to show before hiding</param>
        public void Hide(float minLiveTime = 0)
        {
            if (mGameObject != null)
            {
                if (minLiveTime > 0)
                {
                    float displayedTime = Time.time - mStartingTime;
                    if (displayedTime < minLiveTime)
                    {
                        float  delayTime    = minLiveTime - displayedTime;
                        string coroutineKey = typeof(MyUGUILoadingIndicator).Name + "_Hide";
                        MyCoroutiner.Stop(coroutineKey);
                        MyCoroutiner.Start(coroutineKey, _DoHide(delayTime));
                        return;
                    }
                }

                _Hide();
            }
        }
        /// <summary>
        /// Process OnPointerClick event.
        /// </summary>
        private void _ProcessPointerClickEvent()
        {
            Button.OnSubmit(mPointerEventDataClick);

            switch (mClickAnimationType)
            {
            case EAnimationType.Scale:
            {
                if (!mIsTriggerClickEventAfterAnimationComplete)
                {
                    if (mOnEventPointerClick != null && mPointerEventDataClick != null)
                    {
                        mOnEventPointerClick.Invoke(mPointerEventDataClick);
                    }
                    mPointerEventDataClick = null;
                }

                MyCoroutiner.Start(DO_CLICK_SCALE_ANIMATION, _DoClickScaleAnimation(() =>
                    {
                        if (mIsTriggerClickEventAfterAnimationComplete)
                        {
                            if (mOnEventPointerClick != null && mPointerEventDataClick != null)
                            {
                                mOnEventPointerClick.Invoke(mPointerEventDataClick);
                            }
                        }
                        mPointerEventDataClick = null;
                    }));
            }
            break;

            default:
            {
                if (mPressAnimationType == EAnimationType.None || !mIsTriggerClickEventAfterAnimationComplete || mIsPressAnimationScaleCompleted)
                {
                    if (mOnEventPointerClick != null && mPointerEventDataClick != null)
                    {
                        mOnEventPointerClick.Invoke(mPointerEventDataClick);
                    }
                    mPointerEventDataClick = null;
                }
            }
            break;
            }

            switch (mClickSoundType)
            {
            case ESoundType.ResourcesPath:
            {
                if (!string.IsNullOrEmpty(mClickSoundResourcePath))
                {
                    MySoundManager.Instance.PlaySFX(mClickSoundResourcePath, mClickSoundDelayTime, mClickSoundLocalVolume);
                }
            }
            break;

            case ESoundType.AudioClip:
            {
                if (mClickSoundAudioClip != null)
                {
                    MySoundManager.Instance.PlaySFX(mClickSoundAudioClip, mClickSoundDelayTime, mClickSoundLocalVolume);
                }
            }
            break;
            }

            if (mPressAnimationExtraTouchZone != null)
            {
                mPressAnimationExtraTouchZone.gameObject.SetActive(false);
            }
        }