Example #1
0
    void DrawMenu()
    {
        //if (GUILayout.Button(new GUIContent("IM", (isChatWindowVisible ? "Close" : "Open") + " Private Chat Window"), GUILayout.Width(40)))
        //{
        //    SoundManager.Inst.PlayClick();
        //    isChatWindowVisible = !isChatWindowVisible;
        //    setFocusOnInput = 3; // force focus for 3 cycles, just one cycle was losing focus.
        //}

        if (consoleGui && IsVisible(GUIVis.CONSOLE) && GameManager.Inst.LevelLoaded != GameManager.Level.AVATARSELECT)
        {
            consoleGui.DrawConsoleInput();
        }

        // Base button for native gui button elements.
        Rect nativeConsoleButtonRect = new Rect(ConsoleGUI.consoleLeftIndent + ConsoleGUI.consoleWidth + gutter, Screen.height - (ConsoleGUI.consoleBottomIndent + ConsoleGUI.consoleBarHeight), 120, ConsoleGUI.consoleBarHeight);

        if (IsVisible(GUIVis.VOICE))
        {
            // disable voice options if no mic is available
            GUI.enabled = Microphone.devices.Length != 0;

            if (VoiceManager.Inst.AllowVoiceToggle)
            {
                if (GUI.Button(nativeConsoleButtonRect, new GUIContent("Toggle Voice " + ((VoiceManager.Inst.ToggleToTalk) ? "Off" : "On"), "Click to turn voice chat " + ((VoiceManager.Inst.ToggleToTalk) ? "off" : "on"))))
                {
                    VoiceManager.Inst.ToggleToTalk = !VoiceManager.Inst.ToggleToTalk;
                }
                // Shunt rect over for next button.
                nativeConsoleButtonRect.x += nativeConsoleButtonRect.width + 5;
            }
            if (!VoiceManager.Inst.ToggleToTalk)
            {
                nativeConsoleButtonRect.width          = 80;
                VoiceManager.Inst.PushToTalkButtonDown = GUI.Button(nativeConsoleButtonRect, new GUIContent("VoicePush", "Push and hold to talk")) || Input.GetButton("PushToTalk");
            }

            GUI.enabled = true;
        }

        // Button overrides
        else if (!VoiceManager.Inst.ToggleToTalk && (Input.GetButton("PushToTalk") || Input.GetButton("PushToTalkAlt")))
        {
            pushToTalkKeyPressed = true;
            VoiceManager.Inst.PushToTalkButtonDown = true;
        }
        else if (pushToTalkKeyPressed) // need to allow for the gui layer to control PushToTalkButtonDown, so only change to false if unity input changed to true.
        {
            pushToTalkKeyPressed = false;
            VoiceManager.Inst.PushToTalkButtonDown = false;
        }

        // Show avatar modification button.
        if (IsVisible(GUIVis.AVATARBUTTON))
        {
            nativeConsoleButtonRect.x    += nativeConsoleButtonRect.width + 5;
            nativeConsoleButtonRect.width = 130;
            //"Change the appearance of your avatar"
            if (GUI.Button(nativeConsoleButtonRect, "Change Avatar"))
            {
                GameManager.Inst.LoadLevel(GameManager.Level.AVATARSELECT);
            }
        }
    }