protected override void DrawGUI(int windowId)
    {
        float totalSpaceAvailableY = contentBounds.height; //the total space available between header and footer.

        totalSpaceAvailableY = totalSpaceAvailableY - 2*fieldHeight - 2* labelHeight - loginBoxSpacing - footerSpacing;

        Rect currentRect = new Rect(contentBounds.width/2 - fieldWidth/2, totalSpaceAvailableY/2, fieldWidth, labelHeight);

        if(networkActionInProgress)
            GUI.enabled = false;
        GUI.Label(currentRect, "Username", loginLabelStyle);
        currentRect.y += labelHeight;
        currentRect.width = fieldWidth;
        currentRect.height = fieldHeight;
        username = GUI.TextField(currentRect, username, boxStyle);
        currentRect.y+=fieldHeight;
        currentRect.y += loginBoxSpacing;
        currentRect.width = fieldWidth;
        currentRect.height = labelHeight;

        if(secondaryLogin == SecondaryLogin.None)
        {
            GUI.Label(currentRect, "Password", loginLabelStyle);
            currentRect.y += labelHeight;
            currentRect.width = fieldWidth;
            currentRect.height = fieldHeight;
            password = GUI.PasswordField(currentRect, password, '*', boxStyle);
            currentRect.y += fieldHeight;
            currentRect.y += labelHeight;
        }

        currentRect.x = 0;
        currentRect.width = contentBounds.width;
        GUI.Label(currentRect, status, statusStyle);
        currentRect.y = contentBounds.height - footerSpacing;
        GUI.Box(new Rect(0, contentBounds.height - footerSpacing, contentBounds.width, contentBounds.height), new GUIContent(""), "DefaultFooterStyle");
        currentRect.width = buttonWidth;
        currentRect.height = buttonHeight;
        currentRect.x = contentBounds.width - buttonWidth - buttonSpacing;
        currentRect.y = contentBounds.height - buttonHeight/2 - footerSpacing/2;

        if(secondaryLogin == SecondaryLogin.None)
        {
            GUI.enabled = username.Length > 0 && password.Length > 0 && !networkActionInProgress;
            if ((GUI.Button(currentRect, "Log In", buttonStyle) || ( Event.current.keyCode == KeyCode.Return)) && !networkActionInProgress)
            {

                status = "Logging in...";
                networkActionInProgress = true;
                if (saveUsername)
                {
                    PlayerPrefs.SetString(KEY_USERNAME, username);
                }
                if (savePassword)
                {
                    PlayerPrefs.SetString(KEY_PASSWORD, password);
                }
                if (Debug.isDebugBuild)
                    Debug.Log(string.Format("[Debug] Logging in as [{0}] with password [{1}].", username, password));

                roar.User.Login(username, password, OnRoarLoginComplete);
            }
            currentRect.x -= buttonWidth + buttonSpacing;

            if (GUI.Button(currentRect, "Create", buttonStyle) && !networkActionInProgress)
            {
                status = "Creating new player account...";
                networkActionInProgress = true;
                roar.User.Create(username, password, OnRoarAccountCreateComplete);
            }
            GUI.enabled = true;

            if(allowFacebookLogin)
            {
                currentRect.x -= buttonWidth + buttonSpacing;

                if (GUI.Button(currentRect, "Facebook", buttonStyle))
                {
                    drawSubheading = true;
                    subheaderName = "Facebook";
                    status = "Click 'Login' to log in through facebook or supply a username and click 'Create' to create account through facebook";
                    secondaryLogin = SecondaryLogin.Facebook;
                }
            }
            currentRect.y+= buttonSpacing + buttonHeight;
        }

        if(secondaryLogin == SecondaryLogin.Facebook)
        {

            if ((GUI.Button(currentRect, "Log In", buttonStyle) || ( Event.current.keyCode == KeyCode.Return)) && !networkActionInProgress)
            {
                lastRequestLogin = true;
                status = "Logging in through facebook...";
                networkActionInProgress = true;
                roar.Facebook.DoWebplayerLogin(OnRoarFacebookLoginComplete);
            }
            currentRect.x -= buttonWidth + buttonSpacing;

            GUI.enabled = username.Length > 0 && !networkActionInProgress;

            if (GUI.Button(currentRect, "Create", buttonStyle) && !networkActionInProgress)
            {
                lastRequestLogin = false;
                status = "Logging in to Facebook...";
                networkActionInProgress = true;
                roar.Facebook.DoWebplayerCreate(username, OnRoarFacebookCreateComplete);
            }

            currentRect.x -= buttonWidth + buttonSpacing;

            if (GUI.Button(currentRect, "Back", buttonStyle))
            {
                status = "Supply a username and password to log in or to register a new account";
                drawSubheading = false;
                secondaryLogin = SecondaryLogin.None;
            }

            currentRect.y+= buttonSpacing + buttonHeight;
            GUI.enabled = true;
        }

        GUI.enabled = true;
    }
    protected override void DrawGUI(int windowId)
    {
        float totalSpaceAvailableY = contentBounds.height;         //the total space available between header and footer.

        totalSpaceAvailableY = totalSpaceAvailableY - 2 * fieldHeight - 2 * labelHeight - loginBoxSpacing - footerSpacing;


        Rect currentRect = new Rect(contentBounds.width / 2 - fieldWidth / 2, totalSpaceAvailableY / 2, fieldWidth, labelHeight);

        if (networkActionInProgress)
        {
            GUI.enabled = false;
        }
        GUI.Label(currentRect, "Username", loginLabelStyle);
        currentRect.y     += labelHeight;
        currentRect.width  = fieldWidth;
        currentRect.height = fieldHeight;
        username           = GUI.TextField(currentRect, username, boxStyle);
        currentRect.y     += fieldHeight;
        currentRect.y     += loginBoxSpacing;
        currentRect.width  = fieldWidth;
        currentRect.height = labelHeight;

        if (secondaryLogin == SecondaryLogin.None)
        {
            GUI.Label(currentRect, "Password", loginLabelStyle);
            currentRect.y     += labelHeight;
            currentRect.width  = fieldWidth;
            currentRect.height = fieldHeight;
            password           = GUI.PasswordField(currentRect, password, '*', boxStyle);
            currentRect.y     += fieldHeight;
            currentRect.y     += labelHeight;
        }

        currentRect.x     = 0;
        currentRect.width = contentBounds.width;
        GUI.Label(currentRect, status, statusStyle);
        currentRect.y = contentBounds.height - footerSpacing;
        GUI.Box(new Rect(0, contentBounds.height - footerSpacing, contentBounds.width, contentBounds.height), new GUIContent(""), "DefaultFooterStyle");
        currentRect.width  = buttonWidth;
        currentRect.height = buttonHeight;
        currentRect.x      = contentBounds.width - buttonWidth - buttonSpacing;
        currentRect.y      = contentBounds.height - buttonHeight / 2 - footerSpacing / 2;

        if (secondaryLogin == SecondaryLogin.None)
        {
            GUI.enabled = username.Length > 0 && password.Length > 0 && !networkActionInProgress;
            if ((GUI.Button(currentRect, "Log In", buttonStyle) || (Event.current.keyCode == KeyCode.Return)) && !networkActionInProgress)
            {
                status = "Logging in...";
                networkActionInProgress = true;
                if (saveUsername)
                {
                    PlayerPrefs.SetString(KEY_USERNAME, username);
                }
                if (savePassword)
                {
                    PlayerPrefs.SetString(KEY_PASSWORD, password);
                }
                if (Debug.isDebugBuild)
                {
                    Debug.Log(string.Format("[Debug] Logging in as [{0}] with password [{1}].", username, password));
                }

                roar.User.Login(username, password, OnRoarLoginComplete);
            }
            currentRect.x -= buttonWidth + buttonSpacing;

            if (GUI.Button(currentRect, "Create", buttonStyle) && !networkActionInProgress)
            {
                status = "Creating new player account...";
                networkActionInProgress = true;
                roar.User.Create(username, password, OnRoarAccountCreateComplete);
            }
            GUI.enabled = true;

            if (allowFacebookLogin)
            {
                currentRect.x -= buttonWidth + buttonSpacing;

                if (GUI.Button(currentRect, "Facebook", buttonStyle))
                {
                    drawSubheading = true;
                    subheaderName  = "Facebook";
                    status         = "Click 'Login' to log in through facebook or supply a username and click 'Create' to create account through facebook";
                    secondaryLogin = SecondaryLogin.Facebook;
                }
            }
            currentRect.y += buttonSpacing + buttonHeight;
        }

        if (secondaryLogin == SecondaryLogin.Facebook)
        {
            if ((GUI.Button(currentRect, "Log In", buttonStyle) || (Event.current.keyCode == KeyCode.Return)) && !networkActionInProgress)
            {
                lastRequestLogin        = true;
                status                  = "Logging in through facebook...";
                networkActionInProgress = true;
                roar.Facebook.DoWebplayerLogin(OnRoarFacebookLoginComplete);
            }
            currentRect.x -= buttonWidth + buttonSpacing;

            GUI.enabled = username.Length > 0 && !networkActionInProgress;

            if (GUI.Button(currentRect, "Create", buttonStyle) && !networkActionInProgress)
            {
                lastRequestLogin        = false;
                status                  = "Logging in to Facebook...";
                networkActionInProgress = true;
                roar.Facebook.DoWebplayerCreate(username, OnRoarFacebookCreateComplete);
            }

            currentRect.x -= buttonWidth + buttonSpacing;

            if (GUI.Button(currentRect, "Back", buttonStyle))
            {
                status         = "Supply a username and password to log in or to register a new account";
                drawSubheading = false;
                secondaryLogin = SecondaryLogin.None;
            }

            currentRect.y += buttonSpacing + buttonHeight;
            GUI.enabled    = true;
        }


        GUI.enabled = true;
    }