Simple chat script behaves irregularly

I've been using PUN for quite some time now, am able to log into rooms, have several clients there running around and all that. But when I tried to add a simple in-room chat thing, I encountered some weird behavior. Here's my very minimalistic script:
public class ChatController : Photon.MonoBehaviour {

	private dfPanel   hudPanel;
	private dfTextbox chatInputTextbox;
	private dfListbox chatOutputListbox;

	void OnEnable () {
		hudPanel          = GameObject.Find( "HudPanel" ).GetComponent<dfPanel>();
		chatInputTextbox  = (dfTextbox)hudPanel.Find ( "ChatInputTextbox" );
		chatOutputListbox = (dfListbox)hudPanel.Find ( "ChatOutputListbox" );
		chatInputTextbox.IsVisible = true;

	void OnDisable () {
		chatInputTextbox.IsVisible = false;

	void Update () {
		if ( Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return) ) {
			photonView.RPC ( "AddChatText", PhotonTargets.All, chatInputTextbox.Text );
			chatInputTextbox.Text = "";

	void AddChatText ( string chatText, PhotonMessageInfo info ) {
		chatOutputListbox.AddItem( "[" + info.sender.ID + "]: " + chatText );

I've put Debug.Log all over the place, so I'm sure everything is being called as it should be, so that shouldn't be the problem. AND! It kind of works, but irregularly.

When I press "T" on my keyboard, this ChatController is enabled, so it pops up on the screen, gets focus, and I can start typing away. When I press Return/Enter, the RPC is called to add the text to everyone's chatOutputListbox (DF-GUI component). The text input thing does NOT go away at this moment, but stays until I press ESC.

I can see that items (ie. text items) are being added to chatOutputListbox instantly in the inspector, but the GUI isn't being updated (not even if I force an update) UNLESS - but only sometimes - I ESC out of the input text box immediately after sending the message. That doesn't work every time either, but if I add 3-4 messages, and ESC out, they all appear all of a sudden.

So it's almost like there's a queue that's not working, or something to with OnDisable() on the chatInputTextbox that triggers some kind of update, or something or something. :) Any good ideas are appreciated!


  • From you report looks like problem with chatOutputListbox updates, not with PUN.
    Are you sure that your controls work fine when updated other than from RPC?
  • It turns out it was a bug in DF-GUI which caused this. Sorry for not checking that earlier. :(
  • No problem :)
    Glad that you find the bug.
Sign In or Register to comment.