blob: 7ce8e7c784099f673cd20dcc936280248c502617 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
using System.IO;
using UnityEngine;
public class ServerCtrl
{
private static ServerCtrl m_instance;
private float m_checkTimer;
public static ServerCtrl instance => m_instance;
public static void Initialize()
{
if (m_instance == null)
{
m_instance = new ServerCtrl();
}
}
private ServerCtrl()
{
ClearExitFile();
}
public void Update(float dt)
{
CheckExit(dt);
}
private void CheckExit(float dt)
{
m_checkTimer += dt;
if (m_checkTimer > 2f)
{
m_checkTimer = 0f;
if (File.Exists("server_exit.drp"))
{
Application.Quit();
}
}
}
private void ClearExitFile()
{
try
{
File.Delete("server_exit.drp");
}
catch
{
}
}
}
|