Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2ad723a

Browse files
optimize startup time (disable save prefs on few fields, disable dummy placeholder data in grid to avoid Clear(), adjust GetTargetPlatform method
1 parent 4ced24b commit 2ad723a

File tree

3 files changed

+53
-30
lines changed

3 files changed

+53
-30
lines changed

‎UnityLauncherPro/MainWindow.xaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@
237237
</ContextMenu>
238238
</DataGrid.ContextMenu>
239239

240-
<!-- sample data for testing -->
240+
<!-- TODO cannot have this enabled, otherwise needs additional .Clear() at start before setting itemsource data -->
241+
<!-- sample data for testing --><!--
241242
<local:Project TargetPlatform="win64" GITBranch="Best" Modified="" Title="M dfgh dfghMO" Path="A:/temp" Version="2099年1月2日.3" />
242243
<local:Project GITBranch="" Modified="" Title="asdgdfg" Path="A:/temp" Version="5.6.7f1"/>
243244
<local:Project GITBranch="" Modified="" Title="Mghdfghdf dfghdfgMO" Path="A:/temp" Version="2018年3月13日f1"/>
@@ -269,7 +270,7 @@
269270
<local:Project GITBranch="" Modified="" Title="MMd fghO" Path="A:/temp" Version="2099年1月2日.3"/>
270271
<local:Project GITBranch="" Modified="" Title="MMO" Path="A:/temp" Version="2099年1月2日.3"/>
271272
<local:Project GITBranch="" Modified="" Title="MMdfg hO" Path="A:/temp" Version="2099年1月2日.3"/>
272-
<local:Project GITBranch="" Modified="" Title="Md fghMO" Path="A:/temp" Version="2099年1月2日.3"/>
273+
<local:Project GITBranch="" Modified="" Title="Md fghMO" Path="A:/temp" Version="2099.1.2.3"/>-->
273274
</DataGrid>
274275

275276
<!-- bottom buttoms row -->

‎UnityLauncherPro/MainWindow.xaml.cs‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ void Init()
113113
{
114114
lblVersion.Content = "Build: " + Version.Stamp;
115115
}
116-
117-
CheckCustomIcon();
118116
}
119117

120118
void Start()
@@ -153,7 +151,7 @@ void Start()
153151

154152
//Console.WriteLine("projectsSource.Count: " + projectsSource.Count);
155153

156-
gridRecent.Items.Clear();
154+
//gridRecent.Items.Clear(); // not needed?
157155
gridRecent.ItemsSource = projectsSource;
158156

159157
// clear updates grid
@@ -190,6 +188,8 @@ void Start()
190188

191189
if (Settings.Default.disableUnityHubLaunch == true) StartHubPipe();
192190

191+
CheckCustomIcon();
192+
193193
isInitializing = false;
194194
} // Start()
195195

@@ -2043,8 +2043,10 @@ private void BtnBrowseProjectRootFolder_Click(object sender, RoutedEventArgs e)
20432043

20442044
private void TxtRootFolderForNewProjects_TextChanged(object sender, TextChangedEventArgs e)
20452045
{
2046-
Properties.Settings.Default.newProjectsRoot = txtRootFolderForNewProjects.Text;
2047-
Properties.Settings.Default.Save();
2046+
if (this.IsActive == false) return; // dont run code on window init
2047+
2048+
Settings.Default.newProjectsRoot = txtRootFolderForNewProjects.Text;
2049+
Settings.Default.Save();
20482050
}
20492051

20502052

@@ -2263,8 +2265,8 @@ private void ChkEnableProjectRename_Checked(object sender, RoutedEventArgs e)
22632265
{
22642266
if (this.IsActive == false) return; // dont run code on window init
22652267

2266-
Properties.Settings.Default.enableProjectRename = (bool)chkEnableProjectRename.IsChecked;
2267-
Properties.Settings.Default.Save();
2268+
Settings.Default.enableProjectRename = (bool)chkEnableProjectRename.IsChecked;
2269+
Settings.Default.Save();
22682270
}
22692271

22702272
private void MenuItemKillProcess_Click(object sender, RoutedEventArgs e)
@@ -2666,8 +2668,10 @@ private void MenuStartWebGLServer_Click(object sender, RoutedEventArgs e)
26662668

26672669
private void TxtWebglRelativePath_TextChanged(object sender, TextChangedEventArgs e)
26682670
{
2669-
Properties.Settings.Default.webglBuildPath = txtWebglRelativePath.Text;
2670-
Properties.Settings.Default.Save();
2671+
if (this.IsActive == false) return; // dont run code on window init
2672+
2673+
Settings.Default.webglBuildPath = txtWebglRelativePath.Text;
2674+
Settings.Default.Save();
26712675
}
26722676

