Hey all,
I’m a Unity beginner (and forum newcomer) and am currently using Unity for my graduation game design project. I absolutely love it! I don’t consider myself a programmer at all, and still I feel I can do everything I want to do with this wonderful engine.
Apart from trying to design a good dialogue system, I am trying to think of the best way to make a relative GUI to support this. (Basically, I want the GUI to have: an avatar window to see who’s talking, a speech window, and a window that holds either narrator text or dialogue buttons). A GUI that changes appropriate with changing of resolutions and of which I can enable/disable certain parts.
Now, I’ve read a bunch of references, topics and tutorials and there seem to be a lot of ways to accomplish this. I would like to know which way I could use best (as a beginner).
Currently, this is part of my experiment to make a dialogue GUI.
var message : TextAsset;
var Soundscape : GameObject;
var guicharacters = true;
var characterTalking = "Sophia";
var characterAvatar : Texture2D;
var characterSpeech : TextAsset;
function Awake () {
//check if soundscape = on
if (MainScreen_GUI.musicToggle == true) {
print ("Woohoo!");
Soundscape.audio.Play();
}
}
function OnGUI () {
//Message box
GUI.Box (Rect (Screen.width * 0.02, Screen.height * 0.8, Screen.width * 0.96, 120), "Messages");
GUI.Label (Rect (Screen.width * 0.05, Screen.height * 0.83, Screen.width * 0.90, 110), message.text);
//character box
//if statement here
if (guicharacters == true) {
//avatar box
GUI.Box (Rect (Screen.width * 0.02, Screen.height * 0.02, Screen.width * 0.13, Screen.height * 0.21), characterTalking);
GUI.Label (Rect (Screen.width * 0.03, Screen.height * 0.04, Screen.width * 0.145, Screen.height * 0.185), characterAvatar);
//speech box
GUI.Box (Rect (Screen.width * 0.16, Screen.height * 0.02, Screen.width * 0.82, Screen.height * 0.17), "Speech");
GUI.Label (Rect (Screen.width * 0.17, Screen.height * 0.05, Screen.width * 0.80, Screen.height * 0.17), characterSpeech.text);
}
//gui toggle
guicharacters = GUI.Toggle (Rect (240, 325, 100, 20), guicharacters, " GUI On/Off");
}
As you can see, I use a lot of Screen.height, etc. But I’ve also seen Automatic GUILayouts, and GUI matrices. Would these techniques be more efficient to use? I find that using such simple math solutions as I do know, lacks the controls I have with the absolute/static GUI (in where you simple state the pixels in the Rect).
I’m pretty sure there’s a better way to do this, but I can’t seem to get my head around it.
Also, the toggle is just a test thing, to hide/show the GUI. Is this the best way, or am I better of using other methods?
I’d really appreciate some insight into this :)! If there is any need for more information, I’ll gladly provide it.
-Veliremus