Beispiel #1
0
 private static bool ShouldTreatPackageAsMod(UnityEditor.PackageManager.PackageInfo package)
 {
     //if (package.status == UnityEditor.PackageManager.PackageStatus.Available
     //    && (package.source == UnityEditor.PackageManager.PackageSource.Embedded || package.source == UnityEditor.PackageManager.PackageSource.Git || package.source == UnityEditor.PackageManager.PackageSource.Local)
     //    )
     {
         var path = package.resolvedPath;
         if (!string.IsNullOrEmpty(path))
         {
             if (System.IO.Directory.Exists(path + "/Link~"))
             {
                 return(true);
             }
             if (System.IO.File.Exists(path + "/mcs.rsp"))
             {
                 return(true);
             }
             if (System.IO.File.Exists(path + "/Runtime/Resources/resdesc.asset"))
             {
                 return(true);
             }
             if (System.IO.File.Exists(path + "/Resources/resdesc.asset"))
             {
                 return(true);
             }
             if (System.IO.File.Exists(path + "/mod.readme.md"))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        internal static IEnumerable <AsmDefDescription> AllAssemblyDefinitions()
        {
            var guids = AssetDatabase.FindAssets("t:AssemblyDefinitionAsset");
            var ret   = new List <AsmDefDescription>();

            foreach (var guid in guids)
            {
                var asmdefFile = AssetDatabase.GUIDToAssetPath(guid);

                var fullpath      = new NPath(asmdefFile).MakeAbsolute();
                var asmdef        = JsonUtility.FromJson <AsmDefJsonObject>(fullpath.ReadAllText());
                var packageInfo   = PackageInfo.FindForAssetPath(asmdefFile.ToString());
                var packageSource = packageInfo?.source.ToString() ?? "NoPackage";
                // this creates a world of problems
                //if (AssemblyDefinitionUtility.IsRuntimeAssembly(path))
                ret.Add(new AsmDefDescription
                {
                    AsmdefName    = asmdef.name,
                    FullPath      = Path.GetFullPath(fullpath.ToString()),
                    Guid          = guid,
                    PackageSource = packageSource
                });
            }

            return(ret.OrderBy(asmdef => new NPath(asmdef.FullPath).RelativeTo(new NPath(Application.dataPath).Parent)));
        }
//----------------------------------------------------------------------------------------------------------------------
        void CopyDCCPluginsFromPackage(string dccPluginVersion, Action <string> onSuccess, Action <string> onFail)
        {
            PackageRequestJobManager.CreateListRequest(/*offlineMode=*/ true, /*includeIndirectIndependencies=*/ true,
                                                       /*onSuccess=*/ (listReq) => {
                PackageInfo packageInfo = listReq.FindPackage(MESHSYNC_DCC_PLUGIN_PACKAGE);
                if (null != packageInfo && packageInfo.version == dccPluginVersion)
                {
                    //Package is already installed.
                    CopyDCCPluginsFromPackage(dccPluginVersion);
                    onSuccess(packageInfo.version);
                    return;
                }

                string packageNameAndVer = $"{MESHSYNC_DCC_PLUGIN_PACKAGE}@{dccPluginVersion}";
                PackageRequestJobManager.CreateAddRequest(packageNameAndVer,
                                                          /*onSuccess=*/ (addReq) => {
                    //Package was successfully added
                    CopyDCCPluginsFromPackage(dccPluginVersion);
                    onSuccess(dccPluginVersion);
                },
                                                          /*onFail=*/ (req) => {
                    PackageInfo meshSyncInfo = listReq.FindPackage(MeshSyncConstants.PACKAGE_NAME);
                    onFail?.Invoke(meshSyncInfo.version);
                });
            },
                                                       /*OnFail=*/ null
                                                       );
        }
Beispiel #4
0
        static IEnumerable <string> FindVisualStudioDevEnvPaths()
        {
            string asset = AssetDatabase.FindAssets("VSWhere a:packages").Select(AssetDatabase.GUIDToAssetPath).FirstOrDefault(assetPath => assetPath.Contains("vswhere.exe"));

            if (string.IsNullOrWhiteSpace(asset)) // This may be called too early where the asset database has not replicated this information yet.
            {
                yield break;
            }
            UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(asset);
            var progpath = packageInfo.resolvedPath + asset.Substring("Packages/com.unity.ide.visualstudio".Length);
            var process  = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = progpath,
                    Arguments              = "-prerelease -property productPath",
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                }
            };

            process.Start();
            process.WaitForExit();

            while (!process.StandardOutput.EndOfStream)
            {
                yield return(process.StandardOutput.ReadLine());
            }
        }
        public void CurrentBuilderVersionIsDisplayedInTheTitlebar()
        {
            var packageInfo           = PackageInfo.FindForAssetPath("Packages/" + BuilderConstants.BuilderPackageName);
            var builderPackageVersion = packageInfo.version;

            Assert.True(ViewportPane.subTitle.Contains(builderPackageVersion));
        }
Beispiel #6
0
        private static void LinkPackageToMod(UnityEditor.PackageManager.PackageInfo package)
        {
            var path = package.resolvedPath;
            var mod  = System.IO.Path.GetFileName(path);

            if (mod.Contains("@"))
            {
                mod = mod.Substring(0, mod.IndexOf('@'));
            }
            if (System.IO.Directory.Exists(path + "/Link~/Mod"))
            {
                var link = "Assets/Mods/" + mod;
                if (!System.IO.Directory.Exists(link) && !System.IO.File.Exists(link))
                {
                    System.IO.Directory.CreateDirectory("Assets/Mods/");
                    ResManagerEditorEntryUtils.MakeDirLink(link, path + "/Link~/Mod");
                    ResManagerEditorEntryUtils.AddGitIgnore("Assets/Mods/.gitignore", mod);
                }
            }
            for (int i = 0; i < UniqueSpecialFolders.Length; ++i)
            {
                var usdir  = UniqueSpecialFolders[i];
                var link   = "Assets/" + usdir + "/Mods/" + mod + "/Content";
                var target = path + "/Link~/" + usdir;
                if (System.IO.Directory.Exists(target) && !System.IO.Directory.Exists(link) && !System.IO.File.Exists(link))
                {
                    System.IO.Directory.CreateDirectory("Assets/" + usdir + "/Mods/" + mod);
                    ResManagerEditorEntryUtils.MakeDirLink(link, target);
                }
            }
        }
Beispiel #7
0
        static void WriteAsmdefsJson(NPath directory)
        {
            var file = directory.Combine("asmdefs.json");

            if (file.FileExists() && alreadyWrittenDataFile)
            {
                return;
            }

            var asmdefs = new List <AsmDefDescription>();

            foreach (var asmdefFile in AllAssemblyDefinitions())
            {
                var asmdef        = JsonUtility.FromJson <AsmDefJsonObject>(asmdefFile.MakeAbsolute().ReadAllText());
                var packageInfo   = PackageInfo.FindForAssetPath(asmdefFile.ToString());
                var packageSource = packageInfo?.source.ToString() ?? "NoPackage";
                asmdefs.Add(new AsmDefDescription()
                {
                    AsmdefName = asmdef.name, FullPath = Path.GetFullPath(asmdefFile.ToString()), PackageSource = packageSource
                });
            }

            var projectPath = new NPath(UnityEngine.Application.dataPath).Parent;

            file.UpdateAllText(JsonSerialization.Serialize(new BeeAsmdefConfiguration()
            {
                asmdefs          = asmdefs,
                UnityProjectPath = projectPath.ToString(),
                ProjectName      = projectPath.FileName,
            }));
            alreadyWrittenDataFile = true;
        }
Beispiel #8
0
        /// <summary>
        /// 在PackageManager视窗
        /// 当选择插件包时,获取这个插件包的信息
        /// </summary>
        /// <param name="packageInfo"></param>
        public void OnPackageSelectionChange(PackageInfo packageInfo)
        {
            if (_ui == null)
            {
                return;
            }

            if (packageInfo == null)
            {
                return;
            }

            _selectPackageInfo = packageInfo;
            var packageId = _selectPackageInfo.packageId;

            // 判断这个包是否是git途径获取的
            _gitUrl = GetGitUrl(packageId);

            // 只有git途径获取的包,才能使用UPM Tool拓展功能
            if (string.IsNullOrEmpty(_gitUrl))
            {
                _ui.SetUIVisible(false);
                return;
            }

            _ui.SetUIVisible(true);

            _ui.ResetDrawPackageVersionUI();

            if (_inRequestList == false)
            {
                DrawDependenciesUt();
            }
        }
 private static string FormatName(UnityEditor.PackageManager.PackageInfo pi)
 {
     if (String.IsNullOrEmpty(pi.displayName))
     {
         return($"{pi.name}@{pi.version}");
     }
     return($"{pi.displayName} ({pi.name}@{pi.version})");
 }
Beispiel #10
0
        // package の version (SemVer)
        public static string GetCreatorKitVersion()
        {
            var type     = MethodBase.GetCurrentMethod().DeclaringType;
            var assembly = Assembly.GetAssembly(type);
            var package  = PackageInfo.FindForAssembly(assembly);

            return(package.version);
        }
        private bool OpenWindowsApp(string path, int line)
        {
            var comAssetPath = AssetDatabase.FindAssets("COMIntegration a:packages").Select(AssetDatabase.GUIDToAssetPath).First(assetPath => assetPath.Contains("COMIntegration.dom"));

            if (string.IsNullOrWhiteSpace(comAssetPath)) // This may be called too early where the asset database has not replicated this information yet.
            {
                return(false);
            }
            UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(comAssetPath);
            var    progpath     = packageInfo.resolvedPath + comAssetPath.Substring("Packages/com.unity.ide.visualstudio".Length);
            string absolutePath = "";

            if (!string.IsNullOrWhiteSpace(path))
            {
                absolutePath = Path.GetFullPath(path);
            }


            var solution = GetOrGenerateSolutionFile(path);

            solution = solution == "" ? "" : $"\"{solution}\"";
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = progpath,
                    Arguments              = $"\"{CodeEditor.CurrentEditorInstallation}\" \"{absolutePath}\" {solution} {line}",
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                }
            };
            var result = process.Start();

            while (!process.StandardOutput.EndOfStream)
            {
                var outputLine = process.StandardOutput.ReadLine();
                if (outputLine == "displayProgressBar")
                {
                    EditorUtility.DisplayProgressBar("Opening Visual Studio", "Starting up Visual Studio, this might take some time.", .5f);
                }

                if (outputLine == "clearprogressbar")
                {
                    EditorUtility.ClearProgressBar();
                }
            }
            var errorOutput = process.StandardError.ReadToEnd();

            if (!string.IsNullOrEmpty(errorOutput))
            {
                Console.WriteLine("Error: \n" + errorOutput);
            }

            process.WaitForExit();
            return(result);
        }
