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:
parent
5a4b6ebbe9
commit
030726add0
1 changed files with 15 additions and 0 deletions
|
@ -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()
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue