Pools
Pool GameObjects for Performance
PoolMonitor.cs
1
// With thanks to Jason Weimann -- jason@unity3d.college
2
3
using
UnityEngine
;
4
5
namespace
Askowl
{
6
/// <a href="http://bit.ly/2BQH2pA"></a> <inheritdoc />
7
public
class
PoolMonitor
: MonoBehaviour {
8
/// <a href="http://bit.ly/2BScbco"></a>
9
public
bool
PoolOnDisable
;
10
11
/// <a href="http://bit.ly/2BQH2pA"></a>
12
public
bool
InPool
;
13
14
/// <a href="http://bit.ly/2BQH2pA"></a>
15
public
bool
OkToPool
=
true
;
16
17
/// <a href="http://bit.ly/2BQvdQi"></a>
18
public
string
MasterName
;
19
20
/// <a href="http://bit.ly/2E0ZmxS"></a>
21
public
Transform
PoolRoot
;
22
23
private
void
OnDisable() {
24
OkToPool
=
true
;
25
if
(
PoolOnDisable
&& !
InPool
)
Pool
.
Return
(gameObject);
26
}
27
28
private
void
OnEnable() {
29
if
(
InPool
|| !
PoolOnDisable
)
return
;
30
31
OkToPool
=
false
;
32
Log.Error($
"Pooled '{gameObject.name}' should not be reused"
);
33
}
34
}
35
}
Askowl.Pool
MonoBehaviour to provide pooling functionality for child GameObjects. To be eligible they must be cre...
Definition:
Pool.cs:8
Askowl
Definition:
Pool.cs:6
Askowl.PoolMonitor
Definition:
PoolMonitor.cs:7
Askowl.PoolMonitor.InPool
bool InPool
Definition:
PoolMonitor.cs:12
Askowl.PoolMonitor.PoolOnDisable
bool PoolOnDisable
Definition:
PoolMonitor.cs:9
Askowl.PoolMonitor.PoolRoot
Transform PoolRoot
Definition:
PoolMonitor.cs:21
Askowl.PoolMonitor.OkToPool
bool OkToPool
Definition:
PoolMonitor.cs:15
Askowl.Pool.Return
static void Return(GameObject clone)
Give an object created by Acquire in any pool, return it to the pool for reuse. Only needed if poolOn...
Definition:
Pool.cs:87
UnityEngine
Askowl.PoolMonitor.MasterName
string MasterName
Definition:
PoolMonitor.cs:18
Askowl
Pools
Assets
Askowl
Pools
Scripts
PoolMonitor.cs
Generated by
1.8.14