示例#1
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;
            }
        }
    }