Issue with RaiseEvent

Options
cyrus
cyrus
Hello,

So I have this background UI object (rawImage) that I want to change, this is in lue of changing scenes, I just switch out the background.

Anyway I call a RaiseEvent(); and keep getting back this error:

Exception: Write failed. Custom type not found: UnityEngine.UI.RawImage
ExitGames.Client.Photon.Protocol18.WriteCustomType (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, System.Boolean writeType) (at


I thought it was with BKGRD_CHANGE_EVENT at first, but byte is a type allowed according to documentation, and further study of the exception mentions the rawImage.... (it was formerly a texture2D.. i changed to test)

btw, BKGRD_CHANGE_EVENT in code is:
private const byte BKGRD_CHANGE_EVENT = 0;

Code that causes issue:
            if (base.photonView.IsMine)
            {
                Texture2D tex = Rooms[this.roomIndex].getImage();
                setbackground(tex);

                RawImage img = this.background;

                object[] _datas = new object[] { (object)img };

                //sends custom event... sends the background object and the texture
                PhotonNetwork.RaiseEvent(BKGRD_CHANGE_EVENT, _datas, RaiseEventOptions.Default, SendOptions.SendReliable);
            }

-- sorry for bad formatting, not sure how to better format for code

Comments

  • cyrus
    Options
    Also the cast to (object) inside the object array was me fiddling around!
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited November 2019
    Options
    Hi @cyrus,

    Thank you for choosing Photon!

    Photon can only exchange data of types that the serialization protocol supports.
    You can, however, register custom types. But you need to do it explicitly before trying to send that type.

    For exchanging images: in case you have the same image on all client builds, why not send a reference to it instead, like its name or ID or path and then the receiving client can guess that image and load it.

    Read more here.