public void Initialize(string gameId, bool testMode) { var placeHolderGameObject = new GameObject("UnityMonetizationEditorPlaceHolderObject") { hideFlags = HideFlags.HideAndDontSave | HideFlags.HideInInspector }; m_Placeholder = placeHolderGameObject.AddComponent <Placeholder>(); string configurationUrl = string.Join("/", new string[] { s_BaseUrl, gameId, string.Join("&", new string[] { "configuration?platform=editor", "unityVersion=" + Uri.EscapeDataString(Application.unityVersion), "sdkVersionName=" + Uri.EscapeDataString(s_Version) }) }); WebRequest request = WebRequest.Create(configurationUrl); request.BeginGetResponse(result => { WebResponse response = request.EndGetResponse(result); var reader = new StreamReader(response.GetResponseStream()); string responseBody = reader.ReadToEnd(); try { m_Configuration = new Configuration(responseBody); if (!m_Configuration.enabled) { Debug.LogWarning("gameId " + gameId + " is not enabled"); } } catch (Exception exception) { Debug.LogError("Failed to parse configuration for gameId: " + gameId); Debug.Log(responseBody); Debug.LogException(exception); } reader.Close(); response.Close(); if (m_Configuration != null) { foreach (KeyValuePair <string, PlacementContent> entry in m_Configuration.placementContents) { _callbackExecutor.Post((executor) => { OnPlacementContentReady?.Invoke(this, new PlacementContentReadyEventArgs(entry.Key, entry.Value)); }); } } }, null); isInitialized = true; UnityEngine.Advertisements.Advertisement.Initialize(gameId, testMode); Debug.Log("UnityMonetizationEditor: Initialize(" + gameId + ", " + testMode + ");"); }
void onAdFinished(string placementId, AndroidJavaObject withState) { callbackExecutor.Post((executor) => { if (callbacks?.finishCallback != null) { var showResult = (ShowResult)withState.Call <int>("ordinal"); callbacks?.finishCallback?.Invoke(showResult); } }); }
void FinishHandler(object sender, AdFinishedEventArgs e) { OnAdFinished -= FinishHandler; _executor.Post(executor => { _showAdCallbacks?.finishCallback(e.result); }); }