public static ZBaseEditorCoroutines StartEditorCoroutine(IEnumerator routine)
    {
        ZBaseEditorCoroutines coroutine = new ZBaseEditorCoroutines(routine);

        coroutine.start();
        return(coroutine);
    }
Example #2
0
    private void CheckVersion()
    {
        latest_tag       = string.Empty;
        progressLoadData = 0;

        GetLatestTagRelease();
        mEditorCoroutines = ZBaseEditorCoroutines.StartEditorCoroutine(GetPackageLockServer());
        mEditorCoroutines = ZBaseEditorCoroutines.StartEditorCoroutine(GetVersionFromPackageLockLocal());
    }
Example #3
0
    private void CancelDownload()
    {
        isProcessing = false;

        if (mEditorCoroutines != null)
        {
            mEditorCoroutines.StopEditorCoroutine();
            mEditorCoroutines = null;
        }
    }
Example #4
0
    private IEnumerator GetPackageLockServer()
    {
        while (!string.IsNullOrEmpty(latest_tag))
        {
            yield return(new WaitForSeconds(0.1f));
        }

        if (latest_tag == "none")
        {
            yield return(null);
        }

        string urlPackageLock = string.Format(packLockURL, ZBasePackageIdConfig.REPO);

        mEditorCoroutines = ZBaseEditorCoroutines.StartEditorCoroutine(GetRequest(urlPackageLock, (result) => GetDataFromPackageLockServer(result)));
    }
Example #5
0
    //private void GetToolVersionInfoFromServer(Dictionary<string, object> data)
    //{
    //    zBaseManagerProviderServer = new providerInfo();
    //    foreach (var item in data)
    //    {
    //        try
    //        {
    //            if (item.Key.ToLower().Equals("name"))
    //            {
    //                zBaseManagerProviderServer.providerName = item.Value as string;
    //            }
    //            else if (item.Key.ToLower().Equals("displayname"))
    //            {
    //                zBaseManagerProviderServer.displayProviderName = item.Value as string;
    //            }
    //            else if (item.Key.ToLower().Equals("version"))
    //            {
    //                zBaseManagerProviderServer.currentUnityVersion = zBaseManagerProviderServer.latestUnityVersion = item.Value as string;
    //            }

    //        }
    //        catch (Exception e)
    //        {
    //            Debug.Log("Error parse tool version info " + e.ToString());
    //        }
    //    }

    //    progressLoadData++;
    //    Debug.Log(string.Format("***Tool {0} on server, version {1}***", zBaseManagerProviderServer.displayProviderName, zBaseManagerProviderServer.latestUnityVersion));

    //}

    private void GetDataFromPackageLockServer(Dictionary <string, object> data)
    {
        providersSet.Clear();

        try
        {
            object dependencies;

            if (data.TryGetValue("dependencies", out dependencies))
            {
                if (dependencies != null)
                {
                    Dictionary <string, object> listPackages = dependencies as Dictionary <string, object>;

                    foreach (var item in dependencies as Dictionary <string, object> )
                    {
                        ProviderInfo info = new ProviderInfo();
                        if (ZBasePackageIdConfig.listPackages.ContainsKey(item.Key))
                        {
                            if (info.GetFromJson(item.Key, item.Value as Dictionary <string, object>))
                            {
                                providersSet.Add(info.providerName, info);
                                if (info.currentUnityVersion != "none")
                                {
                                    Debug.Log(string.Format("***Package {0} on server, version {1}***", info.displayProviderName, info.latestUnityVersion));
                                }
                            }
                        }
                    }
                }
            }

            progressLoadData++;

            ZBaseEditorCoroutines.StartEditorCoroutine(GetVersionForEmbeddedPack());
        }
        catch (Exception e)
        {
            Debug.LogError("Error Get Version From Package Lock Server: " + e.Message);
        }
    }
Example #6
0
    private void GetPackageFromServer(string packageName, System.Action <Dictionary <string, object> > callback)
    {
        string urlPackage = string.Format(packVersionURL, ZBasePackageIdConfig.REPO, packageName);

        mEditorCoroutines = ZBaseEditorCoroutines.StartEditorCoroutine(GetRequest(urlPackage, (result) => callback(result)));
    }
