public async void JoinOrCreateLobby() { SetConnectionStatus(Enum.ConnectionStatus.Connecting); if (_runner != null) { LeaveSession(); } if (_runner == null) { Util.Log("runner 생성"); GameObject session = new GameObject("Session"); Util.Log($"{session.name}"); _runner = session.AddComponent <NetworkRunner>(); } _runner.ProvideInput = true; _runner.AddCallbacks(this); if (_pool == null) { _pool = gameObject.AddComponent <FusionObjectPoolRoot>(); } RoomPlayer.Players.Clear(); PlayerModel.Players.Clear(); await _runner.StartGame(new StartGameArgs { GameMode = _gameMode, SessionName = NetworkManager.In.RoomName, ObjectPool = _pool, PlayerCount = Constants.MaxPlayer, SceneObjectProvider = this.GetOrAddComponent <NetworkSceneManagerDefault>() // 없어도 될 듯 싶으나 경고 디버그가 출력되어 추가해둠 }); }
public async void Launch(GameMode mode, string room, INetworkSceneObjectProvider sceneLoader, Action <NetworkRunner, ConnectionStatus, string> onConnect, Action <NetworkRunner> onSpawnWorld, Action <NetworkRunner, PlayerRef> onSpawnPlayer, Action <NetworkRunner, PlayerRef> onDespawnPlayer) { _connectionCallback = onConnect; _spawnWorldCallback = onSpawnWorld; _spawnPlayerCallback = onSpawnPlayer; _despawnPlayerCallback = onDespawnPlayer; SetConnectionStatus(ConnectionStatus.Connecting, ""); DontDestroyOnLoad(gameObject); if (_runner == null) { _runner = gameObject.AddComponent <NetworkRunner>(); } _runner.name = name; _runner.ProvideInput = mode != GameMode.Server; if (_pool == null) { _pool = gameObject.AddComponent <FusionObjectPoolRoot>(); } await _runner.StartGame(new StartGameArgs() { GameMode = mode, SessionName = room, ObjectPool = _pool, SceneObjectProvider = sceneLoader }); }