-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathObjectPoolItemKey.cs
More file actions
executable file
·52 lines (47 loc) · 1.38 KB
/
ObjectPoolItemKey.cs
File metadata and controls
executable file
·52 lines (47 loc) · 1.38 KB
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
using System;
using UnityEngine;
namespace GameUtil
{
[DisallowMultipleComponent]
public class ObjectPoolItemKey : MonoBehaviour, ISpawnHandler, IDisposeHandler
{
[SerializeField] private ObjectPool.LoadMode mLoadMode;
[SerializeField] private string mBundleName;
[SerializeField] private string mAssetName;
public ObjectPool.LoadMode LoadMode => mLoadMode;
public string BundleName => mBundleName;
public string AssetName => mAssetName;
public event Action<ObjectPoolItemKey> SpawnEvent;
public event Action<ObjectPoolItemKey> DisposeEvent;
public void Init(ObjectPool.LoadMode loadMode, string bundleName, string assetName)
{
mLoadMode = loadMode;
mBundleName = bundleName;
mAssetName = assetName;
}
public void OnSpawn()
{
if (SpawnEvent == null) return;
try
{
SpawnEvent(this);
}
catch (Exception e)
{
Debug.LogError(e, this);
}
}
public void OnDispose()
{
if (DisposeEvent == null) return;
try
{
DisposeEvent(this);
}
catch (Exception e)
{
Debug.LogError(e, this);
}
}
}
}