您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

39 行
1.2 KiB

using System;
using Unity.Netcode;
using UnityEngine;
using Unity.Multiplayer.Samples.BossRoom.Visual;
using Unity.Multiplayer.Samples.Utilities;
namespace Unity.Multiplayer.Samples.BossRoom.Client
{
[RequireComponent(typeof(NetworkCharacterState))]
public class ClientCharacter : MonoBehaviour
{
[SerializeField]
ClientCharacterVisualization m_ClientCharacterVisualization;
/// <summary>
/// The Visualization GameObject isn't in the same transform hierarchy as the object, but it registers itself here
/// so that the visual GameObject can be found from a NetworkObjectId.
/// </summary>
public ClientCharacterVisualization ChildVizObject => m_ClientCharacterVisualization;
void Awake()
{
GetComponent<NetcodeHooks>().OnNetworkSpawnHook += OnSpawn;
}
public void OnSpawn()
{
if (!NetworkManager.Singleton.IsClient)
{
enabled = false;
}
}
void OnDestroy()
{
GetComponent<NetcodeHooks>().OnNetworkSpawnHook -= OnSpawn;
}
}
}