This is only useful for text meshes and renders an image inline with the text.
TextMesh是用来生成3D图形字体,不能直接用在UI Canvas下。
Text Meshes can be used for rendering road signs, graffiti etc. The Text Mesh places text in the 3D scene. To make generic 2D text for GUIs, use a GUI Text component instead.
voidDrawSprite(UIGraphicTextSprites spriteGraphic, List<InlineSpriteInfor> listInlineSprite) { var spriteCanvasRenderer = spriteGraphic.GetComponentInChildren<CanvasRenderer>(); if (m_spriteMesh == null) { m_spriteMesh = new Mesh(); }
if (drawSpriteVertices == null) drawSpriteVertices = new List<Vector3>(); else drawSpriteVertices.Clear(); if (drawSpriteUv == null) drawSpriteUv = new List<Vector2>(); else drawSpriteUv.Clear(); if (drawSpriteTriangles == null) drawSpriteTriangles = new List<int>(); else drawSpriteTriangles.Clear();
for (int i = 0; i < listInlineSprite.Count; i++) { var inlineSprite = listInlineSprite[i]; if (inlineSprite.isEmptySprite) { continue; } for (int j = 0; j < inlineSprite.vertices.Length; j++) { drawSpriteVertices.Add(inlineSprite.vertices[j]); } for (int j = 0; j < inlineSprite.uv.Length; j++) { drawSpriteUv.Add(inlineSprite.uv[j]); } for (int j = 0; j < inlineSprite.triangles.Length; j++) { drawSpriteTriangles.Add(inlineSprite.triangles[j]); } } //计算顶点绘制顺序 for (int i = 0; i < drawSpriteTriangles.Count; i++) { if (i % 6 == 0) { int num = i / 6; drawSpriteTriangles[i] = 0 + 4 * num; drawSpriteTriangles[i + 1] = 1 + 4 * num; drawSpriteTriangles[i + 2] = 2 + 4 * num;
voidUpdateAnimSprite() { for (int i = 0; i < m_AnimIndex.Count; i++) { var animIndex = m_AnimIndex[i]; if (!m_AnimSpriteInfo.ContainsKey(animIndex)) continue;
m_AnimSpriteStep[animIndex]++; if (m_AnimSpriteStep[animIndex] >= m_AnimSpriteInfo[animIndex].Length) { m_AnimSpriteStep[animIndex] = 0; } var step = m_AnimSpriteStep[animIndex]; var inlineSprite = m_AnimSpriteInfo[animIndex][step]; Sprite sprite; m_nameToSpriteDict.TryGetValue(inlineSprite.name, out sprite); var spriteGraphic = m_spriteGraphicArray[animIndex]; spriteGraphic.SetMainTexture(sprite.texture); DrawSprite(spriteGraphic, new List<InlineSpriteInfor>(){inlineSprite}); }