For the game we're working on, several NPCs deliver lines of text dialogue. We need to show a graphic with character portraits on either side and space for the dialogue text in the middle.
Since I don't know how big this graphic will be at the moment, i've been looking at using GUILayout for its auto-sizing features. However, it seems the only way to place a GUILayout control involves knowing its size; I need to centre it horizontally on screen and vertically near the bottom of the screen, but I cannot find a straightforward way of doing this. I'd also like to be able to wrap the text since it needs to stay within the middle area of the graphic.
I've been playing around with something like the following but it's not quite right. I've also seen people using `FlexibleSpace()` but I haven't had much luck there either. I'll be honest, despite all the good things i've read about it, i'm not finding the GUI system very intuitive compared to the way we position guiText/guiTextures. If someone could help me get my head around this i'd be extremely grateful.
var areaWidth : float;
var areaHeight : float;
var ScreenX : float;
var ScreenY : float;
var dialogueBG : Texture2D;
private var showDialogue : boolean = false;
function Start(){
ScreenX = ((Screen.width * 0.5) - (areaWidth * 0.5));
ScreenY = ((Screen.height) - 200);
}
function OnGUI(){
if (showDialogue) {
GUILayout.BeginArea (Rect (ScreenX, ScreenY, areaWidth, areaHeight), dialogueBG);
GUILayout.Label(myDialogue);
GUILayout.EndArea();
}
}