示例#1
0
        private static void EditorApplicationOnPlayModeStateChanged(PlayModeStateChange state)
        {
            if (DebuggingLevel > 2)
            {
                UnityEngine.Debug.Log($"Burst - Change of Editor State: {state}");
            }

            switch (state)
            {
            case PlayModeStateChange.ExitingEditMode:
                if (BurstCompiler.Options.RequiresSynchronousCompilation)
                {
                    if (DebuggingLevel > 2)
                    {
                        UnityEngine.Debug.Log("Burst - Exiting EditMode - waiting for any pending synchronous jobs");
                    }

                    EditorUtility.DisplayProgressBar("Burst", "Waiting for synchronous compilation to finish", -1);
                    try
                    {
                        BurstCompiler.WaitUntilCompilationFinished();
                    }
                    finally
                    {
                        EditorUtility.ClearProgressBar();
                    }

                    if (DebuggingLevel > 2)
                    {
                        UnityEngine.Debug.Log("Burst - Exiting EditMode - finished waiting for any pending synchronous jobs");
                    }
                }
                else
                {
                    BurstCompiler.ClearEagerCompilationQueues();
                    if (DebuggingLevel > 2)
                    {
                        UnityEngine.Debug.Log("Burst - Exiting EditMode - cleared eager-compilation queues");
                    }
                }
                break;

            case PlayModeStateChange.ExitingPlayMode:
                // If Synchronous Compilation is checked, then we will already have waited for eager-compilation to finish
                // before entering playmode. But if it was unchecked, we may have cancelled in-progress eager-compilation.
                // We start it again here.
                if (!BurstCompiler.Options.RequiresSynchronousCompilation)
                {
                    if (DebuggingLevel > 2)
                    {
                        UnityEngine.Debug.Log("Burst - Exiting PlayMode - triggering eager-compilation");
                    }

                    MaybeTriggerEagerCompilation();
                }
                break;
            }
        }