mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Allow Room Manager Additional GamePlay Scenes
This commit is contained in:
parent
1433d369c8
commit
a28ccbb477
@ -268,21 +268,22 @@ public override void OnServerDisconnect(NetworkConnection conn)
|
||||
/// <param name="conn">Connection from client.</param>
|
||||
public override void OnServerAddPlayer(NetworkConnection conn)
|
||||
{
|
||||
if (SceneManager.GetActiveScene().name != RoomScene) return;
|
||||
if (SceneManager.GetActiveScene().name == RoomScene)
|
||||
{
|
||||
if (roomSlots.Count == maxConnections) return;
|
||||
|
||||
if (roomSlots.Count == maxConnections) return;
|
||||
allPlayersReady = false;
|
||||
|
||||
allPlayersReady = false;
|
||||
if (LogFilter.Debug) Debug.LogFormat("NetworkRoomManager.OnServerAddPlayer playerPrefab:{0}", roomPlayerPrefab.name);
|
||||
|
||||
if (LogFilter.Debug) Debug.LogFormat("NetworkRoomManager.OnServerAddPlayer playerPrefab:{0}", roomPlayerPrefab.name);
|
||||
GameObject newRoomGameObject = OnRoomServerCreateRoomPlayer(conn);
|
||||
if (newRoomGameObject == null)
|
||||
newRoomGameObject = Instantiate(roomPlayerPrefab.gameObject, Vector3.zero, Quaternion.identity);
|
||||
|
||||
GameObject newRoomGameObject = OnRoomServerCreateRoomPlayer(conn);
|
||||
if (newRoomGameObject == null)
|
||||
newRoomGameObject = Instantiate(roomPlayerPrefab.gameObject, Vector3.zero, Quaternion.identity);
|
||||
|
||||
NetworkServer.AddPlayerForConnection(conn, newRoomGameObject);
|
||||
|
||||
//RecalculateRoomPlayerIndices();
|
||||
NetworkServer.AddPlayerForConnection(conn, newRoomGameObject);
|
||||
}
|
||||
else
|
||||
OnRoomServerAddPlayer(conn);
|
||||
}
|
||||
|
||||
public void RecalculateRoomPlayerIndices()
|
||||
@ -322,7 +323,7 @@ public override void ServerChangeScene(string sceneName)
|
||||
NetworkServer.ReplacePlayerForConnection(identity.connectionToClient, roomPlayer.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
allPlayersReady = false;
|
||||
}
|
||||
|
||||
@ -528,6 +529,17 @@ public virtual GameObject OnRoomServerCreateGamePlayer(NetworkConnection conn, G
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This allows customization of the creation of the GamePlayer object on the server.
|
||||
/// <para>This is only called for subsequent GamePlay scenes after the first one.</para>
|
||||
/// <para>See <see cref="OnRoomServerCreateGamePlayer(NetworkConnection, GameObject)"/> to customize the player object for the initial GamePlay scene.</para>
|
||||
/// </summary>
|
||||
/// <param name="conn">The connection the player object is for.</param>
|
||||
public virtual void OnRoomServerAddPlayer(NetworkConnection conn)
|
||||
{
|
||||
base.OnServerAddPlayer(conn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obsolete: Use <see cref="OnRoomServerCreateGamePlayer(NetworkConnection, GameObject)"/> instead.
|
||||
/// </summary>
|
||||
|
@ -26,7 +26,7 @@ public override void OnStartLocalPlayer()
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
if (isLocalPlayer && Camera.main != null)
|
||||
{
|
||||
Camera.main.orthographic = true;
|
||||
Camera.main.transform.SetParent(null);
|
||||
|
Loading…
Reference in New Issue
Block a user