Print a more informative error than NPE (#31)

* Print a more informative error than NPE

* Improve error message
This commit is contained in:
Paul Pacheco 2018-09-11 03:16:20 -05:00 committed by vis2k
parent dfbde9902d
commit 37ce0ae72d

View File

@ -342,6 +342,12 @@ internal void OnStartClient()
internal void OnStartAuthority()
{
if (m_NetworkBehaviours == null && LogFilter.logError)
{
Debug.LogError("Network object " + name + " not initialized properly. Do you have more than one NetworkIdentity in the same object? Did you forget to spawn this object with NetworkServer?", this);
return;
}
for (int i = 0; i < m_NetworkBehaviours.Length; i++)
{
NetworkBehaviour comp = m_NetworkBehaviours[i];