Question by
Aminjon_Warshav · Nov 09, 2016 at 03:46 PM ·
unity 5unityeditoradsunityads
Unity Ads when Internet not available in starting game , how i can iInitialize, in during game when internet be available?
I ' m using unity3D 5.4.2f2, and Unity Advertisements Service window. So used at first. this script for making Off initializeOnStartup.
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.Advertisements;
public class UnityAdsBuildProcessor : Editor
{
[PostProcessScene]
public static void OnPostprocessScene ()
{
AdvertisementSettings.enabled = true;
AdvertisementSettings.initializeOnStartup = false;
}
}
After this, I used this line of code for checking.
void manualAdsInitilizations()
{
if (Application.internetReachability != NetworkReachability.NotReachable && Advertisement.isSupported)
{
#if UNITY_ANDROID
Advertisement.Initialize ("###");
//Android ID
#elif UNITY_IOS
Advertisement.Initialize("####"); // IOS ID
#endif
}
}
void UnityAdsButtonOnLevelFailed()
{
if (Application.internetReachability != NetworkReachability.NotReachable && Advertisement.isInitialized)
{
if(Advertisement.IsReady())
AdsForLavelFailed.SetActive (true);
}
else if (Application.internetReachability == NetworkReachability.NotReachable )
{
AdsForLavelFailed.SetActive (false);
}
}
// here IEnumerator for checking internet connection
IEnumerator HandleInternetConnection ()
{
while (true)
{
manualAdsInitilizations ();
UnityAdsButtonOnLevelFailed ();
yield return new WaitForEndOfFrame();
}
}
Is Working when Internet Availabe on start of game , but if start without internet game, and make internet on in during game is not working thank you, waiting for any answers.
Comment
Your answer
Follow this Question
Related Questions
Disabling button when Ads not available? 0 Answers
Unity ads not showing rewarded video ad. 1 Answer
Unity Ads not showing in editor (dummy ad placement is not showing too) as well as in the build. 2 Answers
How to display Admob ads in Unity every 5-10 mins? 0 Answers
Problems with revenue after getting 5000+ impressions 0 Answers