当前位置: 首页>>代码示例>>C#>>正文


C# tk2dSprite.SwitchCollectionAndSprite方法代码示例

本文整理汇总了C#中tk2dSprite.SwitchCollectionAndSprite方法的典型用法代码示例。如果您正苦于以下问题:C# tk2dSprite.SwitchCollectionAndSprite方法的具体用法?C# tk2dSprite.SwitchCollectionAndSprite怎么用?C# tk2dSprite.SwitchCollectionAndSprite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tk2dSprite的用法示例。


在下文中一共展示了tk2dSprite.SwitchCollectionAndSprite方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: configureObject

    public void configureObject(tk2dSprite sprite, string resGroup, string spriteName)
    {
        if (!_spriteCollections.ContainsKey(resGroup))
            loadSpriteCollection(resGroup);

        sprite.SwitchCollectionAndSprite(_spriteCollections[resGroup].spriteCollection, _spriteCollections[resGroup].spriteCollection.GetSpriteIdByName(spriteName));
    }
开发者ID:DieselPuppet,项目名称:DatingDash,代码行数:7,代码来源:ContentManager.cs

示例2: Setup

        public void Setup(SpriteFlatData data)
        {
            _data = data;
            _sprite = gameObject.AddComponent<tk2dSprite>();
            _sprite.SwitchCollectionAndSprite(data.data, 0);
            _sprite.Build();

            _dimensionsInit = new Vector3(data.regionWidth, data.regionHeight, 1f);
            dimensions = new Vector3(data.width, data.height, 1f);
        }
开发者ID:hjrhjr,项目名称:Beats2,代码行数:10,代码来源:SpriteFlat.cs

示例3: DrawSpriteEditorGUI

    protected void DrawSpriteEditorGUI(tk2dSprite sprite)
    {
        // maybe cache this if its too slow later
        if (generatorCache.all == null || generatorCache.current != sprite.collection)
        {
            generatorCache.all = tk2dEditorUtility.GetOrCreateIndex().GetSpriteCollectionIndex();
            if (generatorCache.all != null)
            {
                string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(sprite.collection));

                for (int i = 0; i < generatorCache.all.Length; ++i)
                {
                    if (generatorCache.all[i].spriteCollectionDataGUID == guid)
                    {
                        generatorCache.current = sprite.collection;
                        generatorCache.currentGUID = guid;
                        break;
                    }
                }
            }
        }

        if (generatorCache.all == null)
        {
            EditorGUILayout.LabelField("Collection", "Error");
        }
        else
        {
            string[] collNames = new string[generatorCache.all.Length];
            int selIndex = -1;
            for (int i = 0; i < generatorCache.all.Length; ++i)
            {
                collNames[i] = generatorCache.all[i].name;
                if (generatorCache.all[i].spriteCollectionDataGUID == generatorCache.currentGUID)
                    selIndex = i;
            }

            int newIndex = EditorGUILayout.Popup("Collection", (selIndex != -1) ? selIndex : 0, collNames);
            if (newIndex != selIndex)
            {
                generatorCache.currentGUID = generatorCache.all[newIndex].spriteCollectionDataGUID;
                GameObject go = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(generatorCache.currentGUID), typeof(GameObject)) as GameObject;
                tk2dSpriteCollectionData data = go.GetComponent<tk2dSpriteCollectionData>();
                if (data != null)
                {
                    generatorCache.current =  data;
                    int newId = (sprite.spriteId >= generatorCache.current.Count)?0:sprite.spriteId;

                    sprite.SwitchCollectionAndSprite(generatorCache.current, newId);
                    sprite.EditMode__CreateCollider();
                }
            }
        }

        if (sprite.collection)
        {
            // sanity check sprite id
            if (sprite.spriteId < 0 || sprite.spriteId >= sprite.collection.Count)
            {
                sprite.spriteId = 0;
                sprite.EditMode__CreateCollider();
            }

            int newSpriteId = sprite.spriteId;

            if (generatorCache.current)
            {
                newSpriteId = tk2dEditorUtility.SpriteSelectorPopup("Sprite", sprite.spriteId, generatorCache.current);

                if (tk2dPreferences.inst.displayTextureThumbs)
                {
                    if (generatorCache.current.version < 1)
                    {
                        GUILayout.Label("No thumbnail data.\nPlease rebuild Sprite Collection.");
                    }
                    else
                    {
                        var tex = tk2dSpriteThumbnailCache.GetThumbnailTexture(generatorCache.current, sprite.spriteId);
                        if (tex)
                        {
                            float w = tex.width;
                            float h = tex.height;
                            float maxSize = 128.0f;
                            if (w > maxSize)
                            {
                                h = h / w * maxSize;
                                w = maxSize;
                            }

                            Rect r = GUILayoutUtility.GetRect(w, h);
                            GUI.DrawTexture(r, tex, ScaleMode.ScaleToFit);
                            //GUILayout.Box(tex, GUILayout.Width(w), GUILayout.Height(h));
                        }
                    }
                }
            }
            else
            {
                newSpriteId = EditorGUILayout.IntSlider(sprite.spriteId, 0, sprite.collection.Count - 1);
            }
//.........这里部分代码省略.........
开发者ID:CodeStrumpet,项目名称:Elemental,代码行数:101,代码来源:tk2dSpriteEditor.cs


注:本文中的tk2dSprite.SwitchCollectionAndSprite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。