Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions UnityLauncherPro/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@
<CheckBox x:Name="chkFetchAdditionalInfo" Content="Fetch additional info about Editor" ToolTip="Reads releases API for security related info" Checked="chkFetchAdditionalInfo_Checked" Unchecked="chkFetchAdditionalInfo_Checked"/>
<CheckBox x:Name="chkFetchOnlineTemplates" Content="New Project window: Fetch online templates" ToolTip="Automatically fetch template listfrom Unity servers" Checked="chkFetchOnlineTemplates_Checked" Unchecked="chkFetchOnlineTemplates_Checked"/>
<CheckBox x:Name="chkStreamerMode" Content="Streamer Mode (hide project names and folders)" ToolTip="Hide project names and folders in main view" Checked="ChkStreamerMode_Checked" Unchecked="ChkStreamerMode_Checked" HorizontalAlignment="Left"/>
<CheckBox x:Name="chkShowRecoveredScenePopup" Content="Show popup for recovered scene after editor crash" ToolTip="After editor crash, show a popup to load recovered scene (or delete it)" Checked="chkShowRecoveredScenePopup_Checked" Unchecked="chkShowRecoveredScenePopup_Checked" HorizontalAlignment="Left"/>
<!--<StackPanel Orientation="Horizontal" Margin="0,0,0,4">
<TextBox x:Name="txtTemplatePackagesFolder" BorderBrush="Transparent" CaretBrush="{DynamicResource ThemeSearchCaret}" Background="{DynamicResource ThemeTextBoxBackground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" Foreground="{DynamicResource ThemeSearchForeground}" ToolTip="Folder for your custom unitypackage templates (for new project)" Padding="0,3,0,0" Width="110" TextChanged="TxtTemplatePackagesFolder_TextChanged" />
<Button Style="{StaticResource CustomButton}" x:Name="btnBrowseTemplateUnityPackagesFolder" Content="..." Margin="6,0,0,0" MinWidth="22" MinHeight="22" FontSize="16" ToolTip="Browse for new projects root folder.." Click="BtnBrowseTemplateUnityPackagesFolder_Click" />
Expand All @@ -758,23 +759,23 @@
<CheckBox x:Name="chkRunAutomatically" Content="Run automatically on startup" ToolTip="Run automatically using startup registry key" HorizontalAlignment="Left" Checked="ChkRunAutomatically_Checked" Unchecked="ChkRunAutomatically_Checked"/>
<CheckBox x:Name="chkRunAutomaticallyMinimized" Content="as minimized" ToolTip="Minimize to tray when started automatically" HorizontalAlignment="Left" Checked="ChkRunAutomaticallyMinimized_Checked" Unchecked="ChkRunAutomaticallyMinimized_Checked" Margin="5,0,0,3"/>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,6,0,0">
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,-1,0,0">
<Label Content="Initial WebGL server port" Foreground="{DynamicResource ThemeButtonForeground}" />
<TextBox x:Name="txtWebglPort" BorderBrush="Transparent" CaretBrush="{DynamicResource ThemeSearchCaret}" Background="{DynamicResource ThemeTextBoxBackground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" Foreground="{DynamicResource ThemeSearchForeground}" MinWidth="80" ToolTip="Initial port for first local WebGL webserver process (next one will be +1)" Padding="0,3,0,0" TextChanged="txtWebglPort_TextChanged" HorizontalAlignment="Left" Text="50000" LostFocus="txtWebglPort_LostFocus" Margin="1,0,0,0" Height="22" />
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,0,0,4" HorizontalAlignment="Left">
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,-1,0,4" HorizontalAlignment="Left">
<Label Content="Shortcut .bat files folder" Foreground="{DynamicResource ThemeButtonForeground}" HorizontalAlignment="Left" />
<TextBox x:Name="txtShortcutBatchFileFolder" BorderBrush="Transparent" CaretBrush="{DynamicResource ThemeSearchCaret}" Background="{DynamicResource ThemeTextBoxBackground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" Foreground="{DynamicResource ThemeSearchForeground}" MinWidth="169" ToolTip="Save generated .bat files here (they are run from Desktop Shortcut)" Padding="0,3,0,0" HorizontalAlignment="Left" MaxWidth="169" LostFocus="TxtShortcutBatchFileFolder_LostFocus" TextChanged="TxtShortcutBatchFileFolder_TextChanged" Margin="5,0,0,0" Height="22" />
<Button Style="{StaticResource CustomButton}" x:Name="btnBrowseBatchFileFolder" Content="..." Margin="5,0,0,0" MinWidth="22" Click="BtnBrowseBatchFileFolder_Click" MinHeight="22" FontSize="16" ToolTip="Browse for .bat folder (default location is inside AppData/UnityLauncherPro/ and works fine, so this is optional)" HorizontalAlignment="Left" />
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,0,0,4" HorizontalAlignment="Left">
<Label Content="ADB args:" Foreground="{DynamicResource ThemeButtonForeground}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Margin="0,1,0,-4" />
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,-1,0,4" HorizontalAlignment="Left">
<Label Content="ADB args:" Foreground="{DynamicResource ThemeButtonForeground}" HorizontalAlignment="Left" VerticalContentAlignment="Center" Margin="0,0,0,-4" />
<TextBox x:Name="txtLogCatArgs" BorderBrush="Transparent" Text="-s Unity ActivityManager PackageManager dalvikvm DEBUG -v color" CaretBrush="{DynamicResource ThemeSearchCaret}" Background="{DynamicResource ThemeTextBoxBackground}" SelectionBrush="{DynamicResource ThemeSearchSelection}" Foreground="{DynamicResource ThemeSearchForeground}" MinWidth="250" ToolTip="ADB commandline arguments" Padding="0,3,0,0" TextChanged="TxtLogCatArgs_TextChanged" Width="250" Height="22" />
<Button Style="{StaticResource CustomButton}" x:Name="btnResetLogCatArgs" Margin="5,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" ToolTip="Reset to default logcat args" Click="BtnResetLogCatArgs_Click">
<Label Content="Reset" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
</Button>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,6,0,0">
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,-2,0,0">
<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 were already 'false')" Style="{StaticResource CustomButton}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnPatchHubConfig_Click">
<Label Content="Patch Hub editors.json" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Control}}}" />
</Button>
Expand Down
9 changes: 9 additions & 0 deletions UnityLauncherPro/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@
chkAskNameForQuickProject.IsChecked = Settings.Default.askNameForQuickProject;
chkEnableProjectRename.IsChecked = Settings.Default.enableProjectRename;
chkStreamerMode.IsChecked = Settings.Default.streamerMode;
chkShowRecoveredScenePopup.IsChecked = Settings.Default.showRecoveredScenePopup;
chkShowPlatform.IsChecked = Settings.Default.showTargetPlatform;
chkCheckSRP.IsChecked = Settings.Default.checkSRP;
chkUseCustomTheme.IsChecked = Settings.Default.useCustomTheme;
Expand Down Expand Up @@ -1287,7 +1288,7 @@
if (task.IsCompleted == false || task.IsFaulted == true) return;
if (items == null) return;
updatesSource = items.ToArray();
if (updatesSource == null) return;

