Пример #1
0
        /// <summary>
        /// Triggers required compilation or code editor syncing if needed.
        /// </summary>
        internal void Update()
        {
            if (EditorApplication.HasFocus && CodeEditor.IsSolutionDirty)
            {
                CodeEditor.SyncSolution();
            }

            if (EditorApplication.IsStopped && !ProjectLibrary.ImportInProgress)
            {
                if (compilerInstance == null)
                {
                    if (EditorApplication.HasFocus)
                    {
                        string outputDir = EditorApplication.ScriptAssemblyPath;

                        if (isGameAssemblyDirty)
                        {
                            compilerInstance = ScriptCompiler.CompileAsync(
                                ScriptAssemblyType.Game, BuildManager.ActivePlatform, true, outputDir);

                            EditorApplication.SetStatusCompiling(true);
                            isGameAssemblyDirty = false;
                        }
                        else if (isEditorAssemblyDirty)
                        {
                            compilerInstance = ScriptCompiler.CompileAsync(
                                ScriptAssemblyType.Editor, BuildManager.ActivePlatform, true, outputDir);

                            EditorApplication.SetStatusCompiling(true);
                            isEditorAssemblyDirty = false;
                        }
                    }
                }
                else
                {
                    if (compilerInstance.IsDone)
                    {
                        Debug.Clear(DebugMessageType.CompilerWarning);
                        Debug.Clear(DebugMessageType.CompilerError);

                        LogWindow window = EditorWindow.GetWindow <LogWindow>();
                        if (window != null)
                        {
                            window.Refresh();
                        }

                        if (compilerInstance.HasErrors)
                        {
                            foreach (var msg in compilerInstance.WarningMessages)
                            {
                                Debug.LogMessage(FormMessage(msg), DebugMessageType.CompilerWarning);
                            }

                            foreach (var msg in compilerInstance.ErrorMessages)
                            {
                                Debug.LogMessage(FormMessage(msg), DebugMessageType.CompilerError);
                            }
                        }

                        compilerInstance.Dispose();
                        compilerInstance = null;

                        EditorApplication.SetStatusCompiling(false);
                        EditorApplication.ReloadAssemblies();
                    }
                }
            }
        }