static int _CreateUnityEngine_TextGenerator(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 0) { UnityEngine.TextGenerator obj = new UnityEngine.TextGenerator(); ToLua.PushObject(L, obj); return(1); } else if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(int))) { int arg0 = (int)LuaDLL.luaL_checknumber(L, 1); UnityEngine.TextGenerator obj = new UnityEngine.TextGenerator(arg0); ToLua.PushObject(L, obj); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.TextGenerator.New")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void RecalculateTextSizes() { var minimumSize = int.MaxValue; var textGenerator = new TextGenerator(); foreach (var text in TextComponents) { //get current text generation settings var textGenerationSettings = text.GetGenerationSettings(text.rectTransform.rect.size); //update to best fit settings so we can best fit size textGenerationSettings.resizeTextForBestFit = true; textGenerationSettings.resizeTextMinSize = MinSize; textGenerationSettings.resizeTextMaxSize = MaxSize; //populate to calculate the new size textGenerator.Populate(text.text, textGenerationSettings); //set new bestFit if new calculation is smaller than current bestFit minimumSize = textGenerator.fontSizeUsedForBestFit < minimumSize ? textGenerator.fontSizeUsedForBestFit : minimumSize; } // update all text components with new calculated size foreach (var text in TextComponents) { text.fontSize = minimumSize*(int) text.canvas.scaleFactor; } }
static int Invalidate(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)ToLua.CheckObject(L, 1, typeof(UnityEngine.TextGenerator)); obj.Invalidate(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetLines(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)ToLua.CheckObject(L, 1, typeof(UnityEngine.TextGenerator)); System.Collections.Generic.List <UnityEngine.UILineInfo> arg0 = (System.Collections.Generic.List <UnityEngine.UILineInfo>)ToLua.CheckObject(L, 2, typeof(System.Collections.Generic.List <UnityEngine.UILineInfo>)); obj.GetLines(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int QPYX_get_cachedTextGeneratorForLayout_YXQP(IntPtr L_YXQP) { object QPYX_o_YXQP = null; try { QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1); UnityEngine.UI.Text QPYX_obj_YXQP = (UnityEngine.UI.Text)QPYX_o_YXQP; UnityEngine.TextGenerator QPYX_ret_YXQP = QPYX_obj_YXQP.cachedTextGeneratorForLayout; ToLua.PushSealed(L_YXQP, QPYX_ret_YXQP); return(1); } catch (Exception QPYX_e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index cachedTextGeneratorForLayout on a nil value")); } }
static int GetLinesArray(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)ToLua.CheckObject(L, 1, typeof(UnityEngine.TextGenerator)); UnityEngine.UILineInfo[] o = obj.GetLinesArray(); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int get_fontSizeUsedForBestFit(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)o; int ret = obj.fontSizeUsedForBestFit; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index fontSizeUsedForBestFit on a nil value" : e.Message)); } }
static int get_characterCountVisible(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)o; int ret = obj.characterCountVisible; LuaDLL.lua_pushinteger(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index characterCountVisible on a nil value" : e.Message)); } }
static int get_rectExtents(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)o; UnityEngine.Rect ret = obj.rectExtents; ToLua.PushValue(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index rectExtents on a nil value" : e.Message)); } }
static int get_lines(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)o; System.Collections.Generic.IList <UnityEngine.UILineInfo> ret = obj.lines; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index lines on a nil value" : e.Message)); } }
static int Populate(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)ToLua.CheckObject(L, 1, typeof(UnityEngine.TextGenerator)); string arg0 = ToLua.CheckString(L, 2); UnityEngine.TextGenerationSettings arg1 = (UnityEngine.TextGenerationSettings)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextGenerationSettings)); bool o = obj.Populate(arg0, arg1); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetPreferredHeight(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); UnityEngine.TextGenerator obj = (UnityEngine.TextGenerator)ToLua.CheckObject(L, 1, typeof(UnityEngine.TextGenerator)); string arg0 = ToLua.CheckString(L, 2); UnityEngine.TextGenerationSettings arg1 = (UnityEngine.TextGenerationSettings)ToLua.CheckObject(L, 3, typeof(UnityEngine.TextGenerationSettings)); float o = obj.GetPreferredHeight(arg0, arg1); LuaDLL.lua_pushnumber(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int get_cachedTextGeneratorForLayout(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.Text obj = (UnityEngine.UI.Text)o; UnityEngine.TextGenerator ret = obj.cachedTextGeneratorForLayout; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index cachedTextGeneratorForLayout on a nil value" : e.Message)); } }
static int get_cachedTextGenerator(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.Text obj = (UnityEngine.UI.Text)o; UnityEngine.TextGenerator ret = obj.cachedTextGenerator; ToLua.PushSealed(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index cachedTextGenerator on a nil value")); } }
static int get_cachedTextGeneratorForLayout(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.UI.Text.cachedTextGeneratorForLayout"); #endif object o = null; try { o = ToLua.ToObject(L, 1); UnityEngine.UI.Text obj = (UnityEngine.UI.Text)o; UnityEngine.TextGenerator ret = obj.cachedTextGeneratorForLayout; ToLua.PushSealed(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index cachedTextGeneratorForLayout on a nil value")); } }
public void reloadData() { this.removeAllElements(); RectTransform rtran = this.GetComponent<RectTransform>(); //align if (alignType == RichAlignType.DESIGN_CENTER) { rtran.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f); } else if (alignType == RichAlignType.LEFT_TOP) { rtran.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f); } foreach (LRichElement elem in _richElements) { if (elem.type == RichType.TEXT) { LRichElementText elemText = elem as LRichElementText; char[] _charArr = elemText.txt.ToCharArray(); TextGenerator gen = new TextGenerator(); foreach (char strChar in _charArr) { LRenderElement rendElem = new LRenderElement(); rendElem.type = RichType.TEXT; rendElem.strChar = strChar.ToString(); rendElem.isOutLine = elemText.isOutLine; rendElem.isUnderLine = elemText.isUnderLine; rendElem.font = this.font; rendElem.fontSize = elemText.fontSize; rendElem.data = elemText.data; rendElem.color = elemText.color; TextGenerationSettings setting = new TextGenerationSettings(); setting.font = this.font; setting.fontSize = elemText.fontSize; setting.lineSpacing = 1; setting.scaleFactor = 1; setting.verticalOverflow = VerticalWrapMode.Overflow; setting.horizontalOverflow = HorizontalWrapMode.Overflow; rendElem.width = (int)gen.GetPreferredWidth(rendElem.strChar, setting); rendElem.height = (int)gen.GetPreferredHeight(rendElem.strChar, setting); _elemRenderArr.Add(rendElem); } } else if (elem.type == RichType.IMAGE) { LRichElementImage elemImg = elem as LRichElementImage; LRenderElement rendElem = new LRenderElement(); rendElem.type = RichType.IMAGE; rendElem.path = elemImg.path; rendElem.data = elemImg.data; Sprite sp = LLoadBundle.GetInstance().LoadAsset(LGameConfig.WINDOW_BUNDLE, rendElem.path, typeof(Sprite)) as Sprite; // Sprite sp = Resources.Load(rendElem.path,typeof(Sprite)) as Sprite; rendElem.width = sp.texture.width; rendElem.height = sp.texture.height; _elemRenderArr.Add(rendElem); } else if (elem.type == RichType.ANIM) { LRichElementAnim elemAnim = elem as LRichElementAnim; LRenderElement rendElem = new LRenderElement(); rendElem.type = RichType.ANIM; rendElem.path = elemAnim.path; rendElem.data = elemAnim.data; rendElem.fs = elemAnim.fs; Sprite sp = LLoadBundle.GetInstance().LoadAsset(LGameConfig.WINDOW_BUNDLE, rendElem.path + "/1", typeof(Sprite)) as Sprite; // Sprite sp = Resources.Load(rendElem.path+"/1",typeof(Sprite)) as Sprite; rendElem.width = sp.texture.width; rendElem.height = sp.texture.height; _elemRenderArr.Add(rendElem); } else if (elem.type == RichType.NEWLINE) { LRenderElement rendElem = new LRenderElement(); rendElem.isNewLine = true; _elemRenderArr.Add(rendElem); } } _richElements.Clear(); formarRenderers(); }
private static extern bool INTERNAL_CALL_Populate_Internal_cpp(TextGenerator self, string str, Font font, ref Color color, int fontSize, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, int verticalOverFlow, int horizontalOverflow, bool updateBounds, TextAnchor anchor, float extentsX, float extentsY, float pivotX, float pivotY, bool generateOutOfBounds);
public UnityTextRenderer(LWF lwf, TextContext context) : base(lwf) { m_context = context; m_textGenerator = new TextGenerator(); m_empty = true; }
private static extern bool INTERNAL_CALL_Populate_Internal_cpp(TextGenerator self, string str, Font font, ref Color color, int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, int verticalOverFlow, int horizontalOverflow, bool updateBounds, TextAnchor anchor, float extentsX, float extentsY, float pivotX, float pivotY, bool generateOutOfBounds, bool alignByGeometry);
internal bool Populate_Internal_cpp(string str, Font font, Color color, int fontSize, float scaleFactor, float lineSpacing, FontStyle style, bool richText, bool resizeTextForBestFit, int resizeTextMinSize, int resizeTextMaxSize, int verticalOverFlow, int horizontalOverflow, bool updateBounds, TextAnchor anchor, float extentsX, float extentsY, float pivotX, float pivotY, bool generateOutOfBounds, bool alignByGeometry) { return(TextGenerator.INTERNAL_CALL_Populate_Internal_cpp(this, str, font, ref color, fontSize, scaleFactor, lineSpacing, style, richText, resizeTextForBestFit, resizeTextMinSize, resizeTextMaxSize, verticalOverFlow, horizontalOverflow, updateBounds, anchor, extentsX, extentsY, pivotX, pivotY, generateOutOfBounds, alignByGeometry)); }