-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplicationController.cs
48 lines (40 loc) · 1.7 KB
/
ApplicationController.cs
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
using UnityEngine;
using UnityEngine.SceneManagement;
// Loads as part of the startup scene
public class ApplicationController : MonoBehaviour
{
// NOTE: Using IsLocalTesting to signal that we are not using Multiplay or
// matchmaking services, probably isn't the best way. Instead you'd want to
// use a command line argument or a Define Symbol to toggle deployment environment.
public static bool IsLocalTesting = false;
// The server or client IGameManager implementation script will be added to
// the GameManager object in the editor and establish the respective support scripts.
private IGameManager _gameManager;
public const string QueueName = "bad-queue-1";
void Start()
{
GameObject gameManager = GameObject.Find("GameManager");
// NOTE: this is one way to test if we are a server build or not.
// You can also use environment variables or Define Symbols.
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null)
{
Debug.Log("Server build running.");
// Add necessary server scripts to GameManager
_gameManager = gameManager.AddComponent<ServerGameManager>();
}
else
{
Debug.Log("Client build running.");
// Add necessary client scripts to GameManager
_gameManager = gameManager.AddComponent<ClientGameManager>();
}
// Initialize our classes instead of relying on start
_gameManager.Init();
// Load main scene after startup is complete
SceneManager.LoadScene("MainScene", LoadSceneMode.Single);
}
private void Awake()
{
DontDestroyOnLoad(gameObject);
}
}