Skip to content

Commit 35a5fdf

Browse files
committed
adding platform selection (wip)
1 parent 88a39f2 commit 35a5fdf

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

UnityLauncherPro/GetProjects.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public static class GetProjects
1111
// which registries we want to scan for projects
1212
static readonly string[] registryPathsToCheck = new string[] { @"SOFTWARE\Unity Technologies\Unity Editor 5.x", @"SOFTWARE\Unity Technologies\Unity Editor 4.x" };
1313

14-
static Dictionary<string, string> remapPlatformNames = new Dictionary<string, string> { { "StandaloneWindows64", "Windows" }, { "StandaloneWindows", "Windows" }, { "Android", "Android" }, { "WebGL", "WebGL" } };
15-
14+
// convert target platform name into valid buildtarget platform name, NOTE this depends on unity version, now only 2019 and later are supported
15+
static Dictionary<string, string> remapPlatformNames = new Dictionary<string, string> { { "StandaloneWindows64", "Standalone" }, { "StandaloneWindows", "Standalone" }, { "Android", "Android" }, { "WebGL", "WebGL" } };
1616

1717
// TODO separate scan and folders
1818
public static List<Project> Scan(bool getGitBranch = false, bool getArguments = false, bool showMissingFolders = false, bool showTargetPlatform = false)
@@ -134,21 +134,22 @@ public static List<Project> Scan(bool getGitBranch = false, bool getArguments =
134134
p.Modified = lastUpdated;
135135
p.Arguments = customArgs;
136136
p.GITBranch = gitBranch;
137-
// TODO this one should pick best match from available platforms (since they look different: StandaloneWindows64 should be remapped as Windows)
138137
//p.TargetPlatform = targetPlatform;
138+
//Console.WriteLine("targetPlatform="+ targetPlatform);
139+
// get matching buildtarget platform name from dictionary
139140
if (string.IsNullOrEmpty(targetPlatform) == false && remapPlatformNames.ContainsKey(targetPlatform))
140141
{
141142
p.TargetPlatform = remapPlatformNames[targetPlatform];
142143
}
143144
else
144145
{
145-
p.TargetPlatform = null;
146+
Console.WriteLine("Missing buildTarget remap name for: "+ targetPlatform);
147+
p.TargetPlatform = null;
146148
}
147149

148150
// bubblegum(TM) solution, fill available platforms for this unity version, for this project
149151
p.TargetPlatforms = Tools.GetPlatformsForUnityVersion(projectVersion);
150152

151-
152153
p.folderExists = folderExists;
153154

154155
// if want to hide project and folder path for screenshot

UnityLauncherPro/GetUnityInstallations.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ namespace UnityLauncherPro
99
/// </summary>
1010
public static class GetUnityInstallations
1111
{
12-
static Dictionary<string, string> platformNames = new Dictionary<string, string> { { "androidplayer", "Android" }, { "windowsstandalonesupport", "Windows" }, { "linuxstandalonesupport", "Linux" }, { "LinuxStandalone", "Linux" }, { "OSXStandalone", "Mac" }, { "webglsupport", "WebGL" }, { "metrosupport", "UWP" } };
12+
//static Dictionary<string, string> platformNames = new Dictionary<string, string> { { "androidplayer", "Android" }, { "windowsstandalonesupport", "Windows" }, { "linuxstandalonesupport", "Linux" }, { "LinuxStandalone", "Linux" }, { "OSXStandalone", "Mac" }, { "webglsupport", "WebGL" }, { "metrosupport", "UWP" } };
13+
static Dictionary<string, string> platformNames = new Dictionary<string, string> { { "androidplayer", "Android" }, { "windowsstandalonesupport", "Standalone" }, { "linuxstandalonesupport", "Standalone" }, { "LinuxStandalone", "Standalone" }, { "OSXStandalone", "Standalone" }, { "webglsupport", "WebGL" }, { "metrosupport", "UWP" } };
14+
1315

1416
// returns unity installations
1517
public static UnityInstallation[] Scan()

UnityLauncherPro/MainWindow.xaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<Setter Property="VerticalContentAlignment" Value="Center" />
8181
<Setter Property="HorizontalAlignment" Value="Stretch" />
8282
<Setter Property="VerticalAlignment" Value="Center" />
83-
<Setter Property="OverridesDefaultStyle" Value="True"/>
83+
<!--<Setter Property="OverridesDefaultStyle" Value="True"/>-->
8484

8585
<Setter Property="Template">
8686
<Setter.Value>
@@ -473,7 +473,7 @@
473473
<Button Style="{StaticResource CustomButton}" ToolTip="Add existing project" x:Name="btnAddProjectFolder" Content="Add Project.." Height="22" Width="78" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,34,0" Click="BtnAddProjectFolder_Click" BorderBrush="{x:Null}" TabIndex="10" />
474474
<Button Style="{StaticResource CustomButton}" ToolTip="Refresh list (F5)" x:Name="btnRefreshProjectList" Content="" Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Margin="0,4,3,0" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="BtnRefreshProjectList_Click" TabIndex="11"/>
475475

476-
<DataGrid x:Name="gridRecent" SelectionMode="Single" Margin="4,30,2,42" CanUserAddRows="False" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeGridHorizontalGridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" ContextMenuOpening="GridRecent_ContextMenuOpening" BeginningEdit="GridRecent_BeginningEdit" RowHeight="21" >
476+
<DataGrid x:Name="gridRecent" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" SelectionMode="Single" Margin="4,30,2,42" CanUserAddRows="False" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeGridHorizontalGridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" PreviewKeyDown="GridRecent_PreviewKeyDown" Loaded="GridRecent_Loaded" TabIndex="2" CellEditEnding="GridRecent_CellEditEnding" PreviewMouseDoubleClick="GridRecent_PreviewMouseDoubleClick" ContextMenuOpening="GridRecent_ContextMenuOpening" BeginningEdit="GridRecent_BeginningEdit" RowHeight="21" >
477477

478478
<DataGrid.CommandBindings>
479479
<CommandBinding Command="ApplicationCommands.Copy" Executed="CopyRowFolderToClipBoard" CanExecute="CanExecute_Copy"/>
@@ -509,7 +509,7 @@
509509
</DataGridTextColumn>
510510
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Modified, StringFormat=\{0:dd/MM/yyyy HH:mm:ss\}}" ClipboardContentBinding="{x:Null}" Header="Modified" IsReadOnly="True" Width="120"/>
511511
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Arguments}" ClipboardContentBinding="{x:Null}" Header="Arguments" IsReadOnly="False" Width="100"/>
512-
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding GITBranch}" ClipboardContentBinding="{x:Null}" Header="Branch" IsReadOnly="True" Width="100"/>
512+
<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding GITBranch}" ClipboardContentBinding="{x:Null}" Header="Branch" IsReadOnly="True" Width="60"/>
513513
<!--TODO platform as dropdown?-->
514514
<!--<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding TargetPlatform}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>-->
515515
<!--<DataGridComboBoxColumn x:Name="cmbPlatform" CellStyle="{StaticResource NoFocusCellStyle}" SelectedItemBinding="{Binding TargetPlatform, NotifyOnSourceUpdated=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ClipboardContentBinding="{x:Null}" Header="Platform" IsReadOnly="True" Width="100"/>-->
@@ -519,7 +519,7 @@
519519
<DataGridTemplateColumn Header="Platform">
520520
<DataGridTemplateColumn.CellTemplate >
521521
<DataTemplate >
522-
<ComboBox x:Name="cmbPlatformSelection" OverridesDefaultStyle="True" VerticalAlignment="Center" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch" IsEnabled="{Binding ElementName=chkEnablePlatformSelection, Path=IsChecked}" ItemsSource="{Binding TargetPlatforms}" SelectedValue="{Binding TargetPlatform}" Height="18" Foreground="{DynamicResource ThemeButtonForeground}"/>
522+
<ComboBox x:Name="cmbPlatformSelection" OverridesDefaultStyle="True" VerticalAlignment="Center" HorizontalAlignment="Stretch" VerticalContentAlignment="Center" HorizontalContentAlignment="Stretch" IsEnabled="{Binding ElementName=chkEnablePlatformSelection, Path=IsChecked}" ItemsSource="{Binding TargetPlatforms}" SelectedValue="{Binding TargetPlatform}" Height="18" Foreground="{DynamicResource ThemeButtonForeground}" DropDownClosed="CmbPlatformSelection_DropDownClosed"/>
523523
</DataTemplate>
524524
</DataGridTemplateColumn.CellTemplate>
525525
</DataGridTemplateColumn>

UnityLauncherPro/MainWindow.xaml.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,17 @@ private void ChkEnablePlatformSelection_Checked(object sender, RoutedEventArgs e
18531853
chkEnablePlatformSelection.IsChecked = isChecked;
18541854
}
18551855

1856-
1856+
private void CmbPlatformSelection_DropDownClosed(object sender, EventArgs e)
1857+
{
1858+
// TODO need to handle if user initially selects the null row
1859+
if (sender == null) return;
1860+
// get current platform, set it to selected project data
1861+
var cmb = (ComboBox)sender;
1862+
//Console.WriteLine(cmb.SelectedValue);
1863+
var p = GetSelectedProject();
1864+
p.TargetPlatform = cmb.SelectedValue.ToString();
1865+
}
1866+
18571867
//private void CmbPlatformSelection_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
18581868
//{
18591869
// var comb = (ComboBox)sender;

UnityLauncherPro/Tools.cs

+9
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ public static Process LaunchProject(Project proj)
191191
unitycommandlineparameters += " " + customArguments;
192192
}
193193

194+
string projTargetPlatform = proj.TargetPlatform;
195+
if (string.IsNullOrEmpty(projTargetPlatform) == false)
196+
{
197+
unitycommandlineparameters += " -buildTarget " + projTargetPlatform;
198+
}
199+
200+
Console.WriteLine("Start process: " + cmd + " " + unitycommandlineparameters);
201+
194202
newProcess.StartInfo.Arguments = unitycommandlineparameters;
195203
newProcess.Start();
196204

@@ -761,6 +769,7 @@ public static string GetTargetPlatform(string projectPath)
761769
// 2018: standalone, Win, Win64, OSXUniversal, Linux, Linux64, LinuxUniversal, iOS, Android, Web, WebStreamed, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, N3DS, tvOS
762770
// 2019: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
763771
// 2020: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
772+
// 2021: Standalone, Win, Win64, OSXUniversal, Linux64, iOS, Android, WebGL, XboxOne, PS4, WindowsStoreApps, Switch, tvOS
764773
results = csprojsplit[1].Substring(0, endrow);
765774
//results = (Platform)Enum.Parse(typeof(Platform), csprojsplit[1].Substring(0, endrow));
766775
}

0 commit comments

Comments
 (0)