Beispiel #12
0
        public ProjectIssue Analyze()
        {
#if UNITY_2019_3_OR_NEWER
            if (PackageInfo.FindForAssetPath("Packages/com.unity.rendering.hybrid") != null && IsStaticBatchingEnabled(EditorUserBuildSettings.activeBuildTarget))
            {
                return(new ProjectIssue(k_Descriptor, k_Descriptor.description, IssueCategory.ProjectSettings));
            }
#endif
            return(null);
        }
Beispiel #13
0
        /// <summary>
        /// Called by the Package Manager UI when the package selection changed.
        /// </summary>
        /// <param name="packageInfo">The newly selected package information (can be null)</param>
        public void OnPackageSelectionChange(PackageInfo packageInfo)
        {
            if (packageInfo == null)
            {
                return;
            }

            InitializeUI();
            packageDetailsExtension?.OnPackageSelectionChange(packageInfo);
        }
            private static string FormatLabel(UnityEditor.PackageManager.PackageInfo pi)
            {
                var installedPackage = s_ListRequest.Result.FirstOrDefault(l => l.name == pi.name);
                var status           = installedPackage != null ? (installedPackage.version == pi.version ?
                                                                   " - <i>In Project</i>" : " - <b>Update Available</b>") : "";

                if (String.IsNullOrEmpty(pi.displayName))
                {
                    return($"{pi.name}@{pi.version}{status}");
                }
                return($"{FormatName(pi)}{status}");
            }
        public static PackageInfo FindPackageByName(string packageName)
        {
            if (packageName.Substring(0, 4) == "com.")
            {
                return(PackageInfo.FindForAssetPath($"Packages/{packageName}"));
            }

            return(AssetDatabase.FindAssets("package")
                   .Select(AssetDatabase.GUIDToAssetPath)
                   .Where(packageJsonPath => AssetDatabase.LoadAssetAtPath <TextAsset>(packageJsonPath) != null)
                   .Select(PackageInfo.FindForAssetPath)
                   .FirstOrDefault(x => x.displayName == packageName));
        }
        public void OnPackageSelectionChange(PackageInfo packageInfo)
        {
            var thisPackageIsSelected = packageInfo?.name == PackageData.packageUniqueName;

            if (thisPackageIsSelected)
            {
                FetchModel();
            }

            if (_view != null)
            {
                _view.style.display = thisPackageIsSelected ? DisplayStyle.Flex : DisplayStyle.None;
            }
        }
