protected virtual MaterialSpinnerActivity CreateSpinnerActivity(MaterialFrame frame)
        {
            if (frame == null)
            {
                return(null);
            }

            MaterialSpinnerActivity activity = new GameObject(frame.name + " (SpinnerActivity)").AddComponent <MaterialSpinnerActivity>();

            //Setup Has Background
            MaterialDialogCompat dialogFrame = frame as MaterialDialogCompat;

            if (dialogFrame != null)
            {
                activity.hasBackground = dialogFrame.hasBackground;
            }

            if (DialogManager.rectTransform != null)
            {
                activity.Build(DialogManager.rectTransform);
            }
            else
            {
                activity.Build(this.transform.GetRootCanvas());
            }

            activity.SetFrame(frame, this);

            return(activity);
        }
        public static DialogAnimatorSlide AddOrSetupDialogAnimatorSlide(MaterialDialogCompat materialDialog, float animationDuration = 0.5f)
        {
            var animator = GetOrAddTypedDialogAnimator <DialogAnimatorSlide>(materialDialog);

            if (animator != null)
            {
                animator.m_AnimationDuration = animationDuration;
            }

            return(animator);
        }
        public static DialogAnimatorSlide AddOrSetupDialogAnimatorSlide(MaterialDialogCompat materialDialog, float animationDuration, SlideDirection slideInDirection, SlideDirection slideOutDirection)
        {
            var animator = GetOrAddTypedDialogAnimator <DialogAnimatorSlide>(materialDialog);

            if (animator != null)
            {
                animator.m_AnimationDuration = animationDuration;
                animator.m_SlideInDirection  = slideInDirection;
                animator.m_SlideOutDirection = slideOutDirection;
            }

            return(animator);
        }
        public static DialogAnimatorSlide AddOrSetupDialogAnimatorSlide(MaterialDialogCompat materialDialog, float animationDuration, SlideDirection slideInDirection, SlideDirection slideOutDirection, Tween.TweenType slideInTweenType, Tween.TweenType slideOutTweenType)
        {
            var animator = GetOrAddTypedDialogAnimator <DialogAnimatorSlide>(materialDialog);

            if (animator != null)
            {
                animator.m_AnimationDuration = animationDuration;
                animator.m_SlideInDirection  = slideInDirection;
                animator.m_SlideOutDirection = slideOutDirection;

                if (slideInTweenType == Tween.TweenType.Custom || slideOutTweenType == Tween.TweenType.Custom)
                {
                    Debug.LogWarning("Cannot set tween type to 'Custom'");
                }
                else
                {
                    animator.m_SlideInTweenType  = slideInTweenType;
                    animator.m_SlideOutTweenType = slideOutTweenType;
                }
            }

            return(animator);
        }
Example #5
0
        protected static TDialogAnimator GetOrAddTypedDialogAnimator <TDialogAnimator>(MaterialDialogCompat materialDialog) where TDialogAnimator : DialogAnimator
        {
            if (materialDialog != null)
            {
                if (!Application.isPlaying)
                {
                    return(materialDialog.GetComponent <TDialogAnimator>());
                }
                else
                {
                    TDialogAnimator dialogAnimator  = null;
                    var             currentAnimator = materialDialog.GetComponent <DialogAnimator>();
                    if (currentAnimator != null && !(currentAnimator is TDialogAnimator))
                    {
                        UnityEngine.Object.Destroy(currentAnimator);
                        currentAnimator = null;
                    }

                    dialogAnimator = currentAnimator as TDialogAnimator;
                    if (dialogAnimator == null)
                    {
                        dialogAnimator = materialDialog.gameObject.AddComponent <TDialogAnimator>();
                    }

                    return(dialogAnimator);
                }
            }
            return(null);
        }