コード例 #1
0
            public void SendPackageSelectionChangedEvent(IPackage package, IPackageVersion version)
            {
                // Due to the way the Package Manager window initializes, the first `OnPackageSelectionChanged` would happen before the `OnWindowCreated`
                // That means the first time `OnPackageSelectionChanged` is triggered, the window is not fully ready and `m_Window` is null
                // Hence we want to delay calling this first `OnPackageSelectionChanged` until the window is created in `OnWindowCreated`
                if (m_Window == null)
                {
                    m_DelayedPackageSelection = new Tuple <IPackage, IPackageVersion>(package, version);
                    return;
                }

                foreach (var extension in packageSelectionChangedHandlers)
                {
                    try
                    {
                        var args = new PackageSelectionArgs {
                            package = package, packageVersion = version, window = m_Window
                        };
                        extension.OnPackageSelectionChanged(args);
                    }
                    catch (Exception exception)
                    {
                        Debug.LogError(string.Format(k_ExtensionErrorMessage, exception));
                    }
                }
            }
コード例 #2
0
        public void OnPackageSelectionChanged(PackageSelectionArgs args)
        {
            var packageInfo       = args.packageVersion?.packageInfo;
            var editorGameService = GetEditorGameServiceField(packageInfo);
            var configurePath     = GetConfigurePathField(editorGameService);

            m_ConfigureButton.visible = !string.IsNullOrEmpty(configurePath);
            m_ConfigureButton.enabled = args.packageVersion?.isInstalled ?? false;
        }
コード例 #3
0
        private void ValidateClicked(PackageSelectionArgs args)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                Debug.LogWarning("Validation suite requires network access and cannot be used offline.");
                return;
            }

            ValidationSuite.ValidatePackage(args.packageVersion.VersionId(), ValidationType.LocalDevelopment);
            ShowValidationReport(args);
        }
コード例 #4
0
 private void EmbedClicked(PackageSelectionArgs args)
 {
     if (CanBeEmbedded(args.packageVersion))
     {
         Client.Embed(args.packageVersion.name);
     }
     else
     {
         //TODO: Update error message since it's misleading
         UnityEngine.Debug.LogError(L10n.Tr("This package is not installed. Please install it before you can develop it."));
     }
 }
コード例 #5
0
        private void CloneClicked(PackageSelectionArgs args)
        {
            var packageVersion = args.packageVersion;

            EditorUtility.DisplayProgressBar($"{L10n.Tr("Cloning")} {packageVersion.displayName}", $"{packageVersion.packageInfo.repository.url}", 1.0f);

            var process = new Process();

            process.StartInfo.Environment["GIT_TERMINAL_PROMPT"] = "0";
            process.StartInfo.FileName              = "git";
            process.StartInfo.WorkingDirectory      = k_PackagesFolder;
            process.StartInfo.Arguments             = string.Format("clone {0} {1}", packageVersion.packageInfo.repository.url, packageVersion.packageUniqueId);
            process.StartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.UseShellExecute       = false;
            if (!process.Start())
            {
                m_DevelopMenu.enabled = true;
                UnityEngine.Debug.LogError(L10n.Tr("Couldn't start a new process to launch git."));
                return;
            }

            m_ReadBuffer   = new StringBuilder();
            m_StreamReader = process.StandardError;

            var t = new Thread(FetchOutputWindow)
            {
                IsBackground = true
            };

            t.Start();

            EditorApplication.delayCall += () =>
            {
                process.WaitForExit();
                EditorUtility.ClearProgressBar();

                t.Join();

                if (process.ExitCode != 0)
                {
                    m_DevelopMenu.enabled = true;
                    UnityEngine.Debug.LogError(m_ReadBuffer.ToString());
                    return;
                }
                AssetDatabase.Refresh();
            };
        }
コード例 #6
0
        private void ShowTryoutReport(PackageSelectionArgs args)
        {
            string reportFilePath;
            string logFilePath;

            GetTryoutReportAndLogPaths(args.packageVersion, out reportFilePath, out logFilePath);
            if (!string.IsNullOrEmpty(reportFilePath) && File.Exists(reportFilePath))
            {
                var report = JsonUtility.FromJson <TryOutReport>(File.ReadAllText(reportFilePath));
                if (File.Exists(logFilePath))
                {
                    EditorUtility.OpenWithDefaultApp(logFilePath);
                }
                else
                {
                    EditorUtility.DisplayDialog($"Try out package {args.packageVersion.VersionId()}", report.message, "Close");
                }
            }
        }
コード例 #7
0
        private static void OnConfigureClicked(PackageSelectionArgs args)
        {
            var database         = ServicesContainer.instance.Resolve <PackageDatabase>();
            var package          = database.GetPackage(args.package.uniqueId);
            var installedVersion = package?.versions?.installed;

            if (installedVersion == null)
            {
                return;
            }

            var editorGameService = GetEditorGameServiceField(installedVersion.packageInfo);
            var configurePath     = GetConfigurePathField(editorGameService);

            if (!string.IsNullOrEmpty(configurePath))
            {
                PackageManagerWindowAnalytics.SendEvent("configureService", args.package.uniqueId);
            }
            SettingsService.OpenProjectSettings(configurePath);
        }
