Esempio n. 1
0
    private IEnumerator DownloadFile(string downloadFileUrl, string downloadFileName)
    {
        string fileDownloading = string.Format("Downloading {0}", downloadFileName);
        string path            = Path.Combine(ironSourceDownloadDir, downloadFileName);

        downloadWebClient = new UnityWebRequest(downloadFileUrl);
        downloadWebClient.downloadHandler = new DownloadHandlerFile(path);
        downloadWebClient.SendWebRequest();
        if (!downloadWebClient.isHttpError && !downloadWebClient.isNetworkError)
        {
            while (!downloadWebClient.isDone)
            {
                yield return(new WaitForSeconds(0.1f));

                if (EditorUtility.DisplayCancelableProgressBar("Download Manager", fileDownloading, downloadWebClient.downloadProgress))
                {
                    Debug.LogError(downloadWebClient.error);
                    CancelDownload();
                }
            }
        }
        else
        {
            Debug.LogError("Error Downloading " + downloadFileName + " : " + downloadWebClient.error);
        }
        EditorUtility.ClearProgressBar();

        //clean the downloadWebClient object regardless of whether the request succeeded or failed
        downloadWebClient.Dispose();
        downloadWebClient = null;
        IronSourceEditorCoroutines.StartEditorCoroutine(GetVersions());
    }
Esempio n. 2
0
    public static IronSourceEditorCoroutines StartEditorCoroutine(IEnumerator routine)
    {
        IronSourceEditorCoroutines coroutine = new IronSourceEditorCoroutines(routine);

        coroutine.start();
        return(coroutine);
    }
Esempio n. 3
0
    private IEnumerator DownloadFile(string downloadFileUrl)
    {
        int    fileNameIndex    = downloadFileUrl.LastIndexOf("/") + 1;
        string downloadFileName = downloadFileUrl.Substring(fileNameIndex);
        string fileDownloading  = string.Format("Downloading {0}", downloadFileName);
        string genericFileName  = Regex.Replace(downloadFileName, @"_v+(\d\.\d\.\d\.\d|\d\.\d\.\d)", "");
        string path             = Path.Combine(ironSourceDownloadDir, genericFileName);
        bool   isCancelled      = false;

        downloadWebClient = new UnityWebRequest(downloadFileUrl);
        downloadWebClient.downloadHandler = new DownloadHandlerFile(path);
        downloadWebClient.SendWebRequest();
        if (!downloadWebClient.isHttpError && !downloadWebClient.isNetworkError)
        {
            while (!downloadWebClient.isDone)
            {
                yield return(new WaitForSeconds(0.1f));

                if (EditorUtility.DisplayCancelableProgressBar("Download Manager", fileDownloading, downloadWebClient.downloadProgress))
                {
                    if (downloadWebClient.error != null)
                    {
                        Debug.LogError(downloadWebClient.error);
                    }
                    CancelDownload();
                    isCancelled = true;
                }
            }
        }
        else
        {
            Debug.LogError("Error Downloading " + genericFileName + " : " + downloadWebClient.error);
        }

        EditorUtility.ClearProgressBar();

        if (genericFileName.EndsWith(".unitypackage") && !isCancelled)
        {
            AssetDatabase.ImportPackage(Path.Combine(ironSourceDownloadDir, genericFileName), true);
        }
        else
        {
            // in case the download was cancelled, delete the file
            if (isCancelled && File.Exists(ironSourceDownloadDir + genericFileName))
            {
                File.Delete(ironSourceDownloadDir + genericFileName);
            }

            IronSourceEditorCoroutines.StartEditorCoroutine(GetVersions());
        }

        //clean the downloadWebClient object regardless of whether the request succeeded or failed
        downloadWebClient.Dispose();
        downloadWebClient = null;

        IronSourceEditorCoroutines.StartEditorCoroutine(GetVersions());
    }
Esempio n. 4
0
    private void CancelDownload()
    {
        // if downloader object is still active
        if (downloadWebClient != null)
        {
            downloadWebClient.Abort();
            return;
        }

        if (mEditorCoroutines != null)
        {
            mEditorCoroutines.StopEditorCoroutine();
            mEditorCoroutines = null;
        }

        downloadWebClient = null;
    }
Esempio n. 5
0
 void Awake()
 {
     headerStyle = new GUIStyle(EditorStyles.label)
     {
         fontStyle    = FontStyle.Bold,
         fontSize     = 14,
         fixedHeight  = 20,
         stretchWidth = true,
         fixedWidth   = Width / 4 + 5,
         clipping     = TextClipping.Overflow,
         alignment    = TextAnchor.MiddleLeft
     };
     textStyle = new GUIStyle(EditorStyles.label)
     {
         fontStyle = FontStyle.Normal,
         alignment = TextAnchor.MiddleLeft
     };
     boldTextStyle = new GUIStyle(EditorStyles.label)
     {
         fontStyle = FontStyle.Bold
     };
     CancelDownload();
     mEditorCoroutines = IronSourceEditorCoroutines.StartEditorCoroutine(GetVersions());
 }
Esempio n. 6
0
    void DrawProviderItem(providerInfo providerData)
    {
        if (!providerData.Equals(default(providerInfo)))
        {
            using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(false)))
            {
                GUI.enabled = true;
                bool   isNew          = providerData.isNewProvider;
                string isNewAddition  = isNew ? " - New Network" : string.Empty;
                string androidVersion = "";
                string iosVersion     = "";
                string tooltipText    = "Latest Version: \n " + providerData.providerName + " Adapter Version " + providerData.latestUnityVersion;
                if (!providerData.sdkVersionDic.TryGetValue(Android, out androidVersion))
                {
                    androidVersion = "";
                }
                else
                {
                    tooltipText = tooltipText + "\n Android SDK version " + androidVersion;
                }
                if (!providerData.sdkVersionDic.TryGetValue(iOS, out iosVersion))
                {
                    iosVersion = "";
                }
                else
                {
                    tooltipText = tooltipText + "\n iOS SDK version " + iosVersion;
                }

                EditorGUILayout.LabelField(providerData.displayProviderName + isNewAddition, isNew ? boldTextStyle : textStyle);//, isNew ? new GUIStyle { fontStyle = FontStyle.Bold, } : new GUIStyle());
                EditorGUILayout.LabelField(providerData.currentUnityVersion, textStyle);
                EditorGUILayout.LabelField(providerData.latestUnityVersion, textStyle);

                if (providerData.currentStatues == providerInfo.Status.none)
                {
                    bool btn = GUILayout.Button(new GUIContent
                    {
                        text    = "Install",
                        tooltip = tooltipText
                    }, buttonWidth);
                    if (btn && downloadWebClient == null)
                    {
                        GUI.enabled = true;
                        IronSourceEditorCoroutines.StartEditorCoroutine(DownloadFile(providerData.downloadURL, providerData.fileName));
                    }
                }
                else if (providerData.currentStatues == providerInfo.Status.installed)
                {
                    var btn = GUILayout.Button(new GUIContent
                    {
                        text    = "Update",
                        tooltip = tooltipText
                    }
                                               , buttonWidth);
                    if (btn && downloadWebClient == null)
                    {
                        GUI.enabled = true;
                        IronSourceEditorCoroutines.StartEditorCoroutine(DownloadFile(providerData.downloadURL, providerData.fileName));
                    }
                }
                else
                {
                    GUI.enabled = false;
                    GUILayout.Button(new GUIContent
                    {
                        text    = "Updated",
                        tooltip = tooltipText
                    }, buttonWidth);
                }
                GUILayout.Space(5);
                GUI.enabled = true;
            }
        }
    }
Esempio n. 7
0
 private void OnEnable()
 {
     mEditorCoroutines = IronSourceEditorCoroutines.StartEditorCoroutine(GetVersions());
 }