blob: 676c6669f31ab61fbaeced005fea8c4fb570220f (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
using System;
using UnityEngine;
public class DefaultPool : IObjectPool
{
public override int InUse
{
get
{
return 0;
}
}
public override int NotInUse
{
get
{
return 0;
}
}
public static bool InstanceExists
{
get
{
return DefaultPool._instance;
}
}
public static DefaultPool Instance
{
get
{
object @lock = DefaultPool._lock;
DefaultPool instance;
lock (@lock)
{
if (DefaultPool._instance == null)
{
DefaultPool._instance = UnityEngine.Object.FindObjectOfType<DefaultPool>();
if (UnityEngine.Object.FindObjectsOfType<DefaultPool>().Length > 1)
{
Debug.LogError("[Singleton] Something went really wrong - there should never be more than 1 singleton! Reopening the scene might fix it.");
return DefaultPool._instance;
}
if (DefaultPool._instance == null)
{
GameObject gameObject = new GameObject();
DefaultPool._instance = gameObject.AddComponent<DefaultPool>();
gameObject.name = "(singleton) DefaultPool";
}
}
instance = DefaultPool._instance;
}
return instance;
}
}
private static DefaultPool _instance;
private static object _lock = new object();
public void OnDestroy()
{
object @lock = DefaultPool._lock;
lock (@lock)
{
DefaultPool._instance = null;
}
}
public override T Get<T>()
{
throw new NotImplementedException();
}
public override void Reclaim(PoolableBehavior obj)
{
Debug.Log("Default Pool: Destroying this thing.");
UnityEngine.Object.Destroy(obj.gameObject);
}
}
|