Ejemplo n.º 1
0
    static AbstractGoTween alphaTween(this GameObject self, bool directionTo, float duration, float endValue, GoEaseType easeType, float delay)
    {
        List <GameObject> all = self.GetChilds(GetChildOption.FullHierarchy);

        all.Add(self);
        AbstractGoTween tween  = null;
        GoTweenFlow     tweens = null;

        foreach (var v in all)
        {
            Renderer r = v.GetComponent <Renderer>();
            if (r != null)
            {
                Material m = r.material;
                if (m != null)
                {
                    if (tween != null)
                    {
                        if (tweens == null)
                        {
                            tweens = new GoTweenFlow();
                            tweens.insert(0, tween);
                        }
                    }

                    if (directionTo)
                    {
                        tween = m.alphaTo(duration, endValue).eases(easeType);
                    }
                    else
                    {
                        tween = m.alphaFrom(duration, endValue).eases(easeType);
                    }

                    if (tweens != null)
                    {
                        tweens.insert(0, tween);
                    }
                }
            }
        }

        if (tweens != null)
        {
            tweens.delays(delay);
            Go.addTween(tweens);
            return(tweens);
        }
        else
        {
            if (tween != null)
            {
                tween.delays(delay);
            }
            return(tween);
        }
    }