Exemple #1
0
        /**
         * Hides the view with animations
         */
        void HideWithAnimations(System.Action cb)
        {
            //var imageBehindIcon_tf = this.imageBehindIcon.GetComponent<RectTransform> ();

            float fadeTextDur = 0.2f;

            UITween.startAlphaAnimation(textCaption, 1f, 0f, fadeTextDur, 0.25f, Tween.TweenTypes.easeInOutExpo, () => {
                textCaption.gameObject.SetActive(false);
            });

            //fadeTextOff += fadeTextDur / 2f;
            UITween.startAlphaAnimation(textDesc, 1f, 0f, fadeTextDur, 0.25f, Tween.TweenTypes.easeInOutExpo, () => {
                textDesc.gameObject.SetActive(false);
            });

            UITween.startAlphaAnimation(textPrice, 1f, 0f, fadeTextDur, 0.25f, Tween.TweenTypes.easeInOutExpo, () => {
            });


            UITween.startAlphaAnimation(buttonOkay.GetComponent <UnityEngine.UI.Graphic>(), 1f, 0f, fadeTextDur, 0f, Tween.TweenTypes.easeInOutExpo, () => {
                buttonOkay.gameObject.SetActive(false);
            });

            UITween.startAlphaAnimation(buttonCancel.gameObject, 1f, 0f, fadeTextDur, 0f, Tween.TweenTypes.easeInOutExpo, () => {
                buttonCancel.gameObject.SetActive(false);
            });

            //
            UITween.startScaleAnimation(this.imageBehindIcon, 1f, 0f, 0.5f, 0.4f + 0.0f, Tween.TweenTypes.easeOutBounce);
            UITween.startAlphaAnimation(this.imageBehindIcon, 1f, 0f, 0.25f, 0.4f + 0.25f, Tween.TweenTypes.easeInExpo, () => { });
            UITween.startScaleAnimation(this.backgroundImage, 1f, 0f, 0.5f, 0.0f, Tween.TweenTypes.easeInExpo, () => { });

            // Fade away the white background of the dialogue.
            UITween.StartAnimateValue(dialogBG, 1f, 0f, 0.5f, 0.5f, Tween.TweenTypes.Linear, () => {
                var c          = dialogBG.color;
                c.a            = 1.0f;
                dialogBG.color = c;
                dialogBG.SetAllDirty();
            }, ( float value) => {
                var c          = dialogBG.color;
                c.a            = value;
                dialogBG.color = c;
                dialogBG.SetAllDirty();
            }, () => {
                var c          = dialogBG.color;
                c.a            = 0f;
                dialogBG.color = c;
                dialogBG.SetAllDirty();
                cb();
            });
        }