Check warning on line 1291 in UnityLauncherPro/MainWindow.xaml.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Change this condition so that it does not always evaluate to 'False'.

See more on https://sonarcloud.io/project/issues?id=unitycoder_UnityLauncherPro&issues=AZ3di_XTF6edfREPGvIE&open=AZ3di_XTF6edfREPGvIE&pullRequest=227
dataGridUpdates.ItemsSource = updatesSource;
// if search string is set, then filter it (after data is loaded)
if (string.IsNullOrEmpty(searchBoxUpdates.SearchText) == false)
Expand Down Expand Up @@ -2219,6 +2220,14 @@
SetStatus("Streamer mode " + (isChecked ? "enabled" : "disabled"), MessageType.Info);
}

private void chkShowRecoveredScenePopup_Checked(object sender, RoutedEventArgs e)
{
var isChecked = (bool)((CheckBox)sender).IsChecked;

Settings.Default.showRecoveredScenePopup = isChecked;
Settings.Default.Save();
}

private void ChkShowPlatform_Checked(object sender, RoutedEventArgs e)
{
if (this.IsActive == false) return; // dont run code on window init
Expand Down
12 changes: 12 additions & 0 deletions UnityLauncherPro/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 35 additions & 25 deletions UnityLauncherPro/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Windows.Media;
using System.Windows.Threading;
using UnityLauncherPro.Helpers;
using UnityLauncherPro.Properties;

namespace UnityLauncherPro
{
Expand Down Expand Up @@ -404,51 +405,60 @@
return newProcess;
}

static bool CheckCrashBackupScene(string projectPath)

Check failure on line 408 in UnityLauncherPro/Tools.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=unitycoder_UnityLauncherPro&issues=AZ3di_aMF6edfREPGvIF&open=AZ3di_aMF6edfREPGvIF&pullRequest=227
{
var cancelRunningUnity = false;
var recoveryFile = Path.Combine(projectPath, "Temp", "__Backupscenes", "0.backup");
if (File.Exists(recoveryFile))
{
var result = MessageBox.Show("Crash recovery scene found, do you want to MOVE it into Assets/_Recovery/-folder?", "UnityLauncherPro - Scene Recovery", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
if (Settings.Default.showRecoveredScenePopup)
{
var restoreFolder = Path.Combine(projectPath, "Assets", "_Recovery");
if (Directory.Exists(restoreFolder) == false)
var result = MessageBox.Show("Crash recovery scene found, do you want to MOVE it into Assets/_Recovery/-folder?", "UnityLauncherPro - Scene Recovery", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
Directory.CreateDirectory(restoreFolder);
}
if (Directory.Exists(restoreFolder) == true)
{
Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
var uniqueFileName = "Recovered_Scene" + unixTimestamp + ".unity";
var restoreFolder = Path.Combine(projectPath, "Assets", "_Recovery");
if (Directory.Exists(restoreFolder) == false)
{
Directory.CreateDirectory(restoreFolder);
}

try
if (Directory.Exists(restoreFolder) == true)
{
File.Move(recoveryFile, Path.Combine(restoreFolder, uniqueFileName));
// remove folder, otherwise unity 6000.2 asks for recovery
Directory.Delete(Path.Combine(projectPath, "Temp", "__Backupscenes"), true);
Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
var uniqueFileName = "Recovered_Scene" + unixTimestamp + ".unity";

try
{
File.Move(recoveryFile, Path.Combine(restoreFolder, uniqueFileName));
// remove folder, otherwise unity 6000.2 asks for recovery
Directory.Delete(Path.Combine(projectPath, "Temp", "__Backupscenes"), true);

Console.WriteLine("moved file to " + uniqueFileName);
}
catch (IOException)
{
// if move failed, try copy
File.Copy(recoveryFile, Path.Combine(restoreFolder, uniqueFileName));
Console.WriteLine("copied file");
}

Console.WriteLine("moved file to " + uniqueFileName);
Console.WriteLine("Recovered crashed scene into: " + restoreFolder);
}
catch (IOException)
else
{
// if move failed, try copy
File.Copy(recoveryFile, Path.Combine(restoreFolder, uniqueFileName));
Console.WriteLine("copied file");
Console.WriteLine("Error: Failed to create restore folder: " + restoreFolder);
cancelRunningUnity = true;
}

Console.WriteLine("Recovered crashed scene into: " + restoreFolder);
}
else
else if (result == MessageBoxResult.Cancel) // dont do restore, but run Unity
{
Console.WriteLine("Error: Failed to create restore folder: " + restoreFolder);
cancelRunningUnity = true;
}
}
else if (result == MessageBoxResult.Cancel) // dont do restore, but run Unity
else
{
cancelRunningUnity = true;
File.Delete(recoveryFile);
Directory.Delete(Path.GetDirectoryName(recoveryFile));
}
}
return cancelRunningUnity;
Expand Down
Loading