Unity NGO
마지막 업데이트
도움이 되었나요?
도움이 되었나요?
다음은 해당(문서에서 가져온) 일반적인 변경되지 않은 스크립트의 예입니다:
using System.Collections;
using System.Collections.Generic;
using Unity.BossRoom.ConnectionManagement;
using UnityEngine;
namespace Unity.Multiplayer.Samples.BossRoom
{
public class EdgegapServerStarter : MonoBehaviour
{
public string portMapName = "gameport";
// Start is called before the first frame update
// 초기화에 사용
{
if (Application.isBatchMode)
{
ConnectionManager connectionManager = GameObject.Find("ConnectionManager").GetComponent<ConnectionManager>();
string internalPortAsStr = Environment.GetEnvironmentVariable($"ARBITRIUM_PORT_{portMapName.ToUpper()}_INTERNAL");
if (internalPortAsStr == null || !ushort.TryParse(internalPortAsStr, out ushort port))
{
throw new Exception($"포트 매핑을 찾을 수 없습니다. 앱 버전의 포트 이름이 \"{portMapName}\"과 일치하는지 확인하세요");
}
connectionManager.StartHostIp("서버", "0.0.0.0", port);
}
}
}
}116 public override async Task SetupHostConnectionAsync()
117 {
118 //SetConnectionPayload(GetPlayerId(), m_PlayerName); // 호스트도 클라이언트이므로 호스트에 대해 연결 페이로드를 설정해야 함
119 var utp = (UnityTransport)m_ConnectionManager.NetworkManager.NetworkConfig.NetworkTransport;
120 utp.SetConnectionData(m_Ipaddress, m_Port);
121 }66 async void StartHost()
67 {
...
72 // NGO의 StartHost는 모든 것을 실행합니다
-- //if (!m_ConnectionManager.NetworkManager.StartHost())
73 if (!m_ConnectionManager.NetworkManager.StartServer())
74 {
75 StartHostFailed();
76 }
...112 public override void OnNetworkSpawn()
113 {
...
125 m_ServerCharacter.IsStealthy.OnValueChanged += OnStealthyChanged;
126 m_ServerCharacter.MovementStatus.OnValueChanged += OnMovementStatusChanged;
127 //OnMovementStatusChanged(MovementStatus.Normal, m_ServerCharacter.MovementStatus.Value);
...148 ConnectStatus GetConnectStatus(ConnectionPayload connectionPayload)
149 {
...
155 //if (connectionPayload.isDebug != Debug.isDebugBuild)
156 //{
157 // return ConnectStatus.IncompatibleBuildType;
158 //}
...