Skip to content

Commit

Permalink
fix: fixing ArgumentOutOfRangeException when no NetworkIdentity on ob…
Browse files Browse the repository at this point in the history
…ject

InvalidOperationException should be thrown with better message instead
  • Loading branch information
James-Frowen committed Feb 19, 2022
1 parent 23bde16 commit d8e7830
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Assets/Mirage/Runtime/NetworkBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ private NetworkIdentity TryFindIdentity()
#else
// TODO: remove this bit once Unity drops support for 2019 LTS
GetComponentsInParent<NetworkIdentity>(true, networkIdentityGetComponentCacheList);
// if empty, return null other function will throw
if (networkIdentityGetComponentCacheList.Count == 0) return null;
NetworkIdentity identity = networkIdentityGetComponentCacheList[0];
#endif

Expand Down

0 comments on commit d8e7830

Please sign in to comment.