- Home /
GUILayout Window Help
import System.Collections.Generic;
var setupController : SetUpController;
var allPlayers = new List.<GameObject>();
var townspeoplePlayers = new List.<GameObject>();
var maffiaPlayers = new List.<GameObject>();
var isMaffiaVote : boolean;
private var window = Rect(50, 50, 100, 100);
private var window2 = Rect(50, 50, 100, 100);
function Start() {
setupController = GameObject.Find("Name").GetComponent("SetUpController");
}
function Update(){
allPlayers = setupController.allPlayersList;
maffiaPlayers = setupController.mafiaList;
townspeoplePlayers = setupController.townspeopleList;
}
function OnGUI ()
{
if (isMaffiaVote){
GUILayout.FlexibleSpace();
window = GUILayout.Window (5, window, MafiaVoteWindow, "Mafia Vote");
}
else{
window2 = GUILayout.Window (4, window2, AllVoteWindow, "Vote");
}
}
function AllVoteWindow (id2 : int) {
if (!isMaffiaVote){
GUILayout.BeginVertical();
for (var ap in allPlayers)
{
if (GUILayout.Button(ap.name))
{
}
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
}
function MafiaVoteWindow (id : int) {
if (isMaffiaVote){
GUILayout.BeginVertical();
for (var tpp in townspeoplePlayers)
{
if (GUILayout.Button(tpp.name))
{
}
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
}
Both GUI windows are showing up at the same time whether or not "isMafiaVote" is true or not. I suck at GUI, can someone tell me what is going on here?
Comment
Answer by sriram90 · Jun 27, 2011 at 10:36 AM
private var window = Rect(50, 50, 100, 100);
private var window2 = Rect(200, 175, 100, 100);
try it..you're doing mistake in the position of height and width. you gave into same position of width and height.. the first 2 parameters are giving the position of width and height.
Your misunderstanding the question. I want both of the windows to be in the same spot, but I want to toggle between the two. The var is$$anonymous$$affiaVote : boolean; will be changed through another script. It should then turn off one window and turn the other on.