Beispiel #1
0
    private void OnGUI()
    {
        if (!TwitchPlaySettings.data.TwitchPlaysDebugEnabled)
        {
            return;
        }

        GUILayout.BeginArea(new Rect(50, Screen.height - 75, (Screen.width - 50) * 0.2f, 25));
        GUILayout.BeginHorizontal();
        _inputCommand = GUILayout.TextField(_inputCommand, GUILayout.MinWidth(50));
        if ((GUILayout.Button("Send") || Event.current.keyCode == KeyCode.Return) && !string.IsNullOrEmpty(_inputCommand))
        {
            if (_inputCommand.Equals(DebugSequence))
            {
                TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled;
                TwitchPlaySettings.WriteDataToFile();
                _inputCommand = "";
                GUILayout.EndHorizontal();
                GUILayout.EndArea();
                return;
            }
            IRCConnection.SetDebugUsername();
            IRCConnection.SendMessage(_inputCommand);
            IRCConnection.ReceiveMessage(IRCConnection.Instance.UserNickName, IRCConnection.Instance.CurrentColor, _inputCommand);
            _inputCommand = "";
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
    private void SetupChatSimulator()
    {
        chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled);
        var num = MouseControls.SCREEN_BOUNDARY_PERCENT * Screen.height + 5;

        chatSimulator.transform.position = new Vector3(num, num, 0);

        var messageInput = chatSimulator.Traverse <InputField>("MessageInput");
        var sendButton   = chatSimulator.Traverse <Button>("SendButton");

        messageInput.onEndEdit.AddListener(_ =>
        {
            if (Input.GetKey(KeyCode.Return))
            {
                sendButton.onClick.Invoke();
                messageInput.ActivateInputField();
            }
        });

        sendButton.onClick.AddListener(() =>
        {
            var message = messageInput.text;
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            if (message.Equals(DebugSequence))
            {
                TwitchPlaySettings.data.TwitchPlaysDebugEnabled = !TwitchPlaySettings.data.TwitchPlaysDebugEnabled;
                TwitchPlaySettings.WriteDataToFile();

                chatSimulator.SetActive(TwitchPlaySettings.data.TwitchPlaysDebugEnabled);
            }
            else
            {
                IRCConnection.SetDebugUsername();
                IRCConnection.SendMessage(message);
                IRCConnection.ReceiveMessage(IRCConnection.Instance.UserNickName, IRCConnection.Instance.CurrentColor, message);
            }

            messageInput.text = "";
        });
    }