Spellbook.OnGUI C# (CSharp) Method

OnGUI() public method

public OnGUI ( ) : void
return void
    void OnGUI()
    {
        if(enabled){

                        displayCurrentPage();

            if (GUI.Button (new Rect (Screen.width - 200,30,130,65), "Back", button_style))
            {
                enabled = false;
                previous_state.active = true;
                setNoCopyDisplay(false);
            }

            if (!noCopyDisplay && (canCopyAll || currentPage().getName() == "MySpell" || currentPage().getName() == "Flame")) {
                GUIStyle copy_button_style = new GUIStyle();
                copy_button_style.normal.background = copy_button_texture;
                copy_button_style.normal.textColor = Color.black;
                copy_button_style.active.textColor = new Color(0.75f,0.75f,0.75f);
                copy_button_style.alignment = TextAnchor.MiddleCenter;
                copy_button_style.fontSize = 30;

                if (GUI.Button (new Rect (Screen.width * 0.17f, Screen.height * 0.86f, 210, 50), "Copy", copy_button_style)){
                    enabled = false;
                    previous_state.active = true;

                    givePlayerAScroll();

                    SpellCopied(currentPage());
                }
            }
                        //code to use Left and Right keys to move through spellbook

                        if(current_page != 0 && Input.GetKey(KeyCode.LeftArrow))
                        {
                                current_page--;
                                PageTurnedBackward(currentPage());
                                logCurrentPage();

                        }
                        if(current_page != pages.Count - 1 && Input.GetKey(KeyCode.RightArrow))
                        {
                                current_page++;
                                PageTurnedForward(currentPage());
                                logCurrentPage();
                        }

                        GUIStyle prev_button_style = new GUIStyle();
                        prev_button_style.normal.background = prev_button_texture;
                        if(current_page != 0 && GUI.Button (new Rect (Screen.width * 0.025f, Screen.height * 0.5f, 35, 35), "", prev_button_style))
                        {
                                current_page--;
                                PageTurnedBackward(currentPage());
                                logCurrentPage();
                        }

                        GUIStyle next_button_style = new GUIStyle();
                        next_button_style.normal.background = next_button_texture;

                        if(current_page != pages.Count - 1 && GUI.Button (new Rect (Screen.width * 0.95f, Screen.height * 0.5f, 35, 35), "", next_button_style))
                        {
                                current_page++;
                                PageTurnedForward(currentPage());
                                logCurrentPage();
                        }

                        // make it so that we can't click through to the game
                        // NOTE: This must appear LAST in the OnGUI. Otherwise, other buttons won't work!
                    GUI.Button(new Rect(0,0,Screen.width,Screen.height), "", empty_style);
                }
    }