コード例 #1
0
        private void ShowAnimationCell(SpriteInfoGroup group, SpriteInfo info)
        {
            EditorGUILayout.ObjectField("", info.sprite, typeof(Sprite), false, GUILayout.Width(80));

            GUILayout.BeginVertical();

            GUI.enabled = false;
            GUILayout.Label("Name:" + group.tag, GUILayout.Width(200));
            GUI.enabled = true;

            if (GUILayout.Button("Play", GUILayout.Width(80)))
            {
                animations[group] = (float)EditorApplication.timeSinceStartup;
            }

            if (GUILayout.Button("Stop", GUILayout.Width(80)))
            {
                animations.Remove(group);
            }
            GUILayout.EndVertical();
        }
コード例 #2
0
        private void ShowCell(SpriteInfo info)
        {
            GUILayout.BeginVertical(info.sprite.name, "window");

            EditorGUILayout.ObjectField("", info.sprite, typeof(Sprite), false, GUILayout.Width(80));

            GUILayout.Space(1);

            GUI.enabled = false;

            EditorGUILayout.TextField("Name:", info.sprite.name);
            EditorGUILayout.Vector2Field("Pivot:", info.sprite.pivot);
            EditorGUILayout.RectField("Rect:", info.sprite.rect);

            for (int m = 0; m < info.uv.Length; m++)
            {
                EditorGUILayout.Vector2Field("UV" + m + ":", info.uv[m]);
            }

            GUI.enabled = true;

            GUILayout.EndVertical();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        private void ShowWillPackCells()
        {
            EditorGUILayout.BeginHorizontal("HelpBox");

            GUILayout.Label("Tag:", GUILayout.Width(50));
            if (GUILayout.Button(aniTagName, "MiniPopup", GUILayout.Width(100)))
            {
                GenericMenu gm = new GenericMenu();

                for (int i = 0; i < spriteAsset.listSpriteGroup.Count; i++)
                {
                    SpriteInfoGroup group = spriteAsset.listSpriteGroup[i];
                    gm.AddItem(new GUIContent(group.tag), false, () =>
                    {
                        aniTagName = group.tag;
                    });
                }
                gm.ShowAsContext();
            }

            if (GUILayout.Button("Select All", GUILayout.Width(100)))
            {
                for (int i = 0; i < spriteAsset.listSpriteGroup.Count; i++)
                {
                    SpriteInfoGroup group = spriteAsset.listSpriteGroup[i];
                    selections[group.tag] = group;
                }
            }

            if (GUILayout.Button("DisSelect All", GUILayout.Width(100)))
            {
                selections.Clear();
            }

            if (GUILayout.Button("Pack into Animation", GUILayout.Width(150)))
            {
                if (!string.IsNullOrEmpty(aniTagName))
                {
                    List <SpriteInfoGroup> removelist = new List <SpriteInfoGroup>();

                    SpriteInfoGroup firstGroup = null;
                    var             en         = selections.GetEnumerator();
                    while (en.MoveNext())
                    {
                        SpriteInfoGroup group = en.Current.Value;
                        if (firstGroup == null)
                        {
                            firstGroup = group;
                            group.tag  = aniTagName;
                        }
                        else
                        {
                            firstGroup.size = Mathf.Max(firstGroup.size, group.size);
                            firstGroup.spritegroups.AddRange(group.spritegroups);
                            removelist.Add(group);
                        }
                    }

                    for (int i = 0; i < removelist.Count; ++i)
                    {
                        SpriteInfoGroup group = removelist[i];
                        this.spriteAsset.listSpriteGroup.Remove(group);
                    }

                    selections.Clear();
                }
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(2);

            int t = 0;

            for (int i = 0; i < spriteAsset.listSpriteGroup.Count; i++)
            {
                SpriteInfoGroup group = spriteAsset.listSpriteGroup[i];

                EditorGUILayout.BeginHorizontal("HelpBox");

                bool exist     = selections.ContainsKey(group.tag);
                bool newselect = EditorGUILayout.Toggle(exist, GUILayout.Width(20));
                if (newselect != exist)
                {
                    if (newselect)
                    {
                        selections[group.tag] = group;
                    }
                    else
                    {
                        selections.Remove(group.tag);
                    }
                }

                GUILayout.Label(string.Format("[{0}] : {1}", i, group.tag), GUILayout.Width(100));

                AddFoldOutBtn("", group);
                EditorGUILayout.EndHorizontal();


                for (int j = 0; j < group.spritegroups.Count; j++)
                {
                    SpriteInfo info = group.spritegroups[j];

                    if (ReferenceEquals(showdata, group))
                    {
                        ShowCell(info);
                    }
                    ++t;
                }
            }
        }
コード例 #6
0
        private void ShowBatchTools()
        {
            GUILayout.BeginVertical("HelpBox");

            spriteAsset.AssetName = EditorGUILayout.TextField("AssetName:", spriteAsset.AssetName);

            spriteAsset.ID = EditorGUILayout.IntField("ID:", spriteAsset.ID);

            GUILayout.BeginHorizontal();

            addTagName = EditorGUILayout.TextField("add Tag", addTagName);
            if (GUILayout.Button("Sure"))
            {
                ClickSurebtn();
            }

            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            this.batchsize = EditorGUILayout.Vector2Field("batch size", this.batchsize);

            if (GUILayout.Button("Sure"))
            {
                for (int i = 0; i < spriteAsset.listSpriteGroup.Count; i++)
                {
                    SpriteInfoGroup group = spriteAsset.listSpriteGroup[i];
                    group.size  = this.batchsize.x;
                    group.width = this.batchsize.y;
                }
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("RestSize", GUILayout.Width(100)))
            {
                for (int i = 0; i < spriteAsset.listSpriteGroup.Count; i++)
                {
                    SpriteInfoGroup group = spriteAsset.listSpriteGroup[i];

                    for (int j = 0; j < group.spritegroups.Count; ++j)
                    {
                        SpriteInfo info  = group.spritegroups[j];
                        float      value = Mathf.Max(info.sprite.rect.width, info.sprite.rect.height);
                        group.size  = Mathf.Max(value, group.size);
                        group.width = 1;
                    }
                }
            }

            if (GUILayout.Button("Clear Tag", GUILayout.Width(100)))
            {
                ClearTag();
            }

            if (GUILayout.Button("batch pack Tags", GUILayout.Width(120)))
            {
                isPackingAnimation = !isPackingAnimation;
                this.animations.Clear();
                this.animationframes.Clear();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }