private void OnInitializationComplete() { m_UnityAdsInternalListener?.OnInitializationComplete(); m_UserListener?.OnInitializationComplete(); }
public void Initialize(string gameId, bool testMode, bool enablePerPlacementLoad, IUnityAdsInitializationListener initializationListener) { if (m_StartedInitialization) { return; } m_StartedInitialization = true; m_LoadEnabled = enablePerPlacementLoad; m_GameId = gameId; if (m_Platform.DebugMode) { Debug.Log("UnityAdsEditor: Initialize(" + gameId + ", " + testMode + ", " + enablePerPlacementLoad + ");"); } #if ASSET_STORE Debug.LogWarning("Please consider upgrading to the Packman Distribution of the Unity Ads SDK. The Asset Store distribution will not longer be supported after Unity 2018.3"); #endif var placeHolderGameObject = new GameObject("UnityAdsEditorPlaceHolderObject") { hideFlags = HideFlags.HideAndDontSave | HideFlags.HideInInspector }; GameObject.DontDestroyOnLoad(placeHolderGameObject); m_Placeholder = placeHolderGameObject.AddComponent <Placeholder>(); m_Placeholder.OnFinish += (sender, e) => { m_Platform.UnityAdsDidFinish(e.placementId, e.showResult); if (!m_LoadEnabled) { m_Platform.UnityLifecycleManager.Post(() => { var placementIds = new List <string>(m_PlacementMap.Keys); foreach (var placementId in placementIds) { foreach (var listener in GetClonedHashSet(m_Platform.Listeners)) { listener?.OnUnityAdsReady(placementId); } } }); } }; var configurationUrl = string.Join("/", new string[] { k_BaseUrl, gameId, string.Join("&", new string[] { "configuration?platform=editor", "unityVersion=" + Uri.EscapeDataString(Application.unityVersion), "sdkVersionName=" + Uri.EscapeDataString(m_Platform.Version) }) }); var request = WebRequest.Create(configurationUrl); request.BeginGetResponse(result => { try { var response = request.EndGetResponse(result); var reader = new StreamReader(response.GetResponseStream() ?? throw new Exception("Null response stream fetching configuration")); var responseBody = reader.ReadToEnd(); try { m_Configuration = new Configuration(responseBody); if (!m_Configuration.enabled) { Debug.LogWarning("gameId " + gameId + " is not enabled"); } //Add placements to load list foreach (var placement in m_Configuration.placements) { m_PlacementMap.Add(placement.Key, !m_LoadEnabled); } m_Initialized = true; initializationListener?.OnInitializationComplete(); foreach (var placement in m_Configuration.placements) { if (m_LoadEnabled) { foreach (var queuedPlacementId in m_QueuedLoads) { Load(queuedPlacementId, null); } } else { m_Platform.UnityAdsReady(placement.Key); } } } catch (Exception exception) { Debug.LogError($"Failed to parse configuration for gameId: {gameId}"); Debug.Log(responseBody); Debug.LogError(exception.Message); m_Platform.UnityAdsDidError($"Failed to parse configuration for gameId: {gameId}"); initializationListener?.OnInitializationFailed(UnityAdsInitializationError.INTERNAL_ERROR, $"Failed to parse configuration for gameId: {gameId}"); } reader.Close(); response.Close(); } catch (Exception exception) { Debug.LogError($"Invalid configuration request for gameId: {gameId}"); Debug.LogError(exception.Message); m_Platform.UnityAdsDidError($"Invalid configuration request for gameId: {gameId}"); initializationListener?.OnInitializationFailed(UnityAdsInitializationError.INTERNAL_ERROR, $"Invalid configuration request for gameId: {gameId}"); } }, new object()); }
public void onInitializationComplete() { m_ManagedListener?.OnInitializationComplete(); }