Example #7
0
    private void GetLatestTagRelease()
    {
        string urlLatestRelease = string.Format(latestTagURL, ZBasePackageIdConfig.REPO);

        mEditorCoroutines = ZBaseEditorCoroutines.StartEditorCoroutine(GetRequest(urlLatestRelease, (result) => GetLatestTag(result)));
    }
Example #8
0
    void DrawProviderItem(ProviderInfo providerData)
    {
        if (providerData == null)
        {
            return;
        }

        if (!providerData.Equals(default(ProviderInfo)))
        {
            using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(false)))
            {
                GUI.enabled = true;

                EditorGUILayout.LabelField(providerData.displayProviderName, textStyle);
                EditorGUILayout.LabelField(providerData.currentUnityVersion, textStyle);
                EditorGUILayout.LabelField(providerData.latestUnityVersion, textStyle);

                using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))
                {
                    if (providerData.currentStatues == ZBaseEnum.Status.none)
                    {
                        bool btn = GUILayout.Button(new GUIContent
                        {
                            text = "Install",
                        }, buttonWidth);
                        if (btn && !isProcessing)
                        {
                            GUI.enabled = true;
                            try
                            {
                                Debug.LogWarning(">>>>>>>>> Install Click! <<<<<<<<<<");
                                ZBaseEditorCoroutines.StartEditorCoroutine(AddPackage(providerData, (result) =>
                                {
                                    if (result.Status == StatusCode.Success)
                                    {
                                        Debug.Log(string.Format("***Install Success {0} {1}***", providerData.providerName, providerData.latestUnityVersion));
                                        canRefresh = true;
                                    }
                                }));
                            }
                            catch (System.Exception e)
                            {
                                Debug.LogError("Error " + e.Message);
                            }
                        }
                    }
                    else if (providerData.currentStatues == ZBaseEnum.Status.installed)
                    {
                        var btn = GUILayout.Button(new GUIContent
                        {
                            text = "Update",
                        }
                                                   , buttonWidth);
                        if (btn && !isProcessing)
                        {
                            GUI.enabled = true;
                            try
                            {
                                Debug.LogWarning(">>>>>>>>> Update Click! <<<<<<<<<<");
                                ZBaseEditorCoroutines.StartEditorCoroutine(AddPackage(providerData, (result) =>
                                {
                                    if (result.Status == StatusCode.Success)
                                    {
                                        Debug.Log(string.Format("***Update Success {0} {1}***", providerData.providerName, providerData.latestUnityVersion));
                                        canRefresh = true;
                                    }
                                }));
                            }
                            catch (System.Exception e)
                            {
                                Debug.LogError("Error " + e.Message);
                            }
                        }
                    }
                    else
                    {
                        GUI.enabled = false;
                        GUILayout.Button(new GUIContent
                        {
                            text = "Updated",
                        }, buttonWidth);
                    }

                    if (providerData.currentStatues != ZBaseEnum.Status.none && providerData.providerName != ZBasePackageIdConfig.namePackageManager)
                    {
                        GUI.enabled = true;
                        var btn = GUILayout.Button(new GUIContent
                        {
                            text = "Remove",
                        }
                                                   , buttonWidth);
                        if (btn && !isProcessing)
                        {
                            GUI.enabled = true;
                            try
                            {
                                Debug.LogWarning(">>>>>>>>> Remove Click! <<<<<<<<<<");
                                ZBaseEditorCoroutines.StartEditorCoroutine(RemovePackage(providerData.providerName, (result) =>
                                {
                                    if (result.Status == StatusCode.Success)
                                    {
                                        Debug.Log(string.Format("***Remove Success {0} {1}***", providerData.providerName, providerData.latestUnityVersion));
                                        canRefresh = true;
                                    }
                                }));
                            }
                            catch (System.Exception e)
                            {
                                Debug.LogError("Error " + e.Message);
                            }
                        }
                    }
                }

                GUILayout.Space(5);
                GUI.enabled = true;
            }
        }
    }