本文整理汇总了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);
}
//.........这里部分代码省略.........