Why does PhotonStream not work?
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Why does PhotonStream not work?
Sinx
2022-02-21 20:01:50
hey i try to syncronize the color of my players which are random and
got these error messages and i have no clue on how to solve it.
Assets\Scripts\RandomColor.cs(25,18): error CS1061: 'PhotonStream' does not contain a definition for 'isWriting' and no accessible extension method 'isWriting' accepting a first argument of type 'PhotonStream' could be found (are you missing a using directive or an assembly reference?)
Assets\Scripts\RandomColor.cs(29,23): error CS1061: 'PhotonStream' does not contain a definition for 'isReading' and no accessible extension method 'isReading' accepting a first argument of type 'PhotonStream' could be found (are you missing a using directive or an assembly reference?)
Heres the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon;
public class RandomColor : MonoBehaviourPun
{
public SpriteRenderer renderer;
public Color color;
void Start()
{
if(photonView.IsMine)
{
color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), 1f);
renderer.color = color;
}
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.isWriting)
{
stream.SendNext(color);
}
else if(stream.isReading)
{
color = (Color)stream.ReceiveNext();
}
}
}
Thanks in advance :D
Comments
The error is a compile time issue. It has nothing to do with PUN itself.
IsWriting and IsReading needs to be uppercase.
omfg im so dumb. i looked at it soooooo often and compared it to the documentation.
how...
Thanks for pointing it out
Back to top