@@ -30,9 +30,14 @@ public static class SpawnManager
30
30
public delegate void DestroyHandlerDelegate ( NetworkedObject networkedObject ) ;
31
31
32
32
33
- private static readonly Dictionary < ulong , SpawnHandlerDelegate > customSpawnHandlers = new Dictionary < ulong , SpawnHandlerDelegate > ( ) ;
33
+ internal static readonly Dictionary < ulong , SpawnHandlerDelegate > customSpawnHandlers = new Dictionary < ulong , SpawnHandlerDelegate > ( ) ;
34
34
internal static readonly Dictionary < ulong , DestroyHandlerDelegate > customDestroyHandlers = new Dictionary < ulong , DestroyHandlerDelegate > ( ) ;
35
35
36
+ /// <summary>
37
+ /// Registers a delegate for spawning networked prefabs, useful for object pooling
38
+ /// </summary>
39
+ /// <param name="prefabHash">The prefab hash to spawn</param>
40
+ /// <param name="handler">The delegate handler</param>
36
41
public static void RegisterSpawnHandler ( ulong prefabHash , SpawnHandlerDelegate handler )
37
42
{
38
43
if ( customSpawnHandlers . ContainsKey ( prefabHash ) )
@@ -45,6 +50,11 @@ public static void RegisterSpawnHandler(ulong prefabHash, SpawnHandlerDelegate h
45
50
}
46
51
}
47
52
53
+ /// <summary>
54
+ /// Registers a delegate for destroying networked objects, useful for object pooling
55
+ /// </summary>
56
+ /// <param name="prefabHash">The prefab hash to destroy</param>
57
+ /// <param name="handler">The delegate handler</param>
48
58
public static void RegisterCustomDestroyHandler ( ulong prefabHash , DestroyHandlerDelegate handler )
49
59
{
50
60
if ( customDestroyHandlers . ContainsKey ( prefabHash ) )
@@ -57,11 +67,19 @@ public static void RegisterCustomDestroyHandler(ulong prefabHash, DestroyHandler
57
67
}
58
68
}
59
69
70
+ /// <summary>
71
+ /// Removes the custom spawn handler for a specific prefab hash
72
+ /// </summary>
73
+ /// <param name="prefabHash">The prefab hash of the prefab spawn handler that is to be removed</param>
60
74
public static void RemoveCustomSpawnHandler ( ulong prefabHash )
61
75
{
62
76
customSpawnHandlers . Remove ( prefabHash ) ;
63
77
}
64
78
79
+ /// <summary>
80
+ /// Removes the custom destroy handler for a specific prefab hash
81
+ /// </summary>
82
+ /// <param name="prefabHash">The prefab hash of the prefab destroy handler that is to be removed</param>
65
83
public static void RemoveCustomDestroyHandler ( ulong prefabHash )
66
84
{
67
85
customDestroyHandlers . Remove ( prefabHash ) ;
0 commit comments