From 50804045d2153302d142d706f0f4515f8c0c0308 Mon Sep 17 00:00:00 2001 From: unitycoder Date: Wed, 28 May 2025 14:58:55 +0300 Subject: [PATCH] less GC in GetSRP(), search filter: use ordinalignorecase, --- UnityLauncherPro/MainWindow.xaml.cs | 8 ++-- UnityLauncherPro/Properties/AssemblyInfo.cs | 2 +- UnityLauncherPro/Tools.cs | 48 +++++++++++---------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/UnityLauncherPro/MainWindow.xaml.cs b/UnityLauncherPro/MainWindow.xaml.cs index 7cd9dee..5bce4e5 100644 --- a/UnityLauncherPro/MainWindow.xaml.cs +++ b/UnityLauncherPro/MainWindow.xaml.cs @@ -439,16 +439,16 @@ private bool ProjectFilter(object item) bool found = true; foreach (var word in searchWords) { - bool titleMatched = proj.Title.IndexOf(word, 0, StringComparison.CurrentCultureIgnoreCase) != -1; - bool pathMatched = searchProjectPathAlso && proj.Path.IndexOf(word, 0, StringComparison.CurrentCultureIgnoreCase) != -1; + bool titleMatched = proj.Title.IndexOf(word, 0, StringComparison.OrdinalIgnoreCase) != -1; + bool pathMatched = searchProjectPathAlso && proj.Path.IndexOf(word, 0, StringComparison.OrdinalIgnoreCase) != -1; found = found && (titleMatched || pathMatched); } return found; } else // single word search { - bool titleMatched = proj.Title.IndexOf(_filterString, 0, StringComparison.CurrentCultureIgnoreCase) != -1; - bool pathMatched = searchProjectPathAlso && proj.Path.IndexOf(_filterString, 0, StringComparison.CurrentCultureIgnoreCase) != -1; + bool titleMatched = proj.Title.IndexOf(_filterString, 0, StringComparison.OrdinalIgnoreCase) != -1; + bool pathMatched = searchProjectPathAlso && proj.Path.IndexOf(_filterString, 0, StringComparison.OrdinalIgnoreCase) != -1; return titleMatched || pathMatched; } diff --git a/UnityLauncherPro/Properties/AssemblyInfo.cs b/UnityLauncherPro/Properties/AssemblyInfo.cs index b280a55..6fe6e89 100644 --- a/UnityLauncherPro/Properties/AssemblyInfo.cs +++ b/UnityLauncherPro/Properties/AssemblyInfo.cs @@ -12,7 +12,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("UnityCoder.com")] [assembly: AssemblyProduct("UnityLauncherPro")] -[assembly: AssemblyCopyright("Copyright © 2023")] +[assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/UnityLauncherPro/Tools.cs b/UnityLauncherPro/Tools.cs index 8a0d6f0..8b05c88 100644 --- a/UnityLauncherPro/Tools.cs +++ b/UnityLauncherPro/Tools.cs @@ -2603,34 +2603,36 @@ private static async Task DownloadFileAsync(string fileUrl, string destina internal static string GetSRP(string projectPath) { - // read projectsettings/graphicsettings file, look for m_SRPDefaultSettings: value var settingsFile = Path.Combine(projectPath, "ProjectSettings", "GraphicsSettings.asset"); - if (File.Exists(settingsFile) == false) return null; + if (!File.Exists(settingsFile)) return null; - var allText = File.ReadAllText(settingsFile); - var srpIndex = allText.IndexOf("m_SRPDefaultSettings:"); - if (srpIndex == -1) - { - srpIndex = allText.IndexOf("m_RenderPipelineGlobalSettingsMap:"); // unity 6000.2- ? - if (srpIndex == -1) return null; // BIRP - } - - // urp = UnityEngine.Rendering.Universal.UniversalRenderPipeline - // hdrp = UnityEngine.Rendering.HighDefinition.HDRenderPipeline + bool srpSectionFound = false; - if (allText.IndexOf("UnityEngine.Rendering.Universal.UniversalRenderPipeline", srpIndex) > -1) - { - return "URP"; - } - else if (allText.IndexOf("UnityEngine.Rendering.HighDefinition.HDRenderPipeline", srpIndex) > -1) + using (var reader = new StreamReader(settingsFile)) { - return "HDRP"; - } - else - { - return null; // BIRP - } + string line; + while ((line = reader.ReadLine()) != null) + { + if (!srpSectionFound) + { + if (line.Contains("m_SRPDefaultSettings:") || line.Contains("m_RenderPipelineGlobalSettingsMap:")) + { + srpSectionFound = true; + } + continue; + } + if (line.Contains("UniversalRenderPipeline")) + { + return "URP"; + } + else if (line.Contains("HDRenderPipeline")) + { + return "HDRP"; + } + } + } + return null; // BIRP or unknown } internal static void InstallAPK(string ApkPath)