Skip to content

Commit f8343ca

Browse files
committed
add context menu for browse Application.persistentDataPath
1 parent 2cf1d9a commit f8343ca

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

UnityLauncherPro/MainWindow.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@
348348
<MenuItem x:Name="menuItemCopyVersion" Header="Copy Unity Version" Click="MenuItemCopyVersion_Click" />
349349
<MenuItem x:Name="menuItemCopyPath" Header="Copy Project Path" Click="MenuItemCopyPath_Click" />
350350
<MenuItem x:Name="menuItemShowProjectInExplorer" Header="Show in Explorer" Click="MenuItemShowProjectInExplorer_Click" />
351+
<MenuItem x:Name="menuItemBrowsePersistentDataPath" Header="Open PersistentDataPath" Click="MenuItemBrowsePersistentDataPath_Click" />
351352
<Separator/>
352353
<MenuItem x:Name="menuItemKillProcess" Header="Kill Process" Click="MenuItemKillProcess_Click" />
353354
<Separator/>

UnityLauncherPro/MainWindow.xaml.cs

+28-3
Original file line numberDiff line numberDiff line change
@@ -1640,12 +1640,9 @@ private void BtnClearBuildReport_Click(object sender, RoutedEventArgs e)
16401640
private void MenuStartWebGLServer_Click(object sender, RoutedEventArgs e)
16411641
{
16421642
// runs unity SimpleWebServer.exe and launches default Browser into project build/ folder'
1643-
// TODO add setting for your default webgl folder inside Builds/ (examples, Builds/ or Builds/webgl/)
1644-
if (tabControl.SelectedIndex != 0) return;
16451643

16461644
var proj = GetSelectedProject();
16471645
var projPath = proj?.Path.Replace('/', '\\');
1648-
16491646
if (string.IsNullOrEmpty(projPath) == true) return;
16501647

16511648
var buildPath = Path.Combine(projPath, "Builds", txtWebglRelativePath.Text);
@@ -1689,6 +1686,34 @@ private void TxtWebglRelativePath_TextChanged(object sender, TextChangedEventArg
16891686
Properties.Settings.Default.webglBuildPath = txtWebglRelativePath.Text;
16901687
Properties.Settings.Default.Save();
16911688
}
1689+
1690+
private void MenuItemBrowsePersistentDataPath_Click(object sender, RoutedEventArgs e)
1691+
{
1692+
var proj = GetSelectedProject();
1693+
var projPath = proj?.Path.Replace('/', '\\');
1694+
if (string.IsNullOrEmpty(projPath) == true) return;
1695+
1696+
var psPath = Path.Combine(projPath, "ProjectSettings", "ProjectSettings.asset");
1697+
if (File.Exists(psPath) == false) return;
1698+
// read project settings
1699+
var rows = File.ReadAllLines(psPath);
1700+
1701+
// search company and product name rows
1702+
for (int i = 0, len = rows.Length; i < len; i++)
1703+
{
1704+
// skip rows until companyname
1705+
if (rows[i].IndexOf("companyName:") == -1) continue;
1706+
1707+
var companyName = rows[i].Split(new[] { "companyName: " }, StringSplitOptions.None)[1];
1708+
var productName = rows[i + 1].Split(new[] { "productName: " }, StringSplitOptions.None)[1];
1709+
1710+
// open folder from %userprofile%\AppData\LocalLow\<companyname>\<productname>
1711+
var dataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/../LocalLow");
1712+
var psFullPath = Path.Combine(dataFolder, companyName, productName);
1713+
Tools.LaunchExplorer(psFullPath);
1714+
break;
1715+
}
1716+
}
16921717
} // class
16931718
} //namespace
16941719

0 commit comments

Comments
 (0)