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


C# tk2dSprite.EditMode__CreateCollider方法代码示例

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


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

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