Exemplo n.º 1
0
        protected override void OnBegin()
        {
            base.OnBegin();

            var tempFile = mRequestPackageData.Name + ".unitypackage";

            Debug.Log(mRequestPackageData.DownloadUrl + ">>>>>>:");

            EditorUtility.DisplayProgressBar("插件更新", "插件下载中 ...", 0.5f);

            var client = new WebClient();

            client.DownloadProgressChanged += OnProgressChanged;

            client.DownloadFile(new Uri(mRequestPackageData.DownloadUrl), tempFile);

            client.DownloadProgressChanged -= OnProgressChanged;

            EditorUtility.ClearProgressBar();

            AssetDatabase.ImportPackage(tempFile, true);

            File.Delete(tempFile);

            mRequestPackageData.SaveVersionFile();

            AssetDatabase.Refresh();

            InstalledPackageVersions.Reload();
        }
Exemplo n.º 2
0
        protected override void OnBegin()
        {
            base.OnBegin();

            var tempFile = "Assets/" + mRequestPackageData.Name + ".unitypackage";

            Debug.Log(mRequestPackageData.DownloadUrl + ">>>>>>:");

            EditorUtility.DisplayProgressBar("插件更新", "插件下载中 ...", 0.1f);

            var progressListener = new ScheduledNotifier <float>();

            ObservableWWW.GetAndGetBytes(mRequestPackageData.DownloadUrl, null, progressListener)
            .Subscribe(bytes =>
            {
                File.WriteAllBytes(tempFile, bytes);

                EditorUtility.ClearProgressBar();

                AssetDatabase.ImportPackage(tempFile, true);

                File.Delete(tempFile);

                mRequestPackageData.SaveVersionFile();

                AssetDatabase.Refresh();

                InstalledPackageVersions.Reload();
            });

            progressListener.Subscribe(OnProgressChanged);
        }
