/// <inheritdoc/>
        /// <remarks>
        /// Derived class should override this method, implement specific cleanup and then call the base implementation.
        /// </remarks>
        public virtual void Destroy()
        {
            EnsureNotDestroyed();
            if (IsDestroying)
            {
                return;
            }

            Loader.Dispose();
            EditorDebugTools.UnregisterDebugPage(debugPage);
            UnregisterFromDragDropEvents();
            GameForm?.Host?.Dispose();
            IsDestroying = true;

            // Clean after everything
            PostTask(async x =>
            {
                if (serviceRegistry != null)
                {
                    await serviceRegistry.DisposeAsync();
                }
                Game.Exit();
                GameForm?.Dispose();
            }, int.MaxValue)
            // Ensure the properties are correctly set, even in case of a failure (default continuation)
            .ContinueWith(t =>
            {
                Asset.Dispatcher.Invoke(() =>
                {
                    IsDestroyed  = true;
                    IsDestroying = false;
                });
            });
            GameSideNodeContainer.Clear();
        }
Beispiel #2
0
        public void Dispose()
        {
            if (!IsDisposed)
            {
                // Terminate preview control thread
                previewBuildQueue = null;

                session.AssetPropertiesChanged           -= OnAssetPropertyChanged;
                gameSettingsProvider.GameSettingsChanged -= OnGameSettingsChanged;

                if (PreviewGame.IsRunning)
                {
                    PreviewGame.Exit();
                }

                // Wait for the game thread to terminate
                previewGameThread.Join();


                //Game = null;
                host.Dispose();
                //host = null;
                //gameForm = null;
                //windowHandle = IntPtr.Zero;
                previewCompileContext?.Dispose();

                EditorDebugTools.UnregisterDebugPage(loggerDebugPage);

                IsDisposed = true;
            }
        }
Beispiel #3
0
 public override void Dispose()
 {
     base.Dispose();
     if (createDebugTools)
     {
         EditorDebugTools.UnregisterDebugPage(assetBuilderServiceDebugPage);
         EditorDebugTools.UnregisterDebugPage(effectCompilerServiceDebugPage);
     }
     if (!IsDisposed)
     {
         IsDisposed = true;
     }
 }