A game about forced loneliness, made by TACStudios
1/*--------------------------------------------------------------------------------------------- 2 * Copyright (c) Microsoft Corporation. All rights reserved. 3 * Licensed under the MIT License. See License.txt in the project root for license information. 4 *--------------------------------------------------------------------------------------------*/ 5 6using System; 7using UnityEditor; 8using UnityEditor.Compilation; 9 10namespace Microsoft.Unity.VisualStudio.Editor 11{ 12 internal static class UnityInstallation 13 { 14 public static bool IsMainUnityEditorProcess 15 { 16 get 17 { 18#if UNITY_2020_2_OR_NEWER 19 if (UnityEditor.AssetDatabase.IsAssetImportWorkerProcess()) 20 return false; 21#elif UNITY_2019_3_OR_NEWER 22 if (UnityEditor.Experimental.AssetDatabaseExperimental.IsAssetImportWorkerProcess()) 23 return false; 24#endif 25 26#if UNITY_2021_1_OR_NEWER 27 if (UnityEditor.MPE.ProcessService.level == UnityEditor.MPE.ProcessLevel.Secondary) 28 return false; 29#elif UNITY_2020_2_OR_NEWER 30 if (UnityEditor.MPE.ProcessService.level == UnityEditor.MPE.ProcessLevel.Slave) 31 return false; 32#elif UNITY_2020_1_OR_NEWER 33 if (global::Unity.MPE.ProcessService.level == global::Unity.MPE.ProcessLevel.UMP_SLAVE) 34 return false; 35#endif 36 37 return true; 38 } 39 } 40 41 private static readonly Lazy<bool> _lazyIsInSafeMode = new Lazy<bool>(() => 42 { 43 // internal static extern bool isInSafeMode { get {} } 44 var ieu = typeof(EditorUtility); 45 var pinfo = ieu.GetProperty("isInSafeMode", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); 46 if (pinfo == null) 47 return false; 48 49 return Convert.ToBoolean(pinfo.GetValue(null)); 50 }); 51 public static bool IsInSafeMode => _lazyIsInSafeMode.Value; 52 public static Version LatestLanguageVersionSupported(Assembly assembly) 53 { 54#if UNITY_2020_2_OR_NEWER 55 if (assembly?.compilerOptions != null && Version.TryParse(assembly.compilerOptions.LanguageVersion, out var result)) 56 return result; 57 58 // if parsing fails, we know at least we have support for 8.0 59 return new Version(8, 0); 60#else 61 return new Version(7, 3); 62#endif 63 } 64 65 } 66}