I combined the two scripts and only one window will show at a time even though both booleans are true.
public class MageSelectedInfo : MonoBehaviour {
public GUISkin thisSkin;
Rect windowRect = new Rect(20, 20, 250, 45);
public int Mage = 5;
public int oMage = 5;
public string[] toolbarStrings = new string[] { "BlackMage", "BlueMage", "GreenMage", "RedMage", "WhiteMage"};
public Object[] magePrefabs;
public GameObject playerSelection;
public GameObject currentSelection;
float heightPos;
float widthPos;
//This is for the info screen
Rect windowRect01 = new Rect(20, 20, 250, 45);
public string mageName;
public string mageInformation;
float height01 = Screen.height / 2 - 15;
float width01 = Screen.width / 2.5f;
float posX01;
float posY01;
bool MageButtonsGUI;
bool MageInfoGUI;
float offestY;
float offestZ;
MageSelectionVariables mageVars;
MageTextInfo mageText;
// Use this for initialization
void Start ()
{
Intialize();
}
void Intialize()
{
posX01 = Screen.width * 0.2f;
posY01 = height01/2 + 20;
mageVars = GetComponent<MageSelectionVariables>();
mageText = GetComponent<MageTextInfo>();
//this is for the toolbar window that has 5 buttons
heightPos = (Screen.height * .75f);
widthPos = (Screen.width * .5f)-225;
magePrefabs = Resources.LoadAll("MagePrefabs", typeof(GameObject));
playerSelection = GameObject.FindGameObjectWithTag("DnD");
}
// Update is called once per frame
void Update ()
{
checkForEnable();
checkForCharecterChange();
UpdateToolbarWindow();
checkMageColor();
upDateInfoWindow();
checkCurMage();
}
void checkForEnable()
{
if (mageVars.CurrentProgression == MageSelectionVariables.Progression.creatingCharecter)
MageButtonsGUI = true;
}
void checkMageColor(){
if (Mage == 0){mageInformation = mageText.blackMage; }
if (Mage == 1){mageInformation = mageText.blueMage; }
if (Mage == 2){mageInformation = mageText.greenMage; }
if (Mage == 3){mageInformation = mageText.redMage; }
if (Mage == 4){mageInformation = mageText.whiteMage; }
}
void checkCurMage()
{
if (currentSelection != null)
{
GameObject curMage = currentSelection;
mageName = curMage.GetComponent<CommonName>().ThisCommonName;
mageVars.defaultMaxHealth = curMage.GetComponent<Health>().health;
mageVars.defaultMaxMana = curMage.GetComponent<PlayerInfo>().maxMana;
mageVars.minB_Damage = curMage.GetComponent<PlayerInfo>().minBonus_Damage;
mageVars.maxB_Damage = curMage.GetComponent<PlayerInfo>().maxBonus_Damage;
mageVars.defaultCriticalChance = curMage.GetComponent<PlayerInfo>().Critical_Chance;
mageVars.defaultCriticalBonus = curMage.GetComponent<PlayerInfo>().Critical_Bonus;
mageVars.defaultCasting_Speed_Bonus = curMage.GetComponent<PlayerInfo>().Casting_Speed_Bonus;
mageVars.defaultGathering_Bonus = curMage.GetComponent<PlayerInfo>().Gathering_Bonus;
mageVars.defaultConcentration = curMage.GetComponent<PlayerInfo>().Casting_Concentration;
MageInfoGUI = true;
}
}
void upDateInfoWindow()
{
height01 = Screen.height * 0.55f;
width01 = Screen.width * 0.55f;
posX01 = Screen.width * 0.45f;
posY01 = Screen.height * 0.0005f;
windowRect01 = new Rect(posX01, posY01, width01, height01);
}
void UpdateToolbarWindow()
{
float width = Screen.width * .85f;
float height = Screen.height * .35f;;
float posX = Screen.width * .075f;;
float posY = Screen.height * 0.65f;
windowRect = new Rect(posX, posY, width, height);
}
void checkForCharecterChange()
{
if (Mage != oMage)
{
if ( currentSelection != null)
{
Destroy(currentSelection);
}
GameObject mageSelected = Instantiate(magePrefabs[Mage], transform.position, transform.rotation) as GameObject;
oMage = Mage;
currentSelection = mageSelected;
}
}
void OnGUI()
{
GUI.skin = thisSkin;
if (MageButtonsGUI)
DrawMageButtons();
//now adjust to the group. (0,0) is the topleft corner of the group.
GUI.BeginGroup (new Rect (0,0,100,100));
// End the group we started above. This is very important to remember!
GUI.EndGroup ();
if (MageInfoGUI)
DrawInfoScreen();
//now adjust to the group. (0,0) is the topleft corner of the group.
GUI.BeginGroup (new Rect (0,0,100,100));
// End the group we started above. This is very important to remember!
GUI.EndGroup ();
}
#region this is the group for the Mage toolbar on lower third of the screen
void DrawMageButtons()
{
windowRect = GUILayout.Window(0, windowRect, drawMageSelectionTile, "", GUILayout.MinHeight(250));
}
void drawMageSelectionTile (int WindowID)
{
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
//GUILayout.EndVertical();
GUILayout.BeginHorizontal();
Mage = GUILayout.Toolbar ( Mage, toolbarStrings);
GUILayout.EndHorizontal();
//GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}
#endregion
#region this is the group for the Info screen on the right side
void DrawInfoScreen()
{
windowRect01 = GUILayout.Window(0, windowRect01, drawMageSelectedInfo, "", GUILayout.MinHeight(250));
}
void drawMageSelectedInfo(int WindowID)
{
GUILayout.BeginVertical();
GUILayout.Space(40);
//GUILayout.Space(8);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label("" + mageName , "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Health: " + mageVars.defaultMaxHealth + " " , "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.Label("Mana: " + mageVars.defaultMaxMana + " ", "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Critical Chance: " + mageVars.defaultCriticalChance + "%", "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.Label( "Critical Bonus: " + mageVars.defaultCriticalBonus + "%", "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Bonus Damamage: " + mageVars.minB_Damage + "-" + mageVars.maxB_Damage, "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.Label( "Concentration Bouns " + mageVars.defaultConcentration, "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.Label("Casting Bonus: " + mageVars.defaultCasting_Speed_Bonus, "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.Label( "Gathering Bonus: " + mageVars.defaultGathering_Bonus, "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
GUILayout.Label( " " + mageInformation , "LegendaryText");
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
GUILayout.EndVertical();
}
#endregion
}