Skip to content

Commit

Permalink
newproject: add forceDX11 checkbox (fixes #182)
Browse files Browse the repository at this point in the history
  • Loading branch information
unitycoder committed Feb 2, 2025
1 parent 9bde3e2 commit 758e4c2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion UnityLauncherPro/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ void CreateNewEmptyProject(string targetFolder = null)
Console.WriteLine("Create project " + NewProject.newVersion + " : " + rootFolder);
if (string.IsNullOrEmpty(rootFolder)) return;

var p = Tools.FastCreateProject(NewProject.newVersion, rootFolder, NewProject.newProjectName, NewProject.templateZipPath, NewProject.platformsForThisUnity, NewProject.selectedPlatform, (bool)chkUseInitScript.IsChecked, initScriptFileFullPath);
var p = Tools.FastCreateProject(NewProject.newVersion, rootFolder, NewProject.newProjectName, NewProject.templateZipPath, NewProject.platformsForThisUnity, NewProject.selectedPlatform, (bool)chkUseInitScript.IsChecked, initScriptFileFullPath, NewProject.forceDX11);

// add to list (just in case new project fails to start, then folder is already generated..)
if (p != null) AddNewProjectToList(p);
Expand Down
18 changes: 11 additions & 7 deletions UnityLauncherPro/NewProject.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:UnityLauncherPro"
mc:Ignorable="d"
Title="Create New Project" Height="480" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
Title="Create New Project" Height="480" Width="500" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">

<Grid>
<StackPanel Margin="10,3">
Expand All @@ -20,24 +20,28 @@

<Grid HorizontalAlignment="Stretch" Margin="0,3,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40*"/>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="40*"/>
<ColumnDefinition Width="35*"/>
<ColumnDefinition Width="15*"/>
<ColumnDefinition Width="22*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Label x:Name="lblNewProjectNameLabel" Grid.Column="0" Content="Project Name:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,5,0" />
<Label Grid.Column="1" Content="Platform:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,0,0" />
<Label x:Name="lblTemplateTitleAndCount" Grid.Column="2" Content="Templates:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="5,5,5,0" />
<Label Content="Override" Grid.Column="3" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,0,0"/>
</Grid>

<Grid HorizontalAlignment="Stretch" Margin="0,3,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40*"/>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="40*"/>
<ColumnDefinition Width="35*"/>
<ColumnDefinition Width="15*"/>
<ColumnDefinition Width="22*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" x:Name="txtNewProjectName" VerticalAlignment="Center" IsUndoEnabled="True" TextChanged="TxtNewProjectName_TextChanged" PreviewKeyDown="TxtNewProjectName_PreviewKeyDown" TabIndex="0" Margin="0,2,6,2" />
<ComboBox Grid.Column="1" x:Name="cmbNewProjectPlatform" SelectedIndex="0" Margin="0,0,0,0" TabIndex="2" DropDownOpened="CmbNewProjectPlatform_DropDownOpened" />
<ComboBox Grid.Column="2" x:Name="cmbNewProjectTemplate" DisplayMemberPath="Key" SelectedIndex="0" Margin="6,0,0,0" TabIndex="2" DropDownOpened="CmbNewProjectTemplate_DropDownOpened" />
<CheckBox Grid.Column="3" x:Name="chkForceDX11" Content="DX11" ToolTip="Use DX11 instead of DX12" Margin="6,0,0,0" IsChecked="True" Checked="chkForceDX11_Checked" Unchecked="chkForceDX11_Checked"/>
</Grid>

<Label x:Name="lblNewProjectFolder" Content="(folder)" Foreground="{DynamicResource ThemeButtonForegroundDisabled}" Margin="0" FontSize="10" Padding="5,0,5,3" />
Expand Down
10 changes: 10 additions & 0 deletions UnityLauncherPro/NewProject.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class NewProject : Window
public static string newName = null;
public static string templateZipPath = null;
public static string selectedPlatform = null;
public static bool forceDX11 = false;
public static string[] platformsForThisUnity = null;

bool isInitializing = true; // to keep OnChangeEvent from firing too early
Expand Down Expand Up @@ -289,6 +290,10 @@ private void GridAvailableVersions_SelectionChanged(object sender, SelectionChan
// update templates list for selected unity version
UpdateTemplatesDropDown(k.Path);
UpdateModulesDropdown(k.Version);

// hide forceDX11 checkbox if version is below 6000
bool is6000 = k.Version.Contains("6000");
chkForceDX11.Visibility = is6000 ? Visibility.Visible : Visibility.Collapsed;
}

private void GridAvailableVersions_Loaded(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -323,5 +328,10 @@ private void gridAvailableVersions_PreviewMouseDoubleClick(object sender, MouseB
BtnCreateNewProject_Click(null, null);
}
}

private void chkForceDX11_Checked(object sender, RoutedEventArgs e)
{
forceDX11 = chkForceDX11.IsChecked == true;
}
}
}
4 changes: 2 additions & 2 deletions UnityLauncherPro/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ public static string BrowseForOutputFolder(string title, string initialDirectory
}

// TODO too many params..
public static Project FastCreateProject(string version, string baseFolder, string projectName = null, string templateZipPath = null, string[] platformsForThisUnity = null, string platform = null, bool useInitScript = false, string initScriptPath = null)
public static Project FastCreateProject(string version, string baseFolder, string projectName = null, string templateZipPath = null, string[] platformsForThisUnity = null, string platform = null, bool useInitScript = false, string initScriptPath = null, bool forceDX11 = false)
{
// check for base folders in settings tab
if (string.IsNullOrEmpty(baseFolder) == true)
Expand Down Expand Up @@ -1694,7 +1694,7 @@ public static Project FastCreateProject(string version, string baseFolder, strin
proj.TargetPlatform = platform;
proj.Modified = DateTime.Now;
proj.folderExists = true; // have to set this value, so item is green on list

proj.Arguments = version.Contains("6000") ? (forceDX11 ? "-force-d3d11" : null) : null; // this gets erased later, since its not saved? would be nice to not add it at all though
var proc = LaunchProject(proj, null, useInitScript);
ProcessHandler.Add(proj, proc);

Expand Down

0 comments on commit 758e4c2

Please sign in to comment.