예제 #1
0
 public bool InitWithDuration(float duration, float opacity, IColorAttrCatcher attrCatcher = null)
 {
     if (base.InitWithDuration(duration))
     {
         this.toOpacity   = opacity;
         this.attrCatcher = attrCatcher;
         return(true);
     }
     return(false);
 }
예제 #2
0
        public static FadeTo Create(float d, float opacity, IColorAttrCatcher attrCatcher = null)
        {
            FadeTo action = new FadeTo();

            if (action != null && action.InitWithDuration(d, opacity, attrCatcher))
            {
                return(action);
            }
            return(null);
        }
예제 #3
0
        public static FadeOut Create(float d, IColorAttrCatcher attrCatcher = null)
        {
            FadeOut action = new FadeOut();

            if (action != null && action.InitWithDuration(d, 0.0f, attrCatcher))
            {
                return(action);
            }
            return(null);
        }
예제 #4
0
        public static float GetOpacity(Transform target, IColorAttrCatcher attrCatcher = null)
        {
            float opacity = 1.0f;

            if (target != null)
            {
                if (attrCatcher == null)
                {
                    var      renderer = target.GetComponent <MeshRenderer>();
                    Material material = null;
                    if (renderer != null)
                    {
                        material = renderer.material;
                    }
                    if (material != null)
                    {
                        opacity = material.color.a * 255.0f;
                    }
                    else
                    {
                        Graphic graphic = target.GetComponent <Image>();
                        if (graphic == null)
                        {
                            graphic = target.GetComponent <Text>();
                        }
                        if (graphic != null)
                        {
                            opacity = graphic.color.a * 255.0f;
                        }
                    }
                }
                else
                {
                    var color = attrCatcher.GetColor(target);
                    opacity = color.a * 255.0f;
                }
            }
            return(opacity);
        }
예제 #5
0
        public static void SetOpacity(Transform target, float opacity, IColorAttrCatcher attrCatcher = null)
        {
            Color color;

            if (attrCatcher == null)
            {
                var      renderer = target.GetComponent <MeshRenderer>();
                Material material = null;
                if (renderer != null)
                {
                    material = renderer.material;
                }
                if (material != null)
                {
                    color          = material.color;
                    color.a        = opacity;
                    material.color = color;
                }
                else
                {
                    Graphic graphic = target.GetComponent <Image>();
                    if (graphic != null)
                    {
                        color         = graphic.color;
                        color.a       = opacity;
                        graphic.color = color;
                    }
                }
            }
            else
            {
                color   = attrCatcher.GetColor(target);
                color.a = opacity;
                attrCatcher.SetColor(target, color);
            }
        }