// protected Color32 SetColorAlpha (Color32 c, byte newAlpha) { // c.a = newAlpha; // return c; // } // TODO: use canvas group // public virtual void SetAlphaMultiplier (float multiplier) { // MainGraphic().color = SetColorAlpha(MainGraphic().color, (byte)(GetUIColor( colorScheme, useDark ).a * multiplier)); // if (useOutline) outline.effectColor = SetColorAlpha(outline.effectColor, (byte)(GetUIColor( colorScheme, !useDark ).a * multiplier)); // if (useShadow) shadow.effectColor = SetColorAlpha(shadow.effectColor, (byte)(settings.shadowEffectColor.a * multiplier)); // } public void SetColorScheme(UIColorScheme colorScheme, bool useDark) //, bool updateLayout) { { this.useDark = useDark; this.colorScheme = colorScheme; // if (updateLayout) UpdateElementLayout(); _UpdateColors(); }
void TextManager() { indexer = 0; var texts = FindObjectsOfType <Text>(); UIColorScheme scheme = DefaultColorSchemes[2]; Undo.RecordObjects(texts, "Texts"); foreach (Text text in texts) { foreach (UIColorScheme customColorScheme in CustomColorSchemes) { if (text.tag == customColorScheme.tagName || text.tag == NotChangingTag) { return; } } EditorUtility.SetDirty(text.gameObject); if (!text.transform.parent.GetComponent <Button>()) { text.color = scheme.normalColor; Outline tOutline = text.GetComponent <Outline>(); indexer++; if (tOutline) { Undo.RecordObject(tOutline, "ttOutline" + indexer); EditorUtility.SetDirty(tOutline); tOutline.effectColor = scheme.normalColor; tOutline.effectDistance = new Vector2(scheme.outlineSize, -scheme.outlineSize); } } } indexer = 0; }
UIColorScheme loadScheme(string name, bool isDefault) { if (!string.IsNullOrEmpty(PlayerPrefs.GetString(name))) { string loadedTagNameName = name + " tag name"; string loadedNormalColorName = name + " normal color"; string loadedOutlineColorName = name + " outline color"; string loadedOutlineSizeName = name + " outline size"; string loadedTagName = PlayerPrefs.GetString(loadedTagNameName); float loadedOutlineSize = PlayerPrefs.GetFloat(loadedOutlineSizeName); Color loadedOutlineColor = RetrieveColor(loadedOutlineColorName); Color loadeNormalColor = RetrieveColor(loadedNormalColorName); UIColorScheme colorScheme = new UIColorScheme(name, loadeNormalColor, loadedOutlineColor, loadedOutlineSize, loadedTagName); return(colorScheme); } else { Debug.Log("x"); UIColorScheme colorScheme = new UIColorScheme(name, Color.gray, Color.gray, 2, name); if (isDefault) { colorScheme.tagName = ""; } return(colorScheme); } }
void SchemeByTag(string newTag, string scheme) { foreach (string customColorSettingsName in CustomColorSettingsNames) { if (customColorSettingsName == scheme) { Debug.LogWarning("Please use an different scheme name."); return; } } if (string.IsNullOrEmpty(newTag)) { Debug.LogWarning("Please assign an valid tag."); return; } if (string.IsNullOrEmpty(scheme)) { Debug.LogWarning("Please assign an valid scheme name."); return; } UIColorScheme colorScheme = new UIColorScheme(scheme, Color.gray, Color.gray, 2, newTag); CustomColorSchemes.Add(colorScheme); CustomColorSettingsNames.Add(scheme); SceneView.RepaintAll(); EditorSceneManager.MarkAllScenesDirty(); GUILayout.EndHorizontal(); }
public void ShowMessageImmediate(string message, UIColorScheme scheme, bool bulleted) { if (onShowMessage != null) { onShowMessage(message); } UIMessageElement newMessage = elementPool.GetAvailable(settings.messageElement, null, false, null); shownElements.Add(newMessage); if (newMessage.transform.parent != transform) { newMessage.transform.SetParent(transform, Vector3.zero, Quaternion.identity, Vector3.one); } UpdateMessageLayout(newMessage, message, bulleted); newMessage.ShowMessage(parameters.duration, parameters.fadeInOut.x, parameters.fadeInOut.y, scheme); float pivotOffset = (1.0f - yPivot) * shownElements.Count * parameters.messageParams.messageHeight; // newMessage.rectTransform.anchoredPosition = new Vector2((rectTransform.anchorMin.x == 0 ? 0 : -newMessage.elementWidth) + parameters.startXOffset, - pivotOffset); newMessage.rectTransform.anchoredPosition = new Vector2(parameters.startXOffset, -pivotOffset); newMessage.gameObject.SetActive(true); }
protected static Color32 GetUIColor(UIColorScheme schemeType, bool useDarker) { if (settings == null) { return(Color.magenta); } switch (schemeType) { // case UIColorScheme.Normal: return useDarker ? settings.mainDarkColor : settings.mainLightColor; // case UIColorScheme.Warning: return useDarker ? settings.warningDarkColor : settings.warningLightColor; // case UIColorScheme.Invalid: return useDarker ? settings.invalidDarkColor : settings.invalidLightColor; case UIColorScheme.Normal: return(useDarker ? UIManager.DarkenColor(Application.isPlaying ? UIManager.currentUIColor : settings.mainLightColor) : Application.isPlaying ? UIManager.currentUIColor : settings.mainLightColor); case UIColorScheme.Warning: return(useDarker ? UIManager.DarkenColor(settings.warningLightColor) : settings.warningLightColor); case UIColorScheme.Invalid: return(useDarker ? UIManager.DarkenColor(settings.invalidLightColor) : settings.invalidLightColor); case UIColorScheme.Black: return(settings.blackColor); case UIColorScheme.White: return(settings.whiteColor); } return(Color.magenta); }
public void SetColorScheme(UIColorScheme scheme) { switch (scheme) { case UIColorScheme.SkyBlue: this.lightColor = Color.WhiteSmoke; this.darkColor = Color.SteelBlue; break; case UIColorScheme.Dark: this.lightColor = Color.WhiteSmoke; this.darkColor = Color.SlateGray; break; case UIColorScheme.Grey: this.lightColor = Color.WhiteSmoke; this.darkColor = Color.Silver; break; case UIColorScheme.Colorful: this.lightColor = Color.LightYellow; this.darkColor = Color.OrangeRed; break; } SetBrush(); Invalidate(); }
void DeleteScheme(UIColorScheme scheme) { if (GUILayout.Button("Delete", GUILayout.Height(20))) { CustomColorSettingsNames.Remove(scheme.colorSchemeName); CustomColorSchemes.Remove(scheme); } }
public void ShowMessage(int messageIndex, string message, bool immediate, UIColorScheme scheme, bool bulleted) { if (shownMsgs.Count >= maxShownMessages) { messagesQ.Enqueue(message); } else { shownMsgs.Add(message); } }
public void ShowMessage(string message, bool immediate, UIColorScheme scheme, bool bulleted) { if (immediate || (messageQ.Count == 0 && shownElements.Count == 0)) { ShowMessageImmediate(message, scheme, bulleted); } else { messageQ.Enqueue(message); schemesQ.Enqueue(scheme); bulletedQ.Enqueue(bulleted); } }
void drawOnGUI(UIColorScheme scheme) { if (!scheme.isTag || scheme.tagName == DefaultColorSettingsNames[0] || scheme.tagName == DefaultColorSettingsNames[1] || scheme.tagName == DefaultColorSettingsNames[2]) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(scheme.colorSchemeName, GUILayout.Height(20), GUILayout.MaxWidth(100), GUILayout.MinWidth(50)); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Color:", GUILayout.Height(20), GUILayout.MaxWidth(50)); scheme.normalColor = EditorGUILayout.ColorField(scheme.normalColor, GUILayout.Height(20), GUILayout.MaxWidth(100)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Outline Color :", GUILayout.Height(20), GUILayout.MaxWidth(100)); scheme.outlineColor = EditorGUILayout.ColorField(scheme.outlineColor, GUILayout.Height(20), GUILayout.MaxWidth(100)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Outline Size :", GUILayout.Height(20), GUILayout.MaxWidth(100)); scheme.outlineSize = EditorGUILayout.FloatField(scheme.outlineSize, GUILayout.Height(20), GUILayout.MaxWidth(50)); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(scheme.colorSchemeName, GUILayout.Height(20), GUILayout.MaxWidth(100), GUILayout.MinWidth(50)); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Color:", GUILayout.Height(20), GUILayout.MaxWidth(50)); scheme.normalColor = EditorGUILayout.ColorField(scheme.normalColor, GUILayout.Height(20), GUILayout.MaxWidth(100)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Tag :", GUILayout.Height(20), GUILayout.MaxWidth(50)); scheme.tagName = EditorGUILayout.TagField(scheme.tagName, GUILayout.Height(20), GUILayout.MaxWidth(200)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Outline Color :", GUILayout.Height(20), GUILayout.MaxWidth(100)); scheme.outlineColor = EditorGUILayout.ColorField(scheme.outlineColor, GUILayout.Height(20), GUILayout.MaxWidth(100)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Outline Size :", GUILayout.Height(20), GUILayout.MaxWidth(100)); scheme.outlineSize = EditorGUILayout.FloatField(scheme.outlineSize, GUILayout.Height(20), GUILayout.MaxWidth(50)); EditorGUILayout.Space(); DeleteScheme(scheme); GUILayout.EndHorizontal(); } }
public void ShowMessage(float duration, float fadeIn, float fadeOut, UIColorScheme scheme) { alpha = 0; timer = 0; inExit = false; this.duration = duration; this.fadeIn = fadeIn; this.fadeOut = fadeOut; for (int i = 0; i < graphics.Length; i++) { graphics[i].SetColorScheme(scheme, graphics[i].useDark); } canvasGroup.alpha = alpha; }
void saveScheme(UIColorScheme scheme) { if (scheme != null) { string name = scheme.colorSchemeName; string loadedTagNameName = name + " tag name"; string loadedNormalColorName = name + " normal color"; string loadedOutlineColorName = name + " outline color"; string loadedOutlineSizeName = name + " outline size"; PlayerPrefs.SetString(loadedTagNameName, scheme.tagName); PlayerPrefs.SetFloat(loadedOutlineSizeName, scheme.outlineSize); PlayerPrefs.SetString(name, name); SaveColor(scheme.outlineColor, loadedOutlineColorName); SaveColor(scheme.normalColor, loadedNormalColorName); } }
void PanelManager(UIColorScheme scheme) { indexer = 0; var panels = GameObject.FindGameObjectsWithTag(scheme.tagName); if (panels.Length > 0) { foreach (GameObject gObject in panels) { EditorUtility.SetDirty(gObject); Outline outline; Image myIm = gObject.GetComponent <Image>(); if (myIm == null) { Text myTx = gObject.GetComponent <Text>(); Undo.RecordObject(myTx, "TXT" + scheme.tagName + indexer); EditorUtility.SetDirty(myTx); myTx.color = scheme.normalColor; outline = myTx.GetComponent <Outline>(); } else { Undo.RecordObject(myIm, "Image" + scheme.tagName + indexer); EditorUtility.SetDirty(myIm); myIm.color = scheme.normalColor; outline = myIm.GetComponent <Outline>(); } if (outline) { Undo.RecordObject(outline, "Outline" + scheme.tagName + indexer); EditorUtility.SetDirty(outline); outline.effectColor = scheme.outlineColor; outline.effectDistance = new Vector2(scheme.outlineSize, -scheme.outlineSize); } indexer++; } indexer = 0; } }
void UpdateUIObject(float delta, float newValue, float min, float max) { if (onGameValueChange != null) { onGameValueChange(delta, newValue, min, max); } UIColorScheme scheme = UIColorScheme.Normal; for (int i = 0; i < colorSchemeThresholds.Length; i++) { if (newValue <= colorSchemeThresholds[i]) { scheme = i == 0 ? UIColorScheme.Invalid : UIColorScheme.Warning; break; } } if (uiObject != null) { uiObject.SetValue(Mathf.InverseLerp(min, max, newValue), scheme); } }
public void SetColorScheme(UIColorScheme colorScheme, UIColorScheme backgroundColorScheme) { this.colorScheme = colorScheme; this.backgroundColorScheme = backgroundColorScheme; UpdateElementLayout();//false); }
// public override void OnComponentClose() { // // base.OnComponentClose(); // for (int i = 0; i < allImages.Length; i++) // allImages[i].OnComponentClose(); // } public void SetIconColorScheme(UIColorScheme scheme) { iconImage.SetColorScheme(scheme, false); }
public static void ShowGameMessage(string message, bool immediate, UIColorScheme scheme, bool bulleted) { messages.ShowMessage(message, immediate, scheme, bulleted); }
public static void ShowObjectivesMessage(string message, bool immediate, UIColorScheme scheme, bool bulleted) { objectiveMessages.ShowMessage(message, immediate, scheme, bulleted); }
void ButtonManager() { UIColorScheme buttonScheme = DefaultColorSchemes[0]; UIColorScheme buttonTextScheme = DefaultColorSchemes[1]; var buttons = FindObjectsOfType <Button>(); Undo.RecordObjects(buttons, "Button"); indexer = 0; ColorBlock cb = ColorBlock.defaultColorBlock; cb.normalColor = buttonScheme.normalColor; cb.highlightedColor = new Color(buttonScheme.normalColor.r + 0.2f, buttonScheme.normalColor.g + 0.2f, buttonScheme.normalColor.b + 0.2f); cb.pressedColor = new Color(buttonScheme.normalColor.r - 0.3f, buttonScheme.normalColor.g - 0.3f, buttonScheme.normalColor.b - 0.3f); cb.disabledColor = new Color(buttonScheme.normalColor.r - 0.3f, buttonScheme.normalColor.g - 0.3f, buttonScheme.normalColor.b - 0.3f, 0.3f); foreach (Button button in buttons) { bool isEqualToTag = false; foreach (UIColorScheme customColorScheme in CustomColorSchemes) { if (button.tag == customColorScheme.tagName || button.tag == NotChangingTag) { isEqualToTag = true; } } if (isEqualToTag == false) { EditorUtility.SetDirty(button.gameObject); button.colors = cb; Outline bOutline = button.GetComponent <Outline>(); if (bOutline) { Undo.RecordObject(bOutline, "bOutline" + indexer); EditorUtility.SetDirty(bOutline); bOutline.effectColor = buttonScheme.outlineColor; bOutline.effectDistance = new Vector2(buttonScheme.outlineSize, -buttonScheme.outlineSize); } } if (button.transform.childCount > 0) { GameObject text = button.transform.GetChild(0).gameObject; foreach (UIColorScheme customColorScheme in CustomColorSchemes) { if (text.tag == customColorScheme.tagName || text.tag == NotChangingTag) { return; } } Text txt = text.GetComponent <Text>(); Undo.RecordObject(txt, "Text" + indexer); indexer++; EditorUtility.SetDirty(txt); txt.color = buttonTextScheme.normalColor; Outline tOutline = text.GetComponent <Outline>(); if (tOutline) { Undo.RecordObject(tOutline, "tOutline" + indexer); EditorUtility.SetDirty(tOutline); tOutline.effectColor = buttonTextScheme.outlineColor; tOutline.effectDistance = new Vector2(buttonTextScheme.outlineSize, -buttonTextScheme.outlineSize); } } } indexer = 0; }
public static void ShowMessage(int messageIndex, string message, bool immediate, UIColorScheme scheme, bool bulleted) { if (!CheckInitialized()) { return; } handler.ShowMessage(messageIndex, message, immediate, scheme, bulleted); }
public void SetValue(float val, UIColorScheme scheme) { fillImage.mainGraphic.fillAmount = val; fillImage.SetColorScheme(scheme, false); // panel.SetColorScheme(scheme, scheme); }