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); }
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)); } }
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); } } }
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; } }
public void Register(SkinComponent skinComponent) { if (skinComponents.Contains(skinComponent) == false) { skinComponents.Add(skinComponent); } ApplyTo(skinComponent); }
public override void ApplyTo(SkinComponent skinComponent) { var image = skinComponent.GetComponent <Image>(); if (color != null) { image.color = color.GetValue(); } if (sprite != null) { image.sprite = sprite; } }
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); }
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; }
void OnEnable() { targetComponent = (SkinComponent)target; managerProp = serializedObject.FindProperty("skinManager"); }
public void Unregister(SkinComponent skinComponent) { skinComponents.Remove(skinComponent); }
public override bool CanApplyTo(SkinComponent skinComponent) { return(skinComponent.GetComponent <Image>() != null); }
public abstract void ApplyTo(SkinComponent skinComponent);
public abstract bool CanApplyTo(SkinComponent skinComponent);