Exemplo n.º 3
0
        private static bool CheckNewVersionDialog(List <PackageData> requestPackageDatas, List <PackageData> cachedPackageDatas)
        {
            foreach (var requestPackageData in requestPackageDatas)
            {
                var cachedPacakgeData =
                    cachedPackageDatas.Find(packageData => packageData.Name == requestPackageData.Name);

                var installedPackageVersion = InstalledPackageVersions.Get()
                                              .Find(packageVersion => packageVersion.Name == requestPackageData.Name);

                if (installedPackageVersion == null)
                {
                }
                else if (cachedPacakgeData == null &&
                         requestPackageData.VersionNumber > installedPackageVersion.VersionNumber ||
                         cachedPacakgeData != null && requestPackageData.Installed &&
                         requestPackageData.VersionNumber > cachedPacakgeData.VersionNumber &&
                         requestPackageData.VersionNumber > installedPackageVersion.VersionNumber)
                {
                    ShowDisplayDialog(requestPackageData.Name);
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        public void Init(PreferencesWindow window)
        {
            mMainWindow = window;

            mPackageDatas = PackageInfosRequestCache.Get().PackageDatas;

            InstalledPackageVersions.Reload();

            EditorActionKit.ExecuteNode(new GetAllRemotePackageInfo(packageDatas => { mPackageDatas = packageDatas; }));
        }
        public void Init(EditorWindow window)
        {
            FrameworkLocalVersion = FrameworkLocalVersion.Get();

            mPackageDatas = PackageInfosRequestCache.Get().PackageDatas;

            InstalledPackageVersions.Reload();

            EditorActionKit.ExecuteNode(new GetAllRemotePackageInfo(packageDatas => { mPackageDatas = packageDatas; }));
        }
Exemplo n.º 6
0
        protected override void OnBegin()
        {
            base.OnBegin();

            var tempFile = "Assets/" + mRequestPackageData.Name + ".unitypackage";

            Debug.Log(mRequestPackageData.DownloadUrl + ">>>>>>:");

            EditorUtility.DisplayProgressBar("插件更新", "插件下载中 ...", 0.1f);

            var progressListener = new ScheduledNotifier <float>();

            ObservableWWW.GetAndGetBytes(mRequestPackageData.DownloadUrl, null, progressListener)
            .Subscribe(bytes =>
            {
                File.WriteAllBytes(tempFile, bytes);

                EditorUtility.ClearProgressBar();

                AssetDatabase.ImportPackage(tempFile, false);

                File.Delete(tempFile);

                mRequestPackageData.SaveVersionFile();

                AssetDatabase.Refresh();

                EditorUtility.DisplayDialog(mRequestPackageData.Name, "插件下载成功", "OK");

                InstalledPackageVersions.Reload();

//					EditorApplication.ExecuteMenuItem(FrameworkMenuItems.Preferences);
            }, e =>
            {
                EditorUtility.ClearProgressBar();

                EditorUtility.DisplayDialog(mRequestPackageData.Name, "插件安装失败,请联系 [email protected] 或者加入 QQ 群:623597263" + e.ToString() + ";", "OK");
            });

            progressListener.Subscribe(OnProgressChanged);
        }
Exemplo n.º 7
0
        public void OnGUI()
        {
            GUILayout.Label("Framework:");
            GUILayout.BeginVertical("box");

            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("QFramework:{0}",
                                          mPackageDatas.Find(packageData => packageData.Name == "Framework").Version), GUILayout.Width(150));

            VersionCheck = GUILayout.Toggle(VersionCheck, "Version Check");

            GUILayout.EndHorizontal();

            mToolbarIndex = GUILayout.Toolbar(mToolbarIndex, ToolbarNames);

            // 这里开始具体的内容
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Package", GUILayout.Width(150));
            GUILayout.Label("Server", GUILayout.Width(80));
            GUILayout.Label("Local", GUILayout.Width(80));
            GUILayout.Label("Right", GUILayout.Width(120));
            GUILayout.Label("Action", GUILayout.Width(100));
            GUILayout.Label("Readme", GUILayout.Width(100));
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical("box");

            mScrollPos = GUILayout.BeginScrollView(mScrollPos, false, true, GUILayout.Height(240));

            foreach (var packageData in SelectedPackageType)
            {
                GUILayout.Space(2);
                GUILayout.BeginHorizontal();
                GUILayout.Label(packageData.Name, GUILayout.Width(150));
                GUILayout.Label(packageData.Version, GUILayout.Width(80));
                var installedPackage = InstalledPackageVersions.FindVersionByName(packageData.Name);
                GUILayout.Label(installedPackage != null ? installedPackage.Version : " ", GUILayout.Width(80));
                GUILayout.Label(packageData.AccessRight.ToString(), GUILayout.Width(120));

                if (installedPackage == null)
                {
                    if (GUILayout.Button("Import", GUILayout.Width(90)))
                    {
                        EditorActionKit.ExecuteNode(new InstallPackage(packageData));

                        mMainWindow.Close();
                        mMainWindow = null;
                    }
                }
                else if (installedPackage != null && packageData.VersionNumber > installedPackage.VersionNumber)
                {
                    if (GUILayout.Button("Update", GUILayout.Width(90)))
                    {
                        var path = Application.dataPath.Replace("Assets", packageData.InstallPath);

                        if (Directory.Exists(path))
                        {
                            Directory.Delete(path, true);
                        }

                        EditorActionKit.ExecuteNode(new InstallPackage(packageData));

                        mMainWindow.Close();
                        mMainWindow = null;
                    }
                }
                else if (installedPackage != null)
                {
                    // maybe support upload?
                    GUILayout.Space(94);
                }

                if (GUILayout.Button("Readme", GUILayout.Width(90)))
                {
                    ReadmeWindow.Init(packageData.readme, packageData.PackageVersions.First());
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();

            GUILayout.Space(2);

            GUILayout.EndVertical();

            GUILayout.EndVertical();


            GUILayout.Space(50);
        }
        private void DrawWithServer()
        {
            // 这里开始具体的内容
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Package", GUILayout.Width(150));
            GUILayout.Label("Server", GUILayout.Width(100));
            GUILayout.Label("Local", GUILayout.Width(100));
            GUILayout.Label("Action", GUILayout.Width(100));
            GUILayout.Label("Readme", GUILayout.Width(100));
            GUILayout.EndHorizontal();

            GUILayout.BeginVertical("box");

            mScrollPos = GUILayout.BeginScrollView(mScrollPos, false, true, GUILayout.Height(240));

            foreach (var packageData in mPackageDatas)
            {
                GUILayout.Space(2);
                GUILayout.BeginHorizontal();
                GUILayout.Label(packageData.Name, GUILayout.Width(150));
                GUILayout.Label(packageData.Version, GUILayout.Width(100));
                var insalledPackage = InstalledPackageVersions.FindVersionByName(packageData.Name);
                GUILayout.Label(insalledPackage != null ? insalledPackage.Version : " ", GUILayout.Width(90));

                if (insalledPackage != null && packageData.VersionNumber > insalledPackage.VersionNumber)
                {
                    if (GUILayout.Button("Update", GUILayout.Width(90)))
                    {
                        var path = Application.dataPath.Replace("Assets", packageData.InstallPath);

                        if (Directory.Exists(path))
                        {
                            if (EditorUtility.DisplayDialog("UpdatePackage", "是否移除本地旧版本?", "是", "否"))
                            {
                                Directory.Delete(path, true);

                                AssetDatabase.Refresh();
                            }
                        }

                        EditorActionKit.ExecuteNode(new InstallPackage(packageData));
                    }
                }
                else
                {
                    if (GUILayout.Button("Import", GUILayout.Width(90)))
                    {
                        EditorActionKit.ExecuteNode(new InstallPackage(packageData));
                    }
                }

                if (GUILayout.Button("Readme", GUILayout.Width(90)))
                {
                    ShowReadMe(packageData.readme);
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();

            GUILayout.Space(2);

            GUILayout.EndVertical();
        }