|
| 1 | +# UnityNetworkCheckForAndroidandiOS |
| 2 | +## Adding Network Check to your project |
| 3 | + |
| 4 | +1. Download the Netwrok Check Unity Package |
| 5 | + - [Click Here to Download](https://github.com/the16bitgamer/UnityNetworkCheckForAndroidandiOS/blob/master/UnityNetworkCheck%201.unitypackage) |
| 6 | +2. Import the Custom Pagacke into your Assets Folder |
| 7 | + - If you don't know how to import the package here is [Unity's Tutorial on importing custom packages](https://docs.unity3d.com/Manual/AssetPackages.html#ImportingPackages) |
| 8 | + |
| 9 | +## Adding Network Check to your Code |
| 10 | + |
| 11 | +I've included a sample program which goes through all of the programs functionality called [NetworkCheckExample.cs](https://github.com/the16bitgamer/UnityNetworkCheckForAndroidandiOS/blob/master/Assets/NetworkCheckExample.cs) but I will also go over the basic funtionality bellow |
| 12 | + |
| 13 | +To initilize the Network Check you need to call |
| 14 | + |
| 15 | +``` NetworkCheck networkCheck = new NetworkCheck(); ``` |
| 16 | + |
| 17 | +In NetworkCheck you will have access to 3 functions: |
| 18 | + |
| 19 | +1. ```networkCheck.CheckOnline``` |
| 20 | + - This will check if the device is online at any point in time |
| 21 | +2. ```networkCheck.CheckWifiState``` |
| 22 | + - This will check to see if the Wifi router on the device is connected to the internet |
| 23 | +3. ```networkCheck.CheckMobileState``` |
| 24 | + - This will check to see if the device is connected to the internet with Mobile Data |
| 25 | + |
| 26 | +##Testing |
| 27 | + |
| 28 | +Since this module is designed to work on mobile devices there is no way to test the native code in Unity Editor. |
| 29 | + |
| 30 | +To assist with development and testing I added Debug Toggles in the Unity Editor Winodw. Under **16Bit Networking** there is 2 toggles: |
| 31 | + |
| 32 | +1. Enable Wifi Debug |
| 33 | + |
| 34 | +2. Enable Mobile Debug |
| 35 | + |
| 36 | +These can be toggled at run time. |
| 37 | + |
| 38 | +## Required files |
| 39 | + |
| 40 | +The main class **NetworkCheck.cs** is in ./Assets/Plugins/16 Bit Networking/ and can be moved if needed |
| 41 | + |
| 42 | +The menu code is located in **NetworkMenuToggles.cs** and is in ./Assets/Plugins/16 Bit Networking/ and can be moved if needed |
| 43 | + |
| 44 | +For Android to work you will need to include **networking-release.aar** in ./Assets/Plugins/Android/ which is already included in the package |
| 45 | + |
| 46 | +For iOS to work you will need to include **NetworkCheck.mm** in ./Assets/Plugins/iOS/ which is already included in the package |
0 commit comments