Skip to content

fix: Handling empty network prefab entries during NetworkManager.Init - #818

Merged
NoelStephensUnity merged 7 commits into
developfrom
fix/NetworkManager-Init-NetworkPrefab-Error-Fix
May 10, 2021
Merged

fix: Handling empty network prefab entries during NetworkManager.Init#818
NoelStephensUnity merged 7 commits into
developfrom
fix/NetworkManager-Init-NetworkPrefab-Error-Fix

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented May 9, 2021

Copy link
Copy Markdown
Member

If a network prefab is null, then it needs to only warn of the null network prefab and add it to the list of network prefabs to remove, but not try to display the non-existent prefab's name (which can cause an assert and break the initialization process).
This was found while helping with the BossRoom upgrade to MLAPI develop branch.

If a network prefab is null, then it needs to only warn of the null network prefab but not try to display the non-existent prefab's name.
// Provide the name of the prefab with issues so the user can more easily find the prefab and fix it
UnityEngine.Debug.LogWarning($"{nameof(NetworkPrefab)} (\"{NetworkConfig.NetworkPrefabs[i].Prefab.name}\") will be removed and ignored.");
// Don't try to name the prefab if it doesn't exist
if (NetworkConfig.NetworkPrefabs[i] != null && NetworkConfig.NetworkPrefabs[i].Prefab != null)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh? we are already in if (NetworkConfig.NetworkPrefabs[i] == null || NetworkConfig.NetworkPrefabs[i].Prefab == null) scope by now, see line 405
probably, there should be a better fix or logic flow here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... it doesn't need to be there at all. Removed it completely.

Really don't even need to display anything about the prefab.
@NoelStephensUnity
NoelStephensUnity requested a review from 0xFA11 May 9, 2021 20:35
@NoelStephensUnity
NoelStephensUnity enabled auto-merge (squash) May 10, 2021 20:27
@NoelStephensUnity
NoelStephensUnity merged commit ba6fe03 into develop May 10, 2021
@NoelStephensUnity
NoelStephensUnity deleted the fix/NetworkManager-Init-NetworkPrefab-Error-Fix branch May 10, 2021 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants