Example #1
0
    //发送好友消息回调
    private void OnMsgSendMessageToFriend(Request request)
    {
        MsgSendMessageToFriend msgSendMessageToFriend = MsgSendMessageToFriend.Parser.ParseFrom(request.Msg);
        GameObject             messagePrefab;

        if (msgSendMessageToFriend.Result == 1)
        {
            PanelManager.Open <TipPanel>("发送失败");
            return;
        }
        if (msgSendMessageToFriend.Id != GameMain.id)
        {
            messagePrefab = ABManager.Instance.LoadRes <GameObject>("prefab/ui", "OtherMessagePanel");
        }
        else
        {
            messagePrefab = ABManager.Instance.LoadRes <GameObject>("prefab/ui", "MyMessagePanel");
        }
        GameObject message = (GameObject)Instantiate(messagePrefab);

        message.transform.SetParent(worldContent.transform, false);
        message.transform.Find("Text").GetComponent <Text>().text = msgSendMessageToFriend.Message;

        Debug.Log(msgSendMessageToFriend.Id + msgSendMessageToFriend.Message);
    }
Example #2
0
    private void OnSendClick()
    {
        //世界频道
        MsgSendMessageToFriend msgSendMessageToFriend = new MsgSendMessageToFriend();

        msgSendMessageToFriend.Message = input.transform.Find("Text").GetComponent <Text>().text;
        input.transform.Find("Text").GetComponent <Text>().text = "";
        input.GetComponent <InputField>().text = "";
        msgSendMessageToFriend.Id       = GameMain.id;
        msgSendMessageToFriend.FriendId = nameText.text;
        NetManager.Send(msgSendMessageToFriend);
    }