Game Development Reference
In-Depth Information
if (talking)
{
//Layout start
GUI.BeginGroup(new Rect(Screen.width / 2 -
conversationTextWidth / 2, 50, conversationTextWidth +
displayTextureOffset + 10,dialogHeight));
//The background box
GUI.Box(new Rect(0, 0, conversationTextWidth +
displayTextureOffset + 10,dialogHeight), "");
//The character name
GUI.Label(new Rect(displayTextureOffset, 10,
conversationTextWidth + 30, 20),
currentConversationLine.SpeakingCharacterName);
//The conversation text
GUI.Label(new Rect(displayTextureOffset, 30,
conversationTextWidth + 30, 20),
currentConversationLine.ConversationText);
//The character image
GUI.DrawTextureWithTexCoords(new Rect(10, 10, 50, 50),
currentConversationLine.DisplayPic.texture,
scalledTextureRect);
//Layout end
GUI.EndGroup();
}
}
Note that the use of the DrawTextureWithTexCoords function and not the standard
DrawTexture function is normally preferred in GUI drawing. This is because we are
selecting the texture to be drawn from our spritesheet and we have to use scaled coordin-
ates to pick the image as that is what the function uses. The Rect coordinates used in the
Sprite object's textureRect property (the picking coordinates) are unscaled.
Search WWH ::




Custom Search