Skip to content

Commit 7fe567e

Browse files
committed
add button: modify editors.json to make hub think this unity version was installed from Hub
1 parent 90a1086 commit 7fe567e

File tree

2 files changed

+69
-12
lines changed

2 files changed

+69
-12
lines changed

UnityLauncherPro/MainWindow.xaml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,14 +1015,14 @@
10151015
</DataGrid>
10161016

10171017
<StackPanel Grid.Column="1" Orientation="Vertical">
1018-
<DataGrid x:Name="gridBuildReportData" SelectionMode="Single" CanUserAddRows="False" Margin="4,0,2,0" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeDatagridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" VerticalAlignment="Top" PreviewMouseDoubleClick="GridBuildReport_PreviewMouseDoubleClick" HorizontalContentAlignment="Stretch">
1019-
<DataGrid.Columns>
1020-
<DataGridTextColumn Header="Type" Binding="{Binding Category}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
1021-
<DataGridTextColumn Header="Size" Binding="{Binding Size}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
1022-
<DataGridTextColumn Header="%" Binding="{Binding Percentage}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
1023-
</DataGrid.Columns>
1024-
<local:BuildReportItem Category="Texture" Size="10.0 mb" Percentage="50.0%" />
1025-
</DataGrid>
1018+
<DataGrid x:Name="gridBuildReportData" SelectionMode="Single" CanUserAddRows="False" Margin="4,0,2,0" Background="{x:Null}" BorderBrush="{x:Null}" ColumnHeaderStyle="{StaticResource HeaderStyle}" Padding="0" HorizontalScrollBarVisibility="Disabled" HeadersVisibility="Column" Foreground="{DynamicResource ThemeGridForeground}" HorizontalGridLinesBrush="{DynamicResource ThemeDatagridLines}" VerticalGridLinesBrush="{DynamicResource ThemeGridVerticalGridLines}" AutoGenerateColumns="False" VerticalAlignment="Top" PreviewMouseDoubleClick="GridBuildReport_PreviewMouseDoubleClick" HorizontalContentAlignment="Stretch">
1019+
<DataGrid.Columns>
1020+
<DataGridTextColumn Header="Type" Binding="{Binding Category}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
1021+
<DataGridTextColumn Header="Size" Binding="{Binding Size}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
1022+
<DataGridTextColumn Header="%" Binding="{Binding Percentage}" IsReadOnly="True" CanUserResize="False" MinWidth="80" />
1023+
</DataGrid.Columns>
1024+
<local:BuildReportItem Category="Texture" Size="10.0 mb" Percentage="50.0%" />
1025+
</DataGrid>
10261026
<Label Content="Elapsed time:" Foreground="{DynamicResource ThemeButtonForeground}" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
10271027
<TextBox CaretBrush="#FFE2E2E2" x:Name="txtBuildTime" Background="{DynamicResource ThemeTextBoxBackground}" BorderBrush="{x:Null}" Foreground="#FFC7C7C7" SelectionBrush="#FF003966" BorderThickness="0" UndoLimit="64" IsReadOnly="True" VerticalAlignment="Top" HorizontalAlignment="Stretch" Margin="4,0,4,0" />
10281028
</StackPanel>
@@ -1051,7 +1051,7 @@
10511051
</Grid.RowDefinitions>
10521052

10531053
<!-- top labels -->
1054-
<Label Grid.Row="0" Content="Unity Installation Parent Folders" Foreground="{DynamicResource ThemeButtonForeground}" HorizontalAlignment="Left" VerticalAlignment="Bottom" ToolTip="Search will try to find Unity installations under these folders"/>
1054+
<Label Grid.Row="0" Content="Unity Installation(s) Parent Folder(s)" Foreground="{DynamicResource ThemeButtonForeground}" HorizontalAlignment="Left" VerticalAlignment="Bottom" ToolTip="Search will try to find Unity installations under these folders"/>
10551055
<Label x:Name="lblFoundXInstallations" Grid.Row="0" Content="Found .. Installations" Foreground="{DynamicResource ThemeButtonForeground}" HorizontalAlignment="Right" VerticalAlignment="Bottom"/>
10561056
<!-- locations list -->
10571057
<ListBox x:Name="lstRootFolders" Grid.Row="1" Background="{DynamicResource ThemeButtonBackground}" Margin="4,0,2,0" Foreground="{DynamicResource ThemeButtonForeground}" >
@@ -1147,6 +1147,10 @@
11471147
<Button Style="{StaticResource CustomButton}" ToolTip="Explore Scripts folder" x:Name="btnExploreScriptsFolder" Content="..." Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="btnExploreScriptsFolder_Click" Margin="5,0,0,0"/>
11481148
</StackPanel>
11491149

