x


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?

more ▼

asked Jun 22 '11 at 08:04 AM

Moonlight gravatar image

Moonlight
18 5 5 9

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
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.

more ▼

answered Jun 27 '11 at 10:36 AM

sriram90 gravatar image

sriram90
460 33 37 47

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 isMaffiaVote : boolean; will be changed through another script. It should then turn off one window and turn the other on.

Jun 28 '11 at 01:00 AM Moonlight
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3695
x1951
x789
x261
x138

asked: Jun 22 '11 at 08:04 AM

Seen: 1103 times

Last Updated: Jun 28 '11 at 01:00 AM