[Unity] EasyObjectPool modified, Make Pool Info at runtime.
APP 2020. 2. 12. 02:39at line 113
1
|
public PoolInfo[] poolInfo;
|
Changed to List
1
|
public List<PoolInfo> poolInfo;
|
at line 119
1
2
3
4
5
6
7
8
|
void Start () {
//set instance
instance = this;
//check for duplicate names
CheckForDuplicatePoolNames();
//create pools
CreatePools();
}
|
Start Changed
1
2
3
4
5
6
7
|
void Start()
{
//set instance
instance = this;
this.poolInfo = new List<PoolInfo>();
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
at line 127
Added New Method
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
|
public void MakePoolInfo(string poolName, GameObject prefab, int poolSize = 5, bool fixedSize = false)
{
PoolInfo poolInfo = new PoolInfo();
poolInfo.poolName = poolName;
poolInfo.prefab = prefab;
poolInfo.poolSize = poolSize;
poolInfo.fixedSize = fixedSize;
MakePool(poolInfo);
}
public void MakePool(PoolInfo poolInfo)
{
//check for duplicate names
CheckForDuplicatePoolNames();
//create pools
CreatePool(poolInfo);
}
private void CreatePool(PoolInfo poolInfo)
{
poolInfo.poolSize, poolInfo.fixedSize);
//add to mapping dict
poolDictionary[poolInfo.poolName] = pool;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
I did not consider duplicatePoolName.
So if you try to make PoolInfo with same name, it will stuck.
How To Use
1)On your script
1
|
using MarchingBytes;
|
2)Just use this method where you want to make pool
1
|
EasyObjectPool.instance.MakePoolInfo( yourPoolName, yourGameObject);
|
'APP' 카테고리의 다른 글
[Unity] 2020.02.18 포트폴리오 작업내용 (0) | 2020.02.19 |
---|---|
[Unity] 2020.02.14 포트폴리오 작업내용 (0) | 2020.02.14 |
[Unity] Coroutine couldn't be started because the the game object 'Monster03(Clone)' is inactive! (0) | 2020.02.12 |
[Unity] 프로젝트 동영상 (0) | 2020.02.01 |
[Unity] 페이스북로그인샘플, FaceBook Login Sample (0) | 2020.01.30 |