P
P
ProgramDevel2020-10-01 18:44:42
Unity
ProgramDevel, 2020-10-01 18:44:42

Why does it only show a message for one player?

For some reason, the message comes only to one user, and the second does not receive it

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;

public class Nick : MonoBehaviour,  IPunObservable
{
  private PhotonView photonView;
  public Text t;
  public InputField field;

  private string chat;

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
       if (stream.IsWriting)
       {
            stream.SendNext(chat);
       }
       else
       {
            chat = (string) stream.ReceiveNext();
       }         
    }

    private void Start()
    {
    	photonView = GetComponent<PhotonView>();
    }   

    private void Update(){
    	if (photonView.IsMine == false){
    		t.text = chat;
    		return;
    	}
    }

    public void ButtonSend(){
    	chat = field.text;
    	t.text = chat;
    }
}


Many thanks to anyone who can help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question