Getting Started
Last updated
Last updated
Setting Eazy NetChecker up and using it is super easy and straightforward. It is also extremely flexible since it allows you to use either the editor to set it up, or do everything with code on runtime. Of course, using both is also possible. Everything will be explained for both ways.
The only initial setup needed for the editor, is to create the Eazy NetChecker GameObject. This can easily be done by either navigating to GameObject > Hellmade Games and selecting Eazy NetChecker. This will create a GameObject in your scene with the Eazy NetChecker component on it. You can always create an empty GameObject and add the Eazy NetChecker component yourself too.
Do not create or have more than one Eazy NetChecker in the same scene. Eazy NetChecker retains its life over different scenes, so you only need to create it once, in your first scene.
If you want to handle everything with code, there is no reason to add an Eazy NetChecker GameObject. It will automatically be created and initialized for you as soon as you reference it for the first time in your code.
Make sure to always include the namespace Hellmade.Net when using Eazy NetChecker from code. Just use this on the top of every script that uses Eazy NetChecker:
using Hellmade.Net;
Checking for internet connection can be done in a few ways. You can manually perform a check once, start a continuous check which will be performed on a specified interval, or perform a check on start up.
Before you perform any kind of check, you need to select which check method you want to use. For the standard check methods, just use the appropriate check method selection function:
You can also select a check method in the editor before runtime
If no check method is specifically selected, one of the standard check method will be choosen automatically, based on the platform running:
Windows (MicrosoftNCSI)
Linux/Android (Google204)
MacOS/iOS (AppleHotspot)
The simplest case would be to perform a single manual check:
This will start a process for checking the current internet connection status in the background. The check method will raise various events during its lifetime. In this example, we added a listener to the OnCheckFinished event, which will be raised as soon as a check is finished. Here the check is performed on awake, but of course you can perform an internet check whenever and wherever you need to.
You can also start a continuous check, which will run on a specified interval, until you decide to stop it:
The above example will perform a check every 20 seconds (default). It also listens to the OnConnectionStatusChanged event, which is raised everytime the status of the internet connection is changed (after a check is performed).
You can use whatever events you like, depending on your specific game logic. You can even not use an event, and implement your logic by checking the current detected internet connection status like the example below:
The check interval (time between continuous checks), and the timeout time can also be changed. Eazy NetChecker can be configured using both the editor and the runtime API.
Configuring the settings through the editor is very straightforward. All of them can be found in the Settings section
All settings can be set before you perform a check: