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