コード例 #8
0
 public void OnPackageSelectionChanged(PackageSelectionArgs args)
 {
     m_Selection = args;
     RefreshVisibility();
 }
コード例 #9
0
 public void OnPackageSelectionChanged(PackageSelectionArgs args)
 {
     m_DevelopMenu.visible = CanBeEmbedded(args.packageVersion);
 }
コード例 #10
0
 public void OnPackageSelectionChanged(PackageSelectionArgs args)
 {
     m_Selection = args;
     RefreshAllButtons(args.packageVersion);
 }
コード例 #11
0
        private void TryoutClicked(PackageSelectionArgs args)
        {
            var destination = Path.Combine(Directory.GetCurrentDirectory(), "Temp", "TryOut");

            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }

            var packageVersion = args.packageVersion;
            var packageId      = $"{packageVersion.name}-{packageVersion.versionString}";
            var tarballName    = $"{packageId}.tgz";
            var tarballFile    = Path.Combine(destination, tarballName);

            if (File.Exists(tarballFile))
            {
                File.Delete(tarballFile);
            }

            var logFile = Path.Combine(destination, $"{packageId}.tryout.log");

            if (File.Exists(logFile))
            {
                File.Delete(logFile);
            }

            var reportFile = Path.Combine(destination, $"{packageId}.tryout.report");

            if (File.Exists(reportFile))
            {
                File.Delete(reportFile);
            }

            var report = new TryOutReport();

            EditorUtility.DisplayProgressBar($"Try out package {packageId}", $"Publish package {packageId} to tarball...", 1.0f);
            LocalPublishExtension.Publish(packageVersion, destination, path =>
            {
                var p       = new Process();
                var appPath = EditorApplication.applicationPath;
#if UNITY_EDITOR_OSX
                appPath += "/Contents/MacOS/Unity";
#endif
                p.StartInfo.FileName = appPath;

                var projectPath = Path.Combine(Path.GetTempPath(), GUID.Generate().ToString());
                if (!Directory.Exists(projectPath))
                {
                    Directory.CreateDirectory(projectPath);
                }

                Directory.CreateDirectory(Path.Combine(projectPath, "Assets"));
                Directory.CreateDirectory(Path.Combine(projectPath, "Packages"));

                var manifest = "{\"dependencies\":{\"" + packageVersion.name + "\":\"file:" + path.Replace('\\', '/') + '/' + tarballName + "\"}}";
                File.WriteAllText(Path.Combine(projectPath, "Packages", "manifest.json"), manifest);

                p.StartInfo.Arguments = "-upmNoDefaultPackages -forgetProjectPath -projectPath \"" + projectPath + "\" -cleanTestPrefs -logFile \"" + logFile + "\"";

                var message = string.Empty;
                try
                {
                    if (!p.Start())
                    {
                        message = "Unable to start process " + p.StartInfo.FileName;
                    }
                }
                catch (Exception e)
                {
                    message = e.Message;
                }

                if (!string.IsNullOrEmpty(message))
                {
                    Debug.LogError($"[TryOut] Error: {message}");
                    EditorUtility.ClearProgressBar();

                    report.exitCode = -1;
                    report.message  = message;

                    File.WriteAllText(reportFile, JsonUtility.ToJson(report));
                    RefreshTryoutStatus(packageVersion);
                    return;
                }

                EditorUtility.DisplayProgressBar($"Try out package {packageId}", $"Waiting process {p.Id} to end...", 1.0f);
                EditorApplication.delayCall += () =>
                {
                    p.WaitForExit();
                    EditorUtility.ClearProgressBar();

                    report.exitCode = p.ExitCode;
                    report.message  = string.Empty;

                    File.WriteAllText(reportFile, JsonUtility.ToJson(report));

                    RefreshTryoutStatus(packageVersion);
                };
            }, error =>
            {
                Debug.LogError($"[TryOut] Error: {error}");
                EditorUtility.ClearProgressBar();

                report.exitCode = -1;
                report.message  = error;

                File.WriteAllText(reportFile, JsonUtility.ToJson(report));

                RefreshTryoutStatus(packageVersion);
            });
        }
コード例 #12
0
 internal void TestClicked(PackageSelectionArgs args)
 {
     m_PackageTestRunner.Test(args.package?.name, TestMode.PlayMode | TestMode.EditMode);
 }
コード例 #13
0
 internal void ShowValidationReport(PackageSelectionArgs args)
 {
     ValidationSuiteReportWindow.Open(args.packageVersion);
     RefreshValidationStatus(args.packageVersion);
 }