예제 #1
0
    public void UpdateTextInfo(int id, InlineText key, List <SpriteTagInfo> value)
    {
        if (!_indexSpriteGraphic.ContainsKey(id) || !_textMeshInfo.ContainsKey(id) || value.Count <= 0)
        {
            return;
        }
        int     spriteTagCount = value.Count;
        Vector3 textPos        = key.transform.position;
        Vector3 spritePos      = _indexSpriteGraphic[id].SpriteGraphic.transform.position;
        Vector3 disPos         = (textPos - spritePos) * (1.0f / key.pixelsPerUnit);

        //新增摄像机模式的位置判断
        if (key.canvas != null)
        {
            if (key.canvas.renderMode != RenderMode.ScreenSpaceOverlay)
            {
                Vector3 scale = key.canvas.transform.localScale;
                disPos  = new Vector3(disPos.x / scale.x, disPos.y / scale.y, disPos.z / scale.z);
                disPos /= (1.0f / key.pixelsPerUnit);
            }
        }

        MeshInfo meshInfo = new MeshInfo();

        meshInfo.Tag       = new string[spriteTagCount];
        meshInfo.Vertices  = new Vector3[spriteTagCount * 4];
        meshInfo.Uv        = new Vector2[spriteTagCount * 4];
        meshInfo.Triangles = new int[spriteTagCount * 6];
        for (int i = 0; i < value.Count; i++)
        {
            int m = i * 4;
            //标签
            meshInfo.Tag[i] = value[i].Tag;
            //顶点位置
            meshInfo.Vertices[m + 0] = value[i].Pos[0] + disPos;
            meshInfo.Vertices[m + 1] = value[i].Pos[1] + disPos;
            meshInfo.Vertices[m + 2] = value[i].Pos[2] + disPos;
            meshInfo.Vertices[m + 3] = value[i].Pos[3] + disPos;
            //uv
            meshInfo.Uv[m + 0] = value[i].Uv[0];
            meshInfo.Uv[m + 1] = value[i].Uv[1];
            meshInfo.Uv[m + 2] = value[i].Uv[2];
            meshInfo.Uv[m + 3] = value[i].Uv[3];
        }
        if (_textMeshInfo[id].ContainsKey(key))
        {
            MeshInfo oldMeshInfo = _textMeshInfo[id][key];
            if (!meshInfo.Equals(oldMeshInfo))
            {
                _textMeshInfo[id][key] = meshInfo;
            }
        }
        else
        {
            _textMeshInfo[id].Add(key, meshInfo);
        }

        //更新图片
        DrawSprites(id);
    }
예제 #2
0
    public void UpdateTextInfo(int _id, List <SpriteTagInfo> _value)
    {
        if (null == _value || _value.Count <= 0)
        {
            return;
        }
        int _spriteTagCount = _value.Count;
        //Vector3 _textPos = transform.position;
        //Vector3 _spritePos = _IndexSpriteGraphic[_id]._SpriteGraphic.transform.position;
        //Vector3 _spritePos = transform.position;
        //Vector3 _disPos = (_textPos - _spritePos) * (1.0f / pixelsPerUnit);

        MeshInfo _meshInfo = new MeshInfo();

        _meshInfo._Tag       = new string[_spriteTagCount];
        _meshInfo._Vertices  = new Vector3[_spriteTagCount * 4];
        _meshInfo._UV        = new Vector2[_spriteTagCount * 4];
        _meshInfo._Triangles = new int[_spriteTagCount * 6];
        for (int i = 0; i < _value.Count; i++)
        {
            int m = i * 4;
            //标签
            _meshInfo._Tag[i] = _value[i]._Tag;
            //顶点位置
            //_meshInfo._Vertices[m + 0] = _value[i]._Pos[0] + _disPos;
            //_meshInfo._Vertices[m + 1] = _value[i]._Pos[1] + _disPos;
            //_meshInfo._Vertices[m + 2] = _value[i]._Pos[2] + _disPos;
            //_meshInfo._Vertices[m + 3] = _value[i]._Pos[3] + _disPos;

            _meshInfo._Vertices[m + 0] = _value[i]._Pos[0];
            _meshInfo._Vertices[m + 1] = _value[i]._Pos[1];
            _meshInfo._Vertices[m + 2] = _value[i]._Pos[2];
            _meshInfo._Vertices[m + 3] = _value[i]._Pos[3];
            //uv
            _meshInfo._UV[m + 0] = _value[i]._UV[0];
            _meshInfo._UV[m + 1] = _value[i]._UV[1];
            _meshInfo._UV[m + 2] = _value[i]._UV[2];
            _meshInfo._UV[m + 3] = _value[i]._UV[3];
        }
        if (_TextMeshInfo.ContainsKey(_id))
        {
            MeshInfo _oldMeshInfo = _TextMeshInfo[_id];
            if (_meshInfo.Equals(_oldMeshInfo))
            {
                return;
            }
            else
            {
                _TextMeshInfo[_id] = _meshInfo;
            }
        }
        else
        {
            _TextMeshInfo.Add(_id, _meshInfo);
        }

        //更新图片
        DrawSprites(_id);
    }
