2
0
Fork 0
mirror of https://github.com/GTA-ASM/SanAndreasUnity synced 2025-02-20 14:58:29 +00:00

remove chat messages periodically

This commit is contained in:
in0finite 2019-11-16 17:09:43 +01:00
parent 5a4b6ebbe9
commit 030726add0

View file

@ -11,6 +11,7 @@ namespace SanAndreasUnity.UI
Queue<Chat.ChatMessage> m_chatMessages = new Queue<Chat.ChatMessage>();
public int maxNumChatMessages = 5;
public float timeToRemoveMessage = 3f;
public ScreenCorner chatAreaCorner = ScreenCorner.BottomLeft;
public Vector2 chatAreaPadding = new Vector2(50, 50);
@ -29,8 +30,22 @@ namespace SanAndreasUnity.UI
m_chatMessages.Dequeue();
m_chatMessages.Enqueue(chatMsg);
if (!this.IsInvoking(nameof(RemoveMessage)))
this.Invoke(nameof(RemoveMessage), this.timeToRemoveMessage);
}
void RemoveMessage()
{
if (m_chatMessages.Count > 0)
m_chatMessages.Dequeue();
// invoke again if there are more messages
if (m_chatMessages.Count > 0)
this.Invoke(nameof(RemoveMessage), this.timeToRemoveMessage);
}
void OnGUICustom()
{