26732677
private void MenuItemBrowsePersistentDataPath_Click(object sender, RoutedEventArgs e)
@@ -3232,6 +3236,8 @@ private void MenuCreateDesktopShortCut_Click(object sender, RoutedEventArgs e)
32323236

32333237
private void TxtShortcutBatchFileFolder_TextChanged(object sender, TextChangedEventArgs e)
32343238
{
3239+
if (this.IsActive == false) return; // dont run code on window init
3240+
32353241
var folder = ((TextBox)sender).Text;
32363242
if (Directory.Exists(folder))
32373243
{

‎UnityLauncherPro/Tools.cs‎

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,48 +1493,64 @@ private static string ExtractPlasticBranch(string plasticSelectorPath)
14931493
return null;
14941494
}
14951495

1496-
1497-
//public static Platform GetTargetPlatform(string projectPath)
14981496
static string GetTargetPlatformRaw(string projectPath)
14991497
{
15001498
string results = null;
1501-
//Platform results = Platform.Unknown;
15021499

15031500
// get buildtarget from .csproj
15041501
// <UnityBuildTarget>StandaloneWindows64:19</UnityBuildTarget>
15051502
// get main csproj file
15061503
var csproj = Path.Combine(projectPath, "Assembly-CSharp.csproj");
1504+
15071505
// TODO check projname also, if no assembly-.., NOTE already checked above
1508-
//var csproj = Path.Combine(projectPath, projectName + ".csproj");
1506+
// var csproj = Path.Combine(projectPath, projectName + ".csproj");
1507+
15091508
if (File.Exists(csproj))
15101509
{
1511-
var csprojtxt = File.ReadAllText(csproj);
1512-
var csprojsplit = csprojtxt.Split(new[] { "<UnityBuildTarget>" }, StringSplitOptions.None);
1513-
if (csprojsplit != null && csprojsplit.Length > 1)
1510+
// Read the file line by line for performance
1511+
using (var reader = new StreamReader(csproj))
15141512
{
1515-
varendrow=csprojsplit[1].IndexOf(":");
1516-
if(endrow>-1)
1513+
stringline;
1514+
while((line=reader.ReadLine())!=null)
15171515
{
1518-
//Console.WriteLine("build target: " + csprojsplit[1].Substring(0, endrow));
1519-
// 5.6 : win32, win64, osx, linux, linux64, ios, android, web, webstreamed, webgl, xboxone, ps4, psp2, wsaplayer, tizen, samsungtv
1520-
// 2017: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, PSP2, WindowsStoreApps, Switch, WiiU, N3DS, tvOS, PSM
1521-
// 2018: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, N3DS, tvOS
1522-
// 2019: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
1523-
// 2020: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
1524-
// 2021: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
1525-
results = csprojsplit[1].Substring(0, endrow);
1526-
//results = (Platform)Enum.Parse(typeof(Platform), csprojsplit[1].Substring(0, endrow));
1516+
const string tagStart = "<UnityBuildTarget>";
1517+
const string tagEnd = "</UnityBuildTarget>";
1518+
1519+
int startIdx = line.IndexOf(tagStart);
1520+
if (startIdx >= 0)
1521+
{
1522+
int endIdx = line.IndexOf(tagEnd, startIdx);
1523+
if (endIdx > startIdx)
1524+
{
1525+
string inner = line.Substring(startIdx + tagStart.Length, endIdx - startIdx - tagStart.Length);
1526+
int colonIndex = inner.IndexOf(':');
1527+
if (colonIndex > -1)
1528+
{
1529+
//Console.WriteLine("build target: " + inner.Substring(0, colonIndex));
1530+
// 5.6 : win32, win64, osx, linux, linux64, ios, android, web, webstreamed, webgl, xboxone, ps4, psp2, wsaplayer, tizen, samsungtv
1531+
// 2017: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, PSP2, WindowsStoreApps, Switch, WiiU, N3DS, tvOS, PSM
1532+
// 2018: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, N3DS, tvOS
1533+
// 2019: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
1534+
// 2020: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
1535+
// 2021: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
1536+
results = inner.Substring(0, colonIndex);
1537+
//results = (Platform)Enum.Parse(typeof(Platform), inner.Substring(0, colonIndex));
1538+
break; // we found it, exit early
1539+
}
1540+
}
1541+
}
15271542
}
15281543
}
15291544
}
15301545
else
15311546
{
1532-
//Console.WriteLine("Missing csproj, cannot parse target platform: "+ projectPath);
1547+
//Console.WriteLine("Missing csproj, cannot parse target platform: "+ projectPath);
15331548
}
15341549

15351550
return results;
15361551
}
15371552

1553+
15381554
public static string GetTargetPlatform(string projectPath)
15391555
{
15401556
var rawPlatformName = GetTargetPlatformRaw(projectPath);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /