Пример #1
0
        void OnLoad()
        {
            ConsoleKeyInfo key;

            Console.WriteLine("Choose your Unity version:");
            Console.WriteLine("Do you want to detect the version automatically or manually? (y/n)");
            key = Console.ReadKey();

            if (key.Key == ConsoleKey.Y)
            {
                Console.WriteLine("");
                Console.WriteLine("Detecting version...");
                Version version = Patcher.DetectVersion();
                if (version != null)
                {
                    Patcher.CurrentVersion = version;
                    OnVersionDetected();
                }
                else
                {
                    Console.WriteLine("This version is not supported. Try another version of Unity");
                }
            }
            else
            {
                Console.WriteLine("");

                var versions = Versions.Get();
                for (int i = 0; i < versions.Length; ++i)
                {
                    Console.WriteLine($"* {versions[i]} => press {i + 1} key");
                }

                while (true)
                {
                    key = Console.ReadKey();

                    if (int.TryParse(key.KeyChar.ToString(), out int ver))
                    {
                        ver--;
                        if (ver >= 0 && ver < versions.Length)
                        {
                            Patcher.CurrentVersion = versions[ver];
                            OnVersionDetected();
                            break;
                        }
                    }
                }
            }
        }
Пример #2
0
        private void OnFileLoaded()
        {
            Freeze("Detecting version...");
            ThreadHelper.Invoke(() => {
                Version version = Patcher.DetectVersion();

                Dispatcher.Invoke(() => {
                    Freeze(false);

                    if (version != null)
                    {
                        VersionsCombo.SelectedItem = version;
                        OnVersionDetected();
                    }
                    else
                    {
                        Error("This version is not supported. Try another version of Unity");
                    }
                });
            });
        }