Game Development Reference
In-Depth Information
tion as follows, and this is where we but heads between the Unity3D GUI system and the
new Unity3D 2D system:
void DisplayInventoryWindow(int windowID)
{
var currentX = 0 + offsetX;
var currentY = 18 + offsetY;
foreach (var item in GameState.currentPlayer.Inventory)
{
Rect texcoords = item.Sprite.textureRect;
texcoords.x /= item.Sprite.texture.width;
texcoords.y /= item.Sprite.texture.height;
texcoords.width /= item.Sprite.texture.width;
texcoords.height /= item.Sprite.texture.height;
GUI.DrawTextureWithTexCoords(new Rect(
currentX,
currentY,
item.Sprite.textureRect.width,
item.Sprite.textureRect.height),
item.Sprite.texture,
texcoords);
currentX += inventoryItemIconSize.x;
if (currentX + inventoryItemIconSize.x + offsetX >
inventoryWindowSize.x)
{
currentX = offsetX;
currentY += inventoryItemIconSize.y;
if (currentY + inventoryItemIconSize.y + offsetY >
inventoryWindowSize.y)
{
return;
}
}
}
}
Search WWH ::




Custom Search