[18279-bildschirmfoto+2013-11-22+um+14.15.11.png|18279]
Hi guys.
I am currently working an a dialogue system. What I want to right now is having two different speech bubbles (one for each speaker) pop up.
My approach is having two different boxes withing two different areas in two OnGUI functions. Then filling them with different text an options via labels and buttons.
All of this is KIND of working, but here is my problem:
When one of the box has a label in it, the OTHER box (not containing a label) with two button options kind of pretends that the same label was there, too – and shows the buttons at that exact position where the label in the other box ends.
The picture attached shows this problem.
Okay, so I understand that the label obviously affects both boxes, but I don’t understand why – from my code it should be two different functions and areas and therefore different boxes?
I would be very happy for any ideas and solutions to my problem.
I just want to be able to display different text and buttons independently in each boxes.
Thanks in advance!!
Here is the code:
void OnGUI(){
GUI.skin = dialogueGUI;
if (showDialogue&&dan01)
{
GameObject Dusty = GameObject.Find("Dusty");
PlayerControl playerControl = Dusty.GetComponent<PlayerControl>();
playerControl.canMove = false;
GameObject Dan = GameObject.Find("Dan");
GUI.BeginGroup (new Rect (700, 100, 500, 200));
GUI.Box (new Rect (0, 0, 0, 0), "");
if (dialogue1_1)
{
GUILayout.Label("Stop running around, will you? I am nervous enough already. This place gives me the creeps. I really wish this was over and done with. Like, yesterday.");
}
if (dialogue1_2a)
{
GUILayout.Label("Phew! Thought I was the only one.");
}
if (dialogue1_2b)
{
GUILayout.Label("Well, I'm glad at least one of us is enjoying herself.");
}
GUI.EndGroup ();
if (showDialogue&&dan01)
{
StartCoroutine(Wait());
GUI.BeginGroup (new Rect (220, 270, 500, 200));
GUI.Box (new Rect (0, 0, 0, 0), "");
if (dialogue1_1)
{
if (GUILayout.Button("Yeah, me too."))
{
dialogue1_1 = false;
dialogue1_2a = true;
}
if (GUILayout.Button("Really? I'm rather excited!"))
{
dialogue1_1 = false;
dialogue1_2b = true;
}
}
if (dialogue1_2a)
{
if (GUILayout.Button("Don't be too hard on yourself."))
{
dialogue1_2a = false;
dan01 = false;
dan01b = true;
showDialogue = false;
playerControl.canMove = true;
}
}
if (dialogue1_2b)
{
if (GUILayout.Button("You could really ease up a bit."))
{
dialogue1_2b = false;
dan01 = false;
dan01b = true;
showDialogue = false;
playerControl.canMove = true;
}
}
}
GUI.EndGroup ();
}
if (showDialogue&&dan01b){
GUI.BeginGroup (new Rect (Screen.width / 2 - 350, Screen.height / 2 + 150, 700, 140));
GUI.Box (new Rect (0,0,600,200), "");
GUILayout.Label("It's good to see you showing some compassion.");
GUI.EndGroup ();
}
}
Thank you so much; I really wasn't aware of me mixing up fixed and automatic layout. Great help!!
– clarioncat