Getting an error when trying to publish a message.
Options
Chum
✭
in Photon Chat
Heres the error I'm getting:
NullReferenceException: Object reference not set to an instance of an object
PhotonChatManager.SubmitPublicChatOnClick () (at Assets/Scripts/PhotonChatManager.cs:88)
This is my code at line 88:
public void SubmitPublicChatOnClick()
{
if (privateReceiver == "")
{
Debug.Log(currentChat);
line88--> chatClient.PublishMessage("RegionChannel", currentChat);
chatField.text = "";
currentChat = "";
}
}
NullReferenceException: Object reference not set to an instance of an object
PhotonChatManager.SubmitPublicChatOnClick () (at Assets/Scripts/PhotonChatManager.cs:88)
This is my code at line 88:
public void SubmitPublicChatOnClick()
{
if (privateReceiver == "")
{
Debug.Log(currentChat);
line88--> chatClient.PublishMessage("RegionChannel", currentChat);
chatField.text = "";
currentChat = "";
}
}
0
Comments
-
Hi @Chum,
Thank you for choosing Photon!
The exception is in your custom code (PhotonChatManager is your own custom class).
So I'm guessing chatClient is null at that point and needs to be initialized (chatClient = new ChatClient...)
Hi, where should I put this? I already have a:
ChatClient chatClient;
chatClient = new ChatClient gives me a error.0