コード例 #1
0
        public static void OnCSProjectModified()
        {
            var projectPath = Application.dataPath.Substring(0, Application.dataPath.Length - 6);
            var solution    = UnitySolution.Parse(projectPath);

            var projEditor = solution.AssemblyCSharpEditor;

            if (projEditor != null)
            {
                if (projEditor.AnalyzerItems.Count() == 0)
                {
                    bool modified = false;
                    var  path     = PlayerPrefs.GetString(CODE_ANALYZER_DLLPATH_ASSEMBLY_EDITOR);
                    if (!string.IsNullOrEmpty(path) &&
                        (File.Exists(path) || File.Exists(Path.Combine(Application.dataPath, path))))
                    {
                        projEditor.AddAnalyzer(new AnalyzerItem(path));
                        modified = true;
                    }
                    path = PlayerPrefs.GetString(CODE_ANALYZER_CSHARP_DLLPATH_ASSEMBLY_EDITOR);
                    if (!string.IsNullOrEmpty(path) &&
                        (File.Exists(path) || File.Exists(Path.Combine(Application.dataPath, path))))
                    {
                        projEditor.AddAnalyzer(new AnalyzerItem(path));
                        modified = true;
                    }
                    if (modified)
                    {
                        projEditor.WriteToFile();
//                        Debug.Log("Roslyn has been added to Editor.");
                    }
                }
            }
        }
コード例 #2
0
        public static void OnCSProjectModified()
        {
            var projectPath = Application.dataPath.Substring(0, Application.dataPath.Length - 6);
            var solution    = UnitySolution.Parse(projectPath);

            var projAsm = solution.AssemblyCSharp;

            if (projAsm != null)
            {
                if (projAsm.AnalyzerItems == null || projAsm.AnalyzerItems.Count() == 0)
                {
                    var path = PlayerPrefs.GetString(CODE_ANALYZER_DLLPATH_ASSEMBLY);
                    if (!string.IsNullOrEmpty(path) && (File.Exists(path) || File.Exists(Path.Combine(Application.dataPath, path))))
                    {
                        projAsm.AddAnalyzer(new AnalyzerItem(path));
                        projAsm.WriteToFile();
                    }
                }
            }

            var projEditor = solution.AssemblyCSharpEditor;

            if (projEditor != null)
            {
                if (projEditor.AssemblyName == null || projEditor.AnalyzerItems.Count() == 0)
                {
                    var path = PlayerPrefs.GetString(CODE_ANALYZER_DLLPATH_ASSEMBLY_EDITOR);
                    if (!string.IsNullOrEmpty(path) && (File.Exists(path) || File.Exists(Path.Combine(Application.dataPath, path))))
                    {
                        projEditor.AddAnalyzer(new AnalyzerItem(path));
                        projEditor.WriteToFile();
                    }
                }
            }
        }