RaiseEvents error: NotImplementedException

Options
I am trying to integrate RaiseEvents in Unity. I have set up the code from official tutorials from Photon documentation but I get this weird error which I don't know why. But I have successfully setup the photon view, RPC service but RaiseEvents is not working. The error I get is pasted below. THe code is also posted below. I am accessing the function SendMessageToAll from button click event.

NotImplementedException: The method or operation is not implemented.
Photon.Pun.PhotonNetwork.RaiseEvent (System.Object moveUnitsToTargetPositionEventCode, System.Object[] content, Photon.Realtime.RaiseEventOptions raiseEventOptions, System.Object sendReliable) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:33)
HoloLensEventManager.SendMessageToAll () (at Assets/Scripts/HoloLensEventManager.cs:50)
HoloLensEventManager.Awake () (at Assets/Scripts/HoloLensEventManager.cs:26)


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using ExitGames.Client.Photon;
using Photon.Pun;
using Photon.Realtime;
using TMPro;


public class HoloLensEventManager : MonoBehaviour
{
    public static HoloLensEventManager instance;

    [SerializeField]
    private TMP_InputField MessageField;
    
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            instance.SendMessageToAll();
            DontDestroyOnLoad(gameObject);
        }
    }

    private void OnEnable()
    {
        PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
    }

    private void OnDisable()
    {
        PhotonNetwork.NetworkingClient.EventReceived -= OnEvent;
    }

    private enum MessageType:byte
    {
        Hello
    }

    public void SendMessageToAll()
    {
        object[] content = new object[] { instance.MessageField.text };
        RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.All }; // You would have to set the Receivers to All in order to receive this event on the local client as well
        PhotonNetwork.RaiseEvent(MessageType.Hello, content, raiseEventOptions, SendOptions.SendReliable);
        HoloLensLogs.instance.UpdateLogs($"Message Sent!");
        Debug.Log("HELLO");
        instance.MessageField.text = "";
    }

    #region EventListener
    public void OnEvent(EventData photonEvent)
    {
        byte eventCode = photonEvent.Code;
        object[] data = (object[]) photonEvent.CustomData;
        if (eventCode == (byte)MessageType.Hello)
        {
            string msg = (string)data[0];
            Debug.Log(msg);
            HoloLensLogs.instance.UpdateLogs($"Message Received: {msg}");
        }
    }
    #endregion
}

Comments

  • Tobias
    Options
    Does instance.MessageField.text access a string? You could send that as is. No need to wrap it in object[].
    MessageType.Hello is a byte, I guess? Otherwise, it should not work...

    RaiseEvent (System.Object moveUnitsToTargetPositionEventCode, System.Object[] content, Photon.Realtime.RaiseEventOptions raiseEventOptions, System.Object sendReliable) is not some code that's normally in PUN, right? Did you add that??
    Then we can't support that.