1150+
<Button x:Name="btnPatchHubConfig" ToolTip="Modifies json file to set 'manual:true' values into 'false', so that can add modules using Hub. NOTE: This cannot be reversed (not keeping track which values was already 'false')" Style="{StaticResource CustomButton}" BorderBrush="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnPatchHubConfig_Click">
1151+
<Label Content="Patch Hub editors.json" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
1152+
</Button>
1153+
11501154
</StackPanel>
11511155
</StackPanel>
11521156

UnityLauncherPro/MainWindow.xaml.cs

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ async Task CallGetUnityUpdates()
582582
dataGridUpdates.ItemsSource = null;
583583
var task = GetUnityUpdates.Scan();
584584
var items = await task;
585-
Console.WriteLine("CallGetUnityUpdates=" + items == null);
585+
//Console.WriteLine("CallGetUnityUpdates=" + items == null);
586586
if (items == null) return;
587587
updatesSource = GetUnityUpdates.Parse(items);
588588
if (updatesSource == null) return;
@@ -1159,8 +1159,13 @@ private void BtnOpenEditorLogsFolder_Click(object sender, RoutedEventArgs e)
11591159
if (Tools.LaunchExplorer(logfolder) == false)
11601160
{
11611161
Console.WriteLine("Cannot open folder.." + logfolder);
1162+
SetStatus("Cannot open folder: " + logfolder);
11621163
}
11631164
}
1165+
else
1166+
{
1167+
SetStatus("Folder does not exist: " + logfolder);
1168+
}
11641169
}
11651170

11661171
private void BtnOpenPlayerLogs_Click(object sender, RoutedEventArgs e)
@@ -1170,7 +1175,11 @@ private void BtnOpenPlayerLogs_Click(object sender, RoutedEventArgs e)
11701175

11711176
private void BtnOpenADBLogCat_Click(object sender, RoutedEventArgs e)
11721177
{
1173-
if (string.IsNullOrEmpty(adbLogCatArgs)) return;
1178+
if (string.IsNullOrEmpty(adbLogCatArgs))
1179+
{
1180+
SetStatus("ADB logcat args not set in Settings tab");
1181+
return;
1182+
}
11741183

11751184
try
11761185
{
@@ -1184,6 +1193,7 @@ private void BtnOpenADBLogCat_Click(object sender, RoutedEventArgs e)
11841193
catch (Exception ex)
11851194
{
11861195
Console.WriteLine(ex);
1196+
SetStatus("Cannot launch ADB logcat..");
11871197
}
11881198
}
11891199

@@ -1261,6 +1271,7 @@ private void BtnDonwloadInBrowser_Click(object sender, RoutedEventArgs e)
12611271
else
12621272
{
12631273
Console.WriteLine("Failed getting Unity Installer URL for " + unity?.Version);
1274+
SetStatus("Failed getting Unity Installer URL for " + unity?.Version);
12641275
}
12651276
}
12661277

@@ -1461,6 +1472,7 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
14611472
catch (Exception ex)
14621473
{
14631474
Console.WriteLine("Error saving launcher arguments: " + ex);
1475+
SetStatus("Error saving launcher arguments: " + ex.Message);
14641476
}
14651477
}
14661478
else if (e.Column.DisplayIndex == 6) // platform dropdown
@@ -1640,6 +1652,7 @@ void CreateNewEmptyProject(string targetFolder = null)
16401652
if (string.IsNullOrEmpty(newVersion))
16411653
{
16421654
Console.WriteLine("Missing selected unity version");
1655+
SetStatus("Missing selected unity version (its null)");
16431656
return;
16441657
}
16451658

@@ -1968,6 +1981,7 @@ void RefreshBuildReports()
19681981
if (space1 == -1 || space2 == -1)
19691982
{
19701983
Console.WriteLine(("Failed to parse build report row: " + line2));
1984+
SetStatus("Failed to parse build report row: " + line2);
19711985
continue;
19721986
}
19731987

