-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetcodeHooks.cs
26 lines (22 loc) · 796 Bytes
/
NetcodeHooks.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
using System;
using Unity.Netcode;
namespace Unity.Multiplayer.Samples.Utilities
{
// useful for classes that can't be NetworkBehaviours themselves (for example, with dedicated servers, you can't have a NetworkBehaviour that exists
// on clients but gets stripped on the server, this will mess with your NetworkBehaviour indexing.
public class NetcodeHooks : NetworkBehaviour
{
public event Action OnNetworkSpawnHook;
public event Action OnNetworkDespawnHook;
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
OnNetworkSpawnHook?.Invoke();
}
public override void OnNetworkDespawn()
{
base.OnNetworkDespawn();
OnNetworkDespawnHook?.Invoke();
}
}
}