protected override void OnUpdate()
        {
            Entities.ForEach((UnityEngine.TextMesh utextMesh, MeshRenderer meshRenderer) =>
            {
                var entity = GetPrimaryEntity(utextMesh);

                Debug.LogFormat("TextMeshConversionSystem: {0}, {1}", utextMesh.name, entity);

                var textMesh  = new TextMesh();
                textMesh.Text = utextMesh.text;

                //utextMesh.font
                //if (FontData != null)
                //    textMesh.FontId = FontData.Id;
                textMesh.FontId   = 1;
                textMesh.CharSize = utextMesh.characterSize;
                textMesh.Color    = TinyAuthoringUtil.Convert(utextMesh.color);

                DstEntityManager.AddComponentData(entity, textMesh);

                //var renderMesh = new RenderMesh();
                //renderMesh.material =
                //DstEntityManager.AddComponentData(entity, textMesh);
            });
        }
        public static CharacterInfo Convert(UnityEngine.CharacterInfo ucharacterInfo)
        {
            var characterInfo = new PFrame.Tiny.CharacterInfo();

            characterInfo.index   = ucharacterInfo.index;
            characterInfo.uv      = TinyAuthoringUtil.Convert(ucharacterInfo.uv);
            characterInfo.vert    = TinyAuthoringUtil.Convert(ucharacterInfo.vert);
            characterInfo.width   = ucharacterInfo.advance;
            characterInfo.size    = ucharacterInfo.size;
            characterInfo.style   = (FontStyle)((int)ucharacterInfo.style);
            characterInfo.flipped = ucharacterInfo.flipped;

            return(characterInfo);
        }
        private TextMesh GetTextMesh()
        {
            var textMesh = new TextMesh();

            textMesh.Text = Text;
            if (FontData != null)
            {
                textMesh.FontId = FontData.Id;
            }
            textMesh.CharSize = CharacterSize;
            textMesh.Color    = TinyAuthoringUtil.Convert(Color);
            textMesh.OffsetZ  = OffsetZ;

            textMesh.HAlignType = HAlignType;
            textMesh.VAlignType = VAlignType;
            textMesh.HSpacing   = HSpacing;
            textMesh.VSpacing   = VSpacing;

            return(textMesh);
        }
        public static PFrame.Tiny.Font Convert(UnityEngine.Font ufont)
        {
            var font = new PFrame.Tiny.Font();

            font.Ascent     = ufont.ascent;
            font.LineHeight = ufont.lineHeight;
            font.FontSize   = ufont.fontSize;

            var ucharInfos       = ufont.characterInfo;
            var num              = ucharInfos.Length;
            var characterInfoMap = new NativeHashMap <int, PFrame.Tiny.CharacterInfo>(num, Allocator.Temp);

            for (int i = 0; i < num; i++)
            {
                var ucharInfo = ucharInfos[i];
                var charInfo  = TinyAuthoringUtil.Convert(ucharInfo);
                characterInfoMap.Add(charInfo.index, charInfo);
            }
            font.CharacterInfoMap = characterInfoMap;

            return(font);
        }
        private void OnValidate()
        {
            if (FontData == null)
            {
                return;
            }

            var meshRenderer = GetComponent <MeshRenderer>();

            if (meshRenderer.sharedMaterial != FontData.Font.material)
            {
                meshRenderer.sharedMaterial = FontData.Font.material;
            }

            if (Text == null || FontData == null)
            {
                return;
            }

            var meshFilter = GetComponent <MeshFilter>();

            Mesh mesh = meshFilter.mesh;

            if (mesh != null)
            {
                mesh.Clear();
            }
            else
            {
                mesh            = new Mesh();
                meshFilter.mesh = mesh;
            }
            //Mesh mesh = new Mesh();

            //var idx = 4;
            //var triIdx = 6;
            //var _color = Color.red;

            //var Verts = new Vector3[4];
            //Verts[0] = new Vector3(0f, 0f);
            //Verts[1] = new Vector3(0f, 1f);
            //Verts[2] = new Vector3(1f, 1f);
            //Verts[3] = new Vector3(1f, 0f);

            //var UVs = new Vector2[4];
            //UVs[0] = new Vector2(0f, 0f);
            //UVs[1] = new Vector2(0f, 1f);
            //UVs[2] = new Vector2(1f, 1f);
            //UVs[3] = new Vector2(1f, 0f);

            //var Tris = new int[6];
            //Tris[0] = 0;
            //Tris[1] = 1;
            //Tris[2] = 2;
            //Tris[3] = 0;
            //Tris[4] = 2;
            //Tris[5] = 3;

            //mesh.SetVertices(Verts, 0, idx);
            //mesh.SetUVs(0, UVs, 0, idx);
            //mesh.SetIndices(Tris, 0, triIdx, MeshTopology.Triangles, 0, true, 0);
            //var colors = new NativeArray<Color>(idx, Allocator.Temp);
            //for (int i = 0; i < idx; i++)
            //{
            //    colors[i] = _color;
            //}
            //mesh.SetColors(colors, 0, idx);

            var font = TinyAuthoringUtil.Convert(FontData.Font);

            //var textBuffer = new NativeArray<int>(Text.Length, Allocator.TempJob);
            //for (int j = 0; j < Text.Length; j++)
            //{
            //    textBuffer[j] = Text[j];
            //}
            //var color = TinyAuthoringUtil.Convert(Color);

            //var builder = new TextMeshHybridBuilder(textBuffer, font, CharacterSize, color, OffsetZ);
            //builder.Execute();

            //mesh.SetVertices(builder.Verts);
            //mesh.SetUVs(0, builder.UVs);
            //mesh.SetIndices(builder.Tris, 0, builder.Tris.Length, MeshTopology.Triangles, 0, true, 0);
            ////var colors = new NativeArray<Color>(idx, Allocator.Temp);
            ////for (int i = 0; i < idx; i++)
            ////{
            ////    colors[i] = _color;
            ////}
            //mesh.SetColors(builder.Colors);

            //builder.Dispose();

            var textMesh = GetTextMesh();

            TextMeshHybridUtil.CreateTextMesh(textMesh, font, mesh);

            //textBuffer.Dispose();
            font.Dispose();
        }