I Don’t Really Know How To Explain It But I’ll Try.
When I Used An Advertisement Script And Tested It This Error Would Show up :
NullReferenceException: Object reference not set to an instance of an object
System.Net.AutoWebProxyScriptEngine.InitializeRegistryGlobalProxy () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.AutoWebProxyScriptEngine.GetWebProxyData () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.WebProxy.UnsafeUpdateFromRegistry () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.WebProxy…ctor (System.Boolean enableAutoproxy) (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.WebProxy.CreateDefaultProxy () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.Configuration.DefaultProxySectionInternal.GetSection () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.WebRequest.get_InternalDefaultWebProxy () (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.HttpWebRequest…ctor (System.Uri uri) (at <525dc68fbe6640f483d9939a51075a29>:0)
(wrapper remoting-invoke-with-check) System.Net.HttpWebRequest…ctor(System.Uri)
System.Net.HttpRequestCreator.Create (System.Uri uri) (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) (at <525dc68fbe6640f483d9939a51075a29>:0)
System.Net.WebRequest.Create (System.String requestUriString) (at <525dc68fbe6640f483d9939a51075a29>:0)
UnityEngine.Advertisements.Platform.Editor.EditorPlatform.Initialize (System.String gameId, System.Boolean testMode, System.Boolean enablePerPlacementLoad) (at Library/PackageCache/com.unity.ads@3.5.0/Runtime/Advertisement/Platform/Editor/EditorPlatform.cs:85)
UnityEngine.Advertisements.Platform.Platform.Initialize (System.String gameId, System.Boolean testMode, System.Boolean enablePerPlacementLoad) (at Library/PackageCache/com.unity.ads@3.5.0/Runtime/Advertisement/Platform/Platform.cs:64)
UnityEngine.Advertisements.Advertisement.Initialize (System.String gameId, System.Boolean testMode, System.Boolean enablePerPlacementLoad) (at Library/PackageCache/com.unity.ads@3.5.0/Runtime/Advertisement/Advertisement.cs:83)
UnityEngine.Advertisements.Advertisement.Initialize (System.String gameId, System.Boolean testMode) (at Library/PackageCache/com.unity.ads@3.5.0/Runtime/Advertisement/Advertisement.cs:67)
Test.Start () (at Assets/Scripts/Test.cs:29)
I Looked At Different Forums But Can’t Find The Answers, If You Need The Script Then Here :
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Advertisements;
[RequireComponent(typeof(Button))]
public class Test : MonoBehaviour, IUnityAdsListener {
#if UNITY_ANDROID
private string gameId = "3859891";
#elif UNITY_EDITOR
private string gameId = "3859891";
#endif
Button myButton;
public string myPlacementId = "rewardedVideo";
void Start()
{
myButton = GetComponent<Button>();
// Set interactivity to be dependent on the Placement’s status:
myButton.interactable = Advertisement.IsReady(myPlacementId);
// Map the ShowRewardedVideo function to the button’s click listener:
if (myButton) myButton.onClick.AddListener(ShowRewardedVideo);
// Initialize the Ads listener and service:
Advertisement.AddListener(this);
Advertisement.Initialize(gameId, true);
}
// Implement a function for showing a rewarded video ad:
void ShowRewardedVideo()
{
Advertisement.Show(myPlacementId);
}
// Implement IUnityAdsListener interface methods:
public void OnUnityAdsReady(string placementId)
{
// If the ready Placement is rewarded, activate the button:
if (placementId == myPlacementId)
{
myButton.interactable = true;
}
}
public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
// Define conditional logic for each ad completion status:
if (showResult == ShowResult.Finished)
{
// Reward the user for watching the ad to completion.
}
else if (showResult == ShowResult.Skipped)
{
// Do not reward the user for skipping the ad.
}
else if (showResult == ShowResult.Failed)
{
Debug.LogWarning("The ad did not finish due to an error.");
}
}
public void OnUnityAdsDidError(string message)
{
// Log the error.
}
public void OnUnityAdsDidStart(string placementId)
{
// Optional actions to take when the end-users triggers an ad.
}
}