예제 #3
0
    public void UpdateTextInfo(int _id, InlineText _key, List <SpriteTagInfo> _value)
    {
        if (!_IndexSpriteGraphic.ContainsKey(_id) || !_TextMeshInfo.ContainsKey(_id) || _value.Count <= 0)
        {
            return;
        }
        int     _spriteTagCount = _value.Count;
        Vector3 _textPos        = _key.transform.position;
        Vector3 _spritePos      = _IndexSpriteGraphic[_id]._SpriteGraphic.transform.position;
        Vector3 _disPos         = (_textPos - _spritePos) * (1.0f / _key.pixelsPerUnit);

        //新增摄像机模式的位置判断
        if (_key.canvas != null)
        {
            if (_key.canvas.renderMode != RenderMode.ScreenSpaceOverlay)
            {
                Vector3 _scale = _key.canvas.transform.localScale;
                _disPos = new Vector3(_disPos.x / _scale.x, _disPos.y / _scale.y, _disPos.z / _scale.z);
            }
        }

        MeshInfo _meshInfo = new MeshInfo();

        _meshInfo._Tag       = new string[_spriteTagCount];
        _meshInfo._Vertices  = new Vector3[_spriteTagCount * 4];
        _meshInfo._UV        = new Vector2[_spriteTagCount * 4];
        _meshInfo._Triangles = new int[_spriteTagCount * 6];
        for (int i = 0; i < _value.Count; i++)
        {
            int m = i * 4;
            //标签
            _meshInfo._Tag[i] = _value[i]._Tag;
            //顶点位置
            _meshInfo._Vertices[m + 0] = _value[i]._Pos[0] + _disPos;
            _meshInfo._Vertices[m + 1] = _value[i]._Pos[1] + _disPos;
            _meshInfo._Vertices[m + 2] = _value[i]._Pos[2] + _disPos;
            _meshInfo._Vertices[m + 3] = _value[i]._Pos[3] + _disPos;
            //uv
            _meshInfo._UV[m + 0] = _value[i]._UV[0];
            _meshInfo._UV[m + 1] = _value[i]._UV[1];
            _meshInfo._UV[m + 2] = _value[i]._UV[2];
            _meshInfo._UV[m + 3] = _value[i]._UV[3];
        }
        if (_TextMeshInfo[_id].ContainsKey(_key))
        {
            MeshInfo _oldMeshInfo = _TextMeshInfo[_id][_key];
            if (!_meshInfo.Equals(_oldMeshInfo))
            {
                _TextMeshInfo[_id][_key] = _meshInfo;
            }
        }
        else
        {
            _TextMeshInfo[_id].Add(_key, _meshInfo);
        }

        //更新图片
        DrawSprites(_id);
    }
예제 #4
0
    public void UpdateTextInfo(int _id, InlineText _key, List <SpriteTagInfo> _value)
    {
        if (!_IndexSpriteGraphic.ContainsKey(_id) || !_TextMeshInfo.ContainsKey(_id) || _value.Count <= 0)
        {
            return;
        }
        int     _spriteTagCount = _value.Count;
        Vector3 _textPos        = _key.transform.position;
        Vector3 _spritePos      = _IndexSpriteGraphic[_id]._SpriteGraphic.transform.position;
        Vector3 _disPos         = _textPos - _spritePos;

        MeshInfo _meshInfo = new MeshInfo();

        _meshInfo._Tag       = new string[_spriteTagCount];
        _meshInfo._Vertices  = new Vector3[_spriteTagCount * 4];
        _meshInfo._UV        = new Vector2[_spriteTagCount * 4];
        _meshInfo._Triangles = new int[_spriteTagCount * 6];
        for (int i = 0; i < _value.Count; i++)
        {
            int m = i * 4;
            int n = i * 6;
            //标签
            _meshInfo._Tag[i] = _value[i]._Tag;
            //顶点位置
            _meshInfo._Vertices[m + 0] = _value[i]._Pos[0] + _disPos;
            _meshInfo._Vertices[m + 1] = _value[i]._Pos[1] + _disPos;
            _meshInfo._Vertices[m + 2] = _value[i]._Pos[2] + _disPos;
            _meshInfo._Vertices[m + 3] = _value[i]._Pos[3] + _disPos;
            //uv
            _meshInfo._UV[m + 0] = _value[i]._UV[0];
            _meshInfo._UV[m + 1] = _value[i]._UV[1];
            _meshInfo._UV[m + 2] = _value[i]._UV[2];
            _meshInfo._UV[m + 3] = _value[i]._UV[3];
        }
        if (_TextMeshInfo[_id].ContainsKey(_key))
        {
            MeshInfo _oldMeshInfo = _TextMeshInfo[_id][_key];
            if (_meshInfo.Equals(_oldMeshInfo))
            {
                return;
            }
            else
            {
                _TextMeshInfo[_id][_key] = _meshInfo;
            }
        }
        else
        {
            _TextMeshInfo[_id].Add(_key, _meshInfo);
        }

        //更新图片
        DrawSprites(_id);
    }