mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 22:10:17 +00:00
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using UnityEngine;
|
|
using SanAndreasUnity.Net;
|
|
|
|
namespace SanAndreasUnity.UI
|
|
{
|
|
|
|
public class NetworkEvents2MessageBox : MonoBehaviour
|
|
{
|
|
bool m_clientWasConnected = false;
|
|
public string titleToDisplayWhenClientDisconnects = "";
|
|
public string messageToDisplayWhenClientDisconnects = "";
|
|
|
|
|
|
void Start()
|
|
{
|
|
NetManager.Instance.onClientStatusChanged += this.OnClientStatusChanged;
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
NetManager.Instance.onClientStatusChanged -= this.OnClientStatusChanged;
|
|
}
|
|
|
|
void OnClientStatusChanged()
|
|
{
|
|
if (NetStatus.IsClientConnected())
|
|
{
|
|
m_clientWasConnected = true;
|
|
}
|
|
else
|
|
{
|
|
if (m_clientWasConnected && !NetStatus.IsServer)
|
|
{
|
|
ShowMsg();
|
|
}
|
|
}
|
|
}
|
|
|
|
void ShowMsg()
|
|
{
|
|
MessageBox.Show(this.titleToDisplayWhenClientDisconnects, this.messageToDisplayWhenClientDisconnects, false);
|
|
}
|
|
|
|
}
|
|
|
|
}
|