コード例 #1
0
 //回收超链接的信息
 private void ReleaseHrefInfos()
 {
     for (int i = 0; i < _listHrefInfos.Count; i++)
     {
         Pool <HrefInfo> .Release(_listHrefInfos[i]);
     }
     _listHrefInfos.Clear();
 }
コード例 #2
0
 //回收SpriteTagInfo
 private void ReleaseSpriteTageInfo()
 {
     //记录之前的信息
     for (int i = 0; i < _spriteInfo.Count; i++)
     {
         //回收信息到对象池
         Pool <SpriteTagInfo> .Release(_spriteInfo[i]);
     }
     _spriteInfo.Clear();
 }
コード例 #3
0
        public void Release()
        {
            ListPool <Vector3> .Release(Vertices);

            ListPool <Vector2> .Release(UVs);

            ListPool <Color> .Release(Colors);

            ListPool <int> .Release(Triangles);

            Pool <MeshInfo> .Release(this);
        }
コード例 #4
0
        private void Update()
        {
            if (_renderIndexs != null && _renderIndexs.Count > 0)
            {
                for (int i = 0; i < _renderIndexs.Count; i++)
                {
                    int           id            = _renderIndexs[i];
                    SpriteGraphic spriteGraphic = _spriteGraphics.Find(x => x.m_spriteAsset != null && x.m_spriteAsset.Id == id);
                    if (spriteGraphic != null)
                    {
                        if (!_graphicMeshInfo.ContainsKey(id))
                        {
                            spriteGraphic.MeshInfo = null;
                            continue;
                        }

                        Dictionary <InlineText, MeshInfo> textMeshInfo = _graphicMeshInfo[id];
                        if (textMeshInfo == null || textMeshInfo.Count == 0)
                        {
                            spriteGraphic.MeshInfo = null;
                        }
                        else
                        {
                            MeshInfo meshInfo = Pool <MeshInfo> .Get();

                            meshInfo.Reset();
                            foreach (var item in textMeshInfo)
                            {
                                if (item.Value.visable)
                                {
                                    meshInfo.Vertices.AddRange(item.Value.Vertices);
                                    meshInfo.UVs.AddRange(item.Value.UVs);
                                }
                            }
                            if (spriteGraphic.MeshInfo != null)
                            {
                                Pool <MeshInfo> .Release(spriteGraphic.MeshInfo);
                            }

                            spriteGraphic.MeshInfo = meshInfo;
                        }
                    }
                }
                //清掉渲染索引
                _renderIndexs.Clear();
            }
        }
コード例 #5
0
        public void Release()
        {
            if (listsInitalized)
            {
                ListPool <Vector3> .Release(Vertices);

                ListPool <Vector2> .Release(UVs);

                ListPool <Color> .Release(Colors);

                ListPool <int> .Release(Triangles);

                Pool <MeshInfo> .Release(this);

                Vertices  = null;
                UVs       = null;
                Colors    = null;
                Triangles = null;

                listsInitalized = false;
            }
        }
コード例 #6
0
        //处理超链接的信息
        private void DealHrefInfo(VertexHelper toFill)
        {
            if (_listHrefInfos.Count > 0)
            {
                // 处理超链接包围框
                for (int i = 0; i < _listHrefInfos.Count; i++)
                {
                    _listHrefInfos[i].Boxes.Clear();
                    if (_listHrefInfos[i].StartIndex >= toFill.currentVertCount)
                    {
                        continue;
                    }

                    toFill.PopulateUIVertex(ref _tempVertex, _listHrefInfos[i].StartIndex);
                    // 将超链接里面的文本顶点索引坐标加入到包围框
                    var pos    = _tempVertex.position;
                    var bounds = new Bounds(pos, Vector3.zero);
                    for (int j = _listHrefInfos[i].StartIndex + 1; j < _listHrefInfos[i].EndIndex; j++)
                    {
                        if (j >= toFill.currentVertCount)
                        {
                            break;
                        }
                        toFill.PopulateUIVertex(ref _tempVertex, j);
                        pos = _tempVertex.position;
                        if (pos.x < bounds.min.x)
                        {
                            // 换行重新添加包围框
                            _listHrefInfos[i].Boxes.Add(new Rect(bounds.min, bounds.size));
                            bounds = new Bounds(pos, Vector3.zero);
                        }
                        else
                        {
                            bounds.Encapsulate(pos);                             // 扩展包围框
                        }
                    }
                    //添加包围盒
                    _listHrefInfos[i].Boxes.Add(new Rect(bounds.min, bounds.size));
                }

                //添加下划线
                Vector2       extents       = rectTransform.rect.size;
                var           settings      = GetGenerationSettings(extents);
                TextGenerator underlineText = Pool <TextGenerator> .Get();

                underlineText.Populate("_", settings);
                IList <UIVertex> tut = underlineText.verts;
                for (int m = 0; m < _listHrefInfos.Count; m++)
                {
                    for (int i = 0; i < _listHrefInfos[m].Boxes.Count; i++)
                    {
                        //计算下划线的位置
                        Vector3[] ulPos = new Vector3[4];
                        ulPos[0] = _listHrefInfos[m].Boxes[i].position + new Vector2(0.0f, fontSize * 0.2f);
                        ulPos[1] = ulPos[0] + new Vector3(_listHrefInfos[m].Boxes[i].width, 0.0f);
                        ulPos[2] = _listHrefInfos[m].Boxes[i].position + new Vector2(_listHrefInfos[m].Boxes[i].width, 0.0f);
                        ulPos[3] = _listHrefInfos[m].Boxes[i].position;
                        //绘制下划线
                        for (int j = 0; j < 4; j++)
                        {
                            m_TempVerts[j]          = tut[j];
                            m_TempVerts[j].color    = Color.blue;
                            m_TempVerts[j].position = ulPos[j];
                            if (j == 3)
                            {
                                toFill.AddUIVertexQuad(m_TempVerts);
                            }
                        }
                    }
                }
                //回收下划线的对象
                Pool <TextGenerator> .Release(underlineText);
            }
        }