Esempio n. 1
0
        //更新Text文本信息
        public void UpdateTextInfo(InlineText key, int id, List <SpriteTagInfo> value, bool visable)
        {
            Dictionary <InlineText, MeshInfo> textMeshInfo;

            if (value == null)
            {
                if (_graphicMeshInfo.TryGetValue(id, out textMeshInfo) && textMeshInfo.ContainsKey(key))
                {
                    textMeshInfo[key].Release();
                    textMeshInfo.Remove(key);
                }
            }
            else
            {
                SpriteGraphic spriteGraphic = _spriteGraphics.Find(x => x.m_spriteAsset != null && x.m_spriteAsset.Id == id);
                if (spriteGraphic != null)
                {
                    if (!_graphicMeshInfo.TryGetValue(id, out textMeshInfo))
                    {
                        textMeshInfo = new Dictionary <InlineText, MeshInfo>();
                        _graphicMeshInfo.Add(id, textMeshInfo);
                    }

                    MeshInfo meshInfo;
                    if (!textMeshInfo.TryGetValue(key, out meshInfo))
                    {
                        meshInfo = Pool <MeshInfo> .Get();

                        textMeshInfo.Add(key, meshInfo);
                    }
                    meshInfo.Reset();
                    meshInfo.visable = visable;
                    for (int i = 0; i < value.Count; i++)
                    {
                        for (int j = 0; j < value[i].Pos.Length; j++)
                        {
                            //世界转本地坐标->避免位置变换的错位
                            meshInfo.Vertices.Add(Utility.TransformWorld2Point(spriteGraphic.transform, value[i].Pos[j]));
                        }
                        meshInfo.UVs.AddRange(value[i].UVs);
                    }
                }
            }

            //添加到渲染列表里面  --  等待下一帧渲染
            if (!_renderIndexs.Contains(id))
            {
                _renderIndexs.Add(id);
            }
        }
Esempio n. 2
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();
            }
        }