您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
26 行
822 B
26 行
822 B
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();
|
|
}
|
|
}
|
|
}
|