public StyleModifier(GUIStyleName name, StyleType styleType, string value, GUIState state = GUIState.Normal) { this.name = name; this.styleType = styleType; this.state = state; this.stringValue = value; }
public void Set <T>(GUIStyleName styleName, T value, GUIState state = GUIState.Normal) { var nameState = new NameState { Name = styleName, State = state }; var dict = this.GetDict <T>(); dict[nameState] = value; }
public T Get <T>(GUIStyleName styleName) { var rule = this.GetRule <T>(styleName, this.currentState); if (rule == null) { return(GUIStyle.Default.Get <T>(styleName, this.currentState)); } return(rule.Value); }
public void Set <T>(GUIStyleName styleName, T value, GUIState state) { var rule = this.GetRule <T>(styleName, state); if (rule == null) { rule = new StyleRule <T>(styleName, value, state); this.AppendRule(rule); } else { rule.Value = value; } }
public StyleRule <T> GetRule <T>(GUIStyleName name) { var rule = this.rules.Find(i => { var r = i as StyleRule <T>; if (r != null && r.Name == name && r.State == this.currentState) { return(true); } return(false); }) as StyleRule <T>; return(rule); }
public T Get <T>(GUIStyleName styleName, GUIState state = GUIState.Normal) { T value; var nameState = new NameState { Name = styleName, State = state }; var dict = GetDict <T>(); //try get the style value of specified state if (dict.TryGetValue(nameState, out value)) { return(value); } if (state != GUIState.Normal) { //try to get the style value of Normal state if (dict.TryGetValue(new NameState { Name = styleName, State = GUIState.Normal }, out value)) { return(value); } } var defalutDict = Default.GetDict <T>(); //try to get a default value of specified state if (defalutDict.TryGetValue(nameState, out value)) { return(value); } if (state != GUIState.Normal) { // try to get a default value of Normal state if (defalutDict.TryGetValue(new NameState { Name = styleName, State = GUIState.Normal }, out value)) { return(value); } } Log.Warning("Cannot find the style<{0},{1}>", styleName.ToString(), state.ToString()); return(default(T));//still not found, get defalut value of that types //FIXME may we should throw an exception instead? }
public T Get <T>(GUIStyleName styleName, GUIState state = GUIState.Normal) { T value; var nameState = new NameState { Name = styleName, State = state }; var dict = this.GetDict <T>(); //try get the style value of specified state if (dict.TryGetValue(nameState, out value)) { return(value); } if (state != GUIState.Normal) { //try to get the style value of Normal state if (dict.TryGetValue(new NameState { Name = styleName, State = GUIState.Normal }, out value)) { return(value); } } var defalutDict = Default.GetDict <T>(); //try to get a default value of specified state if (defalutDict.TryGetValue(nameState, out value)) { return(value); } if (state != GUIState.Normal) { // try to get a default value of Normal state if (defalutDict.TryGetValue(new NameState { Name = styleName, State = GUIState.Normal }, out value)) { return(value); } } throw new InvalidOperationException($"Cannot find the style<{styleName},{state}>"); }
private void Set <T>(GUIStyleName styleName, T value) { this.s.Set <T>(styleName, value); }
public StyleRule(GUIStyleName name, T value, GUIState state) { this.Name = name; this.Value = value; this.State = state; }
public StyleRule(GUIStyleName name, T value) { this.Name = name; this.Value = value; this.State = GUIState.Normal; }
/// <summary> /// Push 1 style color to stack. /// </summary> /// <param name="name">style name, <see cref="GUIStyleName"/></param> /// <param name="color">color</param> /// <param name="state">which state will this style be apply to</param> public static void PushStyleColor(GUIStyleName name, Color color, GUIState state = GUIState.Normal) { var style = GUIStyle.Basic; style.Push(new StyleModifier(name, StyleType.Color, color, state)); }