-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cs
More file actions
76 lines (65 loc) · 1.39 KB
/
Main.cs
File metadata and controls
76 lines (65 loc) · 1.39 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using UnityEngine;
namespace Uzu
{
/// <summary>
/// The application main entry point.
/// This object is guaranteed to exist at all times.
/// </summary>
public class Main : BaseBehaviour
{
/// <summary>
/// Override this to load application resources.
/// </summary>
protected virtual void OnMainBegin ()
{
}
/// <summary>
/// Override this to provide any application-specific startup logic.
/// </summary>
protected virtual void OnMainBegin2 ()
{
}
/// <summary>
/// Override this to provide any application-specific cleanup logic.
/// </summary>
protected virtual void OnMainEnd ()
{
}
#region Implementation.
#region Singleton implementation.
private static Main _instance;
protected static Main Instance {
get { return _instance; }
private set { Uzu.Util.SingletonSet<Main> (ref _instance, value); }
}
#endregion
protected override void Awake ()
{
base.Awake ();
// Only allow single instance to exist.
if (_instance != null && _instance != this) {
Destroy (gameObject);
return;
}
Instance = this;
DontDestroyOnLoad (gameObject);
// Invoke main.
OnMainBegin ();
}
private void Start ()
{
// Invoke main.
OnMainBegin2 ();
}
protected void OnDestroy ()
{
if (_instance != this) {
return;
}
// Cleanup.
OnMainEnd ();
Instance = null;
}
#endregion
}
}