Exemple #2
0
        /**
         * Shows the view by playing animations.
         */
        void ShowWithAnimations()
        {
            var imageBehindIcon_tf = this.imageBehindIcon.GetComponent <RectTransform> ();

            Vector3[] corners = new Vector3[4];
            imageBehindIcon_tf.GetLocalCorners(corners);
            var imageContainerSz = corners[2] - corners[0];

            float diffx = 0f;

            if (this.clickedIconContainerTF != null)
            {
                this.clickedIconContainerTF.GetLocalCorners(corners);
                var clickedContainerSz = corners[2] - corners[0];
                diffx = clickedContainerSz.x / (imageContainerSz.x > 0f ? imageContainerSz.x : 0.001f);
                //float diffy = clickedContainerSz.y / ( imageContainerSz.y > 0f ? imageContainerSz.y : 0.001f );
            }

            this.backgroundImage.GetComponent <RectTransform>().localScale = Vector2.zero;
            //Vector3 tmp_pos = this.imageBehindIcon.transform.localPosition;
            this.backgroundImage.transform.position = imageBehindIcon_tf.position;

            this.textCaption.gameObject.SetActive(false);
            this.textDesc.gameObject.SetActive(false);
            this.textPrice.gameObject.SetActive(false);
            //Debug.Break();
            this.buttonOkay.gameObject.SetActive(false);
            this.buttonCancel.gameObject.SetActive(false);


            UITween.StartAnimateValue(dialogBG, 0.0f, 1f, 0.5f, Tween.TweenTypes.Linear, () => {
                var c          = dialogBG.color;
                c.a            = 0.0f;
                dialogBG.color = c;
            }, ( float value) => {
                var c          = dialogBG.color;
                c.a            = value;
                dialogBG.color = c;
            }, () => {
                var c          = dialogBG.color;
                c.a            = 1f;
                dialogBG.color = c;
            });

            UITween.startAlphaAnimation(this.imageBehindIcon, 0f, 1f, 0.05f, 0f, Tween.TweenTypes.easeInExpo, () => { });
            UITween.startScaleAnimation(this.imageBehindIcon, diffx, 1f, 0.5f, 0f, Tween.TweenTypes.Linear);
            UITween.startScaleAnimation(this.backgroundImage, 0.0001f, 1f, 0.75f, 0.15f, Tween.TweenTypes.easeInExpo, () => {
                textCaption.gameObject.SetActive(true);
                UITween.startAlphaAnimation(textCaption, 0f, 1f, 0.5f, 0f, Tween.TweenTypes.easeInOutExpo);

                textDesc.gameObject.SetActive(true);
                UITween.startAlphaAnimation(textDesc, 0f, 1f, 0.5f, 0.2f, Tween.TweenTypes.easeInOutExpo);

                textPrice.gameObject.SetActive(true);
                UITween.startAlphaAnimation(textPrice, 0f, 1f, 0.5f, 0.4f, Tween.TweenTypes.easeInOutExpo);

                buttonOkay.gameObject.SetActive(true);
                UITween.startAlphaAnimation(buttonOkay.GetComponent <UnityEngine.UI.MobyShop.AdvImage>(), 0f, 1f, 0.5f, 0.6f, Tween.TweenTypes.easeInOutExpo);

                buttonCancel.gameObject.SetActive(true);
                UITween.startAlphaAnimation(buttonCancel.gameObject, 0f, 1f, 0.5f, 0.8f, Tween.TweenTypes.easeInOutExpo);
            });
            UITween.StartAnimateValue(dialogBG, 0.0f, 0f, 0.32f, Tween.TweenTypes.Linear, () => {
                this.backgroundImage.gameObject.AddMissingComponent <CanvasGroup>().alpha = 0f;
            }, ( float value) => {
                this.backgroundImage.gameObject.AddMissingComponent <CanvasGroup>().alpha = 0f;
            }, () => {
                this.backgroundImage.gameObject.AddMissingComponent <CanvasGroup>().alpha = 1f;
            });

            if (this.clickedIconContainerTF != null)
            {
                UITween.startBezierAnimation(this.imageBehindIcon, imageBehindIcon_tf, this.clickedIconContainerTF, iconPivot, 0.5f, () => {
                }, Tween.TweenTypes.easeOutExpo);
            }
            else
            {
                var img_tf = this.imageBehindIcon.GetComponent <RectTransform> ();
                UITween.startScaleAnimation(img_tf, 0f, 1f, 0.5f, Tween.TweenTypes.easeOutBounce, () => {
                });
            }
        }
        void HideWithAnimations(System.Action cb)
        {
            var imageBehindIcon_tf = this.imageBehindIcon.GetComponent <RectTransform> ();

            Vector3[] corners = new Vector3[4];
            imageBehindIcon_tf.GetLocalCorners(corners);
            //var imageContainerSz = corners[2] - corners[0];


            float fadeTextDur = 0.2f;
            float fadeTextOff = 0f;

            UITween.startAlphaAnimation(textCaption, 1f, 0f, fadeTextDur, fadeTextOff, Tween.TweenTypes.easeInOutExpo, () => {
                textCaption.gameObject.SetActive(false);
            });

            //fadeTextOff += fadeTextDur / 2f;
            UITween.startAlphaAnimation(textDesc, 1f, 0f, fadeTextDur, fadeTextOff, Tween.TweenTypes.easeInOutExpo, () => {
                textDesc.gameObject.SetActive(false);
            });

            //textPrice.gameObject.SetActive(true);
            //UITween.startAlphaAnimation( textPrice, 0f, 1f, fadeTextDur, 0.4f, Tween.TweenTypes.easeInOutExpo );

            //fadeTextOff += fadeTextDur / 2f;
            UITween.startAlphaAnimation(buttonOkay.GetComponent <UnityEngine.UI.Graphic>(), 1f, 0f, fadeTextDur, fadeTextOff, Tween.TweenTypes.easeInOutExpo, () => {
                buttonOkay.gameObject.SetActive(false);
            });

            //fadeTextOff += fadeTextDur / 2f;
            UITween.startAlphaAnimation(buttonCancel.gameObject, 1f, 0f, fadeTextDur, fadeTextOff, Tween.TweenTypes.easeInOutExpo, () => {
                buttonCancel.gameObject.SetActive(false);
            });


            fadeTextOff += fadeTextDur / 2f;


            //float scaleIconFrom = 0f;

            /*if (this.clickedIconContainerTF != null) {
             *      this.clickedIconContainerTF.GetLocalCorners (corners);
             *      var clickedContainerSz = corners[2] - corners[0];
             *      scaleIconFrom = clickedContainerSz.x / ( imageContainerSz.x > 0f ? imageContainerSz.x : 0.001f );
             *      float diffy = clickedContainerSz.y / ( imageContainerSz.y > 0f ? imageContainerSz.y : 0.001f );
             * }*/


            UITween.startScaleAnimation(this.imageBehindIcon, 1f, 0f, 0.5f, 0.4f + 0.0f, Tween.TweenTypes.easeOutBounce);
            UITween.startAlphaAnimation(this.imageBehindIcon, 1f, 0f, 0.25f, 0.4f + 0.25f, Tween.TweenTypes.easeInExpo, () => { });
            UITween.startScaleAnimation(this.backgroundImage, 1f, 0f, 0.5f, 0.0f, Tween.TweenTypes.easeInExpo, () => { });

            // Fade away the white background of the dialogue.
            UITween.StartAnimateValue(dialogBG, 1f, 0f, 0.5f, 0.5f, Tween.TweenTypes.Linear, () => {
                var c          = dialogBG.color;
                c.a            = 1.0f;
                dialogBG.color = c;
                dialogBG.SetAllDirty();
            }, ( float value) => {
                var c          = dialogBG.color;
                c.a            = value;
                dialogBG.color = c;
                dialogBG.SetAllDirty();
            }, () => {
                var c          = dialogBG.color;
                c.a            = 0f;
                dialogBG.color = c;
                dialogBG.SetAllDirty();
                cb();
            });
        }