Example #1
0
 public void AfterCreate()
 {
     UIToolkits.FindComponents <UIEffectPlayer>(mUIObject.transform, mEffectPlayerList);
     foreach (UIEffectPlayer player in mEffectPlayerList)
     {
         player.CreateEffect();
     }
     UIToolkits.FindComponents <Collider>(mUIObject.transform, m_colliders);
 }
Example #2
0
    public override void CreateEffect()
    {
        if (bTweenPos)
        {
            float fromToValX = to.x - from.x;
            float fromToValY = to.y - from.y;

            Vector3 fromPos = new Vector3(transform.localPosition.x - fromToValX, transform.localPosition.y - fromToValY, transform.localPosition.z);
            Vector3 toPos   = transform.localPosition;

            //创建需要的特效
            if (mTweenPos == null)
            {
                mTweenPos = TweenPosition.Begin(transform.gameObject, duration, toPos);
            }

            mTweenPos.from     = fromPos;
            mTweenPos.to       = toPos;
            mTweenPos.duration = duration;

            m_fromY = mTweenPos.from.y;

            mTweenList.Add(mTweenPos);
        }

        if (bTweenScale)
        {
            Vector3 localScale = transform.localScale;
            //创建需要的特效
            if (mTweenScale == null)
            {
                mTweenScale = TweenScale.Begin(transform.gameObject, duration, endScale);
            }

            mTweenScale.value    = new Vector3(localScale.x * startScale.x, localScale.y * startScale.y, localScale.z * startScale.z);
            mTweenScale.from     = mTweenScale.value;
            mTweenScale.to       = new Vector3(localScale.x * endScale.x, localScale.y * endScale.y, localScale.z * endScale.z);
            mTweenScale.duration = duration;

            mTweenList.Add(mTweenScale);
        }

        if (bTweenAlpha)
        {
            if (GetComponent <UIPanel>() != null)            //若为 UIPanel, 添加AlphaTween到自己
            {
                AddEffectTo(gameObject);
            }
            else                                            // 否则,添加AlphaTween到所有自控件
            {
                List <UIWidget> list = new List <UIWidget>();
                UIToolkits.FindComponents <UIWidget>(transform, list);
                foreach (UIWidget widget in list)
                {
                    AddEffectTo(widget.gameObject);
                }
            }
        }

        if (IdleAnim != null)
        {
            m_animation = GetComponent <Animation>();
            if (m_animation == null)
            {
                m_animation = this.gameObject.AddComponent <Animation>();
                if (IdleAnim != null)
                {
                    m_animation.AddClip(IdleAnim, "IdelAnim");
                }
            }
        }
    }