@@ -2000,6 +2014,7 @@ void RefreshBuildReports()
20002014
if (space1 == -1 || space2 == -1)
20012015
{
20022016
Console.WriteLine(("(2) Failed to parse build report row: " + line2));
2017+
SetStatus("(2) Failed to parse build report row: " + line2);
20032018
continue;
20042019
}
20052020

@@ -2026,6 +2041,7 @@ void RefreshBuildReports()
20262041
txtBuildTime.Text = "";
20272042

20282043
Console.WriteLine("Failed to open editor log or other error in parsing: " + logFile);
2044+
SetStatus("Failed to open editor log or other error in parsing: " + logFile);
20292045
return;
20302046
}
20312047

@@ -2041,6 +2057,7 @@ void RefreshBuildReports()
20412057
txtBuildTime.Text = "";
20422058

20432059
Console.WriteLine("Failed to parse Editor.Log (probably no build reports there)");
2060+
SetStatus("Failed to parse Editor.Log (probably no build reports there)");
20442061
return;
20452062
}
20462063

@@ -2183,13 +2200,15 @@ void ApplyTheme(string themeFile)
21832200
catch (Exception e)
21842201
{
21852202
Console.WriteLine(e);
2203+
SetStatus("Failed to parse color value: " + row[1]);
21862204
}
21872205

21882206
}
21892207
}
21902208
else
21912209
{
21922210
Console.WriteLine("Theme file not found: " + themeFile);
2211+
SetStatus("Theme file not found: " + themeFile);
21932212
}
21942213
}
21952214

@@ -2339,7 +2358,7 @@ void ValidateCustomDateFormat(string format)
23392358

23402359
void ValidateFolderFromTextbox(TextBox textBox)
23412360
{
2342-
Console.WriteLine(textBox.Text);
2361+
//Console.WriteLine(textBox.Text);
23432362
if (Directory.Exists(textBox.Text) == true)
23442363
{
23452364
Properties.Settings.Default.shortcutBatchFileFolder = textBox.Text;
@@ -2627,6 +2646,7 @@ private void MenuCreateDesktopShortCut_Click(object sender, RoutedEventArgs e)
26272646
if (res == false)
26282647
{
26292648
Console.WriteLine("Failed to create shortcut, maybe batch folder location is invalid..");
2649+
SetStatus("Failed to create shortcut, maybe batch folder location is invalid: " + txtShortcutBatchFileFolder.Text);
26302650
}
26312651
}
26322652

@@ -2797,6 +2817,39 @@ private void Window_MouseDown(object sender, MouseButtonEventArgs e)
27972817
gridSettingsBg.Focus();
27982818
}
27992819

2820+
void SetStatus(string msg)
2821+
{
2822+
txtStatus.Text = msg;
2823+
}
2824+
2825+
private void btnPatchHubConfig_Click(object sender, RoutedEventArgs e)
2826+
{
2827+
// read the config file from %APPDATA%
2828+
var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "UnityHub", "editors.json");
2829+
2830+
var result = MessageBox.Show("This will modify current " + configFile + " file. Are you sure you want to continue? (This cannot be undone, we dont know which 'manual:'-value was already set to 'false' (but it shouldnt break anything)", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
2831+
if (result == MessageBoxResult.Yes)
2832+
{
2833+
if (File.Exists(configFile) == true)
2834+
{
2835+
// read the config file
2836+
var json = File.ReadAllText(configFile);
2837+
// replace the manual:true with manual:false using regex
2838+
json = json.Replace("\"manual\":true", "\"manual\":false");
2839+
2840+
Console.WriteLine(json);
2841+
2842+
// write the config file
2843+
File.WriteAllText(configFile, json);
2844+
SetStatus("editors.json file saved");
2845+
}
2846+
}
2847+
else
2848+
{
2849+
SetStatus("Cancelled");
2850+
}
2851+
}
2852+
28002853
//private void BtnBrowseTemplateUnityPackagesFolder_Click(object sender, RoutedEventArgs e)
28012854
//{
28022855
// var folder = Tools.BrowseForOutputFolder("Select unitypackage Templates folder");

0 commit comments

Comments
 (0)