Answer the question
In order to leave comments, you need to log in
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;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question