public override void LoadContent() { ContentManager Content = Game.game.Content; screen = Content.Load <Texture2D>(@"MainMenu"); font = Content.Load <SpriteFont>(@"Fonts/MenuFont"); buttonList.SetFont(font); // Populate the buttonList now buttonList.AddButton("Play Game", PlayGameDelegate); buttonList.AddButton("High Scores", HighScoreDelegate); buttonList.AddButton("Exit", ExitDelegate); }
public void Init( IEnumerable <InspectorShelf.InspectorShelfItem> objects, Action <object> onInspectionRequested) { buttonList.Clear(); foreach (var element in objects) { var obj = element; buttonList.AddButton(obj.Name, () => onInspectionRequested(obj.Object)); } }
private void SetupPage(DebugMenuItemNode node) { currentPageNode = node; buttonList.Clear(); if (node.Parent != null) { buttonList.AddButton($"{backCharacter} Back", () => { SetupPage(node.Parent); }); } foreach (var childNode in node.Children.Values) { var isFolder = childNode.IsFolder; var buttonText = childNode.Name + (isFolder ? $" {folderArrowCharacter}" : ""); UnityAction actionFunc = () => { if (isFolder) { SetupPage(childNode); } else { childNode.Action.Invoke(); if (childNode.HideOnClick) { debugMenu.Hide(); } } }; buttonList.AddButton(buttonText, actionFunc); } }
public void Init(IEnumerable <GameObject> objects, Action <GameObject> onSelected, Action <GameObject> onInspectionRequested) { foreach (var element in objects) { var obj = element; var button = buttonList.AddButton(obj.name, () => onSelected(obj)); var inspectButton = button.GetComponentsInChildren <Button>() .FirstOrDefault(c => c != button); if (inspectButton != null) { inspectButton.onClick.AddListener(() => onInspectionRequested(obj)); } } }