public void UnloadResources() { _loadRequestsCDC.Clear(); if (CurrentScene != null) { CurrentScene.Dispose(); CurrentScene = null; } if (CurrentObject != null) { CurrentObject.Dispose(); CurrentObject = null; } while (Resources.Count > 1) { RenderResource resource = Resources[Resources.Keys[1]]; Resources.Remove(Resources.Keys[1]); CurrentObject?.UpdateModels(); CurrentScene?.UpdateModels(); resource.Dispose(); } }
public void Dispose() { if (Mode == EngineMode.Synchronous) { if (_eventTimer != null) { _eventTimer.Stop(); _eventTimer.Elapsed -= EventTimerElapsed; _eventTimer.Dispose(); _eventTimer = null; } _fmod.Stop(_engineContext.SoundChannel); _fmod.Shutdown(); } if (_plugInRouter != null) { try { _plugInRouter.Shutdown(_engineContext.RouterContext); } catch (Exception exception) { MessageBox.Show(Resources.engineShutDownError + exception.Message, Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Hand); } } ProgramEnd = null; SequenceChange = null; if (CurrentObject != null) { CurrentObject.Dispose(); } InstanceList.Remove(this); GC.SuppressFinalize(this); }
public void UnloadResource(string resourceName) { if (resourceName != "" && Resources.ContainsKey(resourceName)) { RenderResource renderResource = Resources[resourceName]; Resources.Remove(resourceName); CurrentObject?.UpdateModels(); CurrentScene?.UpdateModels(); renderResource.Dispose(); if (CurrentScene != null && CurrentScene.Name == resourceName) { CurrentScene.Dispose(); CurrentScene = null; } if (CurrentObject != null && CurrentObject.Name == resourceName) { CurrentObject.Dispose(); CurrentObject = null; } } }