fix: Added null check and error logging to OnDeserializeAllSafely

This commit is contained in:
MrGadget1024 2021-06-30 00:41:56 -04:00
parent a0f5a846d7
commit b86c8615f4

View File

@ -1005,6 +1005,15 @@ void OnDeserializeSafely(NetworkBehaviour comp, NetworkReader reader, bool initi
internal void OnDeserializeAllSafely(NetworkReader reader, bool initialState)
{
if (NetworkBehaviours == null)
{
Debug.LogError($"NetworkBehaviours array is null on {gameObject.name}!\n" +
$"Typically this can happen when a networked object is a child of a " +
$"non-networked parent that's disabled, preventing Awake on the networked object " +
$"from being invoked, where the NetworkBehaviours array is initialized.", gameObject);
return;
}
// deserialize all components that were received
NetworkBehaviour[] components = NetworkBehaviours;
while (reader.Remaining > 0)