- Download the Netwrok Check Unity Package
- Import the Custom Pagacke into your Assets Folder
- If you don't know how to import the package here is Unity's Tutorial on importing custom packages
I've included a sample program which goes through all of the programs functionality called NetworkCheckExample.cs but I will also go over the basic funtionality bellow
To initilize the Network Check you need to call
NetworkCheck networkCheck = new NetworkCheck();
In NetworkCheck you will have access to 3 functions:
networkCheck.CheckOnline
- This will check if the device is online at any point in time
networkCheck.CheckWifiState
- This will check to see if the Wifi router on the device is connected to the internet
networkCheck.CheckMobileState
- This will check to see if the device is connected to the internet with Mobile Data
Since this module is designed to work on mobile devices there is no way to test the native code in Unity Editor.
To assist with development and testing I added Debug Toggles in the Unity Editor Winodw. Under 16Bit Networking there is 2 toggles:
-
Enable Wifi Debug
-
Enable Mobile Debug
These can be toggled at run time.
The main class NetworkCheck.cs is in ./Assets/Plugins/16 Bit Networking/ and can be moved if needed
The menu code is located in NetworkMenuToggles.cs and is in ./Assets/Plugins/16 Bit Networking/ and can be moved if needed
For Android to work you will need to include networking-release.aar in ./Assets/Plugins/Android/ which is already included in the package
For iOS to work you will need to include NetworkCheck.mm in ./Assets/Plugins/iOS/ which is already included in the package
##Source
The Android source files can be found here
The iOS Source files are located in the ./Assets/Plugins/iOS/ folder under NetworkCheck.mm