void OnValidate() { if (m_MaxPlayers <= 0) { m_MaxPlayers = 1; } if (m_MaxPlayersPerConnection <= 0) { m_MaxPlayersPerConnection = 1; } if (m_MaxPlayersPerConnection > maxPlayers) { m_MaxPlayersPerConnection = maxPlayers; } if (m_MinPlayers < 0) { m_MinPlayers = 0; } if (m_MinPlayers > m_MaxPlayers) { m_MinPlayers = m_MaxPlayers; } if (m_LobbyPlayerPrefab != null) { var uv = m_LobbyPlayerPrefab.GetComponent <NetworkIdentity>(); if (uv == null) { m_LobbyPlayerPrefab = null; Debug.LogWarning("LobbyPlayer prefab must have a NetworkIdentity component."); } } if (m_GamePlayerPrefab != null) { var uv = m_GamePlayerPrefab.GetComponent <NetworkIdentity>(); if (uv == null) { m_GamePlayerPrefab = null; Debug.LogWarning("GamePlayer prefab must have a NetworkIdentity component."); } } }
public override void OnValidate() { // always >= 0 maxConnections = Mathf.Max(maxConnections, 0); // always <= maxConnections minPlayers = Mathf.Min(minPlayers, maxConnections); // always >= 0 minPlayers = Mathf.Max(minPlayers, 0); if (lobbyPlayerPrefab != null) { NetworkIdentity identity = lobbyPlayerPrefab.GetComponent <NetworkIdentity>(); if (identity == null) { lobbyPlayerPrefab = null; Debug.LogError("LobbyPlayer prefab must have a NetworkIdentity component."); } } base.OnValidate(); }