| 667 | } |
| 668 | |
| 669 | void ScriptsBuilderService::Update() |
| 670 | { |
| 671 | PROFILE_CPU(); |
| 672 | PROFILE_MEM(Editor); |
| 673 | |
| 674 | // Send compilation events |
| 675 | { |
| 676 | ScopeLock scopeLock(_compileEventsLocker); |
| 677 | |
| 678 | for (int32 i = 0; i < _compileEvents.Count(); i++) |
| 679 | CallCompileEvent(_compileEvents[i]); |
| 680 | _compileEvents.Clear(); |
| 681 | } |
| 682 | |
| 683 | // Check if compile code (if has been edited) |
| 684 | const TimeSpan timeToCallCompileIfDirty = TimeSpan::FromMilliseconds(150); |
| 685 | auto mainWindow = Engine::MainWindow; |
| 686 | if (ScriptsBuilder::IsSourceDirtyFor(timeToCallCompileIfDirty) && mainWindow && mainWindow->IsFocused()) |
| 687 | { |
| 688 | // Check if auto reload is enabled |
| 689 | if (Editor::Managed->CanAutoReloadScripts()) |
| 690 | ScriptsBuilder::Compile(); |
| 691 | } |
| 692 | |
| 693 | ScopeLock scopeLock(_locker); |
| 694 | |
| 695 | // Check if compilation has been requested (some time ago since we want to batch calls to reduce amount of compilations) |
| 696 | if (_isCompileRequested) |
| 697 | { |
| 698 | // Check if compilation isn't running |
| 699 | if (!_isCompileRunning) |
| 700 | { |
| 701 | // Check if editor state can perform scripts reloading |
| 702 | if (Editor::Managed->CanReloadScripts()) |
| 703 | { |
| 704 | // Call compilation (and switch flags) |
| 705 | _isCompileRequested = false; |
| 706 | _isCompileRunning = true; |
| 707 | Function<bool()> action(compileGameScriptsAsync); |
| 708 | Task::StartNew(action); |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | void ScriptsBuilderService::Dispose() |
| 715 | { |
nothing calls this directly
no test coverage detected