public string Add(CuiButton button, string parent = "Hud", string name = null) { if (string.IsNullOrEmpty(name)) { name = CuiHelper.GetGuid(); } Add(new CuiElement { Name = name, Parent = parent, FadeOut = button.FadeOut, Components = { button.Button, button.RectTransform } }); if (!string.IsNullOrEmpty(button.Text.Text)) { Add(new CuiElement { Parent = name, FadeOut = button.FadeOut, Components = { button.Text, new CuiRectTransformComponent() } }); } return(name); }
public string Add(CuiButton button, string parent = "Hud", string name = null) { if (String.IsNullOrEmpty(name)) { name = CuiHelper.GetGuid(); } CuiElement cuiElement = new CuiElement() { Name = name, Parent = parent, FadeOut = button.FadeOut }; cuiElement.Components.Add(button.Button); cuiElement.Components.Add(button.RectTransform); base.Add(cuiElement); if (!String.IsNullOrEmpty(button.Text.Text)) { CuiElement cuiElement1 = new CuiElement() { Parent = name, FadeOut = button.FadeOut }; cuiElement1.Components.Add(button.Text); cuiElement1.Components.Add(new CuiRectTransformComponent()); base.Add(cuiElement1); } return(name); }