本文整理汇总了C#中Sprite.GetTextureName方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.GetTextureName方法的具体用法?C# Sprite.GetTextureName怎么用?C# Sprite.GetTextureName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.GetTextureName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSprite
// Register a new sprite, which is saved into the (internal) sprite list
public void AddSprite(Sprite NewSprite)
{
// Do we have a list of sprites for this texture yet?
ArrayList Sprites = null;
if(!SpriteList.TryGetValue(NewSprite.GetTextureName(), out Sprites))
{
// 1. Generate a new game object and sprite list array
GameObject GameObj = new GameObject();
Models.Add(NewSprite.GetTextureName(), GameObj);
Sprites = new ArrayList();
SpriteList.Add(NewSprite.GetTextureName(), Sprites);
// 2. Generate mesh (model)
GameObj.AddComponent("MeshFilter"); // Mesh (required)
MeshRenderer meshRenderer = GameObj.AddComponent("MeshRenderer") as MeshRenderer; // Material
// 3. Pair with texture
meshRenderer.renderer.material = LoadSpriteTexture(NewSprite.GetTextureName());
}
// Save this sprite into our sorted list (sorted based on depth)
// Note to self: what's the internal data structure? Any speed guarantee over a custom BTree?
Sprites.Add(NewSprite);
}
示例2: RemoveSprite
// Remove a sprite from the renderables list
public void RemoveSprite(Sprite OldSprite)
{
// Which list is this sprite in? If found, remove
ArrayList Sprites = null;
if(SpriteList.TryGetValue(OldSprite.GetTextureName(), out Sprites))
{
// Remove the data
Sprites.Remove(OldSprite);
// If this sprite batch has other sprites, flag those as needing update to
// update the entire geometry
if(Sprites.Count > 0)
{
foreach(Sprite SpriteObj in Sprites)
SpriteObj.Changed();
}
// Else, just remove the sprite list and model completely
else
{
// Remove sprites list
SpriteList.Remove(OldSprite.GetTextureName());
// Remove model
GameObject SpriteModel = null;
if(Models.TryGetValue(OldSprite.GetTextureName(), out SpriteModel))
{
Destroy(SpriteModel);
Models.Remove(OldSprite.GetTextureName());
}
}
}
}