Exemple #1
0
    /// <summary>
    /// Initializes the Unity Ads SDK with <see cref="UnityAdsSettings"/>.
    /// To configure settings, go to Edit > Unity Ads Settings in the Unity Editor menu.
    /// </summary>
    public static void Initialize()
    {
        #if UNITY_ADS_SDK
        if (_isInitializing)
        {
            Debug.LogWarning("Unity Ads is already being initialized.");
            return;
        }
        else
        {
            _isInitializing = true;
        }

        if (isInitialized)
        {
            Debug.LogWarning("Unity Ads is already initialized.");
            _isInitializing = false;
            return;
        }
        else if (!isSupported)
        {
            Debug.LogWarning("Unity Ads is not supported on the current runtime platform.");
            _isInitializing = false;
            return;
        }
        else if (GetInstance() == null)
        {
            Debug.LogError("Failed to initialize the UnityAdsHelper. Instance not found.");
            _isInitializing = false;
            return;
        }
        else
        {
            _instance.DoInitialize();
        }
        #else
        if (isInitialized)
        {
            Debug.Log("Unity Ads is initialized.");
        }
        else
        {
            Debug.LogWarning("Unity Ads is not enabled. See the Connect window in Unity for details.");
        }
        #endif
    }