Beispiel #17
0
        static void WriteAsmdefsJson(NPath directory)
        {
            var file = directory.Combine("asmdefs.json");

            if (file.FileExists() && s_AlreadyWrittenDataFile)
            {
            }

            var asmdefs = AllAssemblyDefinitions().ToList();

            var asmrefs = new List <AsmRefDescription>();

            foreach (var asmrefFile in AllAsmRefs())
            {
                var asmref        = JsonUtility.FromJson <AsmRefJsonObject>(asmrefFile.MakeAbsolute().ReadAllText());
                var packageInfo   = PackageInfo.FindForAssetPath(asmrefFile.ToString());
                var packageSource = packageInfo?.source.ToString() ?? "NoPackage";
                asmrefs.Add(new AsmRefDescription()
                {
                    AsmRefTarget  = asmref.reference,
                    FullPath      = Path.GetFullPath(asmrefFile.ToString()),
                    PackageSource = packageSource
                });
            }

            var           projectPath         = new NPath(UnityEngine.Application.dataPath).Parent;
            var           projectManifestPath = projectPath.Combine("Packages/manifest.json");
            var           projectManifest     = JsonUtility.FromJson <ProjectManifestJsonObject>(projectManifestPath.MakeAbsolute().ReadAllText());
            List <string> testableAsmDefNames = new List <string>();

            foreach (var testablePackageName in projectManifest.testables)
            {
                testableAsmDefNames.AddRange(asmdefs.Where(a => a.AsmdefName.EndsWith(".Tests") && a.FullPath.Contains(testablePackageName)).Select(a => a.AsmdefName));
            }

            var compilationPipelinePath = new NPath(Path.Combine(EditorApplication.applicationContentsPath, "Managed", "Unity.CompilationPipeline.Common.dll"));

            file.UpdateAllText(JsonSerialization.ToJson(new BeeAsmdefConfiguration()
            {
                asmdefs          = asmdefs,
                asmrefs          = asmrefs,
                UnityProjectPath = projectPath.ToString(),
                ProjectName      = projectPath.FileName,
                Testables        = testableAsmDefNames,
                CompilationPipelineAssemblyPath = compilationPipelinePath.ToString(),
                BuildSettingsFileVersion        = BuildStepGenerateBeeFiles.BuildSettingsFileVersion
            }));
            s_AlreadyWrittenDataFile = true;
        }
Beispiel #18
0
 internal static void CreateLocalizationAssets(string path)
 {
     try
     {
         TutorialManager.DirectoryCopy(
             $"{PackageInfo.FindForAssembly(Assembly.GetExecutingAssembly()).assetPath}/.LocalizationAssets",
             path
             );
         AssetDatabase.Refresh();
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
Beispiel #19
0
        public static Rect CalculateRectAfterLabelText(Rect rect, string projectWindowItemPath, bool hasIcon)
        {
            var content = new GUIContent(Path.GetFileNameWithoutExtension(projectWindowItemPath));

            if (projectWindowItemPath.StartsWith("Packages"))
            {
                var pi = PackageInfo.FindForAssetPath(projectWindowItemPath);
                if (!string.IsNullOrEmpty(pi.displayName))
                {
                    content.text = pi.displayName;
                }
            }

            return(CalculateRectAfterLabelText(rect, content, hasIcon));
        }
        public PackageManifest(UnityEditor.PackageManager.PackageInfo info)
        {
            this.info = info;
            var location = Path.Combine(info.assetPath, Paths.PackageManifest);

            asset = AssetDatabase.LoadAssetAtPath <TextAsset>(location);

            if (asset == null)
            {
                throw new System.Exception("Cannot load asset at path " + location);
            }

            JsonUtility.FromJsonOverwrite(asset.text, this);
            OnAfterDeserialize();
            filesystem_location = info.resolvedPath;
        }
Beispiel #21
0
        public void Install()
        {
            var info = PackageInfo.FindForAssetPath("Packages/com.rundotgames.unitybutler");

            if (info == null)
            {
                throw new Exception("unable to locate unity butler package info");
            }

            if (!shell.Run("install-unity-butler.bat", true, MakePackagePath(info)))
            {
                throw new Exception("failed to install unity butler");
            }

            UpdateInstallStatus();
        }
        public void SetUp()
        {
            var assembly = Assembly.Load("Unity.XR.Interaction.Toolkit");

            Assert.That(assembly, Is.Not.Null);

            m_PackageInfo = PackageInfo.FindForAssembly(assembly);
            Assert.That(m_PackageInfo, Is.Not.Null);

            // Parse the major.minor version
            Assert.That(m_PackageInfo.version, Is.Not.Null);
            Assert.That(m_PackageInfo.version, Is.Not.Empty);
            var secondDotIndex = m_PackageInfo.version.IndexOf('.', m_PackageInfo.version.IndexOf('.') + 1);

            Assert.That(secondDotIndex, Is.GreaterThan(0));
            m_MajorMinorVersion = m_PackageInfo.version.Substring(0, secondDotIndex);
        }
Beispiel #23
0
        private string EscapedRelativePathFor(string file, out UnityEditor.PackageManager.PackageInfo packageInfo)
        {
            var projectDir = ProjectDirectory.NormalizePathSeparators();

            file = file.NormalizePathSeparators();
            var path = SkipPathPrefix(file, projectDir);

            packageInfo = m_AssemblyNameProvider.FindForAssetPath(path.NormalizeWindowsToUnix());
            if (packageInfo != null)
            {
                // We have to normalize the path, because the PackageManagerRemapper assumes
                // dir seperators will be os specific.
                var absolutePath = Path.GetFullPath(path.NormalizePathSeparators());

                path = SkipPathPrefix(absolutePath, projectDir);
            }

            return(XmlFilename(path));
        }
Beispiel #24
0
        void CheckNotificationWorthyStates()
        {
            m_PendingNotifications = 0;

#if UNITY_2020_1 || UNITY_2020_2 || UNITY_2020_3
            // Handle the missing UI Toolkit package case.
            var uitkPackageInfo = PackageInfo.FindForAssetPath("Packages/" + BuilderConstants.UIToolkitPackageName);
            if (uitkPackageInfo == null)
            {
                m_PendingNotifications++;
                if (!BuilderProjectSettings.hideNotificationAboutMissingUITKPackage)
                {
                    AddNotification(
                        BuilderConstants.NoUIToolkitPackageInstalledNotification,
                        "https://forum.unity.com/threads/ui-toolkit-1-0-preview-available.927822/",
                        () => BuilderProjectSettings.hideNotificationAboutMissingUITKPackage = true);
                }
            }
#endif
        }
Beispiel #25
0
        private void PackageGUI(PublicationPackageView packageView)
        {
            EditorGUI.BeginChangeCheck();

            if (initialSelection != null && initialSelection.packageId == packageView.package.info.packageId)
            {
                packageView.publish = true;
                initialSelection    = null;
            }

            packageView.publish = EditorGUILayout.BeginToggleGroup(packageView.package.displayName, packageView.publish);
            if (EditorGUI.EndChangeCheck())
            {
                if (!packageView.publish)
                {
                    publishAll = false;
                }
            }

            packageView.registry = packageView.RegistrySelector.SelectRegistry("\t", packageView.registry);
            EditorGUILayout.EndToggleGroup();
        }
//----------------------------------------------------------------------------------------------------------------------
        void TryCopyDCCPluginsFromPackage(Action <string> onSuccess, Action <string> onFail)
        {
            RequestJobManager.CreateListRequest(true, true, (listReq) => {
                PackageInfo packageInfo = listReq.FindPackage(MESHSYNC_DCC_PLUGIN_PACKAGE);
                if (null != packageInfo)
                {
                    //Package is already installed.
                    CopyDCCPluginsFromPackage();
                    onSuccess(packageInfo.version);
                    return;
                }

                RequestJobManager.CreateAddRequest(MESHSYNC_DCC_PLUGIN_PACKAGE, (addReq) => {
                    //Package was successfully added
                    CopyDCCPluginsFromPackage();
                    onSuccess(packageInfo.version);
                }, (req) => {
                    PackageInfo meshSyncInfo = listReq.FindPackage(MESHSYNC_PACKAGE);
                    onFail?.Invoke(meshSyncInfo.version);
                });
            }, null);
        }
        private void Package(UnityEditor.PackageManager.PackageInfo info)
        {
            GUIStyle boxStyle = new GUIStyle();

            boxStyle.padding = new RectOffset(10, 10, 0, 0);

            EditorGUILayout.BeginHorizontal(boxStyle);


            EditorGUI.BeginChangeCheck();

            bool upgrade = false;

            if (upgradeList.ContainsKey(info))
            {
                upgrade = upgradeList[info];
            }

            upgrade = EditorGUILayout.BeginToggleGroup(info.displayName + ":" + info.version, upgrade);
            if (EditorGUI.EndChangeCheck())
            {
                if (!upgrade)
                {
                    upgradeAll = false;
                }
            }

            upgradeList[info] = upgrade;

            EditorGUILayout.EndToggleGroup();


            EditorGUILayout.LabelField(manager.GetLatestVersion(info));

            EditorGUILayout.EndHorizontal();
        }
        // Returns the correct path (forward slash used as the separator) depending whether we're running the tests locally or as a separate package.
        protected static string GetTestAssetPath(string relativeAssetPath)
        {
            var packagePath = PackageInfo.FindForAssembly(Assembly.GetExecutingAssembly()).assetPath;

            return(Path.Combine($"{packagePath}/Tests/Editor", relativeAssetPath).Replace('\\', '/'));
        }
Beispiel #29
0
        public static void Update()
        {
            //if( Application.isPlaying )
            //	return;

            CheckLatePackageImport();
            //if( m_lwPackageInfo != null )
            //{
            //	if( m_srpVersionConverter[ m_lwPackageInfo.version ] != m_currentLWVersion )
            //	{
            //		m_currentLWVersion = m_srpVersionConverter[ m_lwPackageInfo.version ];
            //		EditorPrefs.SetInt( LWEditorPrefsId, (int)m_currentLWVersion );
            //		m_importingPackage = ASEImportState.Lightweight;
            //		string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageLW[ m_currentLWVersion ] );
            //		StartImporting( packagePath );
            //	}
            //}

            //if( m_hdPackageInfo != null )
            //{
            //	if( m_srpVersionConverter[ m_hdPackageInfo.version ] != m_currentHDVersion )
            //	{
            //		m_currentHDVersion = m_srpVersionConverter[ m_hdPackageInfo.version ];
            //		EditorPrefs.SetInt( HDEditorPrefsId, (int)m_currentHDVersion );
            //		m_importingPackage = ASEImportState.HD;
            //		string packagePath = AssetDatabase.GUIDToAssetPath( m_srpToASEPackageHD[ m_currentHDVersion ] );
            //		StartImporting( packagePath );
            //	}
            //}

            if (m_requireUpdateList && m_importingPackage == ASEImportState.None)
            {
                if (m_packageListRequest != null && m_packageListRequest.IsCompleted)
                {
                    m_requireUpdateList = false;
                    foreach (UnityEditor.PackageManager.PackageInfo pi in m_packageListRequest.Result)
                    {
                        if (pi.name.Equals(LWPackageId))
                        {
                            m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
                            m_lwPackageInfo    = pi;
                            ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(LWEditorPrefsId);
                            if (m_srpVersionConverter.ContainsKey(pi.version))
                            {
                                m_currentLWVersion = m_srpVersionConverter[pi.version];
                            }
                            else
                            {
                                m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
                            }

                            EditorPrefs.SetInt(LWEditorPrefsId, (int)m_currentLWVersion);
                            bool foundNewVersion = oldVersion != m_currentLWVersion;
                            if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.LightweigthPBRGUID)) ||
                                !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.LightweigthUnlitGUID)) ||
                                foundNewVersion
                                )
                            {
                                if (foundNewVersion)
                                {
                                    Debug.Log(LightweightNewVersionDetected);
                                }

                                m_importingPackage = ASEImportState.Lightweight;
                                string guid        = m_srpToASEPackageLW.ContainsKey(m_currentLWVersion) ? m_srpToASEPackageLW[m_currentLWVersion] : m_srpToASEPackageLW[ASESRPVersions.ASE_SRP_RECENT];
                                string packagePath = AssetDatabase.GUIDToAssetPath(guid);
                                StartImporting(packagePath);
                            }
                        }

                        if (pi.name.Equals(UniversalPackageId))
                        {
                            m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
                            m_lwPackageInfo    = pi;
                            ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(LWEditorPrefsId);
                            if (m_srpVersionConverter.ContainsKey(pi.version))
                            {
                                m_currentLWVersion = m_srpVersionConverter[pi.version];
                            }
                            else
                            {
                                m_currentLWVersion = ASESRPVersions.ASE_SRP_RECENT;
                            }

                            EditorPrefs.SetInt(LWEditorPrefsId, (int)m_currentLWVersion);
                            bool foundNewVersion = oldVersion != m_currentLWVersion;

                            int urpVersion = EditorPrefs.GetInt(URPTemplateVersion, m_urpTemplateVersion);
                            if (urpVersion < m_urpTemplateVersion)
                            {
                                foundNewVersion = true;
                            }
                            EditorPrefs.SetInt(URPTemplateVersion, m_urpTemplateVersion);

                            if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.UniversalPBRGUID)) ||
                                !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.UniversalUnlitGUID)) ||
                                foundNewVersion
                                )
                            {
                                if (foundNewVersion)
                                {
                                    Debug.Log(LightweightNewVersionDetected);
                                }

                                m_importingPackage = ASEImportState.Lightweight;
                                string guid        = m_srpToASEPackageLW.ContainsKey(m_currentLWVersion) ? m_srpToASEPackageLW[m_currentLWVersion] : m_srpToASEPackageLW[ASESRPVersions.ASE_SRP_RECENT];
                                string packagePath = AssetDatabase.GUIDToAssetPath(guid);
                                StartImporting(packagePath);
                            }
                        }

                        if (pi.name.Equals(HDPackageId))
                        {
                            m_currentHDVersion = ASESRPVersions.ASE_SRP_RECENT;
                            m_hdPackageInfo    = pi;
                            ASESRPVersions oldVersion = (ASESRPVersions)EditorPrefs.GetInt(HDEditorPrefsId);
                            if (m_srpVersionConverter.ContainsKey(pi.version))
                            {
                                m_currentHDVersion = m_srpVersionConverter[pi.version];
                            }
                            else
                            {
                                m_currentHDVersion = ASESRPVersions.ASE_SRP_RECENT;
                            }

                            EditorPrefs.SetInt(HDEditorPrefsId, (int)m_currentHDVersion);
                            bool foundNewVersion = oldVersion != m_currentHDVersion;

                            int hdrpVersion = EditorPrefs.GetInt(HDRPTemplateVersion, m_hdrpTemplateVersion);
                            if (hdrpVersion < m_hdrpTemplateVersion)
                            {
                                foundNewVersion = true;
                            }
                            EditorPrefs.SetInt(HDRPTemplateVersion, m_hdrpTemplateVersion);

#if UNITY_2019_3_OR_NEWER
                            if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDNewLitGUID)) ||
                                !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDNewPBRGUID)) ||
                                !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDNewUnlitGUID)) ||
#else
                            if (!File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDLitGUID)) ||
                                !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDPBRGUID)) ||
                                !File.Exists(AssetDatabase.GUIDToAssetPath(TemplatesManager.HDUnlitGUID)) ||
#endif
                                foundNewVersion
                                )
                            {
                                if (foundNewVersion)
                                {
                                    Debug.Log(HDNewVersionDetected);
                                }

                                m_importingPackage = m_importingPackage == ASEImportState.Lightweight ? ASEImportState.Both : ASEImportState.HD;
                                string guid        = m_srpToASEPackageHD.ContainsKey(m_currentHDVersion) ? m_srpToASEPackageHD[m_currentHDVersion] : m_srpToASEPackageHD[ASESRPVersions.ASE_SRP_RECENT];
                                string packagePath = AssetDatabase.GUIDToAssetPath(guid);
                                StartImporting(packagePath);
                            }
                        }
                    }
                }
            }
        }
 private static string FormatDescription(UnityEditor.PackageManager.PackageInfo pi)
 {
     return(pi.description.Replace("\r", "").Replace("\n", ""));
 }