-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrefabPool.cs
43 lines (38 loc) · 937 Bytes
/
PrefabPool.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
using System;
using Gilzoide.PrefabPool.Internal;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Gilzoide.PrefabPool
{
[Serializable]
public class PrefabPool<T> : APrefabPool<T>
where T : Object
{
[Tooltip("Prefab which instances will be pooled.")]
[SerializeField] protected T _prefab;
public T Prefab
{
get => _prefab;
set
{
Dispose();
_prefab = value;
}
}
public PrefabPool() : base() {}
public PrefabPool(T prefab) : base()
{
_prefab = prefab;
}
public override T GetPrefab()
{
return _prefab;
}
}
[Serializable]
public class PrefabPool : PrefabPool<GameObject>
{
public PrefabPool() : base() {}
public PrefabPool(GameObject prefab) : base(prefab) {}
}
}