} // Initialize #endregion #region Uninitialize /// <summary> /// Unloads the user content and disposes the scene content manager. /// </summary> internal void Unitialize() { if (ContentLoaded) { EndRun(); UnloadContent(); if (AssetContentManager.CurrentContentManager == AssetContentManager) { AssetContentManager.CurrentContentManager = null; } if (GameObjectContentManager.CurrentContentManager == GameObjectContentManager) { GameObjectContentManager.CurrentContentManager = null; } AssetContentManager.Dispose(); GameObjectContentManager.Dispose(); ContentLoaded = false; } } // Unitialize
/// <summary> /// Load layout file. /// </summary> public static Container Load(string filename) { Container mainContainer = null; AssetContentManager userContentManager = AssetContentManager.CurrentContentManager; AssetContentManager temporalContent = new AssetContentManager { Name = "Temporal Content Manager", Hidden = true }; AssetContentManager.CurrentContentManager = temporalContent; try { Document layoutDocument = new Document("Layout\\" + filename); try { if (layoutDocument.Resource.Element("Layout").Element("Controls") != null) { foreach (var control in layoutDocument.Resource.Element("Layout").Element("Controls").Elements()) { string className = control.Attribute("Class").Value; Type type = Type.GetType("XNAFinalEngine.UserInterface." + className); if (type == null) { throw new Exception("Failed to load layout: Control doesn't exist"); } mainContainer = (Container)LoadControl(control, type, null); } } } catch (Exception e) { throw new InvalidOperationException("Failed to load layout: " + filename + ".\nThere are probably syntax errors.", e); } } finally { // Dispose the temporal content manager and restore the user content manager. temporalContent.Dispose(); AssetContentManager.CurrentContentManager = userContentManager; } return mainContainer; } // Load