Last active
May 6, 2024 00:51
-
-
Save nndwn/11436e416c40c9a6753e09330f2f836f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CheckConnection : MonoBehaviour | |
{ | |
private void Start() | |
{ | |
StartCoroutine(IsConnected(connected => | |
{ | |
if (connected) | |
{ | |
Debug.Log("connented in internet") | |
}else | |
{ | |
Debug.Log( "cant connected internet") | |
} | |
})); | |
} | |
public IEnumerator IsConnected(Action<bool> action) | |
{ | |
var isConnected = false; | |
var request = UnityWebRequest.Get("https://www.nndwn.my.id/cultureshock/privacy"); | |
request.method = "HEAD"; | |
request.timeout = 3; | |
yield return request.SendWebRequest(); | |
if (request.responseCode == 200) | |
{ | |
isConnected = true; | |
} | |
action(isConnected); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment