Skip to content

Commit fffa97e

Browse files
committed
adding online templates selection to NewProject window
1 parent e351451 commit fffa97e

File tree

4 files changed

+138
-1
lines changed

4 files changed

+138
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace UnityLauncherPro.Data
2+
{
3+
public class OnlineTemplateItem
4+
{
5+
public string Name { get; set; }
6+
public string Description { get; set; }
7+
public string RenderPipeline { get; set; }
8+
public string Type { get; set; } // Core, Learning, Sample,
9+
public string PreviewImageURL { get; set; }
10+
public string TarBallURL { get; set; }
11+
}
12+
}

UnityLauncherPro/NewProject.xaml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:UnityLauncherPro"
7+
xmlns:data="clr-namespace:UnityLauncherPro.Data"
8+
d:DataContext="{d:DesignInstance Type=local:NewProject}"
79
mc:Ignorable="d"
8-
Title="Create New Project" Height="480" Width="500" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
10+
Title="Create New Project" Height="480" Width="640" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
911

1012
<Grid>
13+
<Grid.ColumnDefinitions>
14+
<ColumnDefinition Width="*"/>
15+
<ColumnDefinition Width="164"/>
16+
</Grid.ColumnDefinitions>
1117
<StackPanel Margin="10,3">
1218
<Label Content="Unity Version" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0,0,0,3" Padding="5,5,5,3" />
1319
<DataGrid x:Name="gridAvailableVersions" KeyboardNavigation.TabNavigation = "None" SelectionMode="Single" Height="230" Margin="0" HeadersVisibility="None" AutoGenerateColumns="False" IsSynchronizedWithCurrentItem="True" Foreground="{DynamicResource ThemeButtonForeground}" Background="{DynamicResource ThemeMainBackgroundColor}" SelectionChanged="GridAvailableVersions_SelectionChanged" IsTabStop="True" TabIndex="1" Loaded="GridAvailableVersions_Loaded" EnableRowVirtualization="False" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" PreviewMouseDoubleClick="gridAvailableVersions_PreviewMouseDoubleClick" CanUserAddRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserDeleteRows="False">
@@ -77,7 +83,67 @@
7783
</StatusBarItem>
7884
</StatusBar>
7985
</Grid>
86+
</StackPanel>
87+
<StackPanel Orientation="Vertical" Margin="0,3,10,3" Grid.Column="1">
88+
<Label Content="Unity Online Templates" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0,0,0,3" Padding="5,5,5,3" />
89+
<!-- search box -->
90+
<Grid Background="{DynamicResource ThemeTextBoxBackground}" VerticalAlignment="Top" Margin="6,5,0,0" Height="20" >
91+
<TextBlock Margin="3,2" MinWidth="100" Text="Filter" Foreground="{DynamicResource ThemeSearchPlaceholder}" Height="24">
92+
<TextBlock.Style>
93+
<Style TargetType="TextBlock">
94+
<Setter Property="Visibility" Value="Collapsed" />
95+
<Style.Triggers>
96+
<DataTrigger Binding="{Binding Text, ElementName=txtFilterTemplates}" Value="">
97+
<Setter Property="Visibility" Value="Visible" />
98+
</DataTrigger>
99+
</Style.Triggers>
100+
</Style>
101+
</TextBlock.Style>
102+
</TextBlock>
103+
<TextBox MinWidth="100" CaretBrush="{DynamicResource ThemeSearchCaret}" x:Name="txtFilterTemplates" Background="Transparent" BorderBrush="{x:Null}" Foreground="{DynamicResource ThemeSearchForeground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" BorderThickness="0" Margin="2,2,0,0" UndoLimit="64" />
104+
<Button x:Name="btnClearUpdatesSearch" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="23" Width="23" Background="Transparent" Padding="0,2" Visibility="Visible" BorderBrush="{x:Null}" >
105+
<TextBlock Text="" FontSize="8" Foreground="{DynamicResource ThemeSearchClose}" Padding="5,3,4,4" HorizontalAlignment="Center">
106+
<TextBlock.Style>
107+
<Style TargetType="{x:Type TextBlock}">
108+
<Style.Triggers>
109+
<DataTrigger Binding="{Binding Text, ElementName=txtFilterTemplates}" Value="">
110+
<Setter Property="Visibility" Value="Hidden"/>
111+
</DataTrigger>
112+
<DataTrigger Binding="{Binding Text, ElementName=txtFilterTemplates}" Value="{x:Null}">
113+
<Setter Property="Visibility" Value="Hidden"/>
114+
</DataTrigger>
115+
</Style.Triggers>
116+
</Style>
117+
</TextBlock.Style>
118+
</TextBlock>
119+
</Button>
120+
</Grid>
80121

