protected override void OnUnload() { // Detach the scene nodes from the scene. if (_skyGroupNode.Parent != null) { _skyGroupNode.Parent.Children.Remove(_skyGroupNode); } _lightGroupNode.Parent.Children.Remove(_lightGroupNode); // Dispose allocated resources. _skyGroupNode.Dispose(false); _lightGroupNode.Dispose(false); if (_enableClouds) { _cloudLayerNode0.CloudMap.Dispose(); _cloudLayerNode1.CloudMap.Dispose(); } if (_cacheSky) { _sceneCaptureNode.RenderToTexture.Texture.Dispose(); _sceneCaptureNode.Dispose(false); _cloudMapRenderer.Dispose(); _skyRenderer.Dispose(); _colorEncoder.Dispose(); _sceneCaptureRenderer.Dispose(); } // Set references to null. _cameraObject = null; _skyGroupNode = null; _lightGroupNode = null; _milkyWayNode = null; _starfieldNode = null; _sunNode = null; _moonNode = null; _scatteringSkyNode = null; _ambientLightNode = null; _sunlightNode = null; _moonlightNode = null; _cloudLayerNode0 = null; _cloudLayerNode1 = null; _sceneCaptureNode = null; SkyboxNode = null; _cloudMapRenderer = null; _skyRenderer = null; _colorEncoder = null; _sceneCaptureRenderer = null; }
protected override void Dispose(bool disposing) { if (disposing) { // Unload content. // We have modified the material of a mesh. These changes should not // affect other samples. Therefore, we unload the assets. The next sample // will reload them with default values.) ContentManager.Unload(); for (int i = 0; i < _sceneCaptureNodes.Length; i++) { _sceneCaptureNodes[i].RenderToTexture.Texture.Dispose(); _sceneCaptureNodes[i].Dispose(false); } _colorEncoder.Dispose(); } base.Dispose(disposing); }