public static Button Create(XmlReader reader, IWidget parent = null) { Button button = new Button(); button.ReadElement(reader, parent); String type = reader.GetAttribute("type"); button.SetParent(parent); while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Text": button.Text = reader.ReadElementContentAsString(); break; case "Sprite": Sprite sprite = SpriteLoader.Load(new SpriteInfo(reader)); button.backgroundComponent.sprite = sprite; //button.backgroundComponent.color = new Color(0, 1, 0, 0.5f); //button.buttonComponent.colors. = new ColorBlock(); //color break; default: XmlReader subReader = reader.ReadSubtree(); GUIController.ReadElement(subReader, button); subReader.Close(); break; } } } switch (type) { case "sliced": default: button.backgroundComponent.type = Image.Type.Sliced; break; case "simple": button.backgroundComponent.type = Image.Type.Simple; button.backgroundComponent.preserveAspect = true; break; } return(button); }