Exemplo n.º 1
0
        private static void ApplyGraphicStyle <T>(GraphicStyleData style, UIReference <T> reference)
            where T : Graphic
        {
            reference.value.color    = style.color;
            reference.value.material = style.material;

            ApplyShadow(style, reference);
        }
Exemplo n.º 2
0
        private static void ApplyShadow <T>(GraphicStyleData style, UIReference <T> reference)
            where T : Graphic
        {
            var gameObject = reference.value.gameObject;

            switch (style.shadowType.resolvedValue)
            {
            case GraphicStyleData.ShadowType.None:
                if (reference.shadow)
                {
                    Destroy(reference.shadow);
                    reference.shadow = null;
                }

                break;

            case GraphicStyleData.ShadowType.Shadow:
                if (!reference.shadow || reference.shadow.GetType() != typeof(Shadow))
                {
                    Destroy(reference.shadow);
                    reference.shadow = gameObject.AddComponent <Shadow>();
                }

                break;

            case GraphicStyleData.ShadowType.Outline:
                if (!reference.shadow || reference.shadow.GetType() != typeof(Outline))
                {
                    Destroy(reference.shadow);
                    reference.shadow = gameObject.AddComponent <Outline>();
                }

                break;
            }

            if (!reference.shadow)
            {
                return;
            }

            // shadow marks layout as dirty on value update, don't update without changes
            if (reference.shadow.effectColor != style.shadowColor)
            {
                reference.shadow.effectColor = style.shadowColor;
            }

            if (reference.shadow.effectDistance != style.shadowDistance)
            {
                reference.shadow.effectDistance = style.shadowDistance;
            }

            if (reference.shadow.useGraphicAlpha != style.shadowUseGraphicAlpha)
            {
                reference.shadow.useGraphicAlpha = style.shadowUseGraphicAlpha;
            }
        }
Exemplo n.º 3
0
 public static void Apply(GraphicStyleData style, UIReference <Graphic> graphic) =>
 ApplyStyle(style, graphic, applyGraphic);