void OnGUI()
    {
        scale.x = Screen.width / origWidth;
        scale.y = Screen.height / origHeight;
        scale.z = 1;
        Matrix4x4 lastMat = GUI.matrix;

        GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);



        if (mode == GUIMode.GAME)
        {
            //draw the abilities overlay and ability icons
            DrawAbilityIcons();


            /*
             * GUI.DrawTexture(new Rect(healthBarDefault.x,healthBarDefault.y
             *                       ,healthBarDefault.height,healthBarDefault.height),
             *              healthBarIcon);
             * GUI.DrawTexture(new Rect(healthBarDefault.x + healthBarDefault.height,healthBarDefault.y,
             *                       healthBarDefault.width,healthBarDefault.height),
             *              healthBarBacking,ScaleMode.StretchToFill);
             * GUI.DrawTexture(new Rect(healthBarDefault.x + healthBarDefault.height,healthBarDefault.y,
             *                       healthBarDefault.width*percentHealth,healthBarDefault.height),
             *              healthBarTexture,ScaleMode.StretchToFill);
             */

            //draw the resources
            float barWidth  = 200;
            float barHeight = 40;
            GUI.BeginGroup(new Rect(10, 10, barWidth, 800));
            //draw the player's health bar
            float percentHealth = pCont.currentHealth / pCont.maxHealth;
            GUI.DrawTexture(new Rect(0, 0, barHeight, barHeight),
                            healthBarIcon);
            GUI.DrawTexture(new Rect(barHeight, 0, barWidth, barHeight),
                            healthBarBacking, ScaleMode.StretchToFill);
            GUI.DrawTexture(new Rect(barHeight, 0, barWidth * percentHealth, barHeight),
                            healthBarTexture, ScaleMode.StretchToFill);
            //draw the xp
            GUI.Label(new Rect(0, barHeight, 100, 30), "XP " + pCont.xp, skin.GetStyle("XPDisplay"));

            GUI.EndGroup();



            if (paused)
            {
                GUI.DrawTexture(new Rect(0, 0, origWidth, origHeight), pauseOverlay);
            }
        }
        else if (mode == GUIMode.ABILITY_PREVIEW)
        {
            if (paused)
            {
                GUI.DrawTexture(new Rect(0, 0, origWidth, origHeight), pauseOverlay);
            }
            float groupWidth  = 880;
            float groupHeight = 720;
            float titleHeight = 100;
            //main group
            GUI.BeginGroup(new Rect(200, 0, 880, 720));
            GUI.DrawTexture(new Rect(0, 0, 880, 720), abilityPreviewOverlay);
            //title
            GUI.Label(new Rect(0, 0, 400, titleHeight),
                      lastReceivedAbility.abilityName, skin.FindStyle("AbilityName"));
            //icon
            DrawRotatedTexture(new Rect(200, titleHeight + 50, 200, 200), lastReceivedAbility.icon.texture, -10);
            //Description group
            GUI.BeginGroup(new Rect(500, titleHeight, 380, groupHeight - titleHeight));
            GUI.Label(new Rect(0, 0, 380, 50), "Active", skin.FindStyle("SubTitle"));
            if (lastReceivedAbility.activeDescription != null)
            {
                GUI.TextArea(new Rect(0, 50, 380, 150),
                             lastReceivedAbility.activeDescription.text, skin.FindStyle("DescriptiveText"));
            }
            GUI.Label(new Rect(0, 200, 380, 50), "Upgrade", skin.FindStyle("SubTitle"));
            if (lastReceivedAbility.upgradeDescription != null)
            {
                GUI.TextArea(new Rect(0, 250, 380, 150),
                             lastReceivedAbility.upgradeDescription.text, skin.FindStyle("DescriptiveText"));
            }
            GUI.Label(new Rect(0, 400, 380, 50), "Passive", skin.FindStyle("SubTitle"));
            if (lastReceivedAbility.passiveDescription != null)
            {
                GUI.TextArea(new Rect(0, 450, 380, 150),
                             lastReceivedAbility.passiveDescription.text, skin.FindStyle("DescriptiveText"));
            }
            GUI.EndGroup();
            //Help text group
            GUI.BeginGroup(new Rect(100, 500, 500, 220));
            GUI.TextArea(new Rect(0, 0, 500, 220),
                         "Press Q,W,E,R to assign\n\n" +
                         "Press LCTRL+(Q,W,E,R) to upgrade an ability\n\n" +
                         "Press (BACKSPACE) to manage abilities\n\n" +
                         "Press (ESC) to continue", skin.FindStyle("DescriptiveText"));
            GUI.EndGroup();

            GUI.EndGroup();
            if (paused)
            {
                GUI.DrawTexture(new Rect(0, 0, origWidth, origHeight), pauseOverlay);
            }
        }
        else if (mode == GUIMode.ABILITY_MENU)
        {
            if (paused)
            {
                GUI.DrawTexture(new Rect(0, 0, origWidth, origHeight), pauseOverlay);
            }
            //draw the abilities overlay and ability icons
            DrawAbilityIcons();
            //draw the abilities area

            numAbilities = abCont.allAbilities.Count;

            Color tmpColor = GUI.color;
            GUI.BeginGroup(new Rect(50, 80, 720, 480));
            GUI.DrawTexture(new Rect(0, 0, 720, 480), abilityPreviewOverlay, ScaleMode.StretchToFill);
            abMenuPosition = GUI.BeginScrollView(new Rect(0, 0, 720, 480), abMenuPosition, new Rect(0, 0, 720, abMenuHeight));
            for (int i = 0; i < abCont.allAbilities.Count; i++)
            {
                Ability ab = abCont.allAbilities[i];
                if (abCont.InUse(ab))
                {
                    GUI.color = Color.gray;
                }
                else
                {
                    GUI.color = tmpColor;
                }
                int  x      = i % abMenuRowSize;
                int  y      = i / abMenuRowSize;
                Rect abRect = new Rect((x + 1) * iconMargin + x * iconSize, (y + 1) * iconMargin + y * iconSize, iconSize, iconSize);
                GUI.Box(abRect, "");
                GUI.DrawTexture(abRect, blankWhite);
                //change the selected if an ability is clicked
                if (GUI.Button(abRect, ab.icon.texture))
                {
                    abMenuSelected = i;
                }
            }
            GUI.color = tmpColor;
            //draw the selection box
            int left = abMenuSelected % abMenuRowSize;
            int top  = abMenuSelected / abMenuRowSize;
            GUI.DrawTexture(new Rect((left + 1) * iconMargin + left * iconSize, (top + 1) * iconMargin + top * iconSize, iconSize, iconSize),
                            abMenuSelection);
            GUI.EndScrollView();
            GUI.EndGroup();
            //draw the ability description area
            GUI.BeginGroup(new Rect(820, 80, 410, 480));
            GUI.DrawTexture(new Rect(0, 0, 410, 480), abilityPreviewOverlay, ScaleMode.StretchToFill);

            GUI.Label(new Rect(0, 0, 410, 40), abCont.allAbilities[abMenuSelected].abilityName, skin.GetStyle("AbilityName"));

            GUI.Label(new Rect(0, 40, 410, 20), "Active Effect", skin.GetStyle("SubTitle"));
            if (abCont.allAbilities[abMenuSelected].activeDescription != null)
            {
                GUI.TextArea(new Rect(0, 60, 410, 90), abCont.allAbilities[abMenuSelected].activeDescription.text,
                             skin.GetStyle("DescriptiveText"));
            }

            GUI.Label(new Rect(0, 150, 410, 20), "Upgrade Effect", skin.GetStyle("SubTitle"));
            if (abCont.allAbilities[abMenuSelected].upgradeDescription != null)
            {
                GUI.TextArea(new Rect(0, 170, 410, 90), abCont.allAbilities[abMenuSelected].upgradeDescription.text,
                             skin.GetStyle("DescriptiveText"));
            }

            GUI.Label(new Rect(0, 260, 410, 20), "Passive Effect", skin.GetStyle("SubTitle"));
            if (abCont.allAbilities[abMenuSelected].passiveDescription != null)
            {
                GUI.TextArea(new Rect(0, 280, 410, 90), abCont.allAbilities[abMenuSelected].passiveDescription.text,
                             skin.GetStyle("DescriptiveText"));
            }

            if (abCont.allAbilities[abMenuSelected].improvements != null)
            {
                GUI.Label(new Rect(0, 370, 410, 20), "Improvements", skin.GetStyle("SubTitle"));
                GUI.BeginGroup(new Rect(0, 390, 410, 110));

                List <Improvement> improvements = abCont.allAbilities[abMenuSelected].improvements;
                int xp = pCont.xp;
                for (int i = 0; i < improvements.Count; i++)
                {
                    Improvement imp = improvements[i];
                    GUI.Label(new Rect(0, 20 * i, 200, 20), imp.displayName, skin.GetStyle("DescriptiveText"));
                    GUIUtility.PointStripDisplay(new Rect(220, 20 * i, 240, 20), 20,
                                                 imp.maxPoints, imp.pointsAllocated - 1, impOn, impOff);
                    if (xp >= imp.costPerPoint &&
                        GUI.Button(new Rect(380, 20 * i, 20, 20), "", skin.GetStyle("ImpButton")))
                    {
                        abCont.allAbilities[abMenuSelected].improveAttribute(i);
                        pCont.xp -= imp.costPerPoint;
                    }
                }
                GUI.EndGroup();
            }
            GUI.EndGroup();

            GUI.BeginGroup(new Rect(910, 600, 320, 90));
            GUI.DrawTexture(new Rect(0, 0, 320, 90), abilityPreviewOverlay, ScaleMode.StretchToFill);
            GUI.Label(new Rect(0, 0, 320, 490), "XP: " + pCont.xp, skin.GetStyle("AvailXPDisplay"));
            GUI.EndGroup();

            //draw the help text area
        }


        GUI.matrix = lastMat;
    }