private void FetchRemoteContent(RectTransform parent) { if (string.IsNullOrEmpty(GameMain.Config.RemoteContentUrl)) { return; } try { var client = new RestClient(GameMain.Config.RemoteContentUrl); var request = new RestRequest("MenuContent.xml", Method.GET); IRestResponse response = client.Execute(request); if (response.ResponseStatus != ResponseStatus.Completed) { return; } if (response.StatusCode != HttpStatusCode.OK) { return; } string xml = response.Content; int index = xml.IndexOf('<'); if (index > 0) { xml = xml.Substring(index, xml.Length - index); } if (string.IsNullOrWhiteSpace(xml)) { return; } XElement element = XDocument.Parse(xml)?.Root; foreach (XElement subElement in element.Elements()) { GUIComponent.FromXML(subElement, parent); } } catch (Exception e) { #if DEBUG DebugConsole.ThrowError("Fetching remote content to the main menu failed.", e); #endif GameAnalyticsManager.AddErrorEventOnce("MainMenuScreen.FetchRemoteContent:Exception", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, "Fetching remote content to the main menu failed. " + e.Message); return; } }
private void Load() { scrollSpeed = configElement.GetAttributeFloat("scrollspeed", 100.0f); int spacing = configElement.GetAttributeInt("spacing", 0); listBox = new GUIListBox(new RectTransform(Vector2.One, RectTransform), style: null) { Spacing = spacing }; foreach (XElement subElement in configElement.Elements()) { GUIComponent.FromXML(subElement, listBox.Content.RectTransform); } foreach (GUIComponent child in listBox.Content.Children) { child.CanBeFocused = false; } listBox.RecalculateChildren(); listBox.UpdateScrollBarSize(); }