void OnGUI()
    {
        //TestGUI();

        if (stage == 0)         //Stage 0 is the login screen
        {
            LoginScreen();
        }         //end of stage 0


        if (stage == 1)        //stage 1 is the character selection screen
        {
            if (generator == null)
            {
                return;
            }
            GUI.enabled = usingLatestConfig && !character.animation.IsPlaying("walkin");
            GUILayout.BeginArea(new Rect(10, 10, typeWidth + 2 * buttonWidth + 8, 500));

            // Buttons for changing the active character.
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("<", GUILayout.Width(buttonWidth)))
            {
                ChangeCharacter(false);
            }

            GUILayout.Box("Character", GUILayout.Width(typeWidth));

            if (GUILayout.Button(">", GUILayout.Width(buttonWidth)))
            {
                ChangeCharacter(true);
            }

            GUILayout.EndHorizontal();

            // Buttons for changing character elements.
            AddCategory("face", "Head", null);
            AddCategory("eyes", "Eyes", null);
            AddCategory("hair", "Hair", null);
            AddCategory("top", "Body", "item_shirt");
            AddCategory("pants", "Legs", "item_pants");
            AddCategory("shoes", "Feet", "item_boots");


            // Buttons for saving and deleting configurations.
            // In a real world application you probably want store these
            // preferences on a server, but for this demo configurations
            // are saved locally using PlayerPrefs.
            if (GUILayout.Button("Save Configuration"))
            {
                PlayerPrefs.SetString(prefName, generator.GetConfig());
            }

            if (GUILayout.Button("Delete Configuration"))
            {
                PlayerPrefs.DeleteKey(prefName);
            }

            // Show download progress or indicate assets are being loaded.
            GUI.enabled = true;
            if (!usingLatestConfig)
            {
                float  progress = generator.CurrentConfigProgress;
                string status   = "Loading";
                if (progress != 1)
                {
                    status = "Downloading " + (int)(progress * 100) + "%";
                }
                GUILayout.Box(status);
            }

            GUILayout.EndArea();

            /*
             *      if(GUI.Button(new Rect(Screen.width-190,Screen.height-140,180,60), "Unlock Customizations"))
             *
             *      {
             *              Unlock uk = GameObject.Find("Unlock").GetComponent<Unlock>();
             *              uk.UnlockEnabled = true;
             *              stage = 2;
             *      }
             */

            if (GUI.Button(new Rect(Screen.width - 190, Screen.height - 70, 180, 60), "Purchase Current Selections"))

            {
                StoreFront sf = GameObject.Find("StoreFront").GetComponent <StoreFront>();
                sf.SetStoreFrontProductPrice();
                sf.StoreFrontEnabled = true;
                stage = 2;
            }
        }    //end of stage 1

        if (stage == 5)
        {
            int confirmButtonX = Screen.width / 2 - 65;
            int confirmButtonY = Screen.height / 2;
            GUI.Box(new Rect(confirmButtonX - 25, confirmButtonY - 20, 280, 100), "Your purchase has been proccessed. \n Thank you for shopping with Co-Op and Co!");

            if (GUI.Button(new Rect(confirmButtonX + 75, confirmButtonY + 20, 80, 40), "Contiune"))
            {
                stage = 1;
            }
        }
    }