Esempio n. 1
0
 internal void RemoveFillData(IFillData data)
 {
     if (_renderTagList != null)
     {
         _renderTagList.Remove(data);
     }
 }
 Graphic Parse(InlineText text, IFillData taginfo, List <string> joblist)
 {
     if (taginfo != null)
     {
         return(ParsePosAndUV(text, taginfo.ID, taginfo.pos, taginfo.uv, joblist));
     }
     return(null);
 }
 SpriteGraphic Parse(InlineText text, IFillData taginfo)
 {
     if (taginfo != null)
     {
         return(ParsePosAndUV(text, taginfo.ID, taginfo.pos, taginfo.uv));
     }
     return(null);
 }
Esempio n. 4
0
 internal void AddFillData(IFillData data)
 {
     if (_renderTagList == null)
     {
         _renderTagList = ListPool <IFillData> .Get();
     }
     this._renderTagList.Add(data);
 }
        void MarkDirtyStaticEmoji()
        {
            if (alltexts != null && alltexts.Count > 0)
            {
                if (listeners == null)
                {
                    listeners = new Dictionary <InlineText, ListenerData>();
                }

                for (int i = 0; i < alltexts.Count; ++i)
                {
                    InlineText       text      = alltexts[i];
                    List <IFillData> emojidata = text.PopEmojiData();
                    if (text != null && emojidata != null && emojidata.Count > 0 && allatlas != null && allatlas.Count > 0)
                    {
                        bool         isdirty = false;
                        ListenerData data    = null;
                        if (listeners.TryGetValue(text, out data))
                        {
                            isdirty = data.Dirty(text);
                            if (isdirty)
                            {
                                data.Set(text);
                            }
                        }
                        else
                        {
                            data = new ListenerData();
                            data.Set(text);

                            listeners.Add(text, data);
                        }

                        int staticcnt = 0;
                        for (int j = 0; j < emojidata.Count; ++j)
                        {
                            IFillData       taginfo   = emojidata[j];
                            SpriteAsset     asset     = null;
                            SpriteInfoGroup groupinfo = manager.FindSpriteGroup(taginfo.Tag, out asset);
                            if (groupinfo != null && groupinfo.spritegroups.Count == 1)
                            {
                                staticcnt++;
                            }
                        }

                        if (staticcnt > 0 && isdirty)
                        {
                            this.TryRendering(text);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
 void CalBoundsInSafe()
 {
     if (_renderTagList != null && _renderTagList.Count > 0)
     {
         Rect rect = rectTransform.rect;
         for (int i = _renderTagList.Count - 1; i >= 0; i--)
         {
             IFillData data = _renderTagList[i];
             if (rect.Contains(data.pos[1]) && rect.Contains(data.pos[3]))
             {
                 data.ignore = false;
             }
             else
             {
                 data.ignore = true;
             }
         }
     }
 }
        void PlayAnimation()
        {
            EmojiTools.BeginSample("Emoji_GroupAnimation");
            if (alltexts != null)
            {
                if (_time == null)
                {
                    _time = Time.timeSinceLevelLoad;
                }
                else
                {
                    float deltatime = Time.timeSinceLevelLoad - _time.Value;

                    int framecnt = Mathf.RoundToInt(deltatime * Speed);
                    if (framecnt > 0)
                    {
                        List <string> joblist = ListPool <string> .Get();

                        for (int i = 0; i < alltexts.Count; ++i)
                        {
                            InlineText       text      = alltexts[i];
                            List <IFillData> emojidata = text.PopEmojiData();
                            if (emojidata != null && emojidata.Count > 0 && allatlas != null && allatlas.Count > 0)
                            {
                                for (int j = 0; j < emojidata.Count; ++j)
                                {
                                    IFillData taginfo = emojidata[j];
                                    if (taginfo == null || taginfo.ignore)
                                    {
                                        continue;
                                    }
                                    SpriteAsset     asset     = null;
                                    SpriteInfoGroup groupinfo = manager.FindSpriteGroup(taginfo.Tag, out asset);
                                    if (groupinfo != null && groupinfo.spritegroups.Count > 1)
                                    {
                                        int        index   = framecnt % groupinfo.spritegroups.Count;
                                        SpriteInfo sprInfo = groupinfo.spritegroups[index];
                                        taginfo.uv = sprInfo.uv;

                                        //render next
                                        CanvasGraphicGroup group = FindGraphicGroup(text.canvas, asset.ID);

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

                                            RefreshSubUIMesh(text, group, asset, taginfo.pos, taginfo.uv, joblist);

                                            if (group.isDirty)
                                            {
                                                group.graphic.SetVerticesDirty();
                                            }
                                            joblist.Add(taginfo.Tag);
                                        }
                                    }
                                }
                            }
                        }
                        ListPool <string> .Release(joblist);
                    }
                }
            }

            EmojiTools.EndSample();
        }
        void RenderRebuild()
        {
            EmojiTools.BeginSample("Emoji_GroupRebuild");
            if (rebuildqueue != null && rebuildqueue.Count > 0)
            {
                List <string> joblist = ListPool <string> .Get();

                this.SetAllGroupDirty(false);

                for (int i = 0; i < alltexts.Count; ++i)
                {
                    InlineText text = alltexts[i];

                    List <IFillData> emojidata = text.PopEmojiData();
                    if (text != null && emojidata != null && emojidata.Count > 0 && allatlas != null && allatlas.Count > 0)
                    {
                        if (tempMesh == null)
                        {
                            tempMesh = UnitMeshInfoPool.Get();
                        }

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

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

                ListPool <string> .Release(joblist);

                rebuildqueue.Clear();
            }
            EmojiTools.EndSample();
        }
        void PlayAnimation()
        {
            EmojiTools.BeginSample("Emoji_UnitAnimation");
            if (alltexts != null)
            {
                if (_time == null)
                {
                    _time = Time.timeSinceLevelLoad;
                }
                else
                {
                    float deltatime = Time.timeSinceLevelLoad - _time.Value;
                    //at least one frame
                    int framecnt = Mathf.RoundToInt(deltatime * Speed);
                    if (framecnt > 0)
                    {
                        for (int i = 0; i < alltexts.Count; ++i)
                        {
                            InlineText       text      = alltexts[i];
                            List <IFillData> emojidata = text.PopEmojiData();
                            if (emojidata != null && emojidata.Count > 0 && allatlas != null && allatlas.Count > 0)
                            {
                                for (int j = 0; j < emojidata.Count; ++j)
                                {
                                    IFillData taginfo = emojidata[j];
                                    if (taginfo == null || taginfo.ignore)
                                    {
                                        continue;
                                    }

                                    SpriteAsset     asset     = null;
                                    SpriteInfoGroup groupinfo = manager.FindSpriteGroup(taginfo.Tag, out asset);
                                    if (groupinfo != null && groupinfo.spritegroups.Count > 1)
                                    {
                                        int        index   = framecnt % groupinfo.spritegroups.Count;
                                        SpriteInfo sprInfo = groupinfo.spritegroups[index];
                                        taginfo.uv = sprInfo.uv;

                                        List <SpriteGraphic> list   = null;
                                        SpriteGraphic        target = FindGraphic(text, asset, out list);
                                        if (target)
                                        {
                                            if (tempMesh == null)
                                            {
                                                tempMesh = UnitMeshInfoPool.Get();
                                            }

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

                                            RefreshSubUIMesh(text, target, asset, taginfo.pos, taginfo.uv);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            EmojiTools.EndSample();
        }
        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();
        }
Esempio n. 11
0
 public FillController(IFillData fillData)
 {
     _fillData = fillData;
 }