public void SendText(NetworkInstanceId senderNetId, string text)
    {
        var go = Instantiate(textLinePrefab) as GameObject;

        go.transform.SetParent(scrollViewContent.transform, false);
        go.GetComponent <TextMeshProUGUI>().text = text;
        scrollView.velocity = new Vector2(0.0f, 1000.0f);
        var localPlayer = NetworkingUtils.GetHumanLocalPlayer();

        if (senderNetId == localPlayer.netId)
        {
            go.GetComponent <TextMeshProUGUI>().color = playerTextColor;
        }
        else
        {
            go.GetComponent <TextMeshProUGUI>().color = opponentTextColor;
        }
    }
    public void SubmitText()
    {
        var localPlayer = NetworkingUtils.GetHumanLocalPlayer();

        if (localPlayer != null)
        {
            var msg = new SendChatTextMessage();
            msg.senderNetId = localPlayer.netId;
            msg.text        = inputField.text;
            if (msg.text.Length > maxChatMessageLength)
            {
                msg.text = msg.text.Substring(0, maxChatMessageLength);
            }
            NetworkManager.singleton.client.Send(NetworkProtocol.SendChatTextMessage, msg);
            inputField.text = string.Empty;
            inputField.ActivateInputField();
        }
    }
Example #3
0
 /// <summary>
 /// Called when the game starts.
 /// </summary>
 /// <param name="msg">Start game message.</param>
 public override void OnStartGame(StartGameMessage msg)
 {
     base.OnStartGame(msg);
     humanPlayer = NetworkingUtils.GetHumanLocalPlayer();
 }