Elin Decompiled Documentation
EA 23.102 Nightly
Loading...
Searching...
No Matches
ManlySingleton.cs
Go to the documentation of this file.
1
using
UnityEngine;
2
3
public
class
ManlySingleton
<T> :
SingletonBase
where T : MonoBehaviour
4
{
5
private
static
T
myInstance
;
6
7
public
static
T
Instance
8
{
9
get
10
{
11
if
(
myInstance
==
null
)
12
{
13
Object[] array = Object.FindObjectsOfType(typeof(T));
14
if
(array.Length > 1)
15
{
16
Debug
.LogError(
"<B>Doubleton?</B> Do you really want two instances of <B><i>"
+ typeof(T).Name +
"</i></B>?\n"
, array[1]);
17
}
18
if
(array.Length >= 1)
19
{
20
myInstance
= (T)array[0];
21
}
22
if
(
myInstance
==
null
)
23
{
24
Debug
.LogError(
"An instance of "
+ typeof(T).Name +
" could not be found. Add it to the scene."
);
25
}
26
}
27
return
myInstance
;
28
}
29
}
30
31
public
static
T
InstanceOrNull
=>
myInstance
?? (
myInstance
= (T)Object.FindObjectOfType(typeof(T)));
32
33
public
static
Transform
STransform
=>
Instance
.transform;
34
35
public
static
Vector3
SPosition
36
{
37
get
38
{
39
return
Instance
.transform.position;
40
}
41
set
42
{
43
Instance.transform.position = value;
44
}
45
}
46
47
public
static
GameObject
SGameObject
=>
Instance
.gameObject;
48
49
public
static
bool
Exists
()
50
{
51
return
InstanceOrNull
!=
null
;
52
}
53
54
public
override
void
Elect
()
55
{
56
myInstance
=
this
as T;
57
}
58
59
protected
void
Abdicate
()
60
{
61
if
(
myInstance
==
this
)
62
{
63
myInstance
=
null
;
64
}
65
}
66
67
protected
virtual
void
OnDestroy
()
68
{
69
myInstance
=
null
;
70
}
71
}
ReleaseMode.Debug
@ Debug
ManlySingleton
Definition:
ManlySingleton.cs:4
ManlySingleton.Instance
static T?? Instance
Definition:
ManlySingleton.cs:8
ManlySingleton.Elect
override void Elect()
Definition:
ManlySingleton.cs:54
ManlySingleton.SGameObject
static GameObject SGameObject
Definition:
ManlySingleton.cs:47
ManlySingleton.STransform
static Transform STransform
Definition:
ManlySingleton.cs:33
ManlySingleton.InstanceOrNull
static T InstanceOrNull
Definition:
ManlySingleton.cs:31
ManlySingleton.Abdicate
void Abdicate()
Definition:
ManlySingleton.cs:59
ManlySingleton.myInstance
static T myInstance
Definition:
ManlySingleton.cs:5
ManlySingleton.SPosition
static Vector3 SPosition
Definition:
ManlySingleton.cs:36
ManlySingleton.OnDestroy
virtual void OnDestroy()
Definition:
ManlySingleton.cs:67
ManlySingleton.Exists
static bool Exists()
Definition:
ManlySingleton.cs:49
SingletonBase
Definition:
SingletonBase.cs:4
Elin
Plugins.UI
ManlySingleton.cs
Generated by
1.9.6