public GameObject CreateTriggeredLabelWidget( GameObject parent = null, string text = "", TextItemFormattingOptions formattingOptions = TextItemFormattingOptions.None, TextAnchor alignment = TextAnchor.MiddleCenter, ContainerConfig configOverride = ContainerConfig.Submissive, int index = -1, int slots = -1) { GameObject labelWidget = GameObject.Instantiate(optionLabelPrefab); //Attach to parent and load up appropriate configurations CoupleToParent( widget: labelWidget, parent: parent, index: index, slots: slots, config: configOverride, configSupplement: ContainerConfig.Squeeze_Y_5); ApplyTextFormattingOptions(labelWidget, formattingOptions); labelWidget.GetComponent <Text>().text = text; labelWidget.GetComponent <Text>().alignment = alignment; labelWidget.GetComponent <Text>().raycastTarget = true; LabelSwapTrigger swapTrigger = labelWidget.AddComponent <LabelSwapTrigger>(); swapTrigger.OnDoubleClick += () => { Debug.Log("Double-clicked"); }; return(labelWidget); }
public GameObject CreateLabelWidget( GameObject parent = null, string text = "", TextItemFormattingOptions formattingOptions = TextItemFormattingOptions.None, TextAnchor alignment = TextAnchor.MiddleCenter, ContainerConfig configOverride = ContainerConfig.Submissive, int index = -1, int slots = -1) { GameObject labelWidget = GameObject.Instantiate(optionLabelPrefab); //Attach to parent and load up appropriate configurations CoupleToParent( widget: labelWidget, parent: parent, index: index, slots: slots, config: configOverride, configSupplement: ContainerConfig.Squeeze_Y_5); ApplyTextFormattingOptions(labelWidget, formattingOptions); labelWidget.GetComponent <Text>().text = text; labelWidget.GetComponent <Text>().alignment = alignment; return(labelWidget); }
private void ApplyTextFormattingOptions( GameObject widget, TextItemFormattingOptions options) { switch (ApplyMask(options, TextItemFormattingOptions.ThemeType_Mask)) { case TextItemFormattingOptions.ThemeType_SystemText: widget.GetComponent <Text>().color = InternalTextNormal; break; case TextItemFormattingOptions.ThemeType_InfoText: widget.GetComponent <Text>().color = InfoTextNormal; break; default: Debug.LogError($"Unrecognized ThemeType: {(int)ApplyMask(options, TextItemFormattingOptions.ThemeType_Mask)}"); break; } }
private static int GetMaskedFlagValue(TextItemFormattingOptions config, TextItemFormattingOptions mask, TextItemFormattingOptions firstBit) { return((int)(config & mask) / (int)firstBit); }
public static TextItemFormattingOptions ApplyMask(TextItemFormattingOptions config, TextItemFormattingOptions mask) { return(config & mask); }
//TextItemFormattingOptions private static bool CheckFlag(TextItemFormattingOptions options, TextItemFormattingOptions flag) { return((options & flag) == flag); }