Пример #1
0
        public List <SkinModifier> GetAppliedModifiers(SkinComponent skinComponent)
        {
            List <SkinModifier> result = new List <SkinModifier>();

            if (currentSkin == null)
            {
                return(result);
            }

            var modifiers = currentSkin.GetModifiers();

            if (modifiers == null || modifiers.Length == 0)
            {
                return(result);
            }

            for (int i = 0; i < modifiers.Length; i++)
            {
                var modifier = modifiers[i];
                if (modifier == null)
                {
                    continue;
                }

                if (modifier.CanMatchSelector(skinComponent) && modifier.CanApplyTo(skinComponent))
                {
                    result.Add(modifier);
                }
            }

            return(result);
        }
Пример #2
0
        public virtual bool CanMatchSelector(SkinComponent skinComponent)
        {
            var otherSelectors = skinComponent.GetSelectors();

            if (otherSelectors == null || otherSelectors.Length == 0)
            {
                return(false);
            }

            if (selectors == null || selectors.Length == 0)
            {
                return(false);
            }

            switch (matchMethod)
            {
            case SelectorMatchMehod.Any:
                return(IsMatchAnySelector(otherSelectors));

            case SelectorMatchMehod.ExactlySame:
                return(IsMatchExactlySameSelector(otherSelectors));

            case SelectorMatchMehod.All:
            default:
                return(IsMatchAllSelector(otherSelectors));
            }
        }
Пример #3
0
        public void ApplyTo(SkinComponent skinComponent)
        {
            if (currentSkin == null)
            {
                return;
            }

            var modifiers = currentSkin.GetModifiers();

            if (modifiers == null || modifiers.Length == 0)
            {
                return;
            }

            for (int i = 0; i < modifiers.Length; i++)
            {
                var modifier = modifiers[i];

                if (modifier == null)
                {
                    continue;
                }

                if (modifier.CanMatchSelector(skinComponent) && modifier.CanApplyTo(skinComponent))
                {
                    modifier.ApplyTo(skinComponent);
                }
            }
        }
Пример #4
0
        public override void ApplyTo(SkinComponent skinComponent)
        {
            var button = skinComponent.GetComponent <Button>();

            button.colors = colors.GetValue();

            var text = skinComponent.GetComponentInChildren <Text>();

            if (text != null)
            {
                if (fontSize != null)
                {
                    text.fontSize = (int)fontSize.GetValue();
                }

                if (fontColor != null)
                {
                    text.color = fontColor.GetValue();
                }

                if (font != null)
                {
                    text.font = font;
                }

                text.fontStyle = fontStyle;
            }
        }
Пример #5
0
        public void Register(SkinComponent skinComponent)
        {
            if (skinComponents.Contains(skinComponent) == false)
            {
                skinComponents.Add(skinComponent);
            }

            ApplyTo(skinComponent);
        }
Пример #6
0
        public override void ApplyTo(SkinComponent skinComponent)
        {
            var image = skinComponent.GetComponent <Image>();

            if (color != null)
            {
                image.color = color.GetValue();
            }

            if (sprite != null)
            {
                image.sprite = sprite;
            }
        }
Пример #7
0
        public List <string> GetPossibleSelectors(SkinComponent skinComponent)
        {
            List <string> result = new List <string>();

            if (currentSkin == null)
            {
                return(result);
            }

            var modifiers = currentSkin.GetModifiers();

            if (modifiers == null)
            {
                return(result);
            }

            for (int i = 0; i < modifiers.Length; i++)
            {
                var modifier = modifiers[i];
                if (modifier == null)
                {
                    continue;
                }

                if (modifier.CanApplyTo(skinComponent))
                {
                    var selectors = modifier.GetSelectors();
                    if (selectors == null)
                    {
                        continue;
                    }

                    foreach (var selector in selectors)
                    {
                        if (selector != null && result.Contains(selector) == false)
                        {
                            result.Add(selector);
                        }
                    }
                }
            }


            return(result);
        }
Пример #8
0
        public override void ApplyTo(SkinComponent skinComponent)
        {
            var textComponent = skinComponent.GetComponent <Text>();

            if (fontSize != null)
            {
                textComponent.fontSize = (int)fontSize.GetValue();
            }

            if (color != null)
            {
                textComponent.color = color.GetValue();
            }

            if (font != null)
            {
                textComponent.font = font;
            }

            textComponent.fontStyle = fontStyle;
        }
Пример #9
0
 void OnEnable()
 {
     targetComponent = (SkinComponent)target;
     managerProp     = serializedObject.FindProperty("skinManager");
 }
Пример #10
0
 public void Unregister(SkinComponent skinComponent)
 {
     skinComponents.Remove(skinComponent);
 }
Пример #11
0
 public override bool CanApplyTo(SkinComponent skinComponent)
 {
     return(skinComponent.GetComponent <Image>() != null);
 }
Пример #12
0
 public abstract void ApplyTo(SkinComponent skinComponent);
Пример #13
0
 public abstract bool CanApplyTo(SkinComponent skinComponent);