joined message delete time
Options
hi, I have a problem when a player joins I want that Photon sends a message as Player234 joined, but unity doesn't send me an error and nothing is on the screen.
I already had the problem solved and it worked perfectly for me but I changed it because with that code I did not know how to delete it when time passed and with this, I did know but still, nothing comes out, it helps.
and this is the code when if it worked but it was never erased
I already had the problem solved and it worked perfectly for me but I changed it because with that code I did not know how to delete it when time passed and with this, I did know but still, nothing comes out, it helps.
[System.Serializable] public class JoinMessage { public string message; public float timer = 0; } List<JoinMessage> joinMessages = new List<JoinMessage>(); void Update() { //hide message for (int i = 0; i < joinMessages.Count; i++) { if (joinMessages[i].timer > 0) { joinMessages[i].timer -= Time.deltaTime; } } } private void OnGUI() { for (int i = 0; i < joinMessages.Count; i++) { if (joinMessages[i].timer > 0) { GUI.backgroundColor = Color.black; GUI.Label(new Rect(5, Screen.height - 85 - 25 * i, 200, 500), joinMessages[i].message); GUI.skin.label.fontSize = 10; } } } [PunRPC] public void SendMessageJoinedRoom(string feed) { JoinMessage m = new JoinMessage(); m.message = feed; m.timer = 15.0f; Debug.Log(PhotonNetwork.NickName + " joined"); }this is my code
and this is the code when if it worked but it was never erased
public int index = -1; public string[] msgJoined; int NormalIndex; private void OnGUI() { GUILayout.BeginArea(new Rect(Screen.width - 85, 25, 200, 500)); GUI.skin.label.fontSize = 10; foreach (string msg in msgJoined) { GUILayout.Label(msg); } GUILayout.EndArea(); } [PunRPC] public void SendMessageJoinedRoom(string feed) { index = index + 1; msgJoined[index] = feed; Debug.Log(PhotonNetwork.NickName + " joined"); }
0