Hello,
I am trying to figure out why my build will not compile. I am getting the Error CS0246 saying I am missing an assembly or reference for ‘NetworkDisconnection’ which is a built in Unity enum. In the code I have the using UnityEngine and using System.Collections, which I know the ‘NetworkDisconnection’ enum is a part of. Any clue how to fix? This is the code that is throwing the error
void OnDisconnectedFromServer( NetworkDisconnection cause )
{
Destroy( gameObject );
}
After some very obscure googling (I don’t blame you for not finding the answer with some googles, took me a few minutes), I found out why this happens on WebGL:
According to the WebGL Documentation on Networking
"Due to security implications, JavaScript code does not have direct access to IP Sockets to implement network connectivity. As a result, the .NET networking classes (ie, everything in the System.Net namespace, particularly System.Net.Sockets) are non-functional in WebGL. The same applies to Unity’s old UnityEngine.Network classes, which are not available when building for WebGL.
If you need to use Networking in WebGL, you currently have the options to use the WWW or UnityWebRequest classes in Unity or the new Unity Networking features which support WebGL, or to implement your own networking using WebSockets or WebRTC in JavaScript."