void RefreshSubUIMesh(InlineText text, SpriteGraphic target, SpriteAsset matchAsset, Vector3[] Pos, Vector2[] UV)
        {
            // set mesh
            tempMesh.SetAtlas(matchAsset);
            tempMesh.SetUVLen(UV.Length);
            tempMesh.SetVertLen(Pos.Length);

            for (int i = 0; i < Pos.Length; ++i)
            {
                //text object pos
                Vector3 value    = Pos[i];
                Vector3 worldpos = text.transform.TransformPoint(value);
                Vector3 localpos = target.transform.InverseTransformPoint(worldpos);
                tempMesh.SetVert(i, localpos);
            }

            for (int i = 0; i < UV.Length; ++i)
            {
                Vector2 value = UV[i];
                tempMesh.SetUV(i, value);
            }

            //rendermesh
            UnitMeshInfo currentMesh = null;

            if (!this.renderData.TryGetValue(target, out currentMesh))
            {
                currentMesh        = new UnitMeshInfo();
                renderData[target] = currentMesh;
            }

            if (!currentMesh.Equals(tempMesh))
            {
                if (target.isDirty)
                {
                    currentMesh.AddCopy(tempMesh);
                    tempMesh.Clear();
                }
                else
                {
                    currentMesh.Copy(tempMesh);
                }
            }

            if (currentMesh.VertCnt() > 3 && currentMesh.UVCnt() > 3)
            {
                target.Draw(this);
                target.SetDirtyMask();
                target.SetVerticesDirty();
            }
            else
            {
                target.Draw(null);
                target.SetDirtyMask();
                target.SetVerticesDirty();
            }
        }
        void RefreshSubUIMesh(InlineText text, CanvasGraphicGroup group, SpriteAsset matchAsset, Vector3[] Pos, Vector2[] UV, List <string> joblist)
        {
            // set mesh
            tempMesh.SetAtlas(matchAsset);
            tempMesh.SetUVLen(UV.Length);
            tempMesh.SetVertLen(Pos.Length);

            SpriteGraphic graphic = group.graphic;

            //think about culling and screen coordinate.......
            for (int i = 0; i < Pos.Length; ++i)
            {
                //text object pos
                Vector3 value    = Pos[i];
                Vector3 worldpos = text.transform.TransformPoint(value);
                Vector3 localpos = group.graphic.transform.InverseTransformPoint(worldpos);
                tempMesh.SetVert(i, localpos);
            }

            for (int i = 0; i < UV.Length; ++i)
            {
                Vector2 value = UV[i];
                tempMesh.SetUV(i, value);
            }

            //rendermesh
            UnitMeshInfo currentMesh = group.mesh;

            if (!currentMesh.Equals(tempMesh))
            {
                if (joblist != null && joblist.Count > 0)
                {
                    currentMesh.AddCopy(tempMesh);
                    tempMesh.Clear();
                }
                else
                {
                    currentMesh.Copy(tempMesh);
                }
            }

            if (currentMesh.VertCnt() > 3 && currentMesh.UVCnt() > 3)
            {
                graphic.Draw(this);
            }
            else
            {
                graphic.Draw(null);
            }

            group.isDirty = true;
        }
        public void Release(Graphic graphic)
        {
            if (graphic is SpriteGraphic && PoolObj != null)
            {
                SpriteGraphic spriteGraphic = graphic as SpriteGraphic;
                spriteGraphic.Draw(null);

                if (GraphicTasks != null)
                {
                    for (int i = 0; i < GraphicTasks.Count; ++i)
                    {
                        CanvasGraphicGroup group = GraphicTasks[i];

                        if (group != null && UnityEngine.Object.ReferenceEquals(group.graphic, graphic))
                        {
                            GraphicTasks.RemoveAt(i);
                            break;
                        }
                    }
                }
            }
        }
        public void Dispose()
        {
            if (allatlas != null)
            {
                ListPool <SpriteAsset> .Release(allatlas);

                allatlas = null;
            }

            if (alltexts != null)
            {
                ListPool <InlineText> .Release(alltexts);

                alltexts = null;
            }

            if (tempMesh != null)
            {
                UnitMeshInfoPool.Release(tempMesh);
                tempMesh = null;
            }

            if (GraphicTasks != null)
            {
                for (int i = 0; i < GraphicTasks.Count; ++i)
                {
                    CanvasGraphicGroup group  = GraphicTasks[i];
                    SpriteGraphic      target = group.graphic;
                    if (target != null)
                    {
                        target.Draw(null);
                        target.SetDirtyMask();
                        target.SetVerticesDirty();
                    }

                    if (group.mesh != null)
                    {
                        UnitMeshInfoPool.Release(group.mesh);
                    }
                }

                GraphicTasks.Clear();
                GraphicTasks = null;
            }

            if (rebuildqueue != null)
            {
                ListPool <InlineText> .Release(rebuildqueue);

                rebuildqueue = null;
            }


            if (listeners != null)
            {
                listeners.Clear();
                listeners = null;
            }

            if (tempMesh != null)
            {
                UnitMeshInfoPool.Release(tempMesh);
                tempMesh = null;
            }

            _time = null;
        }
        void RenderRebuild()
        {
            EmojiTools.BeginSample("Emoji_UnitRebuild");
            if (rebuildqueue != null && rebuildqueue.Count > 0)
            {
                for (int i = 0; i < rebuildqueue.Count; ++i)
                {
                    InlineText       text      = rebuildqueue[i];
                    List <IFillData> emojidata = text.PopEmojiData();
                    if (emojidata != null && emojidata.Count > 0 && allatlas != null && allatlas.Count > 0)
                    {
                        if (tempMesh == null)
                        {
                            tempMesh = UnitMeshInfoPool.Get();
                        }

                        if (renderData == null)
                        {
                            renderData = new Dictionary <Graphic, UnitMeshInfo>(emojidata.Count);
                        }

                        for (int j = 0; j < emojidata.Count; ++j)
                        {
                            IFillData taginfo = emojidata[j];
                            if (taginfo == null || taginfo.ignore)
                            {
                                continue;
                            }
                            Parse(text, taginfo);
                        }

                        List <SpriteGraphic> list;
                        if (textGraphics != null && textGraphics.TryGetValue(text, out list))
                        {
                            for (int j = 0; j < list.Count; ++j)
                            {
                                SpriteGraphic graphic = list[j];
                                //not render
                                if (graphic != null && !graphic.isDirty)
                                {
                                    graphic.Draw(null);
                                    graphic.SetDirtyMask();
                                    graphic.SetVerticesDirty();
                                }
                            }
                        }
                    }
                    else
                    {
                        List <SpriteGraphic> list;
                        if (textGraphics != null && textGraphics.TryGetValue(text, out list))
                        {
                            for (int j = 0; j < list.Count; ++j)
                            {
                                SpriteGraphic graphic = list[j];
                                //not render
                                if (graphic != null)
                                {
                                    graphic.Draw(null);
                                    graphic.SetDirtyMask();
                                    graphic.SetVerticesDirty();
                                }
                            }
                        }
                    }
                }

                rebuildqueue.Clear();
            }
            EmojiTools.EndSample();
        }