private void ApplyToggleFormattingOptions( GameObject widget, ButtonFormattingOptions options) { Color bgColor; Color checkColor; switch (ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask)) { case ButtonFormattingOptions.ThemeType_SystemWidget: bgColor = InternalButtonNormalBG; checkColor = InternalButtonNormalText; break; case ButtonFormattingOptions.ThemeType_KeyInput: bgColor = InternalButtonInvertedBG; checkColor = InternalButtonInvertedText; break; case ButtonFormattingOptions.ThemeType_ListInput: bgColor = InternalButtonSpecialBG; checkColor = InternalButtonSpecialText; break; default: Debug.LogError($"Unrecognized ThemeType: {(int)ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask)}"); goto case ButtonFormattingOptions.ThemeType_SystemWidget; } Toggle toggle = widget.GetComponent <Toggle>(); toggle.targetGraphic.color = bgColor; toggle.graphic.color = checkColor; }
public GameObject CreateToggleWidget( GameObject parent = null, bool value = false, ButtonFormattingOptions formattingOptions = ButtonFormattingOptions.None, UnityEngine.Events.UnityAction <bool> onValueChanged = null, ContainerConfig configOverride = ContainerConfig.Submissive, int index = -1, int slots = -1) { GameObject toggleWidget = GameObject.Instantiate(optionTogglePrefab); //Attach to parent and load up appropriate configurations CoupleToParent( widget: toggleWidget, parent: parent, index: index, slots: slots, config: configOverride); //Apply specific widget options ApplyToggleFormattingOptions(toggleWidget, formattingOptions); Toggle toggle = toggleWidget.GetComponent <Toggle>(); if (onValueChanged != null) { toggle.onValueChanged.AddListener(onValueChanged); } toggle.isOn = value; return(toggleWidget); }
public GameObject UpdateWidgetFormattingOptions( GameObject widget, ButtonFormattingOptions formattingOptions) { ApplyButtonFormattingOptions(widget, formattingOptions); return(widget); }
public GameObject CreateButtonWidget( GameObject parent = null, IConvertible text = null, UnityEngine.Events.UnityAction onClick = null, ButtonFormattingOptions buttonOptions = ButtonFormattingOptions.None, ContainerConfig configOverride = ContainerConfig.Submissive, int index = -1, int slots = -1) { GameObject buttonWidget = GameObject.Instantiate(optionButtonPrefab); //Attach to parent and load up appropriate configurations CoupleToParent( widget: buttonWidget, parent: parent, index: index, slots: slots, config: configOverride); //Apply specific widget options ApplyButtonFormattingOptions(buttonWidget, buttonOptions); Button button = buttonWidget.GetComponent <Button>(); if (onClick != null) { button.onClick.AddListener(onClick); } if (text == null) { text = ""; } Text textElement = buttonWidget.GetComponentInChildren <Text>(); textElement.text = text.ToString(); return(buttonWidget); }
private void ApplyButtonFormattingOptions( GameObject widget, ButtonFormattingOptions options) { Color bgColor; Color textColor; switch (ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask)) { case ButtonFormattingOptions.ThemeType_SystemWidget: bgColor = InternalButtonNormalBG; textColor = InternalButtonNormalText; break; case ButtonFormattingOptions.ThemeType_KeyInput: bgColor = InternalButtonInvertedBG; textColor = InternalButtonInvertedText; break; case ButtonFormattingOptions.ThemeType_DeleteButton: bgColor = DeleteButtonBG; textColor = DeleteButtonText; break; case ButtonFormattingOptions.ThemeType_ListInput: bgColor = InternalButtonSpecialBG; textColor = InternalButtonSpecialText; break; default: Debug.LogError($"Unrecognized ThemeType: {(int)ApplyMask(options, ButtonFormattingOptions.ThemeType_Mask)}"); goto case ButtonFormattingOptions.ThemeType_SystemWidget; } widget.GetComponent <Image>().color = bgColor; widget.GetComponentInChildren <Text>().color = textColor; }
private static int GetMaskedFlagValue(ButtonFormattingOptions config, ButtonFormattingOptions mask, ButtonFormattingOptions firstBit) { return((int)(config & mask) / (int)firstBit); }
public static ButtonFormattingOptions ApplyMask(ButtonFormattingOptions config, ButtonFormattingOptions mask) { return(config & mask); }
//ButtonFormattingOptions private static bool CheckFlag(ButtonFormattingOptions options, ButtonFormattingOptions flag) { return((options & flag) == flag); }