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; string atlas = rendElem.path.Split('/')[0]; string spname = rendElem.path.Split('/')[1]; LTextureAtlas.GetInstance().LoadData(atlas); Sprite sp = LTextureAtlas.GetInstance().getSprite(atlas, spname); //Sprite sp = LLoadBundle.GetInstance().LoadAsset(LGameConfig.PREFAB_BUNDLE, rendElem.path, typeof(Sprite)) as Sprite; // Sprite sp = Resources.Load(rendElem.path,typeof(Sprite)) as Sprite; rendElem.width = (int)sp.rect.size.x; rendElem.height = (int)sp.rect.size.y; _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; LTextureAtlas.GetInstance().LoadData(rendElem.path); Sprite sp = LTextureAtlas.GetInstance().getSprites(rendElem.path)[0]; //Sprite sp = LLoadBundle.GetInstance().LoadAsset(LGameConfig.PREFAB_BUNDLE, rendElem.path + "/1.png", typeof(Sprite)) as Sprite; // Sprite sp = Resources.Load(rendElem.path+"/1",typeof(Sprite)) as Sprite; rendElem.width = (int)sp.rect.size.x; rendElem.height = (int)sp.rect.size.y; _elemRenderArr.Add(rendElem); } else if (elem.type == RichType.NEWLINE) { LRenderElement rendElem = new LRenderElement(); rendElem.isNewLine = true; _elemRenderArr.Add(rendElem); } } _richElements.Clear(); formarRenderers(); }