public override void SubReset() { Name = "Label"; Font_Type = UILabelInspector.FontType.NGUI; UI_Font = null; //Dyn_Font = null; Font_Size = -1; Overflow_Width = -1; Max_Lines = -1; Font_Style = FontStyle.Normal; Overflow_Method = UILabel.Overflow.ResizeFreely; Crisp = UILabel.Crispness.Never; Modifier_Type = UILabel.Modifier.None; Alig_Type = NGUIText.Alignment.Automatic; Symbol_Style = NGUIText.SymbolStyle.Normal; Effect_Type = UILabel.Effect.None; UseEllipsis = false; Gradient = false; BBCode = true; Gradient_Top_Color = Color.white; Gradient_Bottom_Color = new Color(0.7f, 0.7f, 0.7f); Effect_Color = Color.black; Effect_Distance = new Vector2(-1, -1); }
public static void Show(string title, string content, string ok, string cancel, bool hideHeader = false, bool hideCancelButton = false, bool hideCloseButton = false, OnClose closeCallback = null, NGUIText.Alignment alignment = NGUIText.Alignment.Center, bool UseWiderMode = false, bool Higher = false) { if (m_instance == null) { return; } if (!string.IsNullOrEmpty(title)) { m_instance.m_Title.text = m_instance.m_Title.transform.GetChild(0).GetComponent <UILabel>().text = title; m_instance.m_Title.gameObject.CustomSetActive(true); } else { m_instance.m_Title.gameObject.CustomSetActive(false); } m_instance.m_Content.width = UseWiderMode ? 900 : 900; m_instance.m_Content.text = m_instance.m_Content.transform.GetChild(0).GetComponent <UILabel>().text = content; m_instance.m_Content.alignment = m_instance.m_Content.transform.GetChild(0).GetComponent <UILabel>().alignment = alignment; m_instance.m_OKLabel.text = m_instance.m_OKLabel.transform.GetChild(0).GetComponent <UILabel>().text = ok; m_instance.m_CancelLabel.text = m_instance.m_CancelLabel.transform.GetChild(0).GetComponent <UILabel>().text = cancel; m_instance.onClose = closeCallback; //m_instance.m_Header.gameObject.CustomSetActive(!hideHeader); m_instance.m_CancelButton.gameObject.CustomSetActive(!hideCancelButton); m_instance.m_CloseButton.gameObject.CustomSetActive(!hideCloseButton); m_instance.Show(); }
static int IntToEnum(IntPtr L) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); NGUIText.Alignment o = (NGUIText.Alignment)arg0; LuaScriptMgr.Push(L, o); return(1); }
/// <summary> /// 设置文本格式 /// </summary> private void setTextFormat(Color color, int fontsize, NGUIText.Alignment align, int width) { this.label.color = color; this.label.fontSize = fontsize; this.label.alignment = align; this.label.width = width; //根据文本框的长宽自动调整背景图片的宽和高 this.bg.width = width + 30; this.bg.height = this.label.height * 4; }
public void DoLocalize_UILabel(string MainTranslation, string SecondaryTranslation) { //--[ Localize Font Object ]---------- Font newFont = GetSecondaryTranslatedObj <Font>(ref MainTranslation, ref SecondaryTranslation); if (newFont != null) { if (newFont != mTarget_UILabel.ambigiousFont) { mTarget_UILabel.ambigiousFont = newFont; } } else { UIFont newUIFont = GetSecondaryTranslatedObj <UIFont>(ref MainTranslation, ref SecondaryTranslation); if (newUIFont != null && mTarget_UILabel.ambigiousFont != newUIFont) { mTarget_UILabel.ambigiousFont = newUIFont; } } if (mInitializeAlignment) { mInitializeAlignment = false; mOriginalAlignmentNGUI = mTarget_UILabel.alignment; } UIInput input = NGUITools.FindInParents <UIInput>(mTarget_UILabel.gameObject); if (input != null && input.label == mTarget_UILabel) { if (!string.IsNullOrEmpty(MainTranslation) && input.defaultText != MainTranslation) { if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL && (input.label.alignment == NGUIText.Alignment.Left || input.label.alignment == NGUIText.Alignment.Right)) { input.label.alignment = LocalizationManager.IsRight2Left ? NGUIText.Alignment.Right : mOriginalAlignmentNGUI; } input.defaultText = MainTranslation; } } else { if (!string.IsNullOrEmpty(MainTranslation) && mTarget_UILabel.text != MainTranslation) { if (Localize.CurrentLocalizeComponent.CorrectAlignmentForRTL && (mTarget_UILabel.alignment == NGUIText.Alignment.Left || mTarget_UILabel.alignment == NGUIText.Alignment.Right)) { mTarget_UILabel.alignment = LocalizationManager.IsRight2Left ? NGUIText.Alignment.Right : mOriginalAlignmentNGUI; } mTarget_UILabel.text = MainTranslation; } } }
static int set_alignment(IntPtr L) { try { NGUIText.Alignment arg0 = (NGUIText.Alignment)ToLua.CheckObject(L, 2, typeof(NGUIText.Alignment)); NGUIText.alignment = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 动态创建label并按指定行间距从上到下垂直排列,并返回最后一个label最低点的相对坐标 /// </summary> /// <param name="contents">要在label里显示的文本内容的list,一个string对应一个label</param> /// <param name="parent">挂载label的父物体</param> /// <param name="align">label里的文本的对齐方式</param> /// <param name="fontsize">字号</param> /// <param name="font">字体</param> /// <param name="labelDepth">label的depth</param> /// <param name="lineSpace">行间距</param> /// <param name="firstLabelPos">第一个label的生成坐标</param> /// <param name="labelWidth">label的宽度值</param> /// <returns>返回最后一个label最低点的相对坐标</returns> protected Vector3 spanLabels(List <string> contents, GameObject parent, Align align, int fontsize, Font font, int labelDepth, float lineSpace, Vector3 firstLabelPos, int labelWidth) { NGUIText.Alignment alinmt = NGUIText.Alignment.Left; //对齐方式,默认左对齐/ switch (align) { case Align.Center: alinmt = NGUIText.Alignment.Center; break; case Align.Right: alinmt = NGUIText.Alignment.Right; break; } //要返回的值/ Vector3 bottomLocalPos = Vector3.zero; //生成uilabel/ for (int i = 0; i < contents.Count; i++) { UILabel lbl = NGUITools.AddChild <UILabel>(parent); lbl.applyGradient = false; //关闭文字的颜色渐变/ lbl.pivot = UIWidget.Pivot.TopLeft; //将坐标轴位置都设置为label的右上角/ lbl.overflowMethod = UILabel.Overflow.ResizeHeight; //文字溢出时自动增加文本框高度/ lbl.alignment = alinmt; if (font != null) { lbl.ambigiousFont = font; } lbl.fontSize = fontsize; lbl.depth = labelDepth; //label的深度/ lbl.width = labelWidth; //label的宽度/ lbl.text = contents[i]; //设置uilabel的位置/ if (i > 0) { lbl.transform.localPosition = bottomLocalPos - new Vector3(0f, lineSpace, 0f); bottomLocalPos = lbl.transform.localPosition - new Vector3(0f, lbl.height, 0f); } else { lbl.transform.localPosition = firstLabelPos; bottomLocalPos = firstLabelPos - new Vector3(0f, lbl.height, 0f); } Debug.Log(lbl.height); } return(bottomLocalPos); }
public void Initialize(string text, bool isButton, JSONObject markup) { _isTextBox = false; _label.text = text; _label.trueTypeFont = MagicUIManager.Instance.Skin.FontParameters.Font; _label.color = Color.black; _label.keepCrispWhenShrunk = UILabel.Crispness.Always; if (isButton) { _isButton = true; _isMultiline = false; _horizontal = NGUIText.Alignment.Center; // _vertical _fontSize = 999; } else { _isButton = false; bool?multiline = markup.GetBoolSafely("multiline", false); if (multiline.HasValue) { _isMultiline = multiline.Value; } switch (markup.GetStringSafely("halign", "center").ToLower()[0]) { case 'l': _horizontal = NGUIText.Alignment.Left; break; case 'r': _horizontal = NGUIText.Alignment.Right; break; case 'c': default: _horizontal = NGUIText.Alignment.Center; break; } _label.alignment = _horizontal; //control.AddField("valign", valign); _fontSize = markup.GetFloatSafely("fontsize", 25); } }
private static int set_alignment(IntPtr L) { int result; try { NGUIText.Alignment alignment = (NGUIText.Alignment)((int)ToLua.CheckObject(L, 2, typeof(NGUIText.Alignment))); NGUIText.alignment = alignment; result = 0; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
/// <summary> /// 一个只有简单功能的小TIP,可设置文字颜色、大小、对齐方式、文本框宽度,自动多行,可控制显示时长 /// </summary> /// <param name="content">要显示的文字内容</param> /// <param name="alignment">内容的对齐方式</param> /// <param name="labelWidth">用来显示内容的文本框的宽度</param> /// <param name="lifeTime">当前tip的生命周期,使用默认值则须手动控制对象的销毁,设置大于0的时间值则会在指定时间后销毁</param> /// <returns></returns> public SimpleTip init(string content, Color color, int fontsize = 16, NGUIText.Alignment alignment = NGUIText.Alignment.Center, int labelWidth = 150, float lifeTime = -1f) { this.widget = this.GetComponent <UIWidget>(); this.bg = this.transform.Find("bg").GetComponent <UISprite>(); this.label = this.transform.Find("content").GetComponent <UILabel>(); this.label.text = content; //给label赋值/ setTextFormat(color, fontsize, alignment, labelWidth); if (lifeTime > 0) { StartCoroutine(recycle(lifeTime)); } return(this); }
static int set_alignment(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIPopupList obj = (UIPopupList)o; NGUIText.Alignment arg0 = (NGUIText.Alignment)ToLua.CheckObject(L, 2, typeof(NGUIText.Alignment)); obj.alignment = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index alignment on a nil value" : e.Message)); } }
static int get_alignment(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UIPopupList obj = (UIPopupList)o; NGUIText.Alignment ret = obj.alignment; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index alignment on a nil value" : e.Message)); } }
static int set_alignment(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UILabel obj = (UILabel)o; NGUIText.Alignment arg0 = (NGUIText.Alignment)ToLua.CheckObject(L, 2, typeof(NGUIText.Alignment)); obj.alignment = arg0; return 0; } catch(Exception e) { return LuaDLL.toluaL_exception(L, e, o, "attempt to index alignment on a nil value"); } }
static int get_alignment(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UILabel obj = (UILabel)o; NGUIText.Alignment ret = obj.alignment; ToLua.Push(L, ret); return 1; } catch(Exception e) { return LuaDLL.toluaL_exception(L, e, o, "attempt to index alignment on a nil value"); } }
protected void Init() { if (this.mDoInit && this.label != null) { this.mDoInit = false; this.mDefaultText = this.label.text; this.mDefaultColor = this.label.color; this.mEllipsis = this.label.overflowEllipsis; if (this.label.alignment == NGUIText.Alignment.Justified) { this.label.alignment = NGUIText.Alignment.Left; Debug.LogWarning("Input fields using labels with justified alignment are not supported at this time", this); } this.mAlignment = this.label.alignment; this.mPosition = this.label.cachedTransform.localPosition.x; this.UpdateLabel(); } }
private void Awake() { this.m_realMatchs = new List <Match>(); this.m_TextLabel = NGUITools.AddChild <UILabel>(base.gameObject); this.m_TextLabel.name = "textLabel"; if (Config.SnailFont != null) { this.m_TextLabel.trueTypeFont = Config.SnailFont.dynamicFont; } this.m_TextLabel.spacingY = this.spacingY; this.m_TextLabel.fontSize = this.fontSize; this.m_TextLabel.overflowMethod = this.overflowMethod; this.m_TextLabel.alignment = this.alignment; this.m_TextLabel.pivot = this.pivot; this.m_TextLabel.width = this.width; this.m_TextLabel.depth = this.depth; this.m_TextLabel.transform.localPosition = Vector3.zero; this.m_TextLabel.SetSymbolOffset(new Action(this.SymbolOffset)); if (this.overflowMethod == UILabel.Overflow.ClampContent) { this.m_TextLabel.height = this.textHeight; this.m_TextLabel.maxLineCount = this.maxLine; } this.m_SymbolLabel = NGUITools.AddChild <UILabel>(base.gameObject); this.m_SymbolLabel.name = "symbolLabel"; this.m_SymbolLabel.bitmapFont = this.uifont; this.m_SymbolLabel.fontSize = this.symbolSize; this.m_SymbolLabel.overflowMethod = this.overflowMethod; this.m_SymbolLabel.alignment = this.alignment; this.m_SymbolLabel.pivot = this.pivot; this.m_SymbolLabel.depth = this.depth + 1; Vector3 zero = Vector3.zero; zero.x = 0f; zero.y = -3f; zero.z = 0f; this.m_SymbolLabel.transform.localPosition = zero; this.m_SymbolLabel.SetSymbolOffset(new Action(this.SymbolOffset)); UIWidget arg_213_0 = this.m_SymbolLabel; int height = 10; this.m_SymbolLabel.height = height; arg_213_0.width = height; }
public override void SetValue(UIWidget widget) { base.SetValue(widget); UILabel label = (UILabel)widget; FontName = label.bitmapFont.name; FontStyle = label.fontStyle; Alignment = label.alignment; IsGridient = label.applyGradient; GradientTop = new CustomColor(label.gradientTop); GradientBottom = new CustomColor(label.gradientBottom); EffectStyle = label.effectStyle; EffectColor = new CustomColor(label.effectColor); EffectDistance = new CustomVector2(label.effectDistance); EffectiveSpacingX = label.effectiveSpacingX; EffectiveSpacingY = label.effectiveSpacingY; ColorTint = new CustomColor(label.color); }
private static int get_alignment(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIPopupList uIPopupList = (UIPopupList)obj; NGUIText.Alignment alignment = uIPopupList.alignment; ToLua.Push(L, alignment); result = 1; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index alignment on a nil value"); } return(result); }
private static int set_alignment(IntPtr L) { object obj = null; int result; try { obj = ToLua.ToObject(L, 1); UIPopupList uIPopupList = (UIPopupList)obj; NGUIText.Alignment alignment = (NGUIText.Alignment)((int)ToLua.CheckObject(L, 2, typeof(NGUIText.Alignment))); uIPopupList.alignment = alignment; result = 0; } catch (Exception ex) { result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index alignment on a nil value"); } return(result); }
/// <summary> /// Labels used for input shouldn't support rich text. /// </summary> protected void Init () { if (mDoInit && label != null) { mDoInit = false; mDefaultText = label.text; mDefaultColor = label.color; label.supportEncoding = false; mEllipsis = label.overflowEllipsis; if (label.alignment == NGUIText.Alignment.Justified) { label.alignment = NGUIText.Alignment.Left; Debug.LogWarning("Input fields using labels with justified alignment are not supported at this time", this); } mAlignment = label.alignment; mPosition = label.cachedTransform.localPosition.x; UpdateLabel(); } }
public virtual void SetStyle(int contentFontSize, NGUIText.Alignment alignment) { messageLabel.fontSize = contentFontSize; messageLabel.alignment = alignment; }
public static void RegisterLabel(Transform target, string translationKey, Color textColor, Color backgroundColor, NGUIText.Alignment alignment, UiTranslationOverlaySystem.CurrentViewOptions currentViewOption = UiTranslationOverlaySystem.CurrentViewOptions.AllowInWorld) { if (UiTranslationOverlaySystem.Instance && !UiTranslationOverlaySystem.Instance._activeLabels.ContainsKey(target) && UiTranslationDatabase.HasKey(translationKey)) { string text = UiTranslationDatabase.TranslateKey(translationKey, string.Empty, false); if (!string.IsNullOrEmpty(text)) { UiTranslationOverlayLabel uiTranslationOverlayLabel; if (UiTranslationOverlaySystem.Instance._labelPool.Count > 0) { uiTranslationOverlayLabel = UiTranslationOverlaySystem.Instance._labelPool.Dequeue(); uiTranslationOverlayLabel.gameObject.SetActive(true); UiTranslationOverlaySystem.Instance.SetIconHolderTr(uiTranslationOverlayLabel.transform, currentViewOption); } else { uiTranslationOverlayLabel = UnityEngine.Object.Instantiate <UiTranslationOverlayLabel>(UiTranslationOverlaySystem.Instance._overlayLabelPrefab); UiTranslationOverlaySystem.Instance.SetIconHolderTr(uiTranslationOverlayLabel.transform, currentViewOption); uiTranslationOverlayLabel.transform.localScale = UiTranslationOverlaySystem.Instance._overlayLabelPrefab.transform.localScale; } uiTranslationOverlayLabel._label.text = text; bool flag = alignment != NGUIText.Alignment.Left; if (flag) { if (uiTranslationOverlayLabel._label.pivot != UIWidget.Pivot.Center) { uiTranslationOverlayLabel._label.pivot = UIWidget.Pivot.Center; uiTranslationOverlayLabel._label.transform.localPosition = Vector3.zero; uiTranslationOverlayLabel._background.pivot = UIWidget.Pivot.Center; uiTranslationOverlayLabel._background.transform.localPosition = new Vector3(0f, uiTranslationOverlayLabel._background.transform.localPosition.y, 0f); } } else if (uiTranslationOverlayLabel._label.pivot != UIWidget.Pivot.Left) { uiTranslationOverlayLabel._label.pivot = UIWidget.Pivot.Left; uiTranslationOverlayLabel._label.transform.localPosition = Vector3.zero; uiTranslationOverlayLabel._background.pivot = UIWidget.Pivot.Left; uiTranslationOverlayLabel._background.transform.localPosition = new Vector3(-10f, uiTranslationOverlayLabel._background.transform.localPosition.y, 0f); } uiTranslationOverlayLabel._label.color = textColor; uiTranslationOverlayLabel._background.color = backgroundColor; uiTranslationOverlayLabel._follow._target = target; uiTranslationOverlayLabel._follow._inBook = (currentViewOption == UiTranslationOverlaySystem.CurrentViewOptions.AllowInBook); uiTranslationOverlayLabel._follow._inInventory = (currentViewOption == UiTranslationOverlaySystem.CurrentViewOptions.AllowInInventory); UiTranslationOverlaySystem.Instance._activeLabels.Add(target, uiTranslationOverlayLabel); } } }
private bool IsAlignmentRight(NGUIText.Alignment alignment) { return(alignment == NGUIText.Alignment.Right); }
private bool IsOppositeDirection(NGUIText.Alignment alignment, LanguageDirection direction) { return((direction == LanguageDirection.LeftToRight && IsAlignmentRight(alignment)) || (direction == LanguageDirection.RightToLeft && IsAlignmentLeft(alignment))); }
private float addLabel(string str, float x, float y, string name, bool isTitle = false, NGUIText.Alignment alig = NGUIText.Alignment.Center) { int fontSize = isTitle ? 32 : 24; int stand = rect.width - fontSize * 2; int total = str.Length * fontSize; int height = fontSize; float offy = 0; while (total > stand) { height += fontSize; total -= stand; offy += fontSize / 2; } UILabel label = NGUITools.AddChild <UILabel>(father); label.name = name; label.text = str; label.trueTypeFont = font; label.color = isTitle ? Color.red : Color.black; label.width = stand; label.height = height; label.alignment = alig; label.fontSize = fontSize; label.transform.localPosition = new Vector3(fontSize, y - offy, 0.0f); return(y - height); }
public void DoLocalize_UILabel(string mainTranslation, string secondaryTranslation) { //--[ Localize Font Object ]---------- Font newFont = GetSecondaryTranslatedObj <Font>(ref mainTranslation, ref secondaryTranslation); if (newFont != null) { if (newFont != mTarget_UILabel.ambigiousFont) { mTarget_UILabel.ambigiousFont = newFont; } } else { UIFont newUIFont = GetSecondaryTranslatedObj <UIFont>(ref mainTranslation, ref secondaryTranslation); if (newUIFont != null && mTarget_UILabel.ambigiousFont != newUIFont) { mTarget_UILabel.ambigiousFont = newUIFont; } } if (mInitializeAlignment) { mInitializeAlignment = false; mAlignmentNGUI_LTR = mAlignmentNGUI_RTL = mTarget_UILabel.alignment; if (LocalizationManager.IsRight2Left && mAlignmentNGUI_RTL == NGUIText.Alignment.Right) { mAlignmentNGUI_LTR = NGUIText.Alignment.Left; } if (!LocalizationManager.IsRight2Left && mAlignmentNGUI_LTR == NGUIText.Alignment.Left) { mAlignmentNGUI_RTL = NGUIText.Alignment.Right; } } UIInput input = NGUITools.FindInParents <UIInput>(mTarget_UILabel.gameObject); if (input != null && input.label == mTarget_UILabel) { if (mainTranslation != null && input.defaultText != mainTranslation) { if (CurrentLocalizeComponent.CorrectAlignmentForRTL && (input.label.alignment == NGUIText.Alignment.Left || input.label.alignment == NGUIText.Alignment.Right)) { input.label.alignment = LocalizationManager.IsRight2Left ? mAlignmentNGUI_RTL : mAlignmentNGUI_LTR; } input.defaultText = mainTranslation; } } else { if (mainTranslation != null && mTarget_UILabel.text != mainTranslation) { if (CurrentLocalizeComponent.CorrectAlignmentForRTL && (mTarget_UILabel.alignment == NGUIText.Alignment.Left || mTarget_UILabel.alignment == NGUIText.Alignment.Right)) { mTarget_UILabel.alignment = LocalizationManager.IsRight2Left ? mAlignmentNGUI_RTL : mAlignmentNGUI_LTR; } mTarget_UILabel.text = mainTranslation; } } }
private bool IsAlignmentLeft(NGUIText.Alignment alignment) { return(alignment == NGUIText.Alignment.Left); }
public void Open(NGUIText.Alignment alignment) { this.message.alignment = alignment; }
public override void DrawSubProperty() { state = UIModifierUtils.DrawContentHeader("UILabel", state); if (state) { #region Font EditorGUILayout.HelpBox("暂时只支持Dynamic Fonts替换", MessageType.Warning); GUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(true); Font_Type = (UILabelInspector.FontType)EditorGUILayout.EnumPopup(Font_Type, "DropDown", GUILayout.Width(74f)); EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Font", "DropDown", GUILayout.Width(64f))) { ComponentSelector.Show <UIFont>(OnNGUIFont); } EditorGUILayout.ObjectField(UI_Font, typeof(UIFont), false); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Font Size", GUILayout.Width(66)); Font_Size = EditorGUILayout.IntField("", Font_Size, GUILayout.Width(142f)); Font_Style = (FontStyle)EditorGUILayout.EnumPopup(Font_Style); GUILayout.Space(18f); } GUILayout.EndHorizontal(); #endregion GUILayout.BeginHorizontal(); GUILayout.Label("Modifier", GUILayout.Width(66)); Modifier_Type = (UILabel.Modifier)EditorGUILayout.EnumPopup(Modifier_Type); GUILayout.Space(18f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Alignment", GUILayout.Width(66)); Alig_Type = (NGUIText.Alignment)EditorGUILayout.EnumPopup(Alig_Type); GUILayout.Space(18f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Effect", GUILayout.Width(66)); Effect_Type = (UILabel.Effect)EditorGUILayout.EnumPopup(Effect_Type); if (Effect_Type != UILabel.Effect.None) { Effect_Color = EditorGUILayout.ColorField(Effect_Color, GUILayout.MinWidth(10f)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label(" ", GUILayout.Width(66)); EditorGUIUtility.labelWidth = 20f; Effect_Distance.x = EditorGUILayout.FloatField("X", Effect_Distance.x, GUILayout.MinWidth(40f)); Effect_Distance.y = EditorGUILayout.FloatField("Y", Effect_Distance.y, GUILayout.MinWidth(40f)); EditorGUIUtility.labelWidth = 70; } } GUILayout.Space(18f); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Overflow", GUILayout.Width(66)); Overflow_Method = (UILabel.Overflow)EditorGUILayout.EnumPopup(Overflow_Method); GUILayout.Space(18f); GUILayout.EndHorizontal(); //EditorGUI.indentLevel++; if (Overflow_Method == UILabel.Overflow.ClampContent) { GUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(66)); UseEllipsis = EditorGUILayout.ToggleLeft("Use Ellipsis", UseEllipsis); GUILayout.EndHorizontal(); } else if (Overflow_Method == UILabel.Overflow.ResizeFreely) { GUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(66)); Overflow_Width = EditorGUILayout.IntField("Max Width", Overflow_Width, GUILayout.MinWidth(100)); if (Overflow_Width < 1) { GUILayout.Label("unlimited"); } GUILayout.Space(18f); GUILayout.EndHorizontal(); } //EditorGUI.indentLevel--; GUILayout.BeginHorizontal(); Gradient = EditorGUILayout.Toggle("Gradient", Gradient, GUILayout.Width(80)); EditorGUI.BeginDisabledGroup(!Gradient); { EditorGUIUtility.labelWidth = 40; Gradient_Top_Color = EditorGUILayout.ColorField("Top", Gradient_Top_Color, GUILayout.MinWidth(60)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(80)); Gradient_Bottom_Color = EditorGUILayout.ColorField("Bottom", Gradient_Bottom_Color, GUILayout.MinWidth(60)); EditorGUIUtility.labelWidth = 70; } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); BBCode = EditorGUILayout.Toggle("BBCode", BBCode, GUILayout.Width(80)); EditorGUI.BeginDisabledGroup(!BBCode); Symbol_Style = (NGUIText.SymbolStyle)EditorGUILayout.EnumPopup("Symbols", Symbol_Style); EditorGUI.EndDisabledGroup(); GUILayout.Space(18); GUILayout.EndHorizontal(); Max_Lines = EditorGUILayout.IntField("Max Lines", Max_Lines, GUILayout.Width(120)); EditorGUILayout.HelpBox("依据官方文档,强制修改Keep Crisp为Never", MessageType.Warning); EditorGUI.BeginDisabledGroup(true); Crisp = UILabel.Crispness.Never; GUILayout.BeginHorizontal(); GUILayout.Label("Keep Crisp", GUILayout.Width(66)); Crisp = (UILabel.Crispness)EditorGUILayout.EnumPopup(Crisp); GUILayout.Space(18f); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); } }
//渐变的label public static UILabel CreateGradLabel(string text, int x, int y, int w, int h, Transform parent, Color color, Color topColor, Color bottomColor, Color effectColor, int size = 12, FontStyle style = FontStyle.Bold, NGUIText.Alignment align = NGUIText.Alignment.Left, int depth = 13, UIWidget.Pivot pivot = UIWidget.Pivot.TopLeft) { GameObject obj = UnityEngine.Object.Instantiate(FuncUtil.GetUIAssetByPath(LABEL_URL)) as GameObject; if (obj == null) { return(null); } UILabel label = obj.GetComponent <UILabel>(); label.text = text ?? ""; label.width = w; label.height = h; label.fontSize = size; label.fontStyle = style; label.pivot = pivot; label.alignment = align; label.applyGradient = true; label.gradientTop = topColor; label.gradientBottom = bottomColor; label.effectColor = effectColor; label.effectStyle = UILabel.Effect.Outline; if (color == Color.black) { color = new Color(0, 1, 1); } label.color = color; label.depth = depth; obj.transform.parent = parent; obj.transform.localScale = Vector3.one * size / 20.0f; obj.transform.localPosition = new Vector3(x, y, 0); return(label); }
public override void DoLocalize(Localize cmp, string mainTranslation, string secondaryTranslation) { var mTarget = GetTarget(cmp); //--[ Localize Font Object ]---------- Font newFont = cmp.GetSecondaryTranslatedObj <Font>(ref mainTranslation, ref secondaryTranslation); if (newFont != null) { if (newFont != mTarget.ambigiousFont) { mTarget.ambigiousFont = newFont; } } else { UIFont newUIFont = cmp.GetSecondaryTranslatedObj <UIFont>(ref mainTranslation, ref secondaryTranslation); if (newUIFont != null && mTarget.ambigiousFont != newUIFont) { mTarget.ambigiousFont = newUIFont; } } if (mInitializeAlignment) { mInitializeAlignment = false; mAlignment_LTR = mAlignment_RTL = mTarget.alignment; if (LocalizationManager.IsRight2Left && mAlignment_RTL == NGUIText.Alignment.Right) { mAlignment_LTR = NGUIText.Alignment.Left; } if (!LocalizationManager.IsRight2Left && mAlignment_LTR == NGUIText.Alignment.Left) { mAlignment_RTL = NGUIText.Alignment.Right; } } UIInput input = NGUITools.FindInParents <UIInput>(mTarget.gameObject); if (input != null && input.label == mTarget) { if (mainTranslation != null && input.defaultText != mainTranslation) { if (cmp.CorrectAlignmentForRTL && (input.label.alignment == NGUIText.Alignment.Left || input.label.alignment == NGUIText.Alignment.Right)) { input.label.alignment = (LocalizationManager.IsRight2Left ? mAlignment_RTL : mAlignment_LTR); } input.defaultText = mainTranslation; } } else { if (mainTranslation != null && mTarget.text != mainTranslation) { if (cmp.CorrectAlignmentForRTL && (mTarget.alignment == NGUIText.Alignment.Left || mTarget.alignment == NGUIText.Alignment.Right)) { mTarget.alignment = (LocalizationManager.IsRight2Left ? mAlignment_RTL : mAlignment_LTR); } mTarget.text = mainTranslation; } } }
public override void Show(UIDialogeOption option) { base.Show(option); if (Option != option) { // queued return; } if (option is UICustomeDialogueOption == false) { return; } mCustomOption = option as UICustomeDialogueOption; // set style if (mCustomOption.accept != null && acceptButton != null && acceptObject != null && acceptObject.activeSelf) { UILabel acceptLabel = acceptButton.GetComponentInChildren <UILabel>(); if (acceptLabel != null) { mOriginAccept = acceptLabel.text; acceptLabel.text = mCustomOption.accept; } } if (mCustomOption.decline != null && declineButton != null && declineObject != null && declineObject.activeSelf) { UILabel declineLabel = declineButton.GetComponentInChildren <UILabel>(); if (declineLabel != null) { mOriginDecline = declineLabel.text; declineLabel.text = mCustomOption.decline; } } if (mCustomOption.cancel != null && cancelButton != null && cancelObject != null && cancelObject.activeSelf) { UILabel cancelLabel = cancelButton.GetComponentInChildren <UILabel>(); if (cancelLabel != null) { mOriginCancel = cancelLabel.text; cancelLabel.text = mCustomOption.cancel; } } if (body != null && body.activeSelf) { UILabel bodyLabel = body.GetComponentInChildren <UILabel>(); mOriginAllianment = bodyLabel.alignment; mOriginOverflow = bodyLabel.overflowMethod; mOriginHeight = bodyLabel.height; mOriginSpace = bodyLabel.spacingY; //bodyLabel.alignment = mCustomOption.alignment; if (mCustomOption.lineSpace != 0) { bodyLabel.spacingY = mCustomOption.lineSpace; } if (mCustomOption.minHeight != 0) { bodyLabel.ProcessText(); if (bodyLabel.height < mCustomOption.minHeight) { bodyLabel.overflowMethod = UILabel.Overflow.ShrinkContent; bodyLabel.height = Mathf.Max(bodyLabel.height, mCustomOption.minHeight); } } UISprite bodyBackground = body.GetComponentInChildren <UISprite>(true); if (bodyBackground != null) { mOriginBodyBackgroundEnabled = bodyBackground.enabled; bodyBackground.enabled = !mCustomOption.hideBodyBackground; } } }