122+
<ListBox x:Name="listOnlineTemplates" Margin="6,5,0,0" Height="340"
123+
Background="{DynamicResource ThemeMainBackgroundColor}"
124+
Foreground="{DynamicResource ThemeButtonForeground}"
125+
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
126+
d:ItemsSource="{d:SampleData ItemCount=4}">
127+
<ListBox.ItemTemplate>
128+
<DataTemplate>
129+
<StackPanel Orientation="Vertical" Margin="3">
130+
<Image Source="{Binding PreviewImageURL}"
131+
Margin="0,0,0,5"
132+
ToolTip="{Binding Description}"
133+
Stretch="Uniform"
134+
HorizontalAlignment="Stretch"/>
135+
<TextBlock Text="{Binding Name}"
136+
FontWeight="Bold"
137+
TextWrapping="Wrap"
138+
Foreground="{DynamicResource ThemeButtonForeground}"/>
139+
<TextBlock Text="{Binding Type}"
140+
FontSize="10"
141+
Foreground="{DynamicResource ThemeButtonForeground}"
142+
Opacity="0.7"/>
143+
</StackPanel>
144+
</DataTemplate>
145+
</ListBox.ItemTemplate>
146+
</ListBox>
81147
</StackPanel>
82148
</Grid>
83149
</Window>

UnityLauncherPro/NewProject.xaml.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Windows.Controls;
66
using System.Windows.Input;
77
using System.Windows.Media;
8+
using UnityLauncherPro.Data;
89

910
namespace UnityLauncherPro
1011
{
@@ -31,6 +32,9 @@ public NewProject(string unityVersion, string suggestedName, string targetFolder
3132

3233
NewProject.targetFolder = targetFolder;
3334

35+
// TODO could optionally disable templates in settings
36+
_ = LoadOnlineTemplatesAsync();
37+
3438
// get version
3539
newVersion = unityVersion;
3640
newName = suggestedName;
@@ -398,5 +402,59 @@ private void btnCreateMissingFolder_Click(object sender, RoutedEventArgs e)
398402
Tools.SetStatus("Failed to create folder: " + ex.Message);
399403
}
400404
}
405+
406+
private async System.Threading.Tasks.Task LoadOnlineTemplatesAsync()
407+
{
408+
// Simulate async loading (replace with actual async HTTP call later)
409+
await System.Threading.Tasks.Task.Run(() =>
410+
{
411+
var templates = new List<OnlineTemplateItem>
412+
{
413+
new OnlineTemplateItem
414+
{
415+
Name = "3D Template",
416+
Description = "A great starting point for 3D projects using the Universal Render Pipeline (URP).",
417+
PreviewImageURL = "https://storage.googleapis.com/live-platform-resources-prd/templates/assets/AR_Mobile_Thumbnail_HUB_464008d11a/AR_Mobile_Thumbnail_HUB_464008d11a.png",
418+
Type = "CORE",
419+
RenderPipeline = "URP",
420+
TarBallURL = "https://download.packages.unity.com/com.unity.template.hdrp-blank/-/com.unity.template.hdrp-blank-17.0.2.tgz"
421+
},
422+
new OnlineTemplateItem
423+
{
424+
Name = "2D Template",
425+
Description = "A great starting point for 2D projects using the Built-in Render Pipeline.",
426+
PreviewImageURL = "https://storage.googleapis.com/live-platform-resources-prd/templates/assets/Platformer_preview_887cd85a63/Platformer_preview_887cd85a63.png",
427+
Type = "CORE",
428+
RenderPipeline = "Built-in",
429+
TarBallURL = "https://download.packages.unity.com/com.unity.template.mr-multiplayer/-/com.unity.template.mr-multiplayer-1.0.3.tgz"
430+
},
431+
new OnlineTemplateItem
432+
{
433+
Name = "Wubba Template",
434+
Description = "A great asdfasdf projects using.",
435+
PreviewImageURL = "https://storage.googleapis.com/live-platform-resources-prd/templates/assets/2_4_1_Overview_627c09d1be/2_4_1_Overview_627c09d1be.png",
436+
Type = "SAMPLES",
437+
RenderPipeline = "URP",
438+
TarBallURL = "https://download.packages.unity.com/com.unity.template.vr/-/com.unity.template.vr-9.2.0.tgz"
439+
},
440+
new OnlineTemplateItem
441+
{
442+
Name = "ASDF Template",
443+
Description = "A great asdfasdf projects using.",
444+
PreviewImageURL = "https://storage.googleapis.com/live-platform-resources-prd/templates/assets/HDRP_c27702ce66/HDRP_c27702ce66.jpg",
445+
Type = "LEARNING",
446+
RenderPipeline = "HDRP",
447+
TarBallURL = "https://download.packages.unity.com/com.unity.template.platformer/-/com.unity.template.platformer-5.0.5.tgz"
448+
}
449+
};
450+
451+
// Update UI on dispatcher thread
452+
Dispatcher.Invoke(() =>
453+
{
454+
listOnlineTemplates.Items.Clear();
455+
listOnlineTemplates.ItemsSource = templates;
456+
});
457+
});
458+
}
401459
}
402460
}

UnityLauncherPro/UnityLauncherPro.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<Compile Include="Data\BuildReportItem.cs" />
9191
<Compile Include="Data\DownloadProgress.cs" />
9292
<Compile Include="Data\MessageType.cs" />
93+
<Compile Include="Data\OnlineTemplateItem.cs" />
9394
<Compile Include="Data\Platform.cs" />
9495
<Compile Include="Data\Tabs.cs" />
9596
<Compile Include="Data\ThemeColor.cs" />

0 commit comments

Comments
 (0)