Unity: Allow version selection from asset file

This commit is contained in:
Katy Coe
2021-01-11 02:30:26 +01:00
parent 074f13b2f4
commit 361f5179d5
5 changed files with 85 additions and 3 deletions

View File

@@ -212,6 +212,42 @@ namespace Il2CppInspectorGUI
((App) Application.Current).ResetLoadOptions();
}
/// <summary>
/// Select Unity version from asset file
/// </summary>
private void BtnUnityAsset_Click(object sender, RoutedEventArgs e) {
var openFileDialog = new OpenFileDialog {
Filter = "Unity asset files (*.*)|*.*",
CheckFileExists = true
};
if (openFileDialog.ShowDialog() != true)
return;
try {
var unityVersion = UnityVersion.FromAssetFile(openFileDialog.FileName);
var done = false;
foreach (UnityHeaders header in cboPyUnityVersion.Items) {
if (header.VersionRange.Contains(unityVersion)) {
cboPyUnityVersion.SelectedItem = header;
cboCppUnityVersion.SelectedItem = header;
cboJsonUnityVersion.SelectedItem = header;
done = true;
break;
}
}
if (done)
MessageBox.Show(this, $"Selected Unity version {unityVersion}", "Unity version detected", MessageBoxButton.OK, MessageBoxImage.Information);
else
MessageBox.Show(this, $"Asset file Unity version {unityVersion} is not compatible with the loaded IL2CPP application", "Incompatible Unity version", MessageBoxButton.OK, MessageBoxImage.Error);
}
catch (ArgumentException) {
MessageBox.Show(this, "Could not determine Unity version from this asset file", "Unity version could not be detected", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
/// <summary>
/// User has